diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkBlurImageFilter.cpp | 11 | ||||
-rw-r--r-- | src/core/SkGpuBlurUtils.cpp | 24 | ||||
-rw-r--r-- | src/core/SkImageFilter.cpp | 12 |
3 files changed, 33 insertions, 14 deletions
diff --git a/src/core/SkBlurImageFilter.cpp b/src/core/SkBlurImageFilter.cpp index 7590fdcc57..7d51a364d5 100644 --- a/src/core/SkBlurImageFilter.cpp +++ b/src/core/SkBlurImageFilter.cpp @@ -15,6 +15,7 @@ #if SK_SUPPORT_GPU #include "GrContext.h" +#include "GrTextureProxy.h" #include "SkGr.h" #endif @@ -110,8 +111,8 @@ static void get_box3_params(SkScalar s, int *kernelSize, int* kernelSize3, int * } sk_sp<SkSpecialImage> SkBlurImageFilterImpl::onFilterImage(SkSpecialImage* source, - const Context& ctx, - SkIPoint* offset) const { + const Context& ctx, + SkIPoint* offset) const { SkIPoint inputOffset = SkIPoint::Make(0, 0); sk_sp<SkSpecialImage> input(this->filterInput(0, source, ctx, &inputOffset)); @@ -167,9 +168,11 @@ sk_sp<SkSpecialImage> SkBlurImageFilterImpl::onFilterImage(SkSpecialImage* sourc } // TODO: Get the colorSpace from the renderTargetContext (once it has one) - return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(dstBounds.width(), dstBounds.height()), + return SkSpecialImage::MakeDeferredFromGpu( + context, + SkIRect::MakeWH(dstBounds.width(), dstBounds.height()), kNeedNewImageUniqueID_SpecialImage, - renderTargetContext->asTexture(), + sk_ref_sp(renderTargetContext->asDeferredTexture()), sk_ref_sp(input->getColorSpace()), &source->props()); } #endif diff --git a/src/core/SkGpuBlurUtils.cpp b/src/core/SkGpuBlurUtils.cpp index 84cc8d8d14..f210178cef 100644 --- a/src/core/SkGpuBlurUtils.cpp +++ b/src/core/SkGpuBlurUtils.cpp @@ -229,7 +229,7 @@ sk_sp<GrRenderTargetContext> GaussianBlur(GrContext* context, const int height = dstBounds.height(); const GrPixelConfig config = srcTexture->config(); - sk_sp<GrRenderTargetContext> dstRenderTargetContext(context->makeRenderTargetContext( + sk_sp<GrRenderTargetContext> dstRenderTargetContext(context->makeDeferredRenderTargetContext( fit, width, height, config, colorSpace, 0, kDefault_GrSurfaceOrigin)); if (!dstRenderTargetContext) { return nullptr; @@ -248,7 +248,7 @@ sk_sp<GrRenderTargetContext> GaussianBlur(GrContext* context, return dstRenderTargetContext; } - sk_sp<GrRenderTargetContext> tmpRenderTargetContext(context->makeRenderTargetContext( + sk_sp<GrRenderTargetContext> tmpRenderTargetContext(context->makeDeferredRenderTargetContext( fit, width, height, config, colorSpace, 0, kDefault_GrSurfaceOrigin)); if (!tmpRenderTargetContext) { return nullptr; @@ -261,6 +261,8 @@ sk_sp<GrRenderTargetContext> GaussianBlur(GrContext* context, for (int i = 1; i < scaleFactorX || i < scaleFactorY; i *= 2) { GrPaint paint; paint.setGammaCorrect(dstRenderTargetContext->isGammaCorrect()); + // TODO: this matrix relies on the final instantiated size of the texture. This + // will have to be deferred for TextureProxys SkMatrix matrix; matrix.setIDiv(srcTexture->width(), srcTexture->height()); SkIRect dstRect(srcRect); @@ -292,6 +294,9 @@ sk_sp<GrRenderTargetContext> GaussianBlur(GrContext* context, srcRenderTargetContext = dstRenderTargetContext; srcRect = dstRect; srcTexture = srcRenderTargetContext->asTexture(); + if (!srcTexture) { + return nullptr; + } dstRenderTargetContext.swap(tmpRenderTargetContext); localSrcBounds = srcRect; } @@ -314,6 +319,9 @@ sk_sp<GrRenderTargetContext> GaussianBlur(GrContext* context, srcBounds, srcOffset); srcRenderTargetContext = dstRenderTargetContext; srcTexture = srcRenderTargetContext->asTexture(); + if (!srcTexture) { + return nullptr; + } srcRect.offsetTo(0, 0); dstRenderTargetContext.swap(tmpRenderTargetContext); localSrcBounds = srcRect; @@ -350,14 +358,20 @@ sk_sp<GrRenderTargetContext> GaussianBlur(GrContext* context, clearRect = SkIRect::MakeXYWH(srcRect.fRight, srcRect.fTop, 1, srcRect.height()); srcRenderTargetContext->clear(&clearRect, 0x0, false); - SkMatrix matrix; - matrix.setIDiv(srcRenderTargetContext->width(), srcRenderTargetContext->height()); - GrPaint paint; paint.setGammaCorrect(dstRenderTargetContext->isGammaCorrect()); // FIXME: this should be mitchell, not bilinear. GrSamplerParams params(SkShader::kClamp_TileMode, GrSamplerParams::kBilerp_FilterMode); sk_sp<GrTexture> tex(srcRenderTargetContext->asTexture()); + if (!tex) { + return nullptr; + } + + // TODO: this matrix relies on the final instantiated size of the texture. This + // will have to be deferred for TextureProxys + SkMatrix matrix; + matrix.setIDiv(tex->width(), tex->height()); + paint.addColorTextureProcessor(tex.get(), nullptr, matrix, params); paint.setPorterDuffXPFactory(SkBlendMode::kSrc); diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp index 09c26d387e..df46a13d3c 100644 --- a/src/core/SkImageFilter.cpp +++ b/src/core/SkImageFilter.cpp @@ -20,8 +20,9 @@ #include "SkWriteBuffer.h" #if SK_SUPPORT_GPU #include "GrContext.h" -#include "GrRenderTargetContext.h" #include "GrFixedClip.h" +#include "GrRenderTargetContext.h" +#include "GrTextureProxy.h" #include "SkGrPriv.h" #endif @@ -285,7 +286,7 @@ sk_sp<SkSpecialImage> SkImageFilter::DrawWithFP(GrContext* context, sk_sp<SkColorSpace> colorSpace = sk_ref_sp(outputProperties.colorSpace()); GrPixelConfig config = GrRenderableConfigForColorSpace(colorSpace.get()); - sk_sp<GrRenderTargetContext> renderTargetContext(context->makeRenderTargetContext( + sk_sp<GrRenderTargetContext> renderTargetContext(context->makeDeferredRenderTargetContext( SkBackingFit::kApprox, bounds.width(), bounds.height(), config, std::move(colorSpace))); if (!renderTargetContext) { return nullptr; @@ -298,9 +299,10 @@ sk_sp<SkSpecialImage> SkImageFilter::DrawWithFP(GrContext* context, GrFixedClip clip(dstIRect); renderTargetContext->fillRectToRect(clip, paint, SkMatrix::I(), dstRect, srcRect); - return SkSpecialImage::MakeFromGpu(dstIRect, kNeedNewImageUniqueID_SpecialImage, - renderTargetContext->asTexture(), - sk_ref_sp(renderTargetContext->getColorSpace())); + return SkSpecialImage::MakeDeferredFromGpu(context, dstIRect, + kNeedNewImageUniqueID_SpecialImage, + sk_ref_sp(renderTargetContext->asDeferredTexture()), + sk_ref_sp(renderTargetContext->getColorSpace())); } #endif |