aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/effects/SkAlphaThresholdFilter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/effects/SkAlphaThresholdFilter.cpp')
-rw-r--r--src/effects/SkAlphaThresholdFilter.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/effects/SkAlphaThresholdFilter.cpp b/src/effects/SkAlphaThresholdFilter.cpp
index cec45ba911..bfbcfd21f8 100644
--- a/src/effects/SkAlphaThresholdFilter.cpp
+++ b/src/effects/SkAlphaThresholdFilter.cpp
@@ -95,16 +95,24 @@ SkAlphaThresholdFilterImpl::SkAlphaThresholdFilterImpl(const SkRegion& region,
sk_sp<GrTexture> SkAlphaThresholdFilterImpl::createMaskTexture(GrContext* context,
const SkMatrix& inMatrix,
const SkIRect& bounds) const {
- GrPixelConfig config;
+ GrSurfaceDesc maskDesc;
if (context->caps()->isConfigRenderable(kAlpha_8_GrPixelConfig, false)) {
- config = kAlpha_8_GrPixelConfig;
+ maskDesc.fConfig = kAlpha_8_GrPixelConfig;
} else {
- config = kRGBA_8888_GrPixelConfig;
+ maskDesc.fConfig = kRGBA_8888_GrPixelConfig;
+ }
+ maskDesc.fFlags = kRenderTarget_GrSurfaceFlag;
+ // Add one pixel of border to ensure that clamp mode will be all zeros
+ // the outside.
+ maskDesc.fWidth = bounds.width();
+ maskDesc.fHeight = bounds.height();
+ sk_sp<GrTexture> maskTexture(context->textureProvider()->createApproxTexture(maskDesc));
+ if (!maskTexture) {
+ return nullptr;
}
- sk_sp<GrDrawContext> drawContext(context->newDrawContext(GrContext::kLoose_BackingFit,
- bounds.width(), bounds.height(),
- config));
+ sk_sp<GrDrawContext> drawContext(
+ context->drawContext(sk_ref_sp(maskTexture->asRenderTarget())));
if (!drawContext) {
return nullptr;
}
@@ -121,7 +129,7 @@ sk_sp<GrTexture> SkAlphaThresholdFilterImpl::createMaskTexture(GrContext* contex
iter.next();
}
- return drawContext->asTexture();
+ return maskTexture;
}
#endif