aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrSWMaskHelper.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-20 17:32:27 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-20 17:32:27 +0000
commitae81d5c4aa1716756b2cfb4c44f27f4dce2716ef (patch)
tree019b5c1b55da3c7da77943f8b93f5cc28da090c2 /src/gpu/GrSWMaskHelper.cpp
parent723dd790fbef396cd5c6619d0a3656c641b0c3f5 (diff)
Adds local coords to GrEffect system.
Effects can ask the builder for local coords which may or may not be distinct from positions. GrEffectStage tracks changes to relationship between pos and local coords. GrGLEffectMatrix and GrSingleTextureEffect can use either pos or textures as intput coords GrSimpleTextureEffect now allows for an explicit texture coords attribute. Review URL: https://codereview.chromium.org/12531015 git-svn-id: http://skia.googlecode.com/svn/trunk@8264 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/GrSWMaskHelper.cpp')
-rw-r--r--src/gpu/GrSWMaskHelper.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp
index fe9fd8228b..2cf56d63d6 100644
--- a/src/gpu/GrSWMaskHelper.cpp
+++ b/src/gpu/GrSWMaskHelper.cpp
@@ -197,18 +197,29 @@ void GrSWMaskHelper::DrawToTargetWithPathMask(GrTexture* texture,
// && edge rendering (kEdgeEffectStage in GrContext)
kPathMaskStage = GrPaint::kTotalStages,
};
- GrAssert(!drawState->isStageEnabled(kPathMaskStage));
- drawState->createTextureEffect(kPathMaskStage, texture, SkMatrix::I());
- SkScalar w = SkIntToScalar(rect.width());
- SkScalar h = SkIntToScalar(rect.height());
- GrRect maskRect = GrRect::MakeWH(w / texture->width(),
- h / texture->height());
GrRect dstRect = GrRect::MakeLTRB(
SK_Scalar1 * rect.fLeft,
SK_Scalar1 * rect.fTop,
SK_Scalar1 * rect.fRight,
SK_Scalar1 * rect.fBottom);
- target->drawRect(dstRect, NULL, &maskRect, NULL, kPathMaskStage);
+
+ // We want to use device coords to compute the texture coordinates. We set our matrix to be
+ // equal to the view matrix followed by a translation so that the top-left of the device bounds
+ // maps to 0,0, and then a scaling matrix to normalized coords. We apply this matrix to the
+ // vertex positions rather than local coords.
+ SkMatrix maskMatrix;
+ maskMatrix.setIDiv(texture->width(), texture->height());
+ maskMatrix.preTranslate(SkIntToScalar(-rect.fLeft), SkIntToScalar(-rect.fTop));
+ maskMatrix.preConcat(drawState->getViewMatrix());
+
+ GrAssert(!drawState->isStageEnabled(kPathMaskStage));
+ drawState->setEffect(kPathMaskStage,
+ GrSimpleTextureEffect::Create(texture,
+ maskMatrix,
+ false,
+ GrEffect::kPosition_CoordsType))->unref();
+
+ target->drawSimpleRect(dstRect);
drawState->disableStage(kPathMaskStage);
}