aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrSWMaskHelper.cpp
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-09 16:32:28 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-09 16:32:28 +0000
commit5dfb67219a308edecafbe09eebb35c5e149db6e6 (patch)
treecf63f8899846e2c94c71af0df46f2b01dc6ab316 /src/gpu/GrSWMaskHelper.cpp
parentd3ba5cc85e24896f980ed1ba6e3f4495973baeb3 (diff)
Left over cleanup from r4416 (fix for lingering AA clip mask bug)
Diffstat (limited to 'src/gpu/GrSWMaskHelper.cpp')
-rw-r--r--src/gpu/GrSWMaskHelper.cpp61
1 files changed, 47 insertions, 14 deletions
diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp
index e34151c736..fe32110b83 100644
--- a/src/gpu/GrSWMaskHelper.cpp
+++ b/src/gpu/GrSWMaskHelper.cpp
@@ -169,30 +169,63 @@ void GrSWMaskHelper::toTexture(GrTexture *texture, uint8_t alpha) {
////////////////////////////////////////////////////////////////////////////////
/**
* Software rasterizes path to A8 mask (possibly using the context's matrix)
- * and uploads the result to a scratch texture. Returns true on success;
- * false on failure.
+ * and uploads the result to a scratch texture. Returns the resulting
+ * texture on success; NULL on failure.
*/
-bool GrSWMaskHelper::DrawToTexture(GrContext* context,
- const SkPath& path,
- const GrIRect& resultBounds,
- GrPathFill fill,
- GrAutoScratchTexture* result,
- bool antiAlias,
- GrMatrix* matrix) {
+GrTexture* GrSWMaskHelper::DrawPathMaskToTexture(GrContext* context,
+ const SkPath& path,
+ const GrIRect& resultBounds,
+ GrPathFill fill,
+ bool antiAlias,
+ GrMatrix* matrix) {
+ GrAutoScratchTexture ast;
+
GrSWMaskHelper helper(context);
if (!helper.init(resultBounds, matrix)) {
- return false;
+ return NULL;
}
helper.draw(path, SkRegion::kReplace_Op, fill, antiAlias, 0xFF);
- if (!helper.getTexture(result)) {
- return false;
+ if (!helper.getTexture(&ast)) {
+ return NULL;
}
- helper.toTexture(result->texture(), 0x00);
+ helper.toTexture(ast.texture(), 0x00);
- return true;
+ return ast.detach();
+}
+
+void GrSWMaskHelper::DrawToTargetWithPathMask(GrTexture* texture,
+ GrDrawTarget* target,
+ GrDrawState::StageMask stageMask,
+ const GrIRect& rect) {
+ GrDrawState* drawState = target->drawState();
+
+ GrDrawTarget::AutoDeviceCoordDraw adcd(target, stageMask);
+ enum {
+ // the SW path renderer shares this stage with glyph
+ // rendering (kGlyphMaskStage in GrBatchedTextContext)
+ kPathMaskStage = GrPaint::kTotalStages,
+ };
+ GrAssert(!drawState->isStageEnabled(kPathMaskStage));
+ drawState->setTexture(kPathMaskStage, texture);
+ drawState->sampler(kPathMaskStage)->reset();
+ GrScalar w = GrIntToScalar(rect.width());
+ GrScalar h = GrIntToScalar(rect.height());
+ GrRect maskRect = GrRect::MakeWH(w / texture->width(),
+ h / texture->height());
+
+ const GrRect* srcRects[GrDrawState::kNumStages] = { NULL };
+ srcRects[kPathMaskStage] = &maskRect;
+ stageMask |= 1 << kPathMaskStage;
+ GrRect dstRect = GrRect::MakeLTRB(
+ SK_Scalar1 * rect.fLeft,
+ SK_Scalar1 * rect.fTop,
+ SK_Scalar1 * rect.fRight,
+ SK_Scalar1 * rect.fBottom);
+ target->drawRect(dstRect, NULL, stageMask, srcRects, NULL);
+ drawState->setTexture(kPathMaskStage, NULL);
}