Index: gm/convexpolyeffect.cpp |
diff --git a/gm/convexpolyeffect.cpp b/gm/convexpolyeffect.cpp |
index 2632bd41866dcbfa2f886c038ca512973d172dab..9142ca9cbd135811869915cd202b400ba11854ed 100644 |
--- a/gm/convexpolyeffect.cpp |
+++ b/gm/convexpolyeffect.cpp |
@@ -44,7 +44,7 @@ protected: |
} |
virtual SkISize onISize() SK_OVERRIDE { |
- return make_isize(475, 800); |
+ return make_isize(720, 800); |
} |
virtual uint32_t onGetFlags() const SK_OVERRIDE { |
@@ -100,7 +100,6 @@ protected: |
fRects.addToTail(SkRect::MakeLTRB(5.05f, .55f, 5.45f, .85f)); |
// inverted in x and y |
fRects.addToTail(SkRect::MakeLTRB(100.f, 50.5f, 5.f, 0.5f)); |
- |
} |
virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
@@ -174,55 +173,58 @@ protected: |
y += SkScalarCeilToScalar(path->getBounds().height() + 20.f); |
} |
- // Draw rects. We only have specialized effect code for the AA case, so don't do non-AA. |
for (SkTLList<SkRect>::Iter iter(fRects, SkTLList<SkRect>::Iter::kHead_IterStart); |
NULL != iter.get(); |
iter.next()) { |
SkScalar x = 0; |
- GrTestTarget tt; |
- context->getTestTarget(&tt); |
- if (NULL == tt.target()) { |
- SkDEBUGFAIL("Couldn't get Gr test target."); |
- return; |
- } |
- |
- SkRect rect = *iter.get(); |
- rect.offset(x, y); |
- SkAutoTUnref<GrEffectRef> effect(GrConvexPolyEffect::CreateForAAFillRect(rect)); |
- if (!effect) { |
- SkDEBUGFAIL("Couldn't create convex poly effect."); |
- return; |
- } |
+ for (int et = 0; et < GrConvexPolyEffect::kEdgeTypeCnt; ++et) { |
+ GrTestTarget tt; |
+ context->getTestTarget(&tt); |
+ if (NULL == tt.target()) { |
+ SkDEBUGFAIL("Couldn't get Gr test target."); |
+ return; |
+ } |
+ SkRect rect = *iter.get(); |
+ rect.offset(x, y); |
+ GrConvexPolyEffect::EdgeType edgeType = (GrConvexPolyEffect::EdgeType) et; |
+ SkAutoTUnref<GrEffectRef> effect(GrConvexPolyEffect::Create(edgeType, rect)); |
+ if (!effect) { |
+ SkDEBUGFAIL("Couldn't create convex poly effect."); |
+ return; |
+ } |
- GrDrawState* drawState = tt.target()->drawState(); |
- drawState->setVertexAttribs<kAttribs>(SK_ARRAY_COUNT(kAttribs)); |
- drawState->addCoverageEffect(effect, 1); |
- drawState->setIdentityViewMatrix(); |
- drawState->setRenderTarget(rt); |
- drawState->setColor(0xff000000); |
+ GrDrawState* drawState = tt.target()->drawState(); |
+ drawState->setVertexAttribs<kAttribs>(SK_ARRAY_COUNT(kAttribs)); |
+ drawState->addCoverageEffect(effect, 1); |
+ drawState->setIdentityViewMatrix(); |
+ drawState->setRenderTarget(rt); |
+ drawState->setColor(0xff000000); |
- SkPoint verts[4]; |
- SkRect bounds = rect; |
- bounds.outset(5.f, 5.f); |
- bounds.toQuad(verts); |
+ SkPoint verts[4]; |
+ SkRect bounds = rect; |
+ bounds.outset(5.f, 5.f); |
+ bounds.toQuad(verts); |
- tt.target()->setVertexSourceToArray(verts, 4); |
- tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuffer()); |
- tt.target()->drawIndexed(kTriangleFan_GrPrimitiveType, 0, 0, 4, 6); |
+ tt.target()->setVertexSourceToArray(verts, 4); |
+ tt.target()->setIndexSourceToBuffer(context->getQuadIndexBuffer()); |
+ tt.target()->drawIndexed(kTriangleFan_GrPrimitiveType, 0, 0, 4, 6); |
- x += SkScalarCeilToScalar(rect.width() + 10.f); |
+ x += SkScalarCeilToScalar(rect.width() + 10.f); |
+ } |
- // Draw AA rect using normal API for reference |
+ // Draw rect without and with AA using normal API for reference |
canvas->save(); |
canvas->translate(x, y); |
SkPaint paint; |
+ canvas->drawRect(*iter.get(), paint); |
+ x += SkScalarCeilToScalar(iter.get()->width() + 10.f); |
paint.setAntiAlias(true); |
canvas->drawRect(*iter.get(), paint); |
canvas->restore(); |
- y += SkScalarCeilToScalar(rect.height() + 20.f); |
+ y += SkScalarCeilToScalar(iter.get()->height() + 20.f); |
} |
} |