| 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 // This also now serves as a regression test for crbug.com/418417. We used to a
djust the | 227 // This also now serves as a regression test for crbug.com/418417. We used to a
djust the |
| 228 // bounds for the saveLayer, clip, and restore to be greater than the bounds of
the picture. | 228 // bounds for the saveLayer, clip, and restore to be greater than the bounds of
the picture. |
| 229 // (We were applying the saveLayer paint to the bounds after restore, which make
s no sense.) | 229 // (We were applying the saveLayer paint to the bounds after restore, which make
s no sense.) |
| 230 DEF_TEST(RecordDraw_SaveLayerAffectsClipBounds, r) { | 230 DEF_TEST(RecordDraw_SaveLayerAffectsClipBounds, r) { |
| 231 SkRecord record; | 231 SkRecord record; |
| 232 SkRecorder recorder(&record, 50, 50); | 232 SkRecorder recorder(&record, 50, 50); |
| 233 | 233 |
| 234 // We draw a rectangle with a long drop shadow. We used to not update the c
lip | 234 // We draw a rectangle with a long drop shadow. We used to not update the c
lip |
| 235 // bounds based on SaveLayer paints, so the drop shadow could be cut off. | 235 // bounds based on SaveLayer paints, so the drop shadow could be cut off. |
| 236 SkPaint paint; | 236 SkPaint paint; |
| 237 paint.setImageFilter(SkDropShadowImageFilter::Create(20, 0, 0, 0, SK_ColorBL
ACK))->unref(); | 237 paint.setImageFilter(SkDropShadowImageFilter::Create(20, 0, 0, 0, SK_ColorBL
ACK, |
| 238 SkDropShadowImageFilter::kDrawShadowAndForeground_Shado
wMode))->unref(); |
| 238 | 239 |
| 239 recorder.saveLayer(NULL, &paint); | 240 recorder.saveLayer(NULL, &paint); |
| 240 recorder.clipRect(SkRect::MakeWH(20, 40)); | 241 recorder.clipRect(SkRect::MakeWH(20, 40)); |
| 241 recorder.drawRect(SkRect::MakeWH(20, 40), SkPaint()); | 242 recorder.drawRect(SkRect::MakeWH(20, 40), SkPaint()); |
| 242 recorder.restore(); | 243 recorder.restore(); |
| 243 | 244 |
| 244 // Under the original bug, the right edge value of the drawRect would be 20
less than asserted | 245 // Under the original bug, the right edge value of the drawRect would be 20
less than asserted |
| 245 // here because we intersected it with a clip that had not been adjusted for
the drop shadow. | 246 // here because we intersected it with a clip that had not been adjusted for
the drop shadow. |
| 246 // | 247 // |
| 247 // The second bug showed up as adjusting the picture bounds (0,0,50,50) by t
he drop shadow too. | 248 // The second bug showed up as adjusting the picture bounds (0,0,50,50) by t
he drop shadow too. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 | 302 |
| 302 { | 303 { |
| 303 SkRecord record; | 304 SkRecord record; |
| 304 SkRecorder recorder(&record, 10, 10); | 305 SkRecorder recorder(&record, 10, 10); |
| 305 recorder.drawImageRect(image, 0, SkRect::MakeWH(10, 10)); | 306 recorder.drawImageRect(image, 0, SkRect::MakeWH(10, 10)); |
| 306 SkRecordDraw(record, &canvas, 0, 0); | 307 SkRecordDraw(record, &canvas, 0, 0); |
| 307 } | 308 } |
| 308 REPORTER_ASSERT(r, canvas.fDrawImageRectCalled); | 309 REPORTER_ASSERT(r, canvas.fDrawImageRectCalled); |
| 309 | 310 |
| 310 } | 311 } |
| OLD | NEW |