aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar junov@chromium.org <junov@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-21 20:16:17 +0000
committerGravatar junov@chromium.org <junov@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-21 20:16:17 +0000
commitb1c725a108f57ac186542b43de80fa651a4dddba (patch)
treec808ea90dc6ecbbc7d63c13505ac1c95a6add2f4 /tests
parent2e08f19943b69eace09ef2536d2028913ede7725 (diff)
Fixing deferred canvases so that they do not return deferred devices on createCompatibleDevice
TEST= DeferredCanvas unit test. Review URL: https://codereview.chromium.org/15594004 git-svn-id: http://skia.googlecode.com/svn/trunk@9224 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests')
-rw-r--r--tests/DeferredCanvasTest.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/DeferredCanvasTest.cpp b/tests/DeferredCanvasTest.cpp
index 3e73393d14..3def1906ef 100644
--- a/tests/DeferredCanvasTest.cpp
+++ b/tests/DeferredCanvasTest.cpp
@@ -548,6 +548,28 @@ static void TestDeferredCanvasSurface(skiatest::Reporter* reporter, GrContextFac
REPORTER_ASSERT(reporter, pixels4 == pixels5);
}
+static void TestDeferredCanvasCreateCompatibleDevice(skiatest::Reporter* reporter) {
+ SkBitmap store;
+ store.setConfig(SkBitmap::kARGB_8888_Config, 100, 100);
+ store.allocPixels();
+ SkDevice device(store);
+ NotificationCounter notificationCounter;
+ SkDeferredCanvas canvas(&device);
+ canvas.setNotificationClient(&notificationCounter);
+ SkAutoTUnref<SkDevice> secondaryDevice(canvas.createCompatibleDevice(
+ SkBitmap::kARGB_8888_Config, 10, 10, device.isOpaque()));
+ SkCanvas secondaryCanvas(secondaryDevice.get());
+ SkRect rect = SkRect::MakeWH(5, 5);
+ SkPaint paint;
+ // After spawning a compatible canvas:
+ // 1) Verify that secondary canvas is usable and does not report to the notification client.
+ secondaryCanvas.drawRect(rect, paint);
+ REPORTER_ASSERT(reporter, notificationCounter.fStorageAllocatedChangedCount == 0);
+ // 2) Verify that original canvas is usable and still reports to the notification client.
+ canvas.drawRect(rect, paint);
+ REPORTER_ASSERT(reporter, notificationCounter.fStorageAllocatedChangedCount == 1);
+}
+
static void TestDeferredCanvas(skiatest::Reporter* reporter, GrContextFactory* factory) {
TestDeferredCanvasBitmapAccess(reporter);
TestDeferredCanvasFlush(reporter);
@@ -557,6 +579,7 @@ static void TestDeferredCanvas(skiatest::Reporter* reporter, GrContextFactory* f
TestDeferredCanvasSkip(reporter);
TestDeferredCanvasBitmapShaderNoLeak(reporter);
TestDeferredCanvasBitmapSizeThreshold(reporter);
+ TestDeferredCanvasCreateCompatibleDevice(reporter);
TestDeferredCanvasSurface(reporter, NULL);
if (NULL != factory) {
TestDeferredCanvasSurface(reporter, factory);