aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar junov@chromium.org <junov@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-20 13:21:58 +0000
committerGravatar junov@chromium.org <junov@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-20 13:21:58 +0000
commit426aebc8502654642bebfdda22af8acdae84cf05 (patch)
treed1cd0caa4dee9f8a95fe9786e18b9b357c45de52
parent73c48f17137e332f4d1f06ff230d00c98ef92d27 (diff)
Adding new steps to Canvas unit test to validate that the deferred
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
-rw-r--r--tests/CanvasTest.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp
index 38ccc909e0..cf70f433aa 100644
--- a/tests/CanvasTest.cpp
+++ b/tests/CanvasTest.cpp
@@ -530,6 +530,49 @@ static void DrawLayerTestStep(SkCanvas* canvas,
testStep->assertMessage());
}
TEST_STEP(DrawLayer, DrawLayerTestStep);
+
+static void NestedSaveRestoreWithSolidPaintTestStep(SkCanvas* canvas,
+ skiatest::Reporter* reporter,
+ CanvasTestStep* testStep) {
+ // This test step challenges the TestDeferredCanvasStateConsistency
+ // test cases because the opaque paint can trigger an optimization
+ // that discards previously recorded commands. The challenge is to maintain
+ // correct clip and matrix stack state.
+ canvas->resetMatrix();
+ canvas->rotate(SkIntToScalar(30));
+ canvas->save();
+ canvas->translate(SkIntToScalar(2), SkIntToScalar(1));
+ canvas->save();
+ canvas->scale(SkIntToScalar(3), SkIntToScalar(3));
+ SkPaint paint;
+ paint.setColor(0xFFFFFFFF);
+ canvas->drawPaint(paint);
+ canvas->restore();
+ canvas->restore();
+}
+TEST_STEP(NestedSaveRestoreWithSolidPaint, \
+ NestedSaveRestoreWithSolidPaintTestStep);
+
+static void NestedSaveRestoreWithFlushTestStep(SkCanvas* canvas,
+ skiatest::Reporter* reporter,
+ CanvasTestStep* testStep) {
+ // This test step challenges the TestDeferredCanvasStateConsistency
+ // test case because the canvas flush on a deferred canvas will
+ // reset the recording session. The challenge is to maintain correct
+ // clip and matrix stack state on the playback canvas.
+ canvas->resetMatrix();
+ canvas->rotate(SkIntToScalar(30));
+ canvas->save();
+ canvas->translate(SkIntToScalar(2), SkIntToScalar(1));
+ canvas->save();
+ canvas->scale(SkIntToScalar(3), SkIntToScalar(3));
+ canvas->drawRect(kTestRect,kTestPaint);
+ canvas->flush();
+ canvas->restore();
+ canvas->restore();
+}
+TEST_STEP(NestedSaveRestoreWithFlush, \
+ NestedSaveRestoreWithFlushTestStep);
static void AssertCanvasStatesEqual(skiatest::Reporter* reporter,
const SkCanvas* canvas1,