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

Unified Diff: src/gpu/GrClipMaskManager.cpp

Issue 151523005: Use GrConvexPolyEffect when clip is a single convex polygon (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: upload again, rietveld diff failed. 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 | « expectations/gm/ignored-tests.txt ('k') | src/gpu/effects/GrConvexPolyEffect.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrClipMaskManager.cpp
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index 4fd746f3fa4e9cc450740aa8ae410c7384e2d38f..340ede0d314484247d892cf66324c90ba6715e71 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;
« no previous file with comments | « expectations/gm/ignored-tests.txt ('k') | src/gpu/effects/GrConvexPolyEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698