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

Unified Diff: gm/convexpolyeffect.cpp

Issue 183833003: Make GrConvexPolyEffect support inverse fills and non-AA rects (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: update GM width Created 6 years, 10 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 | « no previous file | src/gpu/GrClipMaskManager.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
}
« no previous file with comments | « no previous file | src/gpu/GrClipMaskManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698