Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(431)

Side by Side Diff: tests/RecordDrawTest.cpp

Issue 617403002: Merge to M39: Don't adjust the bounds after a restore with the restore's paired saveLayer's paint. (Closed) Base URL: https://skia.googlesource.com/skia.git@m39
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkRecordDraw.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 assert_type<SkRecords::Save> (r, rerecord, 0); 220 assert_type<SkRecords::Save> (r, rerecord, 0);
221 assert_type<SkRecords::DrawRect>(r, rerecord, 1); 221 assert_type<SkRecords::DrawRect>(r, rerecord, 1);
222 assert_type<SkRecords::Restore> (r, rerecord, 2); 222 assert_type<SkRecords::Restore> (r, rerecord, 2);
223 223
224 const SkRecords::DrawRect* drawRect = assert_type<SkRecords::DrawRect>(r, re record, 1); 224 const SkRecords::DrawRect* drawRect = assert_type<SkRecords::DrawRect>(r, re record, 1);
225 REPORTER_ASSERT(r, drawRect->rect == rect); 225 REPORTER_ASSERT(r, drawRect->rect == rect);
226 REPORTER_ASSERT(r, drawRect->paint.getColor() == SK_ColorRED); 226 REPORTER_ASSERT(r, drawRect->paint.getColor() == SK_ColorRED);
227 } 227 }
228 228
229 // A regression test for crbug.com/415468 and skbug.com/2957. 229 // A regression test for crbug.com/415468 and skbug.com/2957.
230 //
231 // 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.
233 // (We were applying the saveLayer paint to the bounds after restore, which make s no sense.)
230 DEF_TEST(RecordDraw_SaveLayerAffectsClipBounds, r) { 234 DEF_TEST(RecordDraw_SaveLayerAffectsClipBounds, r) {
231 SkRecord record; 235 SkRecord record;
232 SkRecorder recorder(&record, 50, 50); 236 SkRecorder recorder(&record, 50, 50);
233 237
234 // We draw a rectangle with a long drop shadow. We used to not update the c lip 238 // 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. 239 // bounds based on SaveLayer paints, so the drop shadow could be cut off.
236 SkPaint paint; 240 SkPaint paint;
237 paint.setImageFilter(SkDropShadowImageFilter::Create(20, 0, 0, 0, SK_ColorBL ACK))->unref(); 241 paint.setImageFilter(SkDropShadowImageFilter::Create(20, 0, 0, 0, SK_ColorBL ACK))->unref();
238 242
239 recorder.saveLayer(NULL, &paint); 243 recorder.saveLayer(NULL, &paint);
240 recorder.clipRect(SkRect::MakeWH(20, 40)); 244 recorder.clipRect(SkRect::MakeWH(20, 40));
241 recorder.drawRect(SkRect::MakeWH(20, 40), SkPaint()); 245 recorder.drawRect(SkRect::MakeWH(20, 40), SkPaint());
242 recorder.restore(); 246 recorder.restore();
243 247
244 // Under the original bug, all the right edge values would be 20 less than a sserted here 248 // Under the original bug, the right edge value of the drawRect would be 20 less than asserted
245 // because we intersected them with a clip that had not been adjusted for th e drop shadow. 249 // here because we intersected it with a clip that had not been adjusted for the drop shadow.
250 //
251 // The second bug showed up as adjusting the picture bounds (0,0,50,50) by t he drop shadow too.
252 // The saveLayer, clipRect, and restore bounds were incorrectly (0,0,70,50).
246 TestBBH bbh; 253 TestBBH bbh;
247 SkRecordFillBounds(record, &bbh); 254 SkRecordFillBounds(record, &bbh);
248 REPORTER_ASSERT(r, bbh.entries.count() == 4); 255 REPORTER_ASSERT(r, bbh.entries.count() == 4);
249 REPORTER_ASSERT(r, sloppy_rect_eq(bbh.entries[0].bounds, SkRect::MakeLTRB(0, 0, 70, 50))); 256 REPORTER_ASSERT(r, sloppy_rect_eq(bbh.entries[0].bounds, SkRect::MakeLTRB(0, 0, 50, 50)));
250 REPORTER_ASSERT(r, sloppy_rect_eq(bbh.entries[1].bounds, SkRect::MakeLTRB(0, 0, 70, 50))); 257 REPORTER_ASSERT(r, sloppy_rect_eq(bbh.entries[1].bounds, SkRect::MakeLTRB(0, 0, 50, 50)));
251 REPORTER_ASSERT(r, sloppy_rect_eq(bbh.entries[2].bounds, SkRect::MakeLTRB(0, 0, 40, 40))); 258 REPORTER_ASSERT(r, sloppy_rect_eq(bbh.entries[2].bounds, SkRect::MakeLTRB(0, 0, 40, 40)));
252 REPORTER_ASSERT(r, sloppy_rect_eq(bbh.entries[3].bounds, SkRect::MakeLTRB(0, 0, 70, 50))); 259 REPORTER_ASSERT(r, sloppy_rect_eq(bbh.entries[3].bounds, SkRect::MakeLTRB(0, 0, 50, 50)));
253 } 260 }
OLDNEW
« no previous file with comments | « src/core/SkRecordDraw.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698