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

Unified Diff: tests/DeferredCanvasTest.cpp

Issue 545813002: Picture Recording: fix the performance bottleneck in SkDeferredCanvas::isFullFrame (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: a small fix for memory leak in unit test Created 6 years, 3 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 | « src/utils/SkDeferredCanvas.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/DeferredCanvasTest.cpp
diff --git a/tests/DeferredCanvasTest.cpp b/tests/DeferredCanvasTest.cpp
index 61af550e202fe84ac7fb4b628db50bf62199ab58..2938326aba5c42a1b9b4d5b82075008b65143d04 100644
--- a/tests/DeferredCanvasTest.cpp
+++ b/tests/DeferredCanvasTest.cpp
@@ -839,6 +839,59 @@ static void TestDeferredCanvasCreateCompatibleDevice(skiatest::Reporter* reporte
REPORTER_ASSERT(reporter, notificationCounter.fStorageAllocatedChangedCount == 1);
}
+static void TestDeferredCanvasGetCanvasSize(skiatest::Reporter* reporter) {
+ SkRect rect;
+ rect.setXYWH(SkIntToScalar(0), SkIntToScalar(0), SkIntToScalar(gWidth), SkIntToScalar(gHeight));
+ SkRect clip;
+ clip.setXYWH(SkIntToScalar(0), SkIntToScalar(0), SkIntToScalar(1), SkIntToScalar(1));
+
+ SkPaint paint;
+ SkISize size = SkISize::Make(gWidth, gHeight);
+
+ SkAutoTUnref<SkSurface> surface(createSurface(0xFFFFFFFF));
+ SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(surface.get()));
+ SkSurface* newSurface = SkSurface::NewRasterPMColor(4, 4);
+ SkAutoTUnref<SkSurface> aur(newSurface);
+
+ for (int i = 0; i < 2; ++i) {
+ if (i == 1) {
+ canvas->setSurface(newSurface);
+ size = SkISize::Make(4, 4);
+ }
+
+ // verify that canvas size is correctly initialized or set
+ REPORTER_ASSERT(reporter, size == canvas->getCanvasSize());
+
+ // Verify that clear, clip and draw the canvas will not change its size
+ canvas->clear(0x00000000);
+ canvas->clipRect(clip, SkRegion::kIntersect_Op, false);
+ canvas->drawRect(rect, paint);
+ REPORTER_ASSERT(reporter, size == canvas->getCanvasSize());
+
+ // Verify that flush the canvas will not change its size
+ canvas->flush();
+ REPORTER_ASSERT(reporter, size == canvas->getCanvasSize());
+
+ // Verify that clear canvas with saved state will not change its size
+ canvas->save();
+ canvas->clear(0xFFFFFFFF);
+ REPORTER_ASSERT(reporter, size == canvas->getCanvasSize());
+
+ // Verify that restore canvas state will not change its size
+ canvas->restore();
+ REPORTER_ASSERT(reporter, size == canvas->getCanvasSize());
+
+ // Verify that clear within a layer will not change canvas size
+ canvas->saveLayer(&clip, &paint);
+ canvas->clear(0x00000000);
+ REPORTER_ASSERT(reporter, size == canvas->getCanvasSize());
+
+ // Verify that restore from a layer will not change canvas size
+ canvas->restore();
+ REPORTER_ASSERT(reporter, size == canvas->getCanvasSize());
+ }
+}
+
DEF_TEST(DeferredCanvas_CPU, reporter) {
TestDeferredCanvasFlush(reporter);
TestDeferredCanvasSilentFlush(reporter);
@@ -850,6 +903,7 @@ DEF_TEST(DeferredCanvas_CPU, reporter) {
TestDeferredCanvasBitmapSizeThreshold(reporter);
TestDeferredCanvasCreateCompatibleDevice(reporter);
TestDeferredCanvasWritePixelsToSurface(reporter);
+ TestDeferredCanvasGetCanvasSize(reporter);
TestDeferredCanvasSurface(reporter, NULL);
TestDeferredCanvasSetSurface(reporter, NULL);
}
« no previous file with comments | « src/utils/SkDeferredCanvas.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698