Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: tests/PictureTest.cpp

Issue 1090943004: O(1) SkPictureUtils::ApproxBytesUsed() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: const Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/utils/SkPictureUtils.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBBoxHierarchy.h" 8 #include "SkBBoxHierarchy.h"
9 #include "SkBlurImageFilter.h" 9 #include "SkBlurImageFilter.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 1112
1113 recorder.beginRecording(0, 0); 1113 recorder.beginRecording(0, 0);
1114 SkAutoTUnref<SkPicture> empty(recorder.endRecording()); 1114 SkAutoTUnref<SkPicture> empty(recorder.endRecording());
1115 1115
1116 // Sanity check to make sure we aren't under-measuring. 1116 // Sanity check to make sure we aren't under-measuring.
1117 REPORTER_ASSERT(reporter, SkPictureUtils::ApproximateBytesUsed(empty.get()) >= 1117 REPORTER_ASSERT(reporter, SkPictureUtils::ApproximateBytesUsed(empty.get()) >=
1118 sizeof(SkPicture) + sizeof(SkRecord)); 1118 sizeof(SkPicture) + sizeof(SkRecord));
1119 1119
1120 // Protect against any unintentional bloat. 1120 // Protect against any unintentional bloat.
1121 size_t approxUsed = SkPictureUtils::ApproximateBytesUsed(empty.get()); 1121 size_t approxUsed = SkPictureUtils::ApproximateBytesUsed(empty.get());
1122 REPORTER_ASSERT(reporter, approxUsed <= 416); 1122 REPORTER_ASSERT(reporter, approxUsed <= 432);
1123 1123
1124 // Sanity check of nested SkPictures. 1124 // Sanity check of nested SkPictures.
1125 SkPictureRecorder r2; 1125 SkPictureRecorder r2;
1126 r2.beginRecording(0, 0); 1126 r2.beginRecording(0, 0);
1127 r2.getRecordingCanvas()->drawPicture(empty.get()); 1127 r2.getRecordingCanvas()->drawPicture(empty.get());
1128 SkAutoTUnref<SkPicture> nested(r2.endRecording()); 1128 SkAutoTUnref<SkPicture> nested(r2.endRecording());
1129 1129
1130 REPORTER_ASSERT(reporter, SkPictureUtils::ApproximateBytesUsed(nested.get()) > 1130 REPORTER_ASSERT(reporter, SkPictureUtils::ApproximateBytesUsed(nested.get()) >
1131 SkPictureUtils::ApproximateBytesUsed(empty.get())) ; 1131 SkPictureUtils::ApproximateBytesUsed(empty.get())) ;
1132 } 1132 }
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 DEF_TEST(Picture_getRecordingCanvas, r) { 1316 DEF_TEST(Picture_getRecordingCanvas, r) {
1317 SkPictureRecorder rec; 1317 SkPictureRecorder rec;
1318 REPORTER_ASSERT(r, !rec.getRecordingCanvas()); 1318 REPORTER_ASSERT(r, !rec.getRecordingCanvas());
1319 for (int i = 0; i < 3; i++) { 1319 for (int i = 0; i < 3; i++) {
1320 rec.beginRecording(100, 100); 1320 rec.beginRecording(100, 100);
1321 REPORTER_ASSERT(r, rec.getRecordingCanvas()); 1321 REPORTER_ASSERT(r, rec.getRecordingCanvas());
1322 rec.endRecording()->unref(); 1322 rec.endRecording()->unref();
1323 REPORTER_ASSERT(r, !rec.getRecordingCanvas()); 1323 REPORTER_ASSERT(r, !rec.getRecordingCanvas());
1324 } 1324 }
1325 } 1325 }
OLDNEW
« no previous file with comments | « src/utils/SkPictureUtils.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698