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

Side by Side 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: improve comment 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « expectations/gm/ignored-tests.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "GrClipMaskManager.h" 9 #include "GrClipMaskManager.h"
10 #include "GrAAConvexPathRenderer.h" 10 #include "GrAAConvexPathRenderer.h"
11 #include "GrAAHairLinePathRenderer.h" 11 #include "GrAAHairLinePathRenderer.h"
12 #include "GrAARectRenderer.h" 12 #include "GrAARectRenderer.h"
13 #include "GrDrawTargetCaps.h" 13 #include "GrDrawTargetCaps.h"
14 #include "GrGpu.h" 14 #include "GrGpu.h"
15 #include "GrPaint.h" 15 #include "GrPaint.h"
16 #include "GrPathRenderer.h" 16 #include "GrPathRenderer.h"
17 #include "GrRenderTarget.h" 17 #include "GrRenderTarget.h"
18 #include "GrStencilBuffer.h" 18 #include "GrStencilBuffer.h"
19 #include "GrSWMaskHelper.h" 19 #include "GrSWMaskHelper.h"
20 #include "effects/GrTextureDomain.h" 20 #include "effects/GrTextureDomain.h"
21 #include "effects/GrConvexPolyEffect.h"
21 #include "SkRasterClip.h" 22 #include "SkRasterClip.h"
22 #include "SkStrokeRec.h" 23 #include "SkStrokeRec.h"
23 #include "SkTLazy.h" 24 #include "SkTLazy.h"
24 25
25 #define GR_AA_CLIP 1 26 #define GR_AA_CLIP 1
26 27
27 typedef SkClipStack::Element Element; 28 typedef SkClipStack::Element Element;
28 29
29 using namespace GrReducedClip; 30 using namespace GrReducedClip;
30 31
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 } 147 }
147 } 148 }
148 } 149 }
149 150
150 if (ignoreClip) { 151 if (ignoreClip) {
151 fGpu->disableScissor(); 152 fGpu->disableScissor();
152 this->setGpuStencil(); 153 this->setGpuStencil();
153 return true; 154 return true;
154 } 155 }
155 156
157 // If there is only one clip element and it is a convex polygon we just inst all an effect that
158 // clips against the edges.
robertphillips 2014/01/31 19:58:58 Will inverse filled paths work correctly?
bsalomon 2014/01/31 20:05:32 Yup, the effect factory fails.
159 if (1 == elements.count() && SkClipStack::Element::kPath_Type == elements.ta il()->getType() &&
160 SkRegion::kReplace_Op == elements.tail()->getOp()) {
161 const SkPath& p = elements.tail()->getPath();
162 bool isAA = GR_AA_CLIP && elements.tail()->isAA();
163 SkAutoTUnref<GrEffectRef> effect;
164 if (rt->isMultisampled()) {
165 // A coverage effect for AA clipping won't play nicely with MSAA.
166 if (!isAA) {
167 effect.reset(GrConvexPolyEffect::Create(GrConvexPolyEffect::kFil lNoAA_EdgeType, p));
168 }
169 } else {
170 GrConvexPolyEffect::EdgeType type = isAA ? GrConvexPolyEffect::kFill AA_EdgeType :
171 GrConvexPolyEffect::kFill NoAA_EdgeType;
172 effect.reset(GrConvexPolyEffect::Create(type, p));
173 }
174 if (effect) {
175 are->set(fGpu->drawState());
176 fGpu->drawState()->addCoverageEffect(effect);
177 fGpu->disableScissor();
178 this->setGpuStencil();
179 return true;
180 }
181 }
182
156 #if GR_AA_CLIP 183 #if GR_AA_CLIP
157 // TODO: catch isRect && requiresAA and use clip planes if available rather than a mask.
158
159 // If MSAA is enabled we can do everything in the stencil buffer. 184 // If MSAA is enabled we can do everything in the stencil buffer.
160 if (0 == rt->numSamples() && requiresAA) { 185 if (0 == rt->numSamples() && requiresAA) {
161 GrTexture* result = NULL; 186 GrTexture* result = NULL;
162 187
163 if (this->useSWOnlyPath(elements)) { 188 if (this->useSWOnlyPath(elements)) {
164 // The clip geometry is complex enough that it will be more efficien t to create it 189 // The clip geometry is complex enough that it will be more efficien t to create it
165 // entirely in software 190 // entirely in software
166 result = this->createSoftwareClipMask(genID, 191 result = this->createSoftwareClipMask(genID,
167 initialState, 192 initialState,
168 elements, 193 elements,
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 1060
1036 // TODO: dynamically attach a stencil buffer 1061 // TODO: dynamically attach a stencil buffer
1037 int stencilBits = 0; 1062 int stencilBits = 0;
1038 GrStencilBuffer* stencilBuffer = 1063 GrStencilBuffer* stencilBuffer =
1039 drawState.getRenderTarget()->getStencilBuffer(); 1064 drawState.getRenderTarget()->getStencilBuffer();
1040 if (NULL != stencilBuffer) { 1065 if (NULL != stencilBuffer) {
1041 stencilBits = stencilBuffer->bits(); 1066 stencilBits = stencilBuffer->bits();
1042 this->adjustStencilParams(settings, clipMode, stencilBits); 1067 this->adjustStencilParams(settings, clipMode, stencilBits);
1043 } 1068 }
1044 } 1069 }
OLDNEW
« no previous file with comments | « expectations/gm/ignored-tests.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698