diff options
author | 2017-05-31 13:47:09 -0700 | |
---|---|---|
committer | 2017-06-01 14:42:24 +0000 | |
commit | eb0e60f1ec2498f5cdba96708f25bd7929201aff (patch) | |
tree | 08ddc942f5568fb01ae671f3094119fe2d0706ec /src/effects/SkPictureImageFilter.cpp | |
parent | a03d407aea76a606503a835a45cc8ca7666ed680 (diff) |
Ensure SkPictureImageFilter::onFilterImage doesn't double-convert color
Consider the following sequence of events:
1. SkPictureImageFilter::onFilterImage creates a local canvas, wraps it
in a SkColorSpaceXformCanvas, and passed to...
2. SkPictureImageFilter::drawPictureAtLocalResolution creates a local
canvas (localCanvas) wraps that in a SkColorSpaceXformCanvas, draws
the picture to it, doing sRGB->fColorSpace conversion
3. We then call makeImageSnapshot to produce a SkSpecialImage, localImg,
which is not tagged with any color space.
4. When the draw that localImg to the passed-in SkColorSpaceXformCanvas,
which then performs sRGB->fColorSpace conversion a second time.
We now have performed color conversion twice.
One fix for this would be to have the image produced by the call to
localSurface->makeImageSnapshot() be tagged with fColorSpace. This is
somewhat involved.
The less invasive fix is to remove the SkColorSpaceXformCanvas in
SkPictureImageFilter::onFilterImage, and push it down into the two
branches, SkPictureImageFilter::drawPictureAtLocalResolution and
SkPictureImageFilter::drawPictureAtDeviceResolution.
BUG=728332
Change-Id: If2aa32e18ad660b3e361f1d90845eeb8555fe404
Reviewed-on: https://skia-review.googlesource.com/18282
Reviewed-by: Matt Sarett <msarett@google.com>
Reviewed-by: Christopher Cameron <ccameron@google.com>
Commit-Queue: Christopher Cameron <ccameron@google.com>
Diffstat (limited to 'src/effects/SkPictureImageFilter.cpp')
-rw-r--r-- | src/effects/SkPictureImageFilter.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/effects/SkPictureImageFilter.cpp b/src/effects/SkPictureImageFilter.cpp index 3c59e5e109..2a863542fe 100644 --- a/src/effects/SkPictureImageFilter.cpp +++ b/src/effects/SkPictureImageFilter.cpp @@ -131,15 +131,6 @@ sk_sp<SkSpecialImage> SkPictureImageFilter::onFilterImage(SkSpecialImage* source SkCanvas* canvas = surf->getCanvas(); SkASSERT(canvas); - - std::unique_ptr<SkCanvas> xformCanvas = nullptr; - if (fColorSpace) { - // Only non-null in the case where onMakeColorSpace() was called. This instructs - // us to do the color space xform on playback. - xformCanvas = SkCreateColorSpaceXformCanvas(canvas, fColorSpace); - canvas = xformCanvas.get(); - } - canvas->clear(0x0); if (kDeviceSpace_PictureResolution == fPictureResolution || @@ -162,6 +153,13 @@ sk_sp<SkImageFilter> SkPictureImageFilter::onMakeColorSpace(SkColorSpaceXformer* void SkPictureImageFilter::drawPictureAtDeviceResolution(SkCanvas* canvas, const SkIRect& deviceBounds, const Context& ctx) const { + std::unique_ptr<SkCanvas> xformCanvas = nullptr; + if (fColorSpace) { + // Only non-null in the case where onMakeColorSpace() was called. This instructs + // us to do the color space xform on playback. + xformCanvas = SkCreateColorSpaceXformCanvas(canvas, fColorSpace); + canvas = xformCanvas.get(); + } canvas->translate(-SkIntToScalar(deviceBounds.fLeft), -SkIntToScalar(deviceBounds.fTop)); canvas->concat(ctx.ctm()); canvas->drawPicture(fPicture); |