Adding new steps to Canvas unit test to validate that the deferred
authorjunov@chromium.org <junov@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 20 Jul 2012 13:21:58 +0000 (13:21 +0000)
committerjunov@chromium.org <junov@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 20 Jul 2012 13:21:58 +0000 (13:21 +0000)
canvas state coherence test case passes with sequences of draw commands
that trigger flushes and purges of deferred draw commands.

This CL confirms that using SkGPipe fixes the deferred canvas issues that are
the root problem of crbug.com/133432

BUG=https://code.google.com/p/chromium/issues/detail?id=133432
Review URL: https://codereview.appspot.com/6416049

git-svn-id: http://skia.googlecode.com/svn/trunk@4687 2bbb7eff-a529-9590-31e7-b0007b416f81

tests/CanvasTest.cpp

index 38ccc909e0e323eff4f37b2952d2a3630b5d9cab..cf70f433aaa67b976a8a835d010da9e62c331eff 100644 (file)
@@ -530,6 +530,49 @@ static void DrawLayerTestStep(SkCanvas* canvas,
         testStep->assertMessage());
 }
 TEST_STEP(DrawLayer, DrawLayerTestStep);
+\r
+static void NestedSaveRestoreWithSolidPaintTestStep(SkCanvas* canvas,\r
+                                      skiatest::Reporter* reporter,\r
+                                      CanvasTestStep* testStep) {\r
+    // This test step challenges the TestDeferredCanvasStateConsistency\r
+    // test cases because the opaque paint can trigger an optimization\r
+    // that discards previously recorded commands. The challenge is to maintain\r
+    // correct clip and matrix stack state.\r
+    canvas->resetMatrix();\r
+    canvas->rotate(SkIntToScalar(30));\r
+    canvas->save();\r
+    canvas->translate(SkIntToScalar(2), SkIntToScalar(1));\r
+    canvas->save();\r
+    canvas->scale(SkIntToScalar(3), SkIntToScalar(3));\r
+    SkPaint paint;\r
+    paint.setColor(0xFFFFFFFF);\r
+    canvas->drawPaint(paint);\r
+    canvas->restore();\r
+    canvas->restore();\r
+}\r
+TEST_STEP(NestedSaveRestoreWithSolidPaint, \\r
+    NestedSaveRestoreWithSolidPaintTestStep);\r
+\r
+static void NestedSaveRestoreWithFlushTestStep(SkCanvas* canvas,\r
+                                      skiatest::Reporter* reporter,\r
+                                      CanvasTestStep* testStep) {\r
+    // This test step challenges the TestDeferredCanvasStateConsistency\r
+    // test case because the canvas flush on a deferred canvas will\r
+    // reset the recording session. The challenge is to maintain correct\r
+    // clip and matrix stack state on the playback canvas.\r
+    canvas->resetMatrix();\r
+    canvas->rotate(SkIntToScalar(30));\r
+    canvas->save();\r
+    canvas->translate(SkIntToScalar(2), SkIntToScalar(1));\r
+    canvas->save();\r
+    canvas->scale(SkIntToScalar(3), SkIntToScalar(3));\r
+    canvas->drawRect(kTestRect,kTestPaint);\r
+    canvas->flush();\r
+    canvas->restore();\r
+    canvas->restore();\r
+}\r
+TEST_STEP(NestedSaveRestoreWithFlush, \\r
+    NestedSaveRestoreWithFlushTestStep);\r
 
 static void AssertCanvasStatesEqual(skiatest::Reporter* reporter,
                                     const SkCanvas* canvas1,