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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/record/SkRecordDraw.cpp ('k') | tests/RecordOptsTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "Test.h" 8 #include "Test.h"
9 #include "RecordTestUtils.h"
9 10
10 #include "SkDebugCanvas.h" 11 #include "SkDebugCanvas.h"
11 #include "SkRecord.h" 12 #include "SkRecord.h"
12 #include "SkRecordOpts.h" 13 #include "SkRecordOpts.h"
13 #include "SkRecordDraw.h" 14 #include "SkRecordDraw.h"
14 #include "SkRecorder.h" 15 #include "SkRecorder.h"
15 #include "SkRecords.h" 16 #include "SkRecords.h"
16 17
17 static const int W = 1920, H = 1080; 18 static const int W = 1920, H = 1080;
18 19
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 SkRecordAnnotateCullingPairs(&record); 67 SkRecordAnnotateCullingPairs(&record);
67 68
68 // This clip intersects the outer cull, but allows us to quick reject the in ner one. 69 // This clip intersects the outer cull, but allows us to quick reject the in ner one.
69 SkRecord clipped; 70 SkRecord clipped;
70 record_clipped(record, SkRect::MakeLTRB(20, 20, 200, 200), &clipped); 71 record_clipped(record, SkRect::MakeLTRB(20, 20, 200, 200), &clipped);
71 72
72 // We'll keep the clipRect call from above, and the outer two drawRects, and the push/pop pair. 73 // We'll keep the clipRect call from above, and the outer two drawRects, and the push/pop pair.
73 // If culling weren't working, we'd see 8 commands recorded here. 74 // If culling weren't working, we'd see 8 commands recorded here.
74 REPORTER_ASSERT(r, 5 == clipped.count()); 75 REPORTER_ASSERT(r, 5 == clipped.count());
75 } 76 }
77
78 DEF_TEST(RecordDraw_SetMatrixClobber, r) {
79 // Set up an SkRecord that just scales by 2x,3x.
80 SkRecord scaleRecord;
81 SkRecorder scaleCanvas(SkRecorder::kReadWrite_Mode, &scaleRecord, W, H);
82 SkMatrix scale;
83 scale.setScale(2, 3);
84 scaleCanvas.setMatrix(scale);
85
86 // Set up an SkRecord with an initial +20, +20 translate.
87 SkRecord translateRecord;
88 SkRecorder translateCanvas(SkRecorder::kReadWrite_Mode, &translateRecord, W, H);
89 SkMatrix translate;
90 translate.setTranslate(20, 20);
91 translateCanvas.setMatrix(translate);
92
93 SkRecordDraw(scaleRecord, &translateCanvas);
94
95 // When we look at translateRecord now, it should have its first +20,+20 tra nslate,
96 // then a 2x,3x scale that's been concatted with that +20,+20 translate.
97 const SkRecords::SetMatrix* setMatrix;
98 setMatrix = assert_type<SkRecords::SetMatrix>(r, translateRecord, 0);
99 REPORTER_ASSERT(r, setMatrix->matrix == translate);
100
101 setMatrix = assert_type<SkRecords::SetMatrix>(r, translateRecord, 1);
102 SkMatrix expected = scale;
103 expected.postConcat(translate);
104 REPORTER_ASSERT(r, setMatrix->matrix == expected);
105 }
OLDNEW
« 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