diff options
author | Robert Phillips <robertphillips@google.com> | 2017-03-14 09:17:43 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-03-14 14:09:12 +0000 |
commit | d3749485db2de966a80e39669a49192fc7c0bd9d (patch) | |
tree | 2a86aa3d24a394dd569f25f94eae08cd58674efe /src/gpu/GrSWMaskHelper.cpp | |
parent | 4a01ac9e410e7b78fb04c8632e0676082b9408aa (diff) |
Consolidate Proxy caching code in GrResourceProvider
This doesn't implement the GrSurfaceProxy-based caching but just carves out a space for it.
Split out of: https://skia-review.googlesource.com/c/8823/ (Remove GrFragmentProcessor-derived class' GrTexture-based ctors)
Change-Id: Iec87b45e3264b349d7804f63e361e970b925e335
Reviewed-on: https://skia-review.googlesource.com/9626
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/GrSWMaskHelper.cpp')
-rw-r--r-- | src/gpu/GrSWMaskHelper.cpp | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp index 6b6f1e67ab..1ffc40aec1 100644 --- a/src/gpu/GrSWMaskHelper.cpp +++ b/src/gpu/GrSWMaskHelper.cpp @@ -97,8 +97,9 @@ bool GrSWMaskHelper::init(const SkIRect& resultBounds, const SkMatrix* matrix) { return true; } -sk_sp<GrTextureProxy> GrSWMaskHelper::toTexture(GrContext* context, SkBackingFit fit) { +sk_sp<GrTextureProxy> GrSWMaskHelper::toTextureProxy(GrContext* context, SkBackingFit fit) { GrSurfaceDesc desc; + desc.fOrigin = kTopLeft_GrSurfaceOrigin; desc.fWidth = fPixels.width(); desc.fHeight = fPixels.height(); desc.fConfig = kAlpha_8_GrPixelConfig; @@ -132,12 +133,12 @@ void GrSWMaskHelper::toSDF(unsigned char* sdf) { * Software rasterizes shape to A8 mask and uploads the result to a scratch texture. Returns the * resulting texture on success; nullptr on failure. */ -sk_sp<GrTexture> GrSWMaskHelper::DrawShapeMaskToTexture(GrContext* context, - const GrShape& shape, - const SkIRect& resultBounds, - GrAA aa, - SkBackingFit fit, - const SkMatrix* matrix) { +sk_sp<GrTextureProxy> GrSWMaskHelper::DrawShapeMaskToTexture(GrContext* context, + const GrShape& shape, + const SkIRect& resultBounds, + GrAA aa, + SkBackingFit fit, + const SkMatrix* matrix) { GrSWMaskHelper helper; if (!helper.init(resultBounds, matrix)) { @@ -146,15 +147,11 @@ sk_sp<GrTexture> GrSWMaskHelper::DrawShapeMaskToTexture(GrContext* context, helper.drawShape(shape, SkRegion::kReplace_Op, aa, 0xFF); - sk_sp<GrTextureProxy> tProxy = helper.toTexture(context, fit); - if (!tProxy) { - return nullptr; - } - - return sk_ref_sp(tProxy->instantiate(context->resourceProvider())); + return helper.toTextureProxy(context, fit); } -void GrSWMaskHelper::DrawToTargetWithShapeMask(GrTexture* texture, +void GrSWMaskHelper::DrawToTargetWithShapeMask(GrContext* context, + sk_sp<GrTextureProxy> proxy, GrRenderTargetContext* renderTargetContext, GrPaint&& paint, const GrUserStencilSettings& userStencilSettings, @@ -178,7 +175,7 @@ void GrSWMaskHelper::DrawToTargetWithShapeMask(GrTexture* texture, std::unique_ptr<GrMeshDrawOp> op = GrRectOpFactory::MakeNonAAFill( paint.getColor(), SkMatrix::I(), dstRect, nullptr, &invert); paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Make( - texture, nullptr, maskMatrix, GrSamplerParams::kNone_FilterMode)); + context, std::move(proxy), nullptr, maskMatrix, GrSamplerParams::kNone_FilterMode)); GrPipelineBuilder pipelineBuilder(std::move(paint), GrAAType::kNone); pipelineBuilder.setUserStencil(&userStencilSettings); renderTargetContext->addMeshDrawOp(pipelineBuilder, clip, std::move(op)); |