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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 // This also now serves as a regression test for crbug.com/418417. We used to a
djust the | 202 // This also now serves as a regression test for crbug.com/418417. We used to a
djust the |
203 // bounds for the saveLayer, clip, and restore to be greater than the bounds of
the picture. | 203 // bounds for the saveLayer, clip, and restore to be greater than the bounds of
the picture. |
204 // (We were applying the saveLayer paint to the bounds after restore, which make
s no sense.) | 204 // (We were applying the saveLayer paint to the bounds after restore, which make
s no sense.) |
205 DEF_TEST(RecordDraw_SaveLayerAffectsClipBounds, r) { | 205 DEF_TEST(RecordDraw_SaveLayerAffectsClipBounds, r) { |
206 SkRecord record; | 206 SkRecord record; |
207 SkRecorder recorder(&record, 50, 50); | 207 SkRecorder recorder(&record, 50, 50); |
208 | 208 |
209 // We draw a rectangle with a long drop shadow. We used to not update the c
lip | 209 // We draw a rectangle with a long drop shadow. We used to not update the c
lip |
210 // bounds based on SaveLayer paints, so the drop shadow could be cut off. | 210 // bounds based on SaveLayer paints, so the drop shadow could be cut off. |
211 SkPaint paint; | 211 SkPaint paint; |
212 paint.setImageFilter(SkDropShadowImageFilter::Create(20, 0, 0, 0, SK_ColorBL
ACK, | 212 paint.setImageFilter(SkDropShadowImageFilter::Make( |
213 SkDropShadowImageFilter::kDrawShadowAndForeground_Shado
wMode))->unref(); | 213 20, 0, 0, 0, SK_ColorBLACK, |
| 214 SkDropShadowImageFilter::kDrawShadowAndForegrou
nd_ShadowMode, |
| 215 nullptr)); |
214 | 216 |
215 recorder.saveLayer(nullptr, &paint); | 217 recorder.saveLayer(nullptr, &paint); |
216 recorder.clipRect(SkRect::MakeWH(20, 40)); | 218 recorder.clipRect(SkRect::MakeWH(20, 40)); |
217 recorder.drawRect(SkRect::MakeWH(20, 40), SkPaint()); | 219 recorder.drawRect(SkRect::MakeWH(20, 40), SkPaint()); |
218 recorder.restore(); | 220 recorder.restore(); |
219 | 221 |
220 // Under the original bug, the right edge value of the drawRect would be 20
less than asserted | 222 // Under the original bug, the right edge value of the drawRect would be 20
less than asserted |
221 // here because we intersected it with a clip that had not been adjusted for
the drop shadow. | 223 // here because we intersected it with a clip that had not been adjusted for
the drop shadow. |
222 // | 224 // |
223 // The second bug showed up as adjusting the picture bounds (0,0,50,50) by t
he drop shadow too. | 225 // The second bug showed up as adjusting the picture bounds (0,0,50,50) by t
he drop shadow too. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 | 298 |
297 { | 299 { |
298 SkRecord record; | 300 SkRecord record; |
299 SkRecorder recorder(&record, 10, 10); | 301 SkRecorder recorder(&record, 10, 10); |
300 recorder.drawImageRect(image, SkRect::MakeWH(10, 10), nullptr); | 302 recorder.drawImageRect(image, SkRect::MakeWH(10, 10), nullptr); |
301 SkRecordDraw(record, &canvas, nullptr, nullptr, 0, nullptr, 0); | 303 SkRecordDraw(record, &canvas, nullptr, nullptr, 0, nullptr, 0); |
302 } | 304 } |
303 REPORTER_ASSERT(r, canvas.fDrawImageRectCalled); | 305 REPORTER_ASSERT(r, canvas.fDrawImageRectCalled); |
304 | 306 |
305 } | 307 } |
OLD | NEW |