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

Unified Diff: tests/RecordDrawTest.cpp

Issue 290883004: Don't clobber initial transform with SetMatrix. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: setConcat Created 6 years, 7 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/record/SkRecordDraw.cpp ('k') | tests/RecordOptsTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/RecordDrawTest.cpp
diff --git a/tests/RecordDrawTest.cpp b/tests/RecordDrawTest.cpp
index d830aea6e563c2b2b9c6441d0975a7e7102eb3c9..b0e55a6fdbe7160b2c50c5d2c1aebb96a855a687 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);
+}
« no previous file with comments | « src/record/SkRecordDraw.cpp ('k') | tests/RecordOptsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698