diff options
author | senorblanco <senorblanco@chromium.org> | 2016-05-18 07:00:08 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-18 07:00:08 -0700 |
commit | 3949971e8d29345ee89461aec1ef25734ffc03f5 (patch) | |
tree | cd6d565733b3d2ace762a6af783ac5ffdbecabd8 | |
parent | d46e5859863c7401ceb90f1a62086865be957443 (diff) |
Image filters: fix filtering of transparent black in CFIF.
SkColorFilterImageFilter has a codepath to filter transparent black
regions outside of the input image. However, it was treating the
exterior as opaque black, rather than trasparent black.
Note: the results of imagefiltercropexpand GM will change, as it
was tweaked a bit to show this bug.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1978363002
NOTREECHECKS=true
NOTRY=true
NOPRESUBMIT=true
Review-Url: https://codereview.chromium.org/1978363002
-rw-r--r-- | gm/imagefilterscropexpand.cpp | 8 | ||||
-rw-r--r-- | src/effects/SkColorFilterImageFilter.cpp | 2 |
2 files changed, 7 insertions, 3 deletions
diff --git a/gm/imagefilterscropexpand.cpp b/gm/imagefilterscropexpand.cpp index 4ce845d9ee..9b9f7ee817 100644 --- a/gm/imagefilterscropexpand.cpp +++ b/gm/imagefilterscropexpand.cpp @@ -50,11 +50,13 @@ protected: sk_sp<SkImageFilter> gradientCircleSource(SkImageSource::Make(std::move(gradientCircle))); sk_sp<SkImageFilter> noopCropped(SkOffsetImageFilter::Make(0, 0, nullptr, &cropRect)); - SkScalar sk255 = SkIntToScalar(255); + // This color matrix saturates the green component but only partly increases the opacity. + // For the opaque checkerboard, the opacity boost doesn't matter but it does impact the + // area outside the checkerboard. SkScalar matrix[20] = { 1, 0, 0, 0, 0, - 0, 1, 0, 0, sk255, + 0, 1, 0, 0, 255, 0, 0, 1, 0, 0, - 0, 0, 0, 0, sk255 }; + 0, 0, 0, 1, 32 }; sk_sp<SkColorFilter> cfAlphaTrans(SkColorFilter::MakeMatrixFilterRowMajor255(matrix)); SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64)); diff --git a/src/effects/SkColorFilterImageFilter.cpp b/src/effects/SkColorFilterImageFilter.cpp index 8d412cc2f5..63d5942f6a 100644 --- a/src/effects/SkColorFilterImageFilter.cpp +++ b/src/effects/SkColorFilterImageFilter.cpp @@ -98,7 +98,9 @@ sk_sp<SkSpecialImage> SkColorFilterImageFilter::onFilterImage(SkSpecialImage* so 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. + paint.setColor(SK_ColorTRANSPARENT); canvas->drawPaint(paint); + paint.setColor(SK_ColorBLACK); } else { canvas->clear(0x0); } |