aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/RecordDrawTest.cpp
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-19 15:15:24 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-19 15:15:24 +0000
commit0a98d870448f66ea0df7c37a47b38cf2d3b734e5 (patch)
treedbb7d62f7226e2bc050e7277d2f5e5623adae175 /tests/RecordDrawTest.cpp
parent71db88225d4e26303b5c3ad2c44305f6a5660754 (diff)
Don't clobber initial transform with SetMatrix.
BUG=skia:2378 R=reed@google.com, mtklein@google.com, robertphillips@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/290883004 git-svn-id: http://skia.googlecode.com/svn/trunk@14778 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/RecordDrawTest.cpp')
-rw-r--r--tests/RecordDrawTest.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/RecordDrawTest.cpp b/tests/RecordDrawTest.cpp
index d830aea6e5..b0e55a6fdb 100644
--- a/tests/RecordDrawTest.cpp
+++ b/tests/RecordDrawTest.cpp
@@ -6,6 +6,7 @@
*/
#include "Test.h"
+#include "RecordTestUtils.h"
#include "SkDebugCanvas.h"
#include "SkRecord.h"
@@ -73,3 +74,32 @@ DEF_TEST(RecordDraw_Culling, r) {
// If culling weren't working, we'd see 8 commands recorded here.
REPORTER_ASSERT(r, 5 == clipped.count());
}
+
+DEF_TEST(RecordDraw_SetMatrixClobber, r) {
+ // Set up an SkRecord that just scales by 2x,3x.
+ SkRecord scaleRecord;
+ SkRecorder scaleCanvas(SkRecorder::kReadWrite_Mode, &scaleRecord, W, H);
+ SkMatrix scale;
+ scale.setScale(2, 3);
+ scaleCanvas.setMatrix(scale);
+
+ // Set up an SkRecord with an initial +20, +20 translate.
+ SkRecord translateRecord;
+ SkRecorder translateCanvas(SkRecorder::kReadWrite_Mode, &translateRecord, W, H);
+ SkMatrix translate;
+ translate.setTranslate(20, 20);
+ translateCanvas.setMatrix(translate);
+
+ SkRecordDraw(scaleRecord, &translateCanvas);
+
+ // When we look at translateRecord now, it should have its first +20,+20 translate,
+ // then a 2x,3x scale that's been concatted with that +20,+20 translate.
+ const SkRecords::SetMatrix* setMatrix;
+ setMatrix = assert_type<SkRecords::SetMatrix>(r, translateRecord, 0);
+ REPORTER_ASSERT(r, setMatrix->matrix == translate);
+
+ setMatrix = assert_type<SkRecords::SetMatrix>(r, translateRecord, 1);
+ SkMatrix expected = scale;
+ expected.postConcat(translate);
+ REPORTER_ASSERT(r, setMatrix->matrix == expected);
+}