aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrSoftwarePathRenderer.cpp
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2017-08-17 16:14:25 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-08-17 20:33:31 +0000
commitc7da1468e3de821d9be6f086086ea956bb30dbb2 (patch)
tree17a0cdd99d2c97112fe338f671858a0444bdd328 /src/gpu/GrSoftwarePathRenderer.cpp
parent7ca9a74fef3296cdf1385785b5e817e963bb4c35 (diff)
Move DrawToTargetWithShapeMask to GrSoftwarePathRenderer
That function has nothing to do with software masks - I claim it was only in GrSWMaskHelper because it was used by the software path renderer. Also trimmed some includes. Bug: skia: Change-Id: I6939010c70309cdc4135cb250afe85ad7b7be451 Reviewed-on: https://skia-review.googlesource.com/35821 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'src/gpu/GrSoftwarePathRenderer.cpp')
-rw-r--r--src/gpu/GrSoftwarePathRenderer.cpp32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp
index 7201c8bce4..27ba8e6436 100644
--- a/src/gpu/GrSoftwarePathRenderer.cpp
+++ b/src/gpu/GrSoftwarePathRenderer.cpp
@@ -121,6 +121,36 @@ void GrSoftwarePathRenderer::DrawAroundInvPath(GrRenderTargetContext* renderTarg
}
}
+void GrSoftwarePathRenderer::DrawToTargetWithShapeMask(
+ sk_sp<GrTextureProxy> proxy,
+ GrRenderTargetContext* renderTargetContext,
+ GrPaint&& paint,
+ const GrUserStencilSettings& userStencilSettings,
+ const GrClip& clip,
+ const SkMatrix& viewMatrix,
+ const SkIPoint& textureOriginInDeviceSpace,
+ const SkIRect& deviceSpaceRectToDraw) {
+ SkMatrix invert;
+ if (!viewMatrix.invert(&invert)) {
+ return;
+ }
+
+ SkRect dstRect = SkRect::Make(deviceSpaceRectToDraw);
+
+ // We use device coords to compute the texture coordinates. We take the device coords and apply
+ // a translation so that the top-left of the device bounds maps to 0,0, and then a scaling
+ // matrix to normalized coords.
+ SkMatrix maskMatrix = SkMatrix::MakeTrans(SkIntToScalar(-textureOriginInDeviceSpace.fX),
+ SkIntToScalar(-textureOriginInDeviceSpace.fY));
+ maskMatrix.preConcat(viewMatrix);
+ paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(
+ std::move(proxy), nullptr, maskMatrix, GrSamplerParams::kNone_FilterMode));
+ renderTargetContext->addDrawOp(clip,
+ GrRectOpFactory::MakeNonAAFillWithLocalMatrix(
+ std::move(paint), SkMatrix::I(), invert, dstRect,
+ GrAAType::kNone, &userStencilSettings));
+}
+
////////////////////////////////////////////////////////////////////////////////
// return true on success; false on failure
bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) {
@@ -237,7 +267,7 @@ bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) {
*args.fUserStencilSettings, *args.fClip, *args.fViewMatrix, devClipBounds,
unclippedDevShapeBounds);
}
- GrSWMaskHelper::DrawToTargetWithShapeMask(
+ DrawToTargetWithShapeMask(
std::move(proxy), args.fRenderTargetContext, std::move(args.fPaint),
*args.fUserStencilSettings, *args.fClip, *args.fViewMatrix,
SkIPoint{boundsForMask->fLeft, boundsForMask->fTop}, *boundsForMask);