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

Unified Diff: src/effects/SkColorFilterImageFilter.cpp

Issue 1844593002: Fix failed filter followed by an affects-transparent-black filter. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix formatting Created 4 years, 9 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 | « no previous file | tests/ImageFilterTest.cpp » ('j') | tests/ImageFilterTest.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkColorFilterImageFilter.cpp
diff --git a/src/effects/SkColorFilterImageFilter.cpp b/src/effects/SkColorFilterImageFilter.cpp
index 1e2cdacb97ef5eab26c8e8089b1ade73856062af..01b0401a57de2eada03c4a66e7d81237ccbc7cdc 100644
--- a/src/effects/SkColorFilterImageFilter.cpp
+++ b/src/effects/SkColorFilterImageFilter.cpp
@@ -57,13 +57,18 @@ sk_sp<SkSpecialImage> SkColorFilterImageFilter::onFilterImage(SkSpecialImage* so
SkIPoint* offset) const {
SkIPoint inputOffset = SkIPoint::Make(0, 0);
sk_sp<SkSpecialImage> input(this->filterInput(0, source, ctx, &inputOffset));
- if (!input) {
+
+ SkIRect bounds;
+ SkIRect inputBounds;
+ if (fColorFilter->affectsTransparentBlack()) {
robertphillips 2016/03/30 17:12:28 // If the color filter affects transparent black t
Stephen White 2016/04/04 21:50:55 Done. (Isn't that what the code says? :) )
+ inputBounds = ctx.clipBounds();
+ } else if (!input) {
return nullptr;
+ } else {
+ inputBounds = SkIRect::MakeXYWH(inputOffset.x(), inputOffset.y(),
+ input->width(), input->height());
}
robertphillips 2016/03/30 17:12:28 Can we move 'bounds' down here ?
Stephen White 2016/04/04 21:50:55 Done.
- SkIRect bounds;
- const SkIRect inputBounds = SkIRect::MakeXYWH(inputOffset.fX, inputOffset.fY,
- input->width(), input->height());
if (!this->applyCropRect(ctx, inputBounds, &bounds)) {
return nullptr;
}
@@ -77,18 +82,24 @@ sk_sp<SkSpecialImage> SkColorFilterImageFilter::onFilterImage(SkSpecialImage* so
SkCanvas* canvas = surf->getCanvas();
SkASSERT(canvas);
- // TODO: it seems like this clear shouldn't be necessary (see skbug.com/5075)
- canvas->clear(0x0);
-
SkPaint paint;
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
paint.setColorFilter(fColorFilter);
- input->draw(canvas,
- SkIntToScalar(inputOffset.fX - bounds.fLeft),
- SkIntToScalar(inputOffset.fY - bounds.fTop),
- &paint);
+ // TODO: it seems like this clear shouldn't be necessary (see skbug.com/5075)
+ if (fColorFilter->affectsTransparentBlack()) {
robertphillips 2016/03/30 17:12:28 // The following SkSpecialImage::draw call may not
Stephen White 2016/04/04 21:50:55 Done.
+ canvas->drawPaint(paint);
+ } else {
robertphillips 2016/03/30 17:12:28 can we move the "TODO:" comment in here ?
Stephen White 2016/03/30 19:16:08 Well, technically it applies to the drawPaint(), s
Stephen White 2016/04/04 21:50:55 Done.
+ canvas->clear(0x0);
+ }
+
+ if (input) {
+ input->draw(canvas,
+ SkIntToScalar(inputOffset.fX - bounds.fLeft),
+ SkIntToScalar(inputOffset.fY - bounds.fTop),
+ &paint);
+ }
offset->fX = bounds.fLeft;
offset->fY = bounds.fTop;
« no previous file with comments | « no previous file | tests/ImageFilterTest.cpp » ('j') | tests/ImageFilterTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698