OLD | NEW |
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 Loading... |
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 } |
OLD | NEW |