diff options
author | brianosman <brianosman@google.com> | 2016-09-23 08:11:55 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-09-23 08:11:55 -0700 |
commit | 53c38087949252d27cde668368a3eeb59cc2eb00 (patch) | |
tree | 9d005cd6e6037f4b64d1140786e4e687f062f063 /src/effects | |
parent | 27a3aa5921b2aaf95314f955285c3cba91e4c19a (diff) |
Change SkSpecialImage::makeSurface and makeTightSurface to take output
properties (color space), bounds, and (optional) alphaType.
We were being pretty inconsistent before. Raster was honoring all
components of the info. GPU was using the supplied color type, but
propagating the source's color space. All call sites were saying N32.
What we want to do is propagate the original device's color space, and
pick a good format from that. Rather than force all the clients to
jump through hoops constructing an SkImageInfo that meets our criteria,
just have them supply the few bits we care about, and do everything else
internally.
This also lets us always use RGBA on GPU, but N32 on raster.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2349373004
Review-Url: https://codereview.chromium.org/2349373004
Diffstat (limited to 'src/effects')
-rw-r--r-- | src/effects/SkColorFilterImageFilter.cpp | 3 | ||||
-rw-r--r-- | src/effects/SkDisplacementMapEffect.cpp | 13 | ||||
-rw-r--r-- | src/effects/SkDropShadowImageFilter.cpp | 4 | ||||
-rw-r--r-- | src/effects/SkImageSource.cpp | 6 | ||||
-rwxr-xr-x | src/effects/SkMergeImageFilter.cpp | 5 | ||||
-rw-r--r-- | src/effects/SkOffsetImageFilter.cpp | 4 | ||||
-rw-r--r-- | src/effects/SkPaintImageFilter.cpp | 5 | ||||
-rw-r--r-- | src/effects/SkPictureImageFilter.cpp | 9 | ||||
-rw-r--r-- | src/effects/SkTileImageFilter.cpp | 12 | ||||
-rw-r--r-- | src/effects/SkXfermodeImageFilter.cpp | 4 |
10 files changed, 25 insertions, 40 deletions
diff --git a/src/effects/SkColorFilterImageFilter.cpp b/src/effects/SkColorFilterImageFilter.cpp index 63d5942f6a..d6b23d5038 100644 --- a/src/effects/SkColorFilterImageFilter.cpp +++ b/src/effects/SkColorFilterImageFilter.cpp @@ -79,8 +79,7 @@ sk_sp<SkSpecialImage> SkColorFilterImageFilter::onFilterImage(SkSpecialImage* so return nullptr; } - SkImageInfo info = SkImageInfo::MakeN32(bounds.width(), bounds.height(), kPremul_SkAlphaType); - sk_sp<SkSpecialSurface> surf(source->makeSurface(info)); + sk_sp<SkSpecialSurface> surf(source->makeSurface(ctx.outputProperties(), bounds.size())); if (!surf) { return nullptr; } diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp index 8d068072a7..4f6386d92e 100644 --- a/src/effects/SkDisplacementMapEffect.cpp +++ b/src/effects/SkDisplacementMapEffect.cpp @@ -279,7 +279,18 @@ sk_sp<SkSpecialImage> SkDisplacementMapEffect::onFilterImage(SkSpecialImage* sou } SkIPoint displOffset = SkIPoint::Make(0, 0); - sk_sp<SkSpecialImage> displ(this->filterInput(0, source, ctx, &displOffset)); + // Creation of the displacement map should happen in a non-colorspace aware context. This + // texture is a purely mathematical construct, so we want to just operate on the stored + // values. Consider: + // User supplies an sRGB displacement map. If we're rendering to a wider gamut, then we could + // end up filtering the displacement map into that gamut, which has the effect of reducing + // the amount of displacement that it represents (as encoded values move away from the + // primaries). + // With a more complex DAG attached to this input, it's not clear that working in ANY specific + // color space makes sense, so we ignore color spaces (and gamma) entirely. This may not be + // ideal, but it's at least consistent and predictable. + Context displContext(ctx.ctm(), ctx.clipBounds(), ctx.cache(), OutputProperties(nullptr)); + sk_sp<SkSpecialImage> displ(this->filterInput(0, source, displContext, &displOffset)); if (!displ) { return nullptr; } diff --git a/src/effects/SkDropShadowImageFilter.cpp b/src/effects/SkDropShadowImageFilter.cpp index 5befe71194..b4b8cac4f0 100644 --- a/src/effects/SkDropShadowImageFilter.cpp +++ b/src/effects/SkDropShadowImageFilter.cpp @@ -77,9 +77,7 @@ sk_sp<SkSpecialImage> SkDropShadowImageFilter::onFilterImage(SkSpecialImage* sou return nullptr; } - const SkImageInfo info = SkImageInfo::MakeN32(bounds.width(), bounds.height(), - kPremul_SkAlphaType); - sk_sp<SkSpecialSurface> surf(source->makeSurface(info)); + sk_sp<SkSpecialSurface> surf(source->makeSurface(ctx.outputProperties(), bounds.size())); if (!surf) { return nullptr; } diff --git a/src/effects/SkImageSource.cpp b/src/effects/SkImageSource.cpp index f3fc05491e..f434de4aa0 100644 --- a/src/effects/SkImageSource.cpp +++ b/src/effects/SkImageSource.cpp @@ -93,11 +93,7 @@ sk_sp<SkSpecialImage> SkImageSource::onFilterImage(SkSpecialImage* source, const const SkIRect dstIRect = dstRect.roundOut(); - // SRGBTODO: Propagate SkColorType? - const SkImageInfo info = SkImageInfo::MakeN32(dstIRect.width(), dstIRect.height(), - kPremul_SkAlphaType); - - sk_sp<SkSpecialSurface> surf(source->makeSurface(info)); + sk_sp<SkSpecialSurface> surf(source->makeSurface(ctx.outputProperties(), dstIRect.size())); if (!surf) { return nullptr; } diff --git a/src/effects/SkMergeImageFilter.cpp b/src/effects/SkMergeImageFilter.cpp index 2dd02ee529..cc7e336a3d 100755 --- a/src/effects/SkMergeImageFilter.cpp +++ b/src/effects/SkMergeImageFilter.cpp @@ -113,10 +113,7 @@ sk_sp<SkSpecialImage> SkMergeImageFilter::onFilterImage(SkSpecialImage* source, const int x0 = bounds.left(); const int y0 = bounds.top(); - SkImageInfo info = SkImageInfo::MakeN32(bounds.width(), bounds.height(), - kPremul_SkAlphaType); - - sk_sp<SkSpecialSurface> surf(source->makeSurface(info)); + sk_sp<SkSpecialSurface> surf(source->makeSurface(ctx.outputProperties(), bounds.size())); if (!surf) { return nullptr; } diff --git a/src/effects/SkOffsetImageFilter.cpp b/src/effects/SkOffsetImageFilter.cpp index af60164d99..1c99154f16 100644 --- a/src/effects/SkOffsetImageFilter.cpp +++ b/src/effects/SkOffsetImageFilter.cpp @@ -49,9 +49,7 @@ sk_sp<SkSpecialImage> SkOffsetImageFilter::onFilterImage(SkSpecialImage* source, return nullptr; } - SkImageInfo info = SkImageInfo::MakeN32(bounds.width(), bounds.height(), - kPremul_SkAlphaType); - sk_sp<SkSpecialSurface> surf(source->makeSurface(info)); + sk_sp<SkSpecialSurface> surf(source->makeSurface(ctx.outputProperties(), bounds.size())); if (!surf) { return nullptr; } diff --git a/src/effects/SkPaintImageFilter.cpp b/src/effects/SkPaintImageFilter.cpp index 8833629eed..0a0e4e92ed 100644 --- a/src/effects/SkPaintImageFilter.cpp +++ b/src/effects/SkPaintImageFilter.cpp @@ -43,10 +43,7 @@ sk_sp<SkSpecialImage> SkPaintImageFilter::onFilterImage(SkSpecialImage* source, return nullptr; } - SkImageInfo info = SkImageInfo::MakeN32(bounds.width(), bounds.height(), - kPremul_SkAlphaType); - - sk_sp<SkSpecialSurface> surf(source->makeSurface(info)); + sk_sp<SkSpecialSurface> surf(source->makeSurface(ctx.outputProperties(), bounds.size())); if (!surf) { return nullptr; } diff --git a/src/effects/SkPictureImageFilter.cpp b/src/effects/SkPictureImageFilter.cpp index bfe26b62c5..6539104a30 100644 --- a/src/effects/SkPictureImageFilter.cpp +++ b/src/effects/SkPictureImageFilter.cpp @@ -118,8 +118,7 @@ sk_sp<SkSpecialImage> SkPictureImageFilter::onFilterImage(SkSpecialImage* source SkASSERT(!bounds.isEmpty()); - SkImageInfo info = SkImageInfo::MakeN32(bounds.width(), bounds.height(), kPremul_SkAlphaType); - sk_sp<SkSpecialSurface> surf(source->makeSurface(info)); + sk_sp<SkSpecialSurface> surf(source->makeSurface(ctx.outputProperties(), bounds.size())); if (!surf) { return nullptr; } @@ -167,10 +166,8 @@ void SkPictureImageFilter::drawPictureAtLocalResolution(SkSpecialImage* source, sk_sp<SkSpecialImage> localImg; { - const SkImageInfo info = SkImageInfo::MakeN32(localIBounds.width(), localIBounds.height(), - kPremul_SkAlphaType); - - sk_sp<SkSpecialSurface> localSurface(source->makeSurface(info)); + sk_sp<SkSpecialSurface> localSurface(source->makeSurface(ctx.outputProperties(), + localIBounds.size())); if (!localSurface) { return; } diff --git a/src/effects/SkTileImageFilter.cpp b/src/effects/SkTileImageFilter.cpp index c098bc2955..46c4d9af67 100644 --- a/src/effects/SkTileImageFilter.cpp +++ b/src/effects/SkTileImageFilter.cpp @@ -55,9 +55,7 @@ sk_sp<SkSpecialImage> SkTileImageFilter::onFilterImage(SkSpecialImage* source, } const SkIRect dstIRect = dstRect.roundOut(); - int dstWidth = dstIRect.width(); - int dstHeight = dstIRect.height(); - if (!fSrcRect.width() || !fSrcRect.height() || !dstWidth || !dstHeight) { + if (!fSrcRect.width() || !fSrcRect.height() || !dstIRect.width() || !dstIRect.height()) { return nullptr; } @@ -80,9 +78,7 @@ sk_sp<SkSpecialImage> SkTileImageFilter::onFilterImage(SkSpecialImage* source, return nullptr; } } else { - const SkImageInfo info = SkImageInfo::MakeN32(srcIRect.width(), srcIRect.height(), - kPremul_SkAlphaType); - sk_sp<SkSurface> surf(input->makeTightSurface(info)); + sk_sp<SkSurface> surf(input->makeTightSurface(ctx.outputProperties(), srcIRect.size())); if (!surf) { return nullptr; } @@ -102,9 +98,7 @@ sk_sp<SkSpecialImage> SkTileImageFilter::onFilterImage(SkSpecialImage* source, SkASSERT(subset->width() == srcIRect.width()); SkASSERT(subset->height() == srcIRect.height()); - const SkImageInfo info = SkImageInfo::MakeN32(dstWidth, dstHeight, kPremul_SkAlphaType); - - sk_sp<SkSpecialSurface> surf(source->makeSurface(info)); + sk_sp<SkSpecialSurface> surf(source->makeSurface(ctx.outputProperties(), dstIRect.size())); if (!surf) { return nullptr; } diff --git a/src/effects/SkXfermodeImageFilter.cpp b/src/effects/SkXfermodeImageFilter.cpp index c7e4143e11..d655c9484f 100644 --- a/src/effects/SkXfermodeImageFilter.cpp +++ b/src/effects/SkXfermodeImageFilter.cpp @@ -95,9 +95,7 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilter::onFilterImage(SkSpecialImage* sourc } #endif - const SkImageInfo info = SkImageInfo::MakeN32(bounds.width(), bounds.height(), - kPremul_SkAlphaType); - sk_sp<SkSpecialSurface> surf(source->makeSurface(info)); + sk_sp<SkSpecialSurface> surf(source->makeSurface(ctx.outputProperties(), bounds.size())); if (!surf) { return nullptr; } |