diff options
Diffstat (limited to 'src/effects/SkAlphaThresholdFilter.cpp')
-rw-r--r-- | src/effects/SkAlphaThresholdFilter.cpp | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/src/effects/SkAlphaThresholdFilter.cpp b/src/effects/SkAlphaThresholdFilter.cpp index b1c8b21460..abf924ca06 100644 --- a/src/effects/SkAlphaThresholdFilter.cpp +++ b/src/effects/SkAlphaThresholdFilter.cpp @@ -16,8 +16,9 @@ #if SK_SUPPORT_GPU #include "GrAlphaThresholdFragmentProcessor.h" #include "GrContext.h" -#include "GrRenderTargetContext.h" #include "GrFixedClip.h" +#include "GrRenderTargetContext.h" +#include "GrTextureProxy.h" #endif class SK_API SkAlphaThresholdFilterImpl : public SkImageFilter { @@ -37,7 +38,9 @@ protected: SkIPoint* offset) const override; #if SK_SUPPORT_GPU - sk_sp<GrTexture> createMaskTexture(GrContext*, const SkMatrix&, const SkIRect& bounds) const; + sk_sp<GrTextureProxy> createMaskTexture(GrContext*, + const SkMatrix&, + const SkIRect& bounds) const; #endif private: @@ -93,29 +96,29 @@ SkAlphaThresholdFilterImpl::SkAlphaThresholdFilterImpl(const SkRegion& region, } #if SK_SUPPORT_GPU -sk_sp<GrTexture> SkAlphaThresholdFilterImpl::createMaskTexture(GrContext* context, - const SkMatrix& inMatrix, - const SkIRect& bounds) const { +sk_sp<GrTextureProxy> SkAlphaThresholdFilterImpl::createMaskTexture(GrContext* context, + const SkMatrix& inMatrix, + const SkIRect& bounds) const { - sk_sp<GrRenderTargetContext> renderTargetContext(context->makeRenderTargetContextWithFallback( + sk_sp<GrRenderTargetContext> rtContext(context->makeDeferredRenderTargetContextWithFallback( SkBackingFit::kApprox, bounds.width(), bounds.height(), kAlpha_8_GrPixelConfig, nullptr)); - if (!renderTargetContext) { + if (!rtContext) { return nullptr; } GrPaint grPaint; grPaint.setPorterDuffXPFactory(SkBlendMode::kSrc); SkRegion::Iterator iter(fRegion); - renderTargetContext->clear(nullptr, 0x0, true); + rtContext->clear(nullptr, 0x0, true); GrFixedClip clip(SkIRect::MakeWH(bounds.width(), bounds.height())); while (!iter.done()) { SkRect rect = SkRect::Make(iter.rect()); - renderTargetContext->drawRect(clip, grPaint, inMatrix, rect); + rtContext->drawRect(clip, grPaint, inMatrix, rect); iter.next(); } - return renderTargetContext->asTexture(); + return sk_ref_sp(rtContext->asDeferredTexture()); } #endif @@ -158,7 +161,7 @@ sk_sp<SkSpecialImage> SkAlphaThresholdFilterImpl::onFilterImage(SkSpecialImage* SkMatrix matrix(ctx.ctm()); matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top())); - sk_sp<GrTexture> maskTexture(this->createMaskTexture(context, matrix, bounds)); + sk_sp<GrTextureProxy> maskTexture(this->createMaskTexture(context, matrix, bounds)); if (!maskTexture) { return nullptr; } @@ -167,12 +170,12 @@ sk_sp<SkSpecialImage> SkAlphaThresholdFilterImpl::onFilterImage(SkSpecialImage* sk_sp<GrColorSpaceXform> colorSpaceXform = GrColorSpaceXform::Make(input->getColorSpace(), outProps.colorSpace()); sk_sp<GrFragmentProcessor> fp(GrAlphaThresholdFragmentProcessor::Make( - inputTexture.get(), - std::move(colorSpaceXform), - maskTexture.get(), - fInnerThreshold, - fOuterThreshold, - bounds)); + inputTexture.get(), + std::move(colorSpaceXform), + maskTexture->instantiate(context->textureProvider()), + fInnerThreshold, + fOuterThreshold, + bounds)); if (!fp) { return nullptr; } |