aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-02-04 17:49:48 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-02-04 17:49:48 +0000
commit65ee5f424cb4dabd453268902c00086605d77c1d (patch)
tree4df198f1a75fddaf2a0396fa4f0272db8525fe6b
parentd52a99703bd8dcc2567fbe5f8c18d408c15ab7d7 (diff)
Use GrConvexPolyEffect when clip is a single convex polygon
BUG=skia:2051 Committed: http://code.google.com/p/skia/source/detail?r=13286 R=robertphillips@google.com Author: bsalomon@google.com Review URL: https://codereview.chromium.org/151523005 git-svn-id: http://skia.googlecode.com/svn/trunk@13306 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--expectations/gm/ignored-tests.txt5
-rw-r--r--src/gpu/GrClipMaskManager.cpp29
-rw-r--r--src/gpu/effects/GrConvexPolyEffect.cpp2
-rw-r--r--tests/GLProgramsTest.cpp1
4 files changed, 33 insertions, 4 deletions
diff --git a/expectations/gm/ignored-tests.txt b/expectations/gm/ignored-tests.txt
index cf708c836d..2e3afd7918 100644
--- a/expectations/gm/ignored-tests.txt
+++ b/expectations/gm/ignored-tests.txt
@@ -31,4 +31,7 @@
## Added by epoger as part of MADE-UP BUG
## https://code.google.com/p/skia/issues/detail?id=123456 : ignoring failures on
## gradtext GM test
-#gradtext \ No newline at end of file
+#gradtext
+
+# Added by bsalomon for skbug.com/2051, https://codereview.chromium.org/151523005
+filltypespersp
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index 4fd746f3fa..340ede0d31 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -18,6 +18,7 @@
#include "GrStencilBuffer.h"
#include "GrSWMaskHelper.h"
#include "effects/GrTextureDomain.h"
+#include "effects/GrConvexPolyEffect.h"
#include "SkRasterClip.h"
#include "SkStrokeRec.h"
#include "SkTLazy.h"
@@ -153,9 +154,33 @@ bool GrClipMaskManager::setupClipping(const GrClipData* clipDataIn,
return true;
}
-#if GR_AA_CLIP
- // TODO: catch isRect && requiresAA and use clip planes if available rather than a mask.
+ // If there is only one clip element and it is a convex polygon we just install an effect that
+ // clips against the edges.
+ if (1 == elements.count() && SkClipStack::Element::kPath_Type == elements.tail()->getType() &&
+ SkRegion::kReplace_Op == elements.tail()->getOp()) {
+ const SkPath& p = elements.tail()->getPath();
+ bool isAA = GR_AA_CLIP && elements.tail()->isAA();
+ SkAutoTUnref<GrEffectRef> effect;
+ if (rt->isMultisampled()) {
+ // A coverage effect for AA clipping won't play nicely with MSAA.
+ if (!isAA) {
+ effect.reset(GrConvexPolyEffect::Create(GrConvexPolyEffect::kFillNoAA_EdgeType, p));
+ }
+ } else {
+ GrConvexPolyEffect::EdgeType type = isAA ? GrConvexPolyEffect::kFillAA_EdgeType :
+ GrConvexPolyEffect::kFillNoAA_EdgeType;
+ effect.reset(GrConvexPolyEffect::Create(type, p));
+ }
+ if (effect) {
+ are->set(fGpu->drawState());
+ fGpu->drawState()->addCoverageEffect(effect);
+ fGpu->disableScissor();
+ this->setGpuStencil();
+ return true;
+ }
+ }
+#if GR_AA_CLIP
// If MSAA is enabled we can do everything in the stencil buffer.
if (0 == rt->numSamples() && requiresAA) {
GrTexture* result = NULL;
diff --git a/src/gpu/effects/GrConvexPolyEffect.cpp b/src/gpu/effects/GrConvexPolyEffect.cpp
index 4616bdb7a3..e47ed0f866 100644
--- a/src/gpu/effects/GrConvexPolyEffect.cpp
+++ b/src/gpu/effects/GrConvexPolyEffect.cpp
@@ -174,7 +174,7 @@ GrEffectRef* GrConvexPolyEffect::TestCreate(SkRandom* random,
const GrDrawTargetCaps& caps,
GrTexture*[]) {
EdgeType edgeType = static_cast<EdgeType>(random->nextULessThan(kEdgeTypeCnt));
- int count = random->nextULessThan(kMaxEdges + 1);
+ int count = random->nextULessThan(kMaxEdges) + 1;
SkScalar edges[kMaxEdges * 3];
for (int i = 0; i < 3 * count; ++i) {
edges[i] = random->nextSScalar1();
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index 6c4aace96f..f3207352df 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -173,6 +173,7 @@ bool GrGpuGL::programUnitTest(int maxStages) {
this->getContext(),
*this->caps(),
dummyTextures));
+ SkASSERT(effect);
int numAttribs = (*effect)->numVertexAttribs();
// If adding this effect would exceed the max attrib count then generate a