aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrBlurUtils.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2016-12-14 09:00:07 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-12-14 14:48:19 +0000
commit4a24da5ceccbbd5eb91c75ce680c42191a5342d0 (patch)
treeada4a0d19d0a7b7171d1ca160e33c9cf89fd80e2 /src/gpu/GrBlurUtils.cpp
parent2734136b68cfb5fbde5a5929a203d5e26f4afc25 (diff)
Make filterMaskGPU use GrTextureProxy
This is a staging CL to position the writePixels in sw_draw_with_mask_filter to be moved to GrSurfaceContext Change-Id: I808372d30ad4aca4a56125ea75d071f7a3747146 Reviewed-on: https://skia-review.googlesource.com/5926 Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/GrBlurUtils.cpp')
-rw-r--r--src/gpu/GrBlurUtils.cpp57
1 files changed, 36 insertions, 21 deletions
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index 768860525f..2a3c0a8932 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -30,16 +30,25 @@ static bool clip_bounds_quick_reject(const SkIRect& clipBounds, const SkIRect& r
// is already burnt into the mask this boils down to a rect draw.
// Return true if the mask was successfully drawn.
static bool draw_mask(GrRenderTargetContext* renderTargetContext,
+ GrTextureProvider* textureProvider,
const GrClip& clip,
const SkMatrix& viewMatrix,
const SkIRect& maskRect,
GrPaint* grp,
- GrTexture* mask) {
+ sk_sp<GrTextureProxy> mask) {
+
+ // TODO: defer this instantiation
+ GrTexture* maskTex = mask->instantiate(textureProvider);
+ if (!maskTex) {
+ return false;
+ }
+
SkMatrix matrix;
matrix.setTranslate(-SkIntToScalar(maskRect.fLeft), -SkIntToScalar(maskRect.fTop));
- matrix.postIDiv(mask->width(), mask->height());
+ // TODO: this divide relies on the instantiated texture's size!
+ matrix.postIDiv(maskTex->width(), maskTex->height());
matrix.preConcat(viewMatrix);
- grp->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(mask, nullptr, matrix));
+ grp->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(maskTex, nullptr, matrix));
SkMatrix inverse;
if (!viewMatrix.invert(&inverse)) {
@@ -50,8 +59,8 @@ static bool draw_mask(GrRenderTargetContext* renderTargetContext,
return true;
}
-static bool sw_draw_with_mask_filter(GrRenderTargetContext* renderTargetContext,
- GrTextureProvider* textureProvider,
+static bool sw_draw_with_mask_filter(GrContext* context,
+ GrRenderTargetContext* renderTargetContext,
const GrClip& clipData,
const SkMatrix& viewMatrix,
const SkPath& devPath,
@@ -83,14 +92,25 @@ static bool sw_draw_with_mask_filter(GrRenderTargetContext* renderTargetContext,
desc.fHeight = dstM.fBounds.height();
desc.fConfig = kAlpha_8_GrPixelConfig;
- sk_sp<GrTexture> texture(textureProvider->createApproxTexture(desc));
+ sk_sp<GrSurfaceProxy> proxy(GrSurfaceProxy::MakeDeferred(*context->caps(), desc,
+ SkBackingFit::kApprox,
+ SkBudgeted::kYes));
+ if (!proxy || !proxy->asTextureProxy()) {
+ return false;
+ }
+
+ // This is a bit goofy but, until writePixels is moved to GrSurfaceContext, we're stuck
+ // instantiating here to do the writePixels
+ GrTexture* texture = proxy->asTextureProxy()->instantiate(context->textureProvider());
if (!texture) {
return false;
}
+
texture->writePixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig,
- dstM.fImage, dstM.fRowBytes);
+ dstM.fImage, dstM.fRowBytes);
- return draw_mask(renderTargetContext, clipData, viewMatrix, dstM.fBounds, grp, texture.get());
+ return draw_mask(renderTargetContext, context->textureProvider(),
+ clipData, viewMatrix, dstM.fBounds, grp, sk_ref_sp(proxy->asTextureProxy()));
}
// Create a mask of 'devPath' and place the result in 'mask'.
@@ -214,17 +234,13 @@ static void draw_path_with_mask_filter(GrContext* context,
aa,
renderTargetContext->numColorSamples()));
if (maskProxy) {
- GrTexture* filtered;
-
- GrTexture* mask = maskProxy->instantiate(context->textureProvider());
- if (!mask) {
- return;
- }
-
- if (maskFilter->filterMaskGPU(mask, viewMatrix, finalIRect, &filtered)) {
- // filterMaskGPU gives us ownership of a ref to the result
- sk_sp<GrTexture> atu(filtered);
- if (draw_mask(renderTargetContext, clip, viewMatrix, finalIRect, paint, filtered)) {
+ sk_sp<GrTextureProxy> filtered = maskFilter->filterMaskGPU(context,
+ std::move(maskProxy),
+ viewMatrix,
+ finalIRect);
+ if (filtered) {
+ if (draw_mask(renderTargetContext, context->textureProvider(),
+ clip, viewMatrix, finalIRect, paint, std::move(filtered))) {
// This path is completely drawn
return;
}
@@ -232,8 +248,7 @@ static void draw_path_with_mask_filter(GrContext* context,
}
}
- sw_draw_with_mask_filter(renderTargetContext, context->textureProvider(),
- clip, viewMatrix, *path,
+ sw_draw_with_mask_filter(context, renderTargetContext, clip, viewMatrix, *path,
maskFilter, clipBounds, paint, fillOrHairline);
}