Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Unified Diff: src/gpu/GrSWMaskHelper.cpp

Issue 12531015: Adds local coords to GrEffect system. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrInOrderDrawBuffer.cpp ('k') | src/gpu/GrTextContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrSWMaskHelper.cpp
===================================================================
--- src/gpu/GrSWMaskHelper.cpp (revision 8241)
+++ src/gpu/GrSWMaskHelper.cpp (working copy)
@@ -197,18 +197,29 @@
// && 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);
}
« no previous file with comments | « src/gpu/GrInOrderDrawBuffer.cpp ('k') | src/gpu/GrTextContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698