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

Unified Diff: tests/PictureTest.cpp

Issue 490253003: Implement SkPicture::bytesUsed() for SkRecord backend (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix minor edit error in SkTileGrid::bytesUsed Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: tests/PictureTest.cpp
diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp
index 5bc60371c997f957f56a0f122602812822c813fb..3fec27c704670c0389885dc8439c349c8c06f69b 100644
--- a/tests/PictureTest.cpp
+++ b/tests/PictureTest.cpp
@@ -24,6 +24,7 @@
#include "SkPixelRef.h"
#include "SkRRect.h"
#include "SkRandom.h"
+#include "SkRecord.h"
#include "SkShader.h"
#include "SkStream.h"
@@ -1721,6 +1722,20 @@ static void test_gen_id(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, hasData->uniqueID() != empty->uniqueID());
}
+static void test_bytes_used(skiatest::Reporter* reporter) {
+ SkPictureRecorder recorder;
+
+ recorder.beginRecording(0, 0);
+ SkAutoTUnref<SkPicture> empty(recorder.endRecording());
+
+ // Sanity check to make sure we aren't under-measuring.
+ REPORTER_ASSERT(reporter, SkPictureUtils::ApproximateBytesUsed(empty.get()) >=
+ sizeof(SkPicture) + sizeof(SkRecord));
+
+ // Protect against any unintentional bloat.
+ REPORTER_ASSERT(reporter, SkPictureUtils::ApproximateBytesUsed(empty.get()) <= 168);
+}
+
DEF_TEST(Picture, reporter) {
#ifdef SK_DEBUG
test_deleting_empty_picture();
@@ -1743,6 +1758,7 @@ DEF_TEST(Picture, reporter) {
test_hierarchical(reporter);
test_gen_id(reporter);
test_savelayer_extraction(reporter);
+ test_bytes_used(reporter);
}
static void draw_bitmaps(const SkBitmap bitmap, SkCanvas* canvas) {
@@ -1837,6 +1853,7 @@ struct CountingBBH : public SkBBoxHierarchy {
}
virtual void insert(SkAutoTMalloc<SkRect>*, int) SK_OVERRIDE {}
+ virtual size_t bytesUsed() const { return 0; }
};
class SpoonFedBBHFactory : public SkBBHFactory {
« src/core/SkRTree.h ('K') | « src/utils/SkPictureUtils.cpp ('k') | tests/RecordDrawTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698