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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 SkPaint p; | 184 SkPaint p; |
185 | 185 |
186 SkRecord record; | 186 SkRecord record; |
187 SkRecorder recorder(&record, kWidth, kHeight); | 187 SkRecorder recorder(&record, kWidth, kHeight); |
188 recorder.drawRect(r1, p); | 188 recorder.drawRect(r1, p); |
189 recorder.drawRect(r2, p); | 189 recorder.drawRect(r2, p); |
190 recorder.drawRect(r3, p); | 190 recorder.drawRect(r3, p); |
191 | 191 |
192 SkRecord rerecord; | 192 SkRecord rerecord; |
193 SkRecorder canvas(&rerecord, kWidth, kHeight); | 193 SkRecorder canvas(&rerecord, kWidth, kHeight); |
194 SkRecordPartialDraw(record, &canvas, NULL, 0, r1, 1, 2, SkMatrix::I()); // r
eplay just drawRect of r2 | 194 SkRecordPartialDraw(record, &canvas, NULL, 0, 1, 2, SkMatrix::I()); // repla
y just drawRect of r2 |
195 | 195 |
196 REPORTER_ASSERT(r, 3 == rerecord.count()); | 196 REPORTER_ASSERT(r, 3 == rerecord.count()); |
197 assert_type<SkRecords::Save> (r, rerecord, 0); | 197 assert_type<SkRecords::Save> (r, rerecord, 0); |
198 assert_type<SkRecords::DrawRect> (r, rerecord, 1); | 198 assert_type<SkRecords::DrawRect> (r, rerecord, 1); |
199 assert_type<SkRecords::Restore> (r, rerecord, 2); | 199 assert_type<SkRecords::Restore> (r, rerecord, 2); |
200 | 200 |
201 const SkRecords::DrawRect* drawRect = assert_type<SkRecords::DrawRect>(r, re
record, 1); | 201 const SkRecords::DrawRect* drawRect = assert_type<SkRecords::DrawRect>(r, re
record, 1); |
202 REPORTER_ASSERT(r, drawRect->rect == r2); | 202 REPORTER_ASSERT(r, drawRect->rect == r2); |
203 } | 203 } |
204 | 204 |
205 // Check that clears are converted to drawRects | |
206 DEF_TEST(RecordDraw_PartialClear, r) { | |
207 static const int kWidth = 10, kHeight = 10; | |
208 | |
209 SkRect rect = { 0, 0, kWidth, kHeight }; | |
210 | |
211 SkRecord record; | |
212 SkRecorder recorder(&record, kWidth, kHeight); | |
213 recorder.clear(SK_ColorRED); | |
214 | |
215 SkRecord rerecord; | |
216 SkRecorder canvas(&rerecord, kWidth, kHeight); | |
217 SkRecordPartialDraw(record, &canvas, NULL, 0, rect, 0, 1, SkMatrix::I()); //
replay just the clear | |
218 | |
219 REPORTER_ASSERT(r, 3 == rerecord.count()); | |
220 assert_type<SkRecords::Save> (r, rerecord, 0); | |
221 assert_type<SkRecords::DrawRect>(r, rerecord, 1); | |
222 assert_type<SkRecords::Restore> (r, rerecord, 2); | |
223 | |
224 const SkRecords::DrawRect* drawRect = assert_type<SkRecords::DrawRect>(r, re
record, 1); | |
225 REPORTER_ASSERT(r, drawRect->rect == rect); | |
226 REPORTER_ASSERT(r, drawRect->paint.getColor() == SK_ColorRED); | |
227 } | |
228 | |
229 // A regression test for crbug.com/415468 and skbug.com/2957. | 205 // A regression test for crbug.com/415468 and skbug.com/2957. |
230 // | 206 // |
231 // This also now serves as a regression test for crbug.com/418417. We used to a
djust the | 207 // This also now serves as a regression test for crbug.com/418417. We used to a
djust the |
232 // bounds for the saveLayer, clip, and restore to be greater than the bounds of
the picture. | 208 // bounds for the saveLayer, clip, and restore to be greater than the bounds of
the picture. |
233 // (We were applying the saveLayer paint to the bounds after restore, which make
s no sense.) | 209 // (We were applying the saveLayer paint to the bounds after restore, which make
s no sense.) |
234 DEF_TEST(RecordDraw_SaveLayerAffectsClipBounds, r) { | 210 DEF_TEST(RecordDraw_SaveLayerAffectsClipBounds, r) { |
235 SkRecord record; | 211 SkRecord record; |
236 SkRecorder recorder(&record, 50, 50); | 212 SkRecorder recorder(&record, 50, 50); |
237 | 213 |
238 // We draw a rectangle with a long drop shadow. We used to not update the c
lip | 214 // We draw a rectangle with a long drop shadow. We used to not update the c
lip |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 | 303 |
328 { | 304 { |
329 SkRecord record; | 305 SkRecord record; |
330 SkRecorder recorder(&record, 10, 10); | 306 SkRecorder recorder(&record, 10, 10); |
331 recorder.drawImageRect(image, 0, SkRect::MakeWH(10, 10)); | 307 recorder.drawImageRect(image, 0, SkRect::MakeWH(10, 10)); |
332 SkRecordDraw(record, &canvas, NULL, NULL, 0, NULL, 0); | 308 SkRecordDraw(record, &canvas, NULL, NULL, 0, NULL, 0); |
333 } | 309 } |
334 REPORTER_ASSERT(r, canvas.fDrawImageRectCalled); | 310 REPORTER_ASSERT(r, canvas.fDrawImageRectCalled); |
335 | 311 |
336 } | 312 } |
OLD | NEW |