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

Unified Diff: tests/PictureTest.cpp

Issue 1130283004: Revert of Sketch splitting SkPicture into an interface and SkBigPicture. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/GpuLayerCacheTest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/PictureTest.cpp
diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp
index 0ccef3f0a92f2b8403278fc3cdd7326349001847..16d98b324517d670339181410e8892deb53ea898 100644
--- a/tests/PictureTest.cpp
+++ b/tests/PictureTest.cpp
@@ -23,7 +23,6 @@
#include "SkPictureUtils.h"
#include "SkPixelRef.h"
#include "SkPixelSerializer.h"
-#include "SkMiniRecorder.h"
#include "SkRRect.h"
#include "SkRandom.h"
#include "SkRecord.h"
@@ -364,10 +363,9 @@
// Now test out the SaveLayer extraction
if (!SkCanvas::Internal_Private_GetIgnoreSaveLayerBounds()) {
- const SkBigPicture* bp = pict->asSkBigPicture();
- REPORTER_ASSERT(reporter, bp);
-
- const SkBigPicture::AccelData* data = bp->accelData();
+ SkPicture::AccelData::Key key = SkLayerInfo::ComputeKey();
+
+ const SkPicture::AccelData* data = pict->EXPERIMENTAL_getAccelData(key);
REPORTER_ASSERT(reporter, data);
const SkLayerInfo *gpuData = static_cast<const SkLayerInfo*>(data);
@@ -1107,6 +1105,30 @@
// both pictures should have different ids
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.
+ size_t approxUsed = SkPictureUtils::ApproximateBytesUsed(empty.get());
+ REPORTER_ASSERT(reporter, approxUsed <= 432);
+
+ // Sanity check of nested SkPictures.
+ SkPictureRecorder r2;
+ r2.beginRecording(0, 0);
+ r2.getRecordingCanvas()->drawPicture(empty.get());
+ SkAutoTUnref<SkPicture> nested(r2.endRecording());
+
+ REPORTER_ASSERT(reporter, SkPictureUtils::ApproximateBytesUsed(nested.get()) >=
+ SkPictureUtils::ApproximateBytesUsed(empty.get()));
}
DEF_TEST(Picture, reporter) {
@@ -1129,6 +1151,7 @@
test_hierarchical(reporter);
test_gen_id(reporter);
test_savelayer_extraction(reporter);
+ test_bytes_used(reporter);
}
static void draw_bitmaps(const SkBitmap bitmap, SkCanvas* canvas) {
@@ -1244,10 +1267,7 @@
SpoonFedBBHFactory factory(&bbh);
SkPictureRecorder recorder;
- SkCanvas* c = recorder.beginRecording(bound, &factory);
- // Record a few ops so we don't hit a small- or empty- picture optimization.
- c->drawRect(bound, SkPaint());
- c->drawRect(bound, SkPaint());
+ recorder.beginRecording(bound, &factory);
SkAutoTUnref<const SkPicture> picture(recorder.endRecording());
SkCanvas big(640, 480), small(300, 200);
@@ -1303,13 +1323,3 @@
REPORTER_ASSERT(r, !rec.getRecordingCanvas());
}
}
-
-DEF_TEST(MiniRecorderLeftHanging, r) {
- // Any shader or other ref-counted effect will do just fine here.
- SkPaint paint;
- paint.setShader(SkShader::CreateColorShader(SK_ColorRED))->unref();
-
- SkMiniRecorder rec;
- REPORTER_ASSERT(r, rec.drawRect(SkRect::MakeWH(20,30), paint));
- // Don't call rec.detachPicture(). Test succeeds by not asserting or leaking the shader.
-}
« no previous file with comments | « tests/GpuLayerCacheTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698