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 #include "RecordTestUtils.h" |
10 | 10 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 SkPaint p; | 183 SkPaint p; |
184 | 184 |
185 SkRecord record; | 185 SkRecord record; |
186 SkRecorder recorder(&record, kWidth, kHeight); | 186 SkRecorder recorder(&record, kWidth, kHeight); |
187 recorder.drawRect(r1, p); | 187 recorder.drawRect(r1, p); |
188 recorder.drawRect(r2, p); | 188 recorder.drawRect(r2, p); |
189 recorder.drawRect(r3, p); | 189 recorder.drawRect(r3, p); |
190 | 190 |
191 SkRecord rerecord; | 191 SkRecord rerecord; |
192 SkRecorder canvas(&rerecord, kWidth, kHeight); | 192 SkRecorder canvas(&rerecord, kWidth, kHeight); |
193 SkRecordPartialDraw(record, &canvas, r1, 1, 2); // replay just drawRect of r
2 | 193 SkRecordPartialDraw(record, &canvas, r1, 1, 2, SkMatrix::I()); // replay jus
t drawRect of r2 |
194 | 194 |
195 REPORTER_ASSERT(r, 3 == rerecord.count()); | 195 REPORTER_ASSERT(r, 3 == rerecord.count()); |
196 assert_type<SkRecords::Save> (r, rerecord, 0); | 196 assert_type<SkRecords::Save> (r, rerecord, 0); |
197 assert_type<SkRecords::DrawRect> (r, rerecord, 1); | 197 assert_type<SkRecords::DrawRect> (r, rerecord, 1); |
198 assert_type<SkRecords::Restore> (r, rerecord, 2); | 198 assert_type<SkRecords::Restore> (r, rerecord, 2); |
199 | 199 |
200 const SkRecords::DrawRect* drawRect = assert_type<SkRecords::DrawRect>(r, re
record, 1); | 200 const SkRecords::DrawRect* drawRect = assert_type<SkRecords::DrawRect>(r, re
record, 1); |
201 REPORTER_ASSERT(r, drawRect->rect == r2); | 201 REPORTER_ASSERT(r, drawRect->rect == r2); |
202 } | 202 } |
203 | 203 |
204 // Check that clears are converted to drawRects | 204 // Check that clears are converted to drawRects |
205 DEF_TEST(RecordDraw_PartialClear, r) { | 205 DEF_TEST(RecordDraw_PartialClear, r) { |
206 static const int kWidth = 10, kHeight = 10; | 206 static const int kWidth = 10, kHeight = 10; |
207 | 207 |
208 SkRect rect = { 0, 0, kWidth, kHeight }; | 208 SkRect rect = { 0, 0, kWidth, kHeight }; |
209 | 209 |
210 SkRecord record; | 210 SkRecord record; |
211 SkRecorder recorder(&record, kWidth, kHeight); | 211 SkRecorder recorder(&record, kWidth, kHeight); |
212 recorder.clear(SK_ColorRED); | 212 recorder.clear(SK_ColorRED); |
213 | 213 |
214 SkRecord rerecord; | 214 SkRecord rerecord; |
215 SkRecorder canvas(&rerecord, kWidth, kHeight); | 215 SkRecorder canvas(&rerecord, kWidth, kHeight); |
216 SkRecordPartialDraw(record, &canvas, rect, 0, 1); // replay just the clear | 216 SkRecordPartialDraw(record, &canvas, rect, 0, 1, SkMatrix::I()); // replay j
ust the clear |
217 | 217 |
218 REPORTER_ASSERT(r, 3 == rerecord.count()); | 218 REPORTER_ASSERT(r, 3 == rerecord.count()); |
219 assert_type<SkRecords::Save> (r, rerecord, 0); | 219 assert_type<SkRecords::Save> (r, rerecord, 0); |
220 assert_type<SkRecords::DrawRect>(r, rerecord, 1); | 220 assert_type<SkRecords::DrawRect>(r, rerecord, 1); |
221 assert_type<SkRecords::Restore> (r, rerecord, 2); | 221 assert_type<SkRecords::Restore> (r, rerecord, 2); |
222 | 222 |
223 const SkRecords::DrawRect* drawRect = assert_type<SkRecords::DrawRect>(r, re
record, 1); | 223 const SkRecords::DrawRect* drawRect = assert_type<SkRecords::DrawRect>(r, re
record, 1); |
224 REPORTER_ASSERT(r, drawRect->rect == rect); | 224 REPORTER_ASSERT(r, drawRect->rect == rect); |
225 REPORTER_ASSERT(r, drawRect->paint.getColor() == SK_ColorRED); | 225 REPORTER_ASSERT(r, drawRect->paint.getColor() == SK_ColorRED); |
226 } | 226 } |
OLD | NEW |