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

Unified Diff: tests/RecordDrawTest.cpp

Issue 595953002: We need to adjust the bounds of clip ops with SaveLayer paints too. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: grammar Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkRecordDraw.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/RecordDrawTest.cpp
diff --git a/tests/RecordDrawTest.cpp b/tests/RecordDrawTest.cpp
index 70f0250ccaa7307ed08939dea043db0e004494ae..1108af6e36503c9471ad2c10b3364a7e1f85e865 100644
--- a/tests/RecordDrawTest.cpp
+++ b/tests/RecordDrawTest.cpp
@@ -10,9 +10,10 @@
#include "SkDebugCanvas.h"
#include "SkDrawPictureCallback.h"
+#include "SkDropShadowImageFilter.h"
#include "SkRecord.h"
-#include "SkRecordOpts.h"
#include "SkRecordDraw.h"
+#include "SkRecordOpts.h"
#include "SkRecorder.h"
#include "SkRecords.h"
@@ -224,3 +225,29 @@ DEF_TEST(RecordDraw_PartialClear, r) {
REPORTER_ASSERT(r, drawRect->rect == rect);
REPORTER_ASSERT(r, drawRect->paint.getColor() == SK_ColorRED);
}
+
+// A regression test for crbug.com/415468 and skbug.com/2957.
+DEF_TEST(RecordDraw_SaveLayerAffectsClipBounds, r) {
+ SkRecord record;
+ SkRecorder recorder(&record, 50, 50);
+
+ // We draw a rectangle with a long drop shadow. We used to not update the clip
+ // bounds based on SaveLayer paints, so the drop shadow could be cut off.
+ SkPaint paint;
+ paint.setImageFilter(SkDropShadowImageFilter::Create(20, 0, 0, 0, SK_ColorBLACK))->unref();
+
+ recorder.saveLayer(NULL, &paint);
+ recorder.clipRect(SkRect::MakeWH(20, 40));
+ recorder.drawRect(SkRect::MakeWH(20, 40), SkPaint());
+ recorder.restore();
+
+ // Under the original bug, all the right edge values would be 20 less than asserted here
+ // because we intersected them with a clip that had not been adjusted for the drop shadow.
+ TestBBH bbh;
+ SkRecordFillBounds(record, &bbh);
+ REPORTER_ASSERT(r, bbh.entries.count() == 4);
+ REPORTER_ASSERT(r, sloppy_rect_eq(bbh.entries[0].bounds, SkRect::MakeLTRB(0, 0, 70, 50)));
+ REPORTER_ASSERT(r, sloppy_rect_eq(bbh.entries[1].bounds, SkRect::MakeLTRB(0, 0, 70, 50)));
+ REPORTER_ASSERT(r, sloppy_rect_eq(bbh.entries[2].bounds, SkRect::MakeLTRB(0, 0, 40, 40)));
+ REPORTER_ASSERT(r, sloppy_rect_eq(bbh.entries[3].bounds, SkRect::MakeLTRB(0, 0, 70, 50)));
+}
« 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