| Index: src/effects/SkColorFilterImageFilter.cpp
|
| diff --git a/src/effects/SkColorFilterImageFilter.cpp b/src/effects/SkColorFilterImageFilter.cpp
|
| index c1637d81284b062602954483a68a46cfc89aacdf..1fdc668f9b42ae6a446452c6a7a5b23ec5baf53f 100644
|
| --- a/src/effects/SkColorFilterImageFilter.cpp
|
| +++ b/src/effects/SkColorFilterImageFilter.cpp
|
| @@ -57,13 +57,19 @@ 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 inputBounds;
|
| + if (fColorFilter->affectsTransparentBlack()) {
|
| + // If the color filter affects transparent black, the bounds are the entire clip.
|
| + inputBounds = ctx.clipBounds();
|
| + } else if (!input) {
|
| return nullptr;
|
| + } else {
|
| + inputBounds = SkIRect::MakeXYWH(inputOffset.x(), inputOffset.y(),
|
| + input->width(), input->height());
|
| }
|
|
|
| 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 +83,27 @@ 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 may not be necessary to clear or drawPaint inside the input bounds
|
| + // (see skbug.com/5075)
|
| + if (fColorFilter->affectsTransparentBlack()) {
|
| + // The subsequent input->draw() call may not fill the entire canvas. For filters which
|
| + // affect transparent black, ensure that the filter is applied everywhere.
|
| + canvas->drawPaint(paint);
|
| + } else {
|
| + 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;
|
|
|