diff options
author | brianosman <brianosman@google.com> | 2016-09-22 07:15:37 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-09-22 07:15:37 -0700 |
commit | 2a75e5df300a2838f943ca52a52a85a5cf69802b (patch) | |
tree | ef64ee5043762606de08fde3da60b39777c3bc22 /src/effects | |
parent | 4be0e7cfe0efceeaf4c7a4d598d77c27cfd3e69b (diff) |
Add output format properties to SkImageFilter::Context
For now, this is just the color space (of the original
requesting device). This is used when constructing
intermediate rendering surfaces, so that we ensure we
land in a surface that's similar/compatible to the
final consumer of the DAG's output.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2357273002
Review-Url: https://codereview.chromium.org/2357273002
Diffstat (limited to 'src/effects')
-rw-r--r-- | src/effects/SkAlphaThresholdFilter.cpp | 2 | ||||
-rw-r--r-- | src/effects/SkComposeImageFilter.cpp | 4 | ||||
-rw-r--r-- | src/effects/SkDisplacementMapEffect.cpp | 5 | ||||
-rw-r--r-- | src/effects/SkLightingImageFilter.cpp | 21 | ||||
-rw-r--r-- | src/effects/SkMagnifierImageFilter.cpp | 2 | ||||
-rw-r--r-- | src/effects/SkMatrixConvolutionImageFilter.cpp | 2 | ||||
-rw-r--r-- | src/effects/SkMorphologyImageFilter.cpp | 17 | ||||
-rw-r--r-- | src/effects/SkXfermodeImageFilter.cpp | 20 |
8 files changed, 41 insertions, 32 deletions
diff --git a/src/effects/SkAlphaThresholdFilter.cpp b/src/effects/SkAlphaThresholdFilter.cpp index 1f9a9cc5e2..1d92aa51a6 100644 --- a/src/effects/SkAlphaThresholdFilter.cpp +++ b/src/effects/SkAlphaThresholdFilter.cpp @@ -177,7 +177,7 @@ sk_sp<SkSpecialImage> SkAlphaThresholdFilterImpl::onFilterImage(SkSpecialImage* return nullptr; } - return DrawWithFP(context, std::move(fp), bounds, sk_ref_sp(input->getColorSpace())); + return DrawWithFP(context, std::move(fp), bounds, ctx.outputProperties()); } #endif diff --git a/src/effects/SkComposeImageFilter.cpp b/src/effects/SkComposeImageFilter.cpp index a54e53b67a..a5b9190a4c 100644 --- a/src/effects/SkComposeImageFilter.cpp +++ b/src/effects/SkComposeImageFilter.cpp @@ -38,7 +38,7 @@ sk_sp<SkSpecialImage> SkComposeImageFilter::onFilterImage(SkSpecialImage* source // filter requires as input. This matters if the outer filter moves pixels. SkIRect innerClipBounds; innerClipBounds = this->getInput(0)->filterBounds(ctx.clipBounds(), ctx.ctm()); - Context innerContext(ctx.ctm(), innerClipBounds, ctx.cache()); + Context innerContext(ctx.ctm(), innerClipBounds, ctx.cache(), ctx.outputProperties()); SkIPoint innerOffset = SkIPoint::Make(0, 0); sk_sp<SkSpecialImage> inner(this->filterInput(1, source, innerContext, &innerOffset)); if (!inner) { @@ -49,7 +49,7 @@ sk_sp<SkSpecialImage> SkComposeImageFilter::onFilterImage(SkSpecialImage* source outerMatrix.postTranslate(SkIntToScalar(-innerOffset.x()), SkIntToScalar(-innerOffset.y())); SkIRect clipBounds = ctx.clipBounds(); clipBounds.offset(-innerOffset.x(), -innerOffset.y()); - Context outerContext(outerMatrix, clipBounds, ctx.cache()); + Context outerContext(outerMatrix, clipBounds, ctx.cache(), ctx.outputProperties()); SkIPoint outerOffset = SkIPoint::Make(0, 0); sk_sp<SkSpecialImage> outer(this->filterInput(0, inner.get(), outerContext, &outerOffset)); diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp index 0f49a991c2..8fc0ec1366 100644 --- a/src/effects/SkDisplacementMapEffect.cpp +++ b/src/effects/SkDisplacementMapEffect.cpp @@ -336,10 +336,11 @@ sk_sp<SkSpecialImage> SkDisplacementMapEffect::onFilterImage(SkSpecialImage* sou SkMatrix matrix; matrix.setTranslate(-SkIntToScalar(colorBounds.x()), -SkIntToScalar(colorBounds.y())); + SkColorSpace* colorSpace = ctx.outputProperties().colorSpace(); sk_sp<GrDrawContext> drawContext( context->makeDrawContext(SkBackingFit::kApprox, bounds.width(), bounds.height(), - GrRenderableConfigForColorSpace(source->getColorSpace()), - sk_ref_sp(source->getColorSpace()))); + GrRenderableConfigForColorSpace(colorSpace), + sk_ref_sp(colorSpace))); if (!drawContext) { return nullptr; } diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp index 3485bd867c..138ba8bdc4 100644 --- a/src/effects/SkLightingImageFilter.cpp +++ b/src/effects/SkLightingImageFilter.cpp @@ -360,7 +360,8 @@ protected: sk_sp<SkSpecialImage> filterImageGPU(SkSpecialImage* source, SkSpecialImage* input, const SkIRect& bounds, - const SkMatrix& matrix) const; + const SkMatrix& matrix, + const OutputProperties& outputProperties) const; virtual sk_sp<GrFragmentProcessor> makeFragmentProcessor(GrTexture*, const SkMatrix&, const SkIRect* srcBounds, @@ -399,10 +400,12 @@ void SkLightingImageFilterInternal::drawRect(GrDrawContext* drawContext, drawContext->fillRectToRect(clip, paint, SkMatrix::I(), dstRect, srcRect); } -sk_sp<SkSpecialImage> SkLightingImageFilterInternal::filterImageGPU(SkSpecialImage* source, - SkSpecialImage* input, - const SkIRect& offsetBounds, - const SkMatrix& matrix) const { +sk_sp<SkSpecialImage> SkLightingImageFilterInternal::filterImageGPU( + SkSpecialImage* source, + SkSpecialImage* input, + const SkIRect& offsetBounds, + const SkMatrix& matrix, + const OutputProperties& outputProperties) const { SkASSERT(source->isTextureBacked()); GrContext* context = source->getContext(); @@ -412,8 +415,8 @@ sk_sp<SkSpecialImage> SkLightingImageFilterInternal::filterImageGPU(SkSpecialIma sk_sp<GrDrawContext> drawContext( context->makeDrawContext(SkBackingFit::kApprox,offsetBounds.width(), offsetBounds.height(), - GrRenderableConfigForColorSpace(source->getColorSpace()), - sk_ref_sp(source->getColorSpace()))); + GrRenderableConfigForColorSpace(outputProperties.colorSpace()), + sk_ref_sp(outputProperties.colorSpace()))); if (!drawContext) { return nullptr; } @@ -1260,7 +1263,7 @@ sk_sp<SkSpecialImage> SkDiffuseLightingImageFilter::onFilterImage(SkSpecialImage SkMatrix matrix(ctx.ctm()); matrix.postTranslate(SkIntToScalar(-offset->fX), SkIntToScalar(-offset->fY)); - return this->filterImageGPU(source, input.get(), bounds, matrix); + return this->filterImageGPU(source, input.get(), bounds, matrix, ctx.outputProperties()); } #endif @@ -1425,7 +1428,7 @@ sk_sp<SkSpecialImage> SkSpecularLightingImageFilter::onFilterImage(SkSpecialImag SkMatrix matrix(ctx.ctm()); matrix.postTranslate(SkIntToScalar(-offset->fX), SkIntToScalar(-offset->fY)); - return this->filterImageGPU(source, input.get(), bounds, matrix); + return this->filterImageGPU(source, input.get(), bounds, matrix, ctx.outputProperties()); } #endif diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp index eee9ce2d0c..4b03125739 100644 --- a/src/effects/SkMagnifierImageFilter.cpp +++ b/src/effects/SkMagnifierImageFilter.cpp @@ -337,7 +337,7 @@ sk_sp<SkSpecialImage> SkMagnifierImageFilter::onFilterImage(SkSpecialImage* sour return nullptr; } - return DrawWithFP(context, std::move(fp), bounds, sk_ref_sp(input->getColorSpace())); + return DrawWithFP(context, std::move(fp), bounds, ctx.outputProperties()); } #endif diff --git a/src/effects/SkMatrixConvolutionImageFilter.cpp b/src/effects/SkMatrixConvolutionImageFilter.cpp index 5e5f20ba8f..5477d7ab7e 100644 --- a/src/effects/SkMatrixConvolutionImageFilter.cpp +++ b/src/effects/SkMatrixConvolutionImageFilter.cpp @@ -328,7 +328,7 @@ sk_sp<SkSpecialImage> SkMatrixConvolutionImageFilter::onFilterImage(SkSpecialIma return nullptr; } - return DrawWithFP(context, std::move(fp), bounds, sk_ref_sp(input->getColorSpace())); + return DrawWithFP(context, std::move(fp), bounds, ctx.outputProperties()); } #endif diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp index f6d400111c..b8d4884239 100644 --- a/src/effects/SkMorphologyImageFilter.cpp +++ b/src/effects/SkMorphologyImageFilter.cpp @@ -469,14 +469,16 @@ static void apply_morphology_pass(GrDrawContext* drawContext, } } -static sk_sp<SkSpecialImage> apply_morphology(GrContext* context, - SkSpecialImage* input, - const SkIRect& rect, - GrMorphologyEffect::MorphologyType morphType, - SkISize radius) { +static sk_sp<SkSpecialImage> apply_morphology( + GrContext* context, + SkSpecialImage* input, + const SkIRect& rect, + GrMorphologyEffect::MorphologyType morphType, + SkISize radius, + const SkImageFilter::OutputProperties& outputProperties) { sk_sp<GrTexture> srcTexture(input->asTextureRef(context)); SkASSERT(srcTexture); - sk_sp<SkColorSpace> colorSpace = sk_ref_sp(input->getColorSpace()); + sk_sp<SkColorSpace> colorSpace = sk_ref_sp(outputProperties.colorSpace()); GrPixelConfig config = GrRenderableConfigForColorSpace(colorSpace.get()); // setup new clip @@ -571,7 +573,8 @@ sk_sp<SkSpecialImage> SkMorphologyImageFilter::onFilterImage(SkSpecialImage* sou auto type = (kDilate_Op == this->op()) ? GrMorphologyEffect::kDilate_MorphologyType : GrMorphologyEffect::kErode_MorphologyType; sk_sp<SkSpecialImage> result(apply_morphology(context, input.get(), srcBounds, type, - SkISize::Make(width, height))); + SkISize::Make(width, height), + ctx.outputProperties())); if (result) { offset->fX = bounds.left(); offset->fY = bounds.top(); diff --git a/src/effects/SkXfermodeImageFilter.cpp b/src/effects/SkXfermodeImageFilter.cpp index 537175bc4a..62daa5ae3b 100644 --- a/src/effects/SkXfermodeImageFilter.cpp +++ b/src/effects/SkXfermodeImageFilter.cpp @@ -91,7 +91,7 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilter::onFilterImage(SkSpecialImage* sourc return this->filterImageGPU(source, background, backgroundOffset, foreground, foregroundOffset, - bounds); + bounds, ctx.outputProperties()); } #endif @@ -159,12 +159,14 @@ void SkXfermodeImageFilter::toString(SkString* str) const { #include "SkXfermode_proccoeff.h" -sk_sp<SkSpecialImage> SkXfermodeImageFilter::filterImageGPU(SkSpecialImage* source, - sk_sp<SkSpecialImage> background, - const SkIPoint& backgroundOffset, - sk_sp<SkSpecialImage> foreground, - const SkIPoint& foregroundOffset, - const SkIRect& bounds) const { +sk_sp<SkSpecialImage> SkXfermodeImageFilter::filterImageGPU( + SkSpecialImage* source, + sk_sp<SkSpecialImage> background, + const SkIPoint& backgroundOffset, + sk_sp<SkSpecialImage> foreground, + const SkIPoint& foregroundOffset, + const SkIRect& bounds, + const OutputProperties& outputProperties) const { SkASSERT(source->isTextureBacked()); GrContext* context = source->getContext(); @@ -243,8 +245,8 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilter::filterImageGPU(SkSpecialImage* sour sk_sp<GrDrawContext> drawContext( context->makeDrawContext(SkBackingFit::kApprox, bounds.width(), bounds.height(), - GrRenderableConfigForColorSpace(source->getColorSpace()), - sk_ref_sp(source->getColorSpace()))); + GrRenderableConfigForColorSpace(outputProperties.colorSpace()), + sk_ref_sp(outputProperties.colorSpace()))); if (!drawContext) { return nullptr; } |