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

Side by Side Diff: src/gpu/GrClipMaskManager.cpp

Issue 732693002: Drawstate on stack (Closed) Base URL: https://skia.googlesource.com/skia.git@real_def_gp
Patch Set: ready Created 6 years, 1 month 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
OLDNEW
1
2 /* 1 /*
3 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
4 * 3 *
5 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 5 * found in the LICENSE file.
7 */ 6 */
8 7
9 #include "GrClipMaskManager.h" 8 #include "GrClipMaskManager.h"
10 #include "GrAAConvexPathRenderer.h" 9 #include "GrAAConvexPathRenderer.h"
11 #include "GrAAHairLinePathRenderer.h" 10 #include "GrAAHairLinePathRenderer.h"
12 #include "GrAARectRenderer.h" 11 #include "GrAARectRenderer.h"
13 #include "GrDrawTargetCaps.h" 12 #include "GrDrawTargetCaps.h"
14 #include "GrPaint.h" 13 #include "GrPaint.h"
15 #include "GrPathRenderer.h" 14 #include "GrPathRenderer.h"
16 #include "GrRenderTarget.h" 15 #include "GrRenderTarget.h"
17 #include "GrStencilBuffer.h" 16 #include "GrStencilBuffer.h"
18 #include "GrSWMaskHelper.h" 17 #include "GrSWMaskHelper.h"
19 #include "SkRasterClip.h" 18 #include "SkRasterClip.h"
20 #include "SkStrokeRec.h" 19 #include "SkStrokeRec.h"
21 #include "SkTLazy.h" 20 #include "SkTLazy.h"
22 #include "effects/GrTextureDomain.h" 21 #include "effects/GrTextureDomain.h"
23 #include "effects/GrConvexPolyEffect.h" 22 #include "effects/GrConvexPolyEffect.h"
24 #include "effects/GrRRectEffect.h" 23 #include "effects/GrRRectEffect.h"
25 24
26 #define GR_AA_CLIP 1 25 #define GR_AA_CLIP 1
27
28 typedef SkClipStack::Element Element; 26 typedef SkClipStack::Element Element;
29 27
30 //////////////////////////////////////////////////////////////////////////////// 28 ////////////////////////////////////////////////////////////////////////////////
31 namespace { 29 namespace {
32 // set up the draw state to enable the aa clipping mask. Besides setting up the 30 // set up the draw state to enable the aa clipping mask. Besides setting up the
33 // stage matrix this also alters the vertex layout 31 // stage matrix this also alters the vertex layout
34 void setup_drawstate_aaclip(GrDrawTarget* gpu, 32 void setup_drawstate_aaclip(const SkIRect &devBound,
35 GrTexture* result, 33 GrDrawState* drawState,
36 const SkIRect &devBound) { 34 GrTexture* result) {
37 GrDrawState* drawState = gpu->drawState();
38 SkASSERT(drawState); 35 SkASSERT(drawState);
39 36
40 SkMatrix mat; 37 SkMatrix mat;
41 // We want to use device coords to compute the texture coordinates. We set o ur matrix to be 38 // We want to use device coords to compute the texture coordinates. We set o ur matrix to be
42 // equal to the view matrix followed by an offset to the devBound, and then a scaling matrix to 39 // equal to the view matrix followed by an offset to the devBound, and then a scaling matrix to
43 // normalized coords. We apply this matrix to the vertex positions rather th an local coords. 40 // normalized coords. We apply this matrix to the vertex positions rather th an local coords.
44 mat.setIDiv(result->width(), result->height()); 41 mat.setIDiv(result->width(), result->height());
45 mat.preTranslate(SkIntToScalar(-devBound.fLeft), 42 mat.preTranslate(SkIntToScalar(-devBound.fLeft),
46 SkIntToScalar(-devBound.fTop)); 43 SkIntToScalar(-devBound.fTop));
47 mat.preConcat(drawState->getViewMatrix()); 44 mat.preConcat(drawState->getViewMatrix());
48 45
49 SkIRect domainTexels = SkIRect::MakeWH(devBound.width(), devBound.height()); 46 SkIRect domainTexels = SkIRect::MakeWH(devBound.width(), devBound.height());
50 // This could be a long-lived effect that is cached with the alpha-mask. 47 // This could be a long-lived effect that is cached with the alpha-mask.
51 drawState->addCoverageProcessor( 48 drawState->addCoverageProcessor(
52 GrTextureDomainEffect::Create(result, 49 GrTextureDomainEffect::Create(result,
53 mat, 50 mat,
54 GrTextureDomain::MakeTexelDomain(result, d omainTexels), 51 GrTextureDomain::MakeTexelDomain(result, d omainTexels),
55 GrTextureDomain::kDecal_Mode, 52 GrTextureDomain::kDecal_Mode,
56 GrTextureParams::kNone_FilterMode, 53 GrTextureParams::kNone_FilterMode,
57 kPosition_GrCoordSet))->unref(); 54 kPosition_GrCoordSet))->unref();
58 } 55 }
59 56
60 bool path_needs_SW_renderer(GrContext* context, 57 bool path_needs_SW_renderer(GrContext* context,
61 GrDrawTarget* gpu, 58 const GrDrawTarget* gpu,
59 const GrDrawState* drawState,
62 const SkPath& origPath, 60 const SkPath& origPath,
63 const SkStrokeRec& stroke, 61 const SkStrokeRec& stroke,
64 bool doAA) { 62 bool doAA) {
65 // the gpu alpha mask will draw the inverse paths as non-inverse to a temp b uffer 63 // the gpu alpha mask will draw the inverse paths as non-inverse to a temp b uffer
66 SkTCopyOnFirstWrite<SkPath> path(origPath); 64 SkTCopyOnFirstWrite<SkPath> path(origPath);
67 if (path->isInverseFillType()) { 65 if (path->isInverseFillType()) {
68 path.writable()->toggleInverseFillType(); 66 path.writable()->toggleInverseFillType();
69 } 67 }
70 // last (false) parameter disallows use of the SW path renderer 68 // last (false) parameter disallows use of the SW path renderer
71 GrPathRendererChain::DrawType type = doAA ? 69 GrPathRendererChain::DrawType type = doAA ?
72 GrPathRendererChain::kColorAntiAlias_Dr awType : 70 GrPathRendererChain::kColorAntiAlias_Dr awType :
73 GrPathRendererChain::kColor_DrawType; 71 GrPathRendererChain::kColor_DrawType;
74 72
75 return NULL == context->getPathRenderer(*path, stroke, gpu, false, type); 73 return NULL == context->getPathRenderer(gpu, drawState, *path, stroke, false , type);
76 } 74 }
77
78 } 75 }
79 76
80 /* 77 /*
81 * This method traverses the clip stack to see if the GrSoftwarePathRenderer 78 * This method traverses the clip stack to see if the GrSoftwarePathRenderer
82 * will be used on any element. If so, it returns true to indicate that the 79 * will be used on any element. If so, it returns true to indicate that the
83 * entire clip should be rendered in SW and then uploaded en masse to the gpu. 80 * entire clip should be rendered in SW and then uploaded en masse to the gpu.
84 */ 81 */
85 bool GrClipMaskManager::useSWOnlyPath(const GrReducedClip::ElementList& elements ) { 82 bool GrClipMaskManager::useSWOnlyPath(const GrDrawState* drawState,
86 83 const GrReducedClip::ElementList& elements ) {
87 // TODO: generalize this function so that when 84 // TODO: generalize this function so that when
88 // a clip gets complex enough it can just be done in SW regardless 85 // a clip gets complex enough it can just be done in SW regardless
89 // of whether it would invoke the GrSoftwarePathRenderer. 86 // of whether it would invoke the GrSoftwarePathRenderer.
90 SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle); 87 SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle);
91 88
92 for (GrReducedClip::ElementList::Iter iter(elements.headIter()); iter.get(); iter.next()) { 89 for (GrReducedClip::ElementList::Iter iter(elements.headIter()); iter.get(); iter.next()) {
93 const Element* element = iter.get(); 90 const Element* element = iter.get();
94 // rects can always be drawn directly w/o using the software path 91 // rects can always be drawn directly w/o using the software path
95 // Skip rrects once we're drawing them directly. 92 // Skip rrects once we're drawing them directly.
96 if (Element::kRect_Type != element->getType()) { 93 if (Element::kRect_Type != element->getType()) {
97 SkPath path; 94 SkPath path;
98 element->asPath(&path); 95 element->asPath(&path);
99 if (path_needs_SW_renderer(this->getContext(), fClipTarget, path, st roke, 96 if (path_needs_SW_renderer(this->getContext(), fClipTarget, drawStat e, path, stroke,
100 element->isAA())) { 97 element->isAA())) {
101 return true; 98 return true;
102 } 99 }
103 } 100 }
104 } 101 }
105 return false; 102 return false;
106 } 103 }
107 104
108 bool GrClipMaskManager::installClipEffects(const GrReducedClip::ElementList& ele ments, 105 bool GrClipMaskManager::installClipEffects(GrDrawState* drawState,
109 GrDrawState::AutoRestoreEffects* are, 106 GrDrawState::AutoRestoreEffects* are,
107 const GrReducedClip::ElementList& ele ments,
110 const SkVector& clipToRTOffset, 108 const SkVector& clipToRTOffset,
111 const SkRect* drawBounds) { 109 const SkRect* drawBounds) {
112
113 GrDrawState* drawState = fClipTarget->drawState();
114 SkRect boundsInClipSpace; 110 SkRect boundsInClipSpace;
115 if (drawBounds) { 111 if (drawBounds) {
116 boundsInClipSpace = *drawBounds; 112 boundsInClipSpace = *drawBounds;
117 boundsInClipSpace.offset(-clipToRTOffset.fX, -clipToRTOffset.fY); 113 boundsInClipSpace.offset(-clipToRTOffset.fX, -clipToRTOffset.fY);
118 } 114 }
119 115
120 are->set(drawState); 116 are->set(drawState);
121 GrRenderTarget* rt = drawState->getRenderTarget(); 117 GrRenderTarget* rt = drawState->getRenderTarget();
122 GrReducedClip::ElementList::Iter iter(elements); 118 GrReducedClip::ElementList::Iter iter(elements);
123
124 bool setARE = false;
125 bool failed = false; 119 bool failed = false;
126
127 while (iter.get()) { 120 while (iter.get()) {
128 SkRegion::Op op = iter.get()->getOp(); 121 SkRegion::Op op = iter.get()->getOp();
129 bool invert; 122 bool invert;
130 bool skip = false; 123 bool skip = false;
131 switch (op) { 124 switch (op) {
132 case SkRegion::kReplace_Op: 125 case SkRegion::kReplace_Op:
133 SkASSERT(iter.get() == elements.head()); 126 SkASSERT(iter.get() == elements.head());
134 // Fallthrough, handled same as intersect. 127 // Fallthrough, handled same as intersect.
135 case SkRegion::kIntersect_Op: 128 case SkRegion::kIntersect_Op:
136 invert = false; 129 invert = false;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 case SkClipStack::Element::kRect_Type: { 173 case SkClipStack::Element::kRect_Type: {
181 SkRect rect = iter.get()->getRect(); 174 SkRect rect = iter.get()->getRect();
182 rect.offset(clipToRTOffset.fX, clipToRTOffset.fY); 175 rect.offset(clipToRTOffset.fX, clipToRTOffset.fY);
183 fp.reset(GrConvexPolyEffect::Create(edgeType, rect)); 176 fp.reset(GrConvexPolyEffect::Create(edgeType, rect));
184 break; 177 break;
185 } 178 }
186 default: 179 default:
187 break; 180 break;
188 } 181 }
189 if (fp) { 182 if (fp) {
190 if (!setARE) { 183 drawState->addCoverageProcessor(fp);
191 are->set(fClipTarget->drawState());
192 setARE = true;
193 }
194 fClipTarget->drawState()->addCoverageProcessor(fp);
195 } else { 184 } else {
196 failed = true; 185 failed = true;
197 break; 186 break;
198 } 187 }
199 } 188 }
200 iter.next(); 189 iter.next();
201 } 190 }
202 191
203 if (failed) { 192 if (failed) {
204 are->set(NULL); 193 are->set(NULL);
205 } 194 }
206
207 return !failed; 195 return !failed;
208 } 196 }
209 197
210 //////////////////////////////////////////////////////////////////////////////// 198 ////////////////////////////////////////////////////////////////////////////////
211 // sort out what kind of clip mask needs to be created: alpha, stencil, 199 // sort out what kind of clip mask needs to be created: alpha, stencil,
212 // scissor, or entirely software 200 // scissor, or entirely software
213 bool GrClipMaskManager::setupClipping(const GrClipData* clipDataIn, 201 bool GrClipMaskManager::setupClipping(GrDrawState* drawState,
214 const SkRect* devBounds,
215 GrDrawState::AutoRestoreEffects* are, 202 GrDrawState::AutoRestoreEffects* are,
216 GrDrawState::AutoRestoreStencil* ars, 203 GrDrawState::AutoRestoreStencil* ars,
217 ScissorState* scissorState) { 204 ScissorState* scissorState,
205 const GrClipData* clipDataIn,
206 const SkRect* devBounds) {
218 fCurrClipMaskType = kNone_ClipMaskType; 207 fCurrClipMaskType = kNone_ClipMaskType;
219 if (kRespectClip_StencilClipMode == fClipMode) { 208 if (kRespectClip_StencilClipMode == fClipMode) {
220 fClipMode = kIgnoreClip_StencilClipMode; 209 fClipMode = kIgnoreClip_StencilClipMode;
221 } 210 }
222 211
223 GrReducedClip::ElementList elements(16); 212 GrReducedClip::ElementList elements(16);
224 int32_t genID; 213 int32_t genID;
225 GrReducedClip::InitialState initialState; 214 GrReducedClip::InitialState initialState;
226 SkIRect clipSpaceIBounds; 215 SkIRect clipSpaceIBounds;
227 bool requiresAA; 216 bool requiresAA;
217 GrRenderTarget* rt = drawState->getRenderTarget();
228 218
229 GrDrawState* drawState = fClipTarget->drawState();
230
231 const GrRenderTarget* rt = drawState->getRenderTarget();
232 // GrDrawTarget should have filtered this for us 219 // GrDrawTarget should have filtered this for us
233 SkASSERT(rt); 220 SkASSERT(rt);
234 221
235 bool ignoreClip = !drawState->isClipState() || clipDataIn->fClipStack->isWid eOpen(); 222 bool ignoreClip = !drawState->isClipState() || clipDataIn->fClipStack->isWid eOpen();
236 if (!ignoreClip) { 223 if (!ignoreClip) {
237 SkIRect clipSpaceRTIBounds = SkIRect::MakeWH(rt->width(), rt->height()); 224 SkIRect clipSpaceRTIBounds = SkIRect::MakeWH(rt->width(), rt->height());
238 clipSpaceRTIBounds.offset(clipDataIn->fOrigin); 225 clipSpaceRTIBounds.offset(clipDataIn->fOrigin);
239 GrReducedClip::ReduceClipStack(*clipDataIn->fClipStack, 226 GrReducedClip::ReduceClipStack(*clipDataIn->fClipStack,
240 clipSpaceRTIBounds, 227 clipSpaceRTIBounds,
241 &elements, 228 &elements,
242 &genID, 229 &genID,
243 &initialState, 230 &initialState,
244 &clipSpaceIBounds, 231 &clipSpaceIBounds,
245 &requiresAA); 232 &requiresAA);
246 if (elements.isEmpty()) { 233 if (elements.isEmpty()) {
247 if (GrReducedClip::kAllIn_InitialState == initialState) { 234 if (GrReducedClip::kAllIn_InitialState == initialState) {
248 ignoreClip = clipSpaceIBounds == clipSpaceRTIBounds; 235 ignoreClip = clipSpaceIBounds == clipSpaceRTIBounds;
249 } else { 236 } else {
250 return false; 237 return false;
251 } 238 }
252 } 239 }
253 } 240 }
254 241
255 if (ignoreClip) { 242 if (ignoreClip) {
256 this->setDrawStateStencil(ars); 243 this->setDrawStateStencil(drawState, ars);
257 return true; 244 return true;
258 } 245 }
259 246
260 // An element count of 4 was chosen because of the common pattern in Blink o f: 247 // An element count of 4 was chosen because of the common pattern in Blink o f:
261 // isect RR 248 // isect RR
262 // diff RR 249 // diff RR
263 // isect convex_poly 250 // isect convex_poly
264 // isect convex_poly 251 // isect convex_poly
265 // when drawing rounded div borders. This could probably be tuned based on a 252 // when drawing rounded div borders. This could probably be tuned based on a
266 // configuration's relative costs of switching RTs to generate a mask vs 253 // configuration's relative costs of switching RTs to generate a mask vs
267 // longer shaders. 254 // longer shaders.
268 if (elements.count() <= 4) { 255 if (elements.count() <= 4) {
269 SkVector clipToRTOffset = { SkIntToScalar(-clipDataIn->fOrigin.fX), 256 SkVector clipToRTOffset = { SkIntToScalar(-clipDataIn->fOrigin.fX),
270 SkIntToScalar(-clipDataIn->fOrigin.fY) }; 257 SkIntToScalar(-clipDataIn->fOrigin.fY) };
271 if (elements.isEmpty() || 258 if (elements.isEmpty() ||
272 (requiresAA && this->installClipEffects(elements, are, clipToRTOffse t, devBounds))) { 259 (requiresAA && this->installClipEffects(drawState, are, elements, cl ipToRTOffset, devBounds))) {
273 SkIRect scissorSpaceIBounds(clipSpaceIBounds); 260 SkIRect scissorSpaceIBounds(clipSpaceIBounds);
274 scissorSpaceIBounds.offset(-clipDataIn->fOrigin); 261 scissorSpaceIBounds.offset(-clipDataIn->fOrigin);
275 if (NULL == devBounds || 262 if (NULL == devBounds ||
276 !SkRect::Make(scissorSpaceIBounds).contains(*devBounds)) { 263 !SkRect::Make(scissorSpaceIBounds).contains(*devBounds)) {
277 scissorState->set(scissorSpaceIBounds); 264 scissorState->set(scissorSpaceIBounds);
278 } 265 }
279 this->setDrawStateStencil(ars); 266 this->setDrawStateStencil(drawState, ars);
280 return true; 267 return true;
281 } 268 }
282 } 269 }
283 270
284 #if GR_AA_CLIP 271 #if GR_AA_CLIP
285 // If MSAA is enabled we can do everything in the stencil buffer. 272 // If MSAA is enabled we can do everything in the stencil buffer.
286 if (0 == rt->numSamples() && requiresAA) { 273 if (0 == rt->numSamples() && requiresAA) {
287 GrTexture* result = NULL; 274 GrTexture* result = NULL;
288 275
289 if (this->useSWOnlyPath(elements)) { 276 if (this->useSWOnlyPath(drawState, elements)) {
290 // The clip geometry is complex enough that it will be more efficien t to create it 277 // The clip geometry is complex enough that it will be more efficien t to create it
291 // entirely in software 278 // entirely in software
292 result = this->createSoftwareClipMask(genID, 279 result = this->createSoftwareClipMask(genID,
293 initialState, 280 initialState,
294 elements, 281 elements,
295 clipSpaceIBounds); 282 clipSpaceIBounds);
296 } else { 283 } else {
297 result = this->createAlphaClipMask(genID, 284 result = this->createAlphaClipMask(genID,
298 initialState, 285 initialState,
299 elements, 286 elements,
300 clipSpaceIBounds); 287 clipSpaceIBounds);
301 } 288 }
302 289
303 if (result) { 290 if (result) {
304 // The mask's top left coord should be pinned to the rounded-out top left corner of 291 // The mask's top left coord should be pinned to the rounded-out top left corner of
305 // clipSpace bounds. We determine the mask's position WRT to the ren der target here. 292 // clipSpace bounds. We determine the mask's position WRT to the ren der target here.
306 SkIRect rtSpaceMaskBounds = clipSpaceIBounds; 293 SkIRect rtSpaceMaskBounds = clipSpaceIBounds;
307 rtSpaceMaskBounds.offset(-clipDataIn->fOrigin); 294 rtSpaceMaskBounds.offset(-clipDataIn->fOrigin);
308 are->set(fClipTarget->drawState()); 295 setup_drawstate_aaclip(rtSpaceMaskBounds, drawState, result);
309 setup_drawstate_aaclip(fClipTarget, result, rtSpaceMaskBounds); 296 this->setDrawStateStencil(drawState, ars);
310 this->setDrawStateStencil(ars);
311 return true; 297 return true;
312 } 298 }
313 // if alpha clip mask creation fails fall through to the non-AA code pat hs 299 // if alpha clip mask creation fails fall through to the non-AA code pat hs
314 } 300 }
315 #endif // GR_AA_CLIP 301 #endif // GR_AA_CLIP
316 302
317 // Either a hard (stencil buffer) clip was explicitly requested or an anti-a liased clip couldn't 303 // Either a hard (stencil buffer) clip was explicitly requested or an anti-a liased clip couldn't
318 // be created. In either case, free up the texture in the anti-aliased mask cache. 304 // be created. In either case, free up the texture in the anti-aliased mask cache.
319 // TODO: this may require more investigation. Ganesh performs a lot of utili ty draws (e.g., 305 // TODO: this may require more investigation. Ganesh performs a lot of utili ty draws (e.g.,
320 // clears, InOrderDrawBuffer playbacks) that hit the stencil buffer path. Th ese may be 306 // clears, InOrderDrawBuffer playbacks) that hit the stencil buffer path. Th ese may be
321 // "incorrectly" clearing the AA cache. 307 // "incorrectly" clearing the AA cache.
322 fAACache.reset(); 308 fAACache.reset();
323 309
324 // use the stencil clip if we can't represent the clip as a rectangle. 310 // use the stencil clip if we can't represent the clip as a rectangle.
325 SkIPoint clipSpaceToStencilSpaceOffset = -clipDataIn->fOrigin; 311 SkIPoint clipSpaceToStencilSpaceOffset = -clipDataIn->fOrigin;
326 this->createStencilClipMask(genID, 312 this->createStencilClipMask(rt,
313 genID,
327 initialState, 314 initialState,
328 elements, 315 elements,
329 clipSpaceIBounds, 316 clipSpaceIBounds,
330 clipSpaceToStencilSpaceOffset); 317 clipSpaceToStencilSpaceOffset);
331 318
332 // This must occur after createStencilClipMask. That function may change the scissor. Also, it 319 // This must occur after createStencilClipMask. That function may change the scissor. Also, it
333 // only guarantees that the stencil mask is correct within the bounds it was passed, so we must 320 // only guarantees that the stencil mask is correct within the bounds it was passed, so we must
334 // use both stencil and scissor test to the bounds for the final draw. 321 // use both stencil and scissor test to the bounds for the final draw.
335 SkIRect scissorSpaceIBounds(clipSpaceIBounds); 322 SkIRect scissorSpaceIBounds(clipSpaceIBounds);
336 scissorSpaceIBounds.offset(clipSpaceToStencilSpaceOffset); 323 scissorSpaceIBounds.offset(clipSpaceToStencilSpaceOffset);
337 scissorState->set(scissorSpaceIBounds); 324 scissorState->set(scissorSpaceIBounds);
338 this->setDrawStateStencil(ars); 325 this->setDrawStateStencil(drawState, ars);
339 return true; 326 return true;
340 } 327 }
341 328
342 #define VISUALIZE_COMPLEX_CLIP 0 329 #define VISUALIZE_COMPLEX_CLIP 0
343 330
344 #if VISUALIZE_COMPLEX_CLIP 331 #if VISUALIZE_COMPLEX_CLIP
345 #include "SkRandom.h" 332 #include "SkRandom.h"
346 SkRandom gRandom; 333 SkRandom gRandom;
347 #define SET_RANDOM_COLOR drawState->setColor(0xff000000 | gRandom.nextU()); 334 #define SET_RANDOM_COLOR drawState->setColor(0xff000000 | gRandom.nextU());
348 #else 335 #else
349 #define SET_RANDOM_COLOR 336 #define SET_RANDOM_COLOR
350 #endif 337 #endif
351 338
352 namespace { 339 namespace {
353
354 //////////////////////////////////////////////////////////////////////////////// 340 ////////////////////////////////////////////////////////////////////////////////
355 // set up the OpenGL blend function to perform the specified 341 // set up the OpenGL blend function to perform the specified
356 // boolean operation for alpha clip mask creation 342 // boolean operation for alpha clip mask creation
357 void setup_boolean_blendcoeffs(GrDrawState* drawState, SkRegion::Op op) { 343 void setup_boolean_blendcoeffs(SkRegion::Op op, GrDrawState* drawState) {
358
359 switch (op) { 344 switch (op) {
360 case SkRegion::kReplace_Op: 345 case SkRegion::kReplace_Op:
361 drawState->setBlendFunc(kOne_GrBlendCoeff, kZero_GrBlendCoeff); 346 drawState->setBlendFunc(kOne_GrBlendCoeff, kZero_GrBlendCoeff);
362 break; 347 break;
363 case SkRegion::kIntersect_Op: 348 case SkRegion::kIntersect_Op:
364 drawState->setBlendFunc(kDC_GrBlendCoeff, kZero_GrBlendCoeff); 349 drawState->setBlendFunc(kDC_GrBlendCoeff, kZero_GrBlendCoeff);
365 break; 350 break;
366 case SkRegion::kUnion_Op: 351 case SkRegion::kUnion_Op:
367 drawState->setBlendFunc(kOne_GrBlendCoeff, kISC_GrBlendCoeff); 352 drawState->setBlendFunc(kOne_GrBlendCoeff, kISC_GrBlendCoeff);
368 break; 353 break;
369 case SkRegion::kXOR_Op: 354 case SkRegion::kXOR_Op:
370 drawState->setBlendFunc(kIDC_GrBlendCoeff, kISC_GrBlendCoeff); 355 drawState->setBlendFunc(kIDC_GrBlendCoeff, kISC_GrBlendCoeff);
371 break; 356 break;
372 case SkRegion::kDifference_Op: 357 case SkRegion::kDifference_Op:
373 drawState->setBlendFunc(kZero_GrBlendCoeff, kISC_GrBlendCoeff); 358 drawState->setBlendFunc(kZero_GrBlendCoeff, kISC_GrBlendCoeff);
374 break; 359 break;
375 case SkRegion::kReverseDifference_Op: 360 case SkRegion::kReverseDifference_Op:
376 drawState->setBlendFunc(kIDC_GrBlendCoeff, kZero_GrBlendCoeff); 361 drawState->setBlendFunc(kIDC_GrBlendCoeff, kZero_GrBlendCoeff);
377 break; 362 break;
378 default: 363 default:
379 SkASSERT(false); 364 SkASSERT(false);
380 break; 365 break;
381 } 366 }
382 } 367 }
383
384 } 368 }
385 369
386 //////////////////////////////////////////////////////////////////////////////// 370 ////////////////////////////////////////////////////////////////////////////////
387 bool GrClipMaskManager::drawElement(GrTexture* target, 371 bool GrClipMaskManager::drawElement(GrDrawState* drawState,
372 GrTexture* target,
388 const SkClipStack::Element* element, 373 const SkClipStack::Element* element,
389 GrPathRenderer* pr) { 374 GrPathRenderer* pr) {
390 GrDrawState* drawState = fClipTarget->drawState(); 375 GrDrawTarget::AutoGeometryPush agp(fClipTarget);
391 376
392 drawState->setRenderTarget(target->asRenderTarget()); 377 drawState->setRenderTarget(target->asRenderTarget());
393 378
394 // TODO: Draw rrects directly here. 379 // TODO: Draw rrects directly here.
395 switch (element->getType()) { 380 switch (element->getType()) {
396 case Element::kEmpty_Type: 381 case Element::kEmpty_Type:
397 SkDEBUGFAIL("Should never get here with an empty element."); 382 SkDEBUGFAIL("Should never get here with an empty element.");
398 break; 383 break;
399 case Element::kRect_Type: 384 case Element::kRect_Type:
400 // TODO: Do rects directly to the accumulator using a aa-rect GrProc essor that covers 385 // TODO: Do rects directly to the accumulator using a aa-rect GrProc essor that covers
401 // the entire mask bounds and writes 0 outside the rect. 386 // the entire mask bounds and writes 0 outside the rect.
402 if (element->isAA()) { 387 if (element->isAA()) {
403 this->getContext()->getAARectRenderer()->fillAARect(fClipTarget, 388 this->getContext()->getAARectRenderer()->fillAARect(fClipTarget,
389 drawState,
404 element->get Rect(), 390 element->get Rect(),
405 SkMatrix::I( ), 391 SkMatrix::I( ),
406 element->get Rect()); 392 element->get Rect());
407 } else { 393 } else {
408 fClipTarget->drawSimpleRect(element->getRect()); 394 fClipTarget->drawSimpleRect(drawState, element->getRect());
409 } 395 }
410 return true; 396 return true;
411 default: { 397 default: {
412 SkPath path; 398 SkPath path;
413 element->asPath(&path); 399 element->asPath(&path);
414 path.setIsVolatile(true); 400 path.setIsVolatile(true);
415 if (path.isInverseFillType()) { 401 if (path.isInverseFillType()) {
416 path.toggleInverseFillType(); 402 path.toggleInverseFillType();
417 } 403 }
418 SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle); 404 SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle);
419 if (NULL == pr) { 405 if (NULL == pr) {
420 GrPathRendererChain::DrawType type; 406 GrPathRendererChain::DrawType type;
421 type = element->isAA() ? GrPathRendererChain::kColorAntiAlias_Dr awType : 407 type = element->isAA() ? GrPathRendererChain::kColorAntiAlias_Dr awType :
422 GrPathRendererChain::kColor_DrawType; 408 GrPathRendererChain::kColor_DrawType;
423 pr = this->getContext()->getPathRenderer(path, stroke, fClipTarg et, false, type); 409 pr = this->getContext()->getPathRenderer(fClipTarget, drawState, path, stroke,
410 false, type);
424 } 411 }
425 if (NULL == pr) { 412 if (NULL == pr) {
426 return false; 413 return false;
427 } 414 }
428 pr->drawPath(path, stroke, fClipTarget, element->isAA()); 415
416 pr->drawPath(fClipTarget, drawState, path, stroke, element->isAA());
429 break; 417 break;
430 } 418 }
431 } 419 }
432 return true; 420 return true;
433 } 421 }
434 422
435 bool GrClipMaskManager::canStencilAndDrawElement(GrTexture* target, 423 bool GrClipMaskManager::canStencilAndDrawElement(GrDrawState* drawState,
436 const SkClipStack::Element* ele ment, 424 GrTexture* target,
437 GrPathRenderer** pr) { 425 GrPathRenderer** pr,
438 GrDrawState* drawState = fClipTarget->drawState(); 426 const SkClipStack::Element* ele ment) {
439 drawState->setRenderTarget(target->asRenderTarget()); 427 drawState->setRenderTarget(target->asRenderTarget());
440 428
441 if (Element::kRect_Type == element->getType()) { 429 if (Element::kRect_Type == element->getType()) {
442 return true; 430 return true;
443 } else { 431 } else {
444 // We shouldn't get here with an empty clip element. 432 // We shouldn't get here with an empty clip element.
445 SkASSERT(Element::kEmpty_Type != element->getType()); 433 SkASSERT(Element::kEmpty_Type != element->getType());
446 SkPath path; 434 SkPath path;
447 element->asPath(&path); 435 element->asPath(&path);
448 if (path.isInverseFillType()) { 436 if (path.isInverseFillType()) {
449 path.toggleInverseFillType(); 437 path.toggleInverseFillType();
450 } 438 }
451 SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle); 439 SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle);
452 GrPathRendererChain::DrawType type = element->isAA() ? 440 GrPathRendererChain::DrawType type = element->isAA() ?
453 GrPathRendererChain::kStencilAndColorAntiAlias_DrawType : 441 GrPathRendererChain::kStencilAndColorAntiAlias_DrawType :
454 GrPathRendererChain::kStencilAndColor_DrawType; 442 GrPathRendererChain::kStencilAndColor_DrawType;
455 *pr = this->getContext()->getPathRenderer(path, stroke, fClipTarget, fal se, type); 443 *pr = this->getContext()->getPathRenderer(fClipTarget, drawState, path, stroke, false, type);
456 return SkToBool(*pr); 444 return SkToBool(*pr);
457 } 445 }
458 } 446 }
459 447
460 void GrClipMaskManager::mergeMask(GrTexture* dstMask, 448 void GrClipMaskManager::mergeMask(GrDrawState* drawState,
449 GrTexture* dstMask,
461 GrTexture* srcMask, 450 GrTexture* srcMask,
462 SkRegion::Op op, 451 SkRegion::Op op,
463 const SkIRect& dstBound, 452 const SkIRect& dstBound,
464 const SkIRect& srcBound) { 453 const SkIRect& srcBound) {
465 GrDrawState::AutoViewMatrixRestore avmr; 454 GrDrawState::AutoViewMatrixRestore avmr;
466 GrDrawState* drawState = fClipTarget->drawState();
467 SkAssertResult(avmr.setIdentity(drawState)); 455 SkAssertResult(avmr.setIdentity(drawState));
468 GrDrawState::AutoRestoreEffects are(drawState); 456 GrDrawState::AutoRestoreEffects are(drawState);
469 457
470 drawState->setRenderTarget(dstMask->asRenderTarget()); 458 drawState->setRenderTarget(dstMask->asRenderTarget());
471 459
472 setup_boolean_blendcoeffs(drawState, op); 460 setup_boolean_blendcoeffs(op, drawState);
473 461
474 SkMatrix sampleM; 462 SkMatrix sampleM;
475 sampleM.setIDiv(srcMask->width(), srcMask->height()); 463 sampleM.setIDiv(srcMask->width(), srcMask->height());
476 464
477 drawState->addColorProcessor( 465 drawState->addColorProcessor(
478 GrTextureDomainEffect::Create(srcMask, 466 GrTextureDomainEffect::Create(srcMask,
479 sampleM, 467 sampleM,
480 GrTextureDomain::MakeTexelDomain(srcMask, srcBound), 468 GrTextureDomain::MakeTexelDomain(srcMask, srcBound),
481 GrTextureDomain::kDecal_Mode, 469 GrTextureDomain::kDecal_Mode,
482 GrTextureParams::kNone_FilterMode))->unref (); 470 GrTextureParams::kNone_FilterMode))->unref ();
483 fClipTarget->drawSimpleRect(SkRect::Make(dstBound)); 471 fClipTarget->drawSimpleRect(drawState, SkRect::Make(dstBound));
484 } 472 }
485 473
486 GrTexture* GrClipMaskManager::createTempMask(int width, int height) { 474 GrTexture* GrClipMaskManager::createTempMask(int width, int height) {
487 GrSurfaceDesc desc; 475 GrSurfaceDesc desc;
488 desc.fFlags = kRenderTarget_GrSurfaceFlag|kNoStencil_GrSurfaceFlag; 476 desc.fFlags = kRenderTarget_GrSurfaceFlag|kNoStencil_GrSurfaceFlag;
489 desc.fWidth = width; 477 desc.fWidth = width;
490 desc.fHeight = height; 478 desc.fHeight = height;
491 desc.fConfig = kAlpha_8_GrPixelConfig; 479 desc.fConfig = kAlpha_8_GrPixelConfig;
492 480
493 return this->getContext()->refScratchTexture(desc, GrContext::kApprox_Scratc hTexMatch); 481 return this->getContext()->refScratchTexture(desc, GrContext::kApprox_Scratc hTexMatch);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 SkIntToScalar(-clipSpaceIBounds.fLeft), 544 SkIntToScalar(-clipSpaceIBounds.fLeft),
557 SkIntToScalar(-clipSpaceIBounds.fTop) 545 SkIntToScalar(-clipSpaceIBounds.fTop)
558 }; 546 };
559 // The texture may be larger than necessary, this rect represents the part o f the texture 547 // The texture may be larger than necessary, this rect represents the part o f the texture
560 // we populate with a rasterization of the clip. 548 // we populate with a rasterization of the clip.
561 SkIRect maskSpaceIBounds = SkIRect::MakeWH(clipSpaceIBounds.width(), clipSpa ceIBounds.height()); 549 SkIRect maskSpaceIBounds = SkIRect::MakeWH(clipSpaceIBounds.width(), clipSpa ceIBounds.height());
562 550
563 // Set the matrix so that rendered clip elements are transformed to mask spa ce from clip space. 551 // Set the matrix so that rendered clip elements are transformed to mask spa ce from clip space.
564 SkMatrix translate; 552 SkMatrix translate;
565 translate.setTranslate(clipToMaskOffset); 553 translate.setTranslate(clipToMaskOffset);
566 GrDrawTarget::AutoGeometryAndStatePush agasp(fClipTarget, GrDrawTarget::kRes et_ASRInit,
567 &translate);
568
569 GrDrawState* drawState = fClipTarget->drawState();
570
571 // We're drawing a coverage mask and want coverage to be run through the ble nd function.
572 drawState->enableState(GrDrawState::kCoverageDrawing_StateBit);
573 554
574 // The scratch texture that we are drawing into can be substantially larger than the mask. Only 555 // The scratch texture that we are drawing into can be substantially larger than the mask. Only
575 // clear the part that we care about. 556 // clear the part that we care about.
576 fClipTarget->clear(&maskSpaceIBounds, 557 fClipTarget->clear(&maskSpaceIBounds,
577 GrReducedClip::kAllIn_InitialState == initialState ? 0xff ffffff : 0x00000000, 558 GrReducedClip::kAllIn_InitialState == initialState ? 0xff ffffff : 0x00000000,
578 true, 559 true,
579 result->asRenderTarget()); 560 result->asRenderTarget());
580 561
581 // When we use the stencil in the below loop it is important to have this cl ip installed. 562 // When we use the stencil in the below loop it is important to have this cl ip installed.
582 // The second pass that zeros the stencil buffer renders the rect maskSpaceI Bounds so the first 563 // The second pass that zeros the stencil buffer renders the rect maskSpaceI Bounds so the first
583 // pass must not set values outside of this bounds or stencil values outside the rect won't be 564 // pass must not set values outside of this bounds or stencil values outside the rect won't be
584 // cleared. 565 // cleared.
585 GrDrawTarget::AutoClipRestore acr(fClipTarget, maskSpaceIBounds); 566 GrDrawTarget::AutoClipRestore acr(fClipTarget, maskSpaceIBounds);
586 drawState->enableState(GrDrawState::kClip_StateBit); 567 SkAutoTUnref<GrTexture> temp;
587 568
588 SkAutoTUnref<GrTexture> temp;
589 // walk through each clip element and perform its set op 569 // walk through each clip element and perform its set op
590 for (GrReducedClip::ElementList::Iter iter = elements.headIter(); iter.get() ; iter.next()) { 570 for (GrReducedClip::ElementList::Iter iter = elements.headIter(); iter.get() ; iter.next()) {
591 const Element* element = iter.get(); 571 const Element* element = iter.get();
592 SkRegion::Op op = element->getOp(); 572 SkRegion::Op op = element->getOp();
593 bool invert = element->isInverseFilled(); 573 bool invert = element->isInverseFilled();
574 if (invert || SkRegion::kIntersect_Op == op || SkRegion::kReverseDiffere nce_Op == op) {
575 GrDrawState drawState(translate);
576 // We're drawing a coverage mask and want coverage to be run through the blend function.
577 drawState.enableState(GrDrawState::kCoverageDrawing_StateBit |
578 GrDrawState::kClip_StateBit);
594 579
595 if (invert || SkRegion::kIntersect_Op == op || SkRegion::kReverseDiffere nce_Op == op) {
596 GrPathRenderer* pr = NULL; 580 GrPathRenderer* pr = NULL;
597 bool useTemp = !this->canStencilAndDrawElement(result, element, &pr) ; 581 bool useTemp = !this->canStencilAndDrawElement(&drawState, result, & pr, element);
598 GrTexture* dst; 582 GrTexture* dst;
599 // This is the bounds of the clip element in the space of the alpha- mask. The temporary 583 // This is the bounds of the clip element in the space of the alpha- mask. The temporary
600 // mask buffer can be substantially larger than the actually clip st ack element. We 584 // mask buffer can be substantially larger than the actually clip st ack element. We
601 // touch the minimum number of pixels necessary and use decal mode t o combine it with 585 // touch the minimum number of pixels necessary and use decal mode t o combine it with
602 // the accumulator. 586 // the accumulator.
603 SkIRect maskSpaceElementIBounds; 587 SkIRect maskSpaceElementIBounds;
604 588
605 if (useTemp) { 589 if (useTemp) {
606 if (invert) { 590 if (invert) {
607 maskSpaceElementIBounds = maskSpaceIBounds; 591 maskSpaceElementIBounds = maskSpaceIBounds;
608 } else { 592 } else {
609 SkRect elementBounds = element->getBounds(); 593 SkRect elementBounds = element->getBounds();
610 elementBounds.offset(clipToMaskOffset); 594 elementBounds.offset(clipToMaskOffset);
611 elementBounds.roundOut(&maskSpaceElementIBounds); 595 elementBounds.roundOut(&maskSpaceElementIBounds);
612 } 596 }
613 597
614 if (!temp) { 598 if (!temp) {
615 temp.reset(this->createTempMask(maskSpaceIBounds.fRight, 599 temp.reset(this->createTempMask(maskSpaceIBounds.fRight,
616 maskSpaceIBounds.fBottom)); 600 maskSpaceIBounds.fBottom));
617 if (!temp) { 601 if (!temp) {
618 fAACache.reset(); 602 fAACache.reset();
619 return NULL; 603 return NULL;
620 } 604 }
621 } 605 }
622 dst = temp; 606 dst = temp;
623 // clear the temp target and set blend to replace 607 // clear the temp target and set blend to replace
624 fClipTarget->clear(&maskSpaceElementIBounds, 608 fClipTarget->clear(&maskSpaceElementIBounds,
625 invert ? 0xffffffff : 0x00000000, 609 invert ? 0xffffffff : 0x00000000,
626 true, 610 true,
627 dst->asRenderTarget()); 611 dst->asRenderTarget());
628 setup_boolean_blendcoeffs(drawState, SkRegion::kReplace_Op); 612 setup_boolean_blendcoeffs(SkRegion::kReplace_Op, &drawState);
629
630 } else { 613 } else {
631 // draw directly into the result with the stencil set to make th e pixels affected 614 // draw directly into the result with the stencil set to make th e pixels affected
632 // by the clip shape be non-zero. 615 // by the clip shape be non-zero.
633 dst = result; 616 dst = result;
634 GR_STATIC_CONST_SAME_STENCIL(kStencilInElement, 617 GR_STATIC_CONST_SAME_STENCIL(kStencilInElement,
635 kReplace_StencilOp, 618 kReplace_StencilOp,
636 kReplace_StencilOp, 619 kReplace_StencilOp,
637 kAlways_StencilFunc, 620 kAlways_StencilFunc,
638 0xffff, 621 0xffff,
639 0xffff, 622 0xffff,
640 0xffff); 623 0xffff);
641 drawState->setStencil(kStencilInElement); 624 drawState.setStencil(kStencilInElement);
642 setup_boolean_blendcoeffs(drawState, op); 625 setup_boolean_blendcoeffs(op, &drawState);
643 } 626 }
644 627
645 drawState->setAlpha(invert ? 0x00 : 0xff); 628 drawState.setAlpha(invert ? 0x00 : 0xff);
646 629
647 if (!this->drawElement(dst, element, pr)) { 630 // We have to backup the drawstate because the draw will consume ti
bsalomon 2014/11/14 21:51:02 still true?
joshualitt 2014/11/14 23:25:40 Unfortunately it is. DrawElements may call into t
bsalomon 2014/11/17 14:41:16 Oh that makes sense. lgtm
631 GrDrawState backupDrawState = drawState;
632
633 if (!this->drawElement(&drawState, dst, element, pr)) {
648 fAACache.reset(); 634 fAACache.reset();
649 return NULL; 635 return NULL;
650 } 636 }
651 637
652 if (useTemp) { 638 if (useTemp) {
653 // Now draw into the accumulator using the real operation and th e temp buffer as a 639 // Now draw into the accumulator using the real operation and th e temp buffer as a
654 // texture 640 // texture
655 this->mergeMask(result, 641 this->mergeMask(&backupDrawState,
642 result,
656 temp, 643 temp,
657 op, 644 op,
658 maskSpaceIBounds, 645 maskSpaceIBounds,
659 maskSpaceElementIBounds); 646 maskSpaceElementIBounds);
660 } else { 647 } else {
661 // Draw to the exterior pixels (those with a zero stencil value) . 648 // Draw to the exterior pixels (those with a zero stencil value) .
662 drawState->setAlpha(invert ? 0xff : 0x00); 649 backupDrawState.setAlpha(invert ? 0xff : 0x00);
663 GR_STATIC_CONST_SAME_STENCIL(kDrawOutsideElement, 650 GR_STATIC_CONST_SAME_STENCIL(kDrawOutsideElement,
664 kZero_StencilOp, 651 kZero_StencilOp,
665 kZero_StencilOp, 652 kZero_StencilOp,
666 kEqual_StencilFunc, 653 kEqual_StencilFunc,
667 0xffff, 654 0xffff,
668 0x0000, 655 0x0000,
669 0xffff); 656 0xffff);
670 drawState->setStencil(kDrawOutsideElement); 657 backupDrawState.setStencil(kDrawOutsideElement);
671 fClipTarget->drawSimpleRect(clipSpaceIBounds); 658 fClipTarget->drawSimpleRect(&backupDrawState, clipSpaceIBounds);
672 drawState->disableStencil();
673 } 659 }
674 } else { 660 } else {
661 GrDrawState drawState(translate);
662 drawState.enableState(GrDrawState::kCoverageDrawing_StateBit |
663 GrDrawState::kClip_StateBit);
664
675 // all the remaining ops can just be directly draw into the accumula tion buffer 665 // all the remaining ops can just be directly draw into the accumula tion buffer
676 drawState->setAlpha(0xff); 666 drawState.setAlpha(0xff);
677 setup_boolean_blendcoeffs(drawState, op); 667 setup_boolean_blendcoeffs(op, &drawState);
678 this->drawElement(result, element); 668 this->drawElement(&drawState, result, element);
679 } 669 }
680 } 670 }
681 671
682 fCurrClipMaskType = kAlpha_ClipMaskType; 672 fCurrClipMaskType = kAlpha_ClipMaskType;
683 return result; 673 return result;
684 } 674 }
685 675
686 //////////////////////////////////////////////////////////////////////////////// 676 ////////////////////////////////////////////////////////////////////////////////
687 // Create a 1-bit clip mask in the stencil buffer. 'devClipBounds' are in device 677 // Create a 1-bit clip mask in the stencil buffer. 'devClipBounds' are in device
688 // (as opposed to canvas) coordinates 678 // (as opposed to canvas) coordinates
689 bool GrClipMaskManager::createStencilClipMask(int32_t elementsGenID, 679 bool GrClipMaskManager::createStencilClipMask(GrRenderTarget* rt,
680 int32_t elementsGenID,
690 GrReducedClip::InitialState initia lState, 681 GrReducedClip::InitialState initia lState,
691 const GrReducedClip::ElementList& elements, 682 const GrReducedClip::ElementList& elements,
692 const SkIRect& clipSpaceIBounds, 683 const SkIRect& clipSpaceIBounds,
693 const SkIPoint& clipSpaceToStencil Offset) { 684 const SkIPoint& clipSpaceToStencil Offset) {
694
695 SkASSERT(kNone_ClipMaskType == fCurrClipMaskType); 685 SkASSERT(kNone_ClipMaskType == fCurrClipMaskType);
696
697 GrDrawState* drawState = fClipTarget->drawState();
698 SkASSERT(drawState->isClipState());
699
700 GrRenderTarget* rt = drawState->getRenderTarget();
701 SkASSERT(rt); 686 SkASSERT(rt);
702 687
703 // TODO: dynamically attach a SB when needed. 688 // TODO: dynamically attach a SB when needed.
704 GrStencilBuffer* stencilBuffer = rt->getStencilBuffer(); 689 GrStencilBuffer* stencilBuffer = rt->getStencilBuffer();
705 if (NULL == stencilBuffer) { 690 if (NULL == stencilBuffer) {
706 return false; 691 return false;
707 } 692 }
708 693
709 if (stencilBuffer->mustRenderClip(elementsGenID, clipSpaceIBounds, clipSpace ToStencilOffset)) { 694 if (stencilBuffer->mustRenderClip(elementsGenID, clipSpaceIBounds, clipSpace ToStencilOffset)) {
710 stencilBuffer->setLastClip(elementsGenID, clipSpaceIBounds, clipSpaceToS tencilOffset); 695 stencilBuffer->setLastClip(elementsGenID, clipSpaceIBounds, clipSpaceToS tencilOffset);
711
712 // Set the matrix so that rendered clip elements are transformed from cl ip to stencil space. 696 // Set the matrix so that rendered clip elements are transformed from cl ip to stencil space.
713 SkVector translate = { 697 SkVector translate = {
714 SkIntToScalar(clipSpaceToStencilOffset.fX), 698 SkIntToScalar(clipSpaceToStencilOffset.fX),
715 SkIntToScalar(clipSpaceToStencilOffset.fY) 699 SkIntToScalar(clipSpaceToStencilOffset.fY)
716 }; 700 };
717 SkMatrix matrix; 701 SkMatrix matrix;
718 matrix.setTranslate(translate); 702 matrix.setTranslate(translate);
719 GrDrawTarget::AutoGeometryAndStatePush agasp(fClipTarget, GrDrawTarget:: kReset_ASRInit,
720 &matrix);
721 drawState = fClipTarget->drawState();
722
723 drawState->setRenderTarget(rt);
724 703
725 // We set the current clip to the bounds so that our recursive draws are scissored to them. 704 // We set the current clip to the bounds so that our recursive draws are scissored to them.
726 SkIRect stencilSpaceIBounds(clipSpaceIBounds); 705 SkIRect stencilSpaceIBounds(clipSpaceIBounds);
727 stencilSpaceIBounds.offset(clipSpaceToStencilOffset); 706 stencilSpaceIBounds.offset(clipSpaceToStencilOffset);
728 GrDrawTarget::AutoClipRestore acr(fClipTarget, stencilSpaceIBounds); 707 GrDrawTarget::AutoClipRestore acr(fClipTarget, stencilSpaceIBounds);
729 drawState->enableState(GrDrawState::kClip_StateBit);
730
731 #if !VISUALIZE_COMPLEX_CLIP
732 drawState->enableState(GrDrawState::kNoColorWrites_StateBit);
733 #endif
734 708
735 int clipBit = stencilBuffer->bits(); 709 int clipBit = stencilBuffer->bits();
736 SkASSERT((clipBit <= 16) && "Ganesh only handles 16b or smaller stencil buffers"); 710 SkASSERT((clipBit <= 16) && "Ganesh only handles 16b or smaller stencil buffers");
737 clipBit = (1 << (clipBit-1)); 711 clipBit = (1 << (clipBit-1));
738 712
739 fClipTarget->clearStencilClip(stencilSpaceIBounds, 713 fClipTarget->clearStencilClip(stencilSpaceIBounds,
740 GrReducedClip::kAllIn_InitialState == init ialState, 714 GrReducedClip::kAllIn_InitialState == init ialState,
741 rt); 715 rt);
742 716
743 // walk through each clip element and perform its set op 717 // walk through each clip element and perform its set op
744 // with the existing clip. 718 // with the existing clip.
745 for (GrReducedClip::ElementList::Iter iter(elements.headIter()); iter.ge t(); iter.next()) { 719 for (GrReducedClip::ElementList::Iter iter(elements.headIter()); iter.ge t(); iter.next()) {
746 const Element* element = iter.get(); 720 const Element* element = iter.get();
747 bool fillInverted = false; 721 bool fillInverted = false;
748 // enabled at bottom of loop 722 // enabled at bottom of loop
749 fClipMode = kIgnoreClip_StencilClipMode; 723 fClipMode = kIgnoreClip_StencilClipMode;
750 // if the target is MSAA then we want MSAA enabled when the clip is soft
751 if (rt->isMultisampled()) {
752 drawState->setState(GrDrawState::kHWAntialias_StateBit, element- >isAA());
753 }
754 724
755 // This will be used to determine whether the clip shape can be rend ered into the 725 // This will be used to determine whether the clip shape can be rend ered into the
756 // stencil with arbitrary stencil settings. 726 // stencil with arbitrary stencil settings.
757 GrPathRenderer::StencilSupport stencilSupport; 727 GrPathRenderer::StencilSupport stencilSupport;
758 728
759 SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle); 729 SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle);
760
761 SkRegion::Op op = element->getOp(); 730 SkRegion::Op op = element->getOp();
762 731
763 GrPathRenderer* pr = NULL; 732 GrPathRenderer* pr = NULL;
764 SkPath clipPath; 733 SkPath clipPath;
765 if (Element::kRect_Type == element->getType()) { 734 if (Element::kRect_Type == element->getType()) {
766 stencilSupport = GrPathRenderer::kNoRestriction_StencilSupport; 735 stencilSupport = GrPathRenderer::kNoRestriction_StencilSupport;
767 fillInverted = false; 736 fillInverted = false;
768 } else { 737 } else {
769 element->asPath(&clipPath); 738 element->asPath(&clipPath);
770 fillInverted = clipPath.isInverseFillType(); 739 fillInverted = clipPath.isInverseFillType();
771 if (fillInverted) { 740 if (fillInverted) {
772 clipPath.toggleInverseFillType(); 741 clipPath.toggleInverseFillType();
773 } 742 }
774 pr = this->getContext()->getPathRenderer(clipPath, 743 // TODO not sure which drawstate this should be
744 GrDrawState drawState;
745 drawState.setRenderTarget(rt);
746 pr = this->getContext()->getPathRenderer(fClipTarget,
747 &drawState,
748 clipPath,
775 stroke, 749 stroke,
776 fClipTarget,
777 false, 750 false,
778 GrPathRendererChain::kS tencilOnly_DrawType, 751 GrPathRendererChain::kS tencilOnly_DrawType,
779 &stencilSupport); 752 &stencilSupport);
780 if (NULL == pr) { 753 if (NULL == pr) {
781 return false; 754 return false;
782 } 755 }
783 } 756 }
784 757
785 int passes; 758 int passes;
786 GrStencilSettings stencilSettings[GrStencilSettings::kMaxStencilClip Passes]; 759 GrStencilSettings stencilSettings[GrStencilSettings::kMaxStencilClip Passes];
787 760
788 bool canRenderDirectToStencil = 761 bool canRenderDirectToStencil =
789 GrPathRenderer::kNoRestriction_StencilSupport == stencilSupport; 762 GrPathRenderer::kNoRestriction_StencilSupport == stencilSupport;
790 bool canDrawDirectToClip; // Given the renderer, the element, 763 bool canDrawDirectToClip; // Given the renderer, the element,
791 // fill rule, and set operation can 764 // fill rule, and set operation can
792 // we render the element directly to 765 // we render the element directly to
793 // stencil bit used for clipping. 766 // stencil bit used for clipping.
794 canDrawDirectToClip = GrStencilSettings::GetClipPasses(op, 767 canDrawDirectToClip = GrStencilSettings::GetClipPasses(op,
795 canRenderDire ctToStencil, 768 canRenderDire ctToStencil,
796 clipBit, 769 clipBit,
797 fillInverted, 770 fillInverted,
798 &passes, 771 &passes,
799 stencilSettin gs); 772 stencilSettin gs);
800 773
801 // draw the element to the client stencil bits if necessary 774 // draw the element to the client stencil bits if necessary
802 if (!canDrawDirectToClip) { 775 if (!canDrawDirectToClip) {
776 GrDrawState drawState(matrix);
777 drawState.setRenderTarget(rt);
778 drawState.enableState(GrDrawState::kClip_StateBit);
779 #if !VISUALIZE_COMPLEX_CLIP
780 drawState.enableState(GrDrawState::kNoColorWrites_StateBit);
781 #endif
782 // if the target is MSAA then we want MSAA enabled when the clip is soft
783 if (rt->isMultisampled()) {
784 drawState.setState(GrDrawState::kHWAntialias_StateBit, eleme nt->isAA());
785 }
786
803 GR_STATIC_CONST_SAME_STENCIL(gDrawToStencil, 787 GR_STATIC_CONST_SAME_STENCIL(gDrawToStencil,
804 kIncClamp_StencilOp, 788 kIncClamp_StencilOp,
805 kIncClamp_StencilOp, 789 kIncClamp_StencilOp,
806 kAlways_StencilFunc, 790 kAlways_StencilFunc,
807 0xffff, 791 0xffff,
808 0x0000, 792 0x0000,
809 0xffff); 793 0xffff);
810 SET_RANDOM_COLOR 794 SET_RANDOM_COLOR
811 if (Element::kRect_Type == element->getType()) { 795 if (Element::kRect_Type == element->getType()) {
812 *drawState->stencil() = gDrawToStencil; 796 *drawState.stencil() = gDrawToStencil;
813 fClipTarget->drawSimpleRect(element->getRect()); 797 fClipTarget->drawSimpleRect(&drawState, element->getRect());
814 } else { 798 } else {
815 if (!clipPath.isEmpty()) { 799 if (!clipPath.isEmpty()) {
800 GrDrawTarget::AutoGeometryPush agp(fClipTarget);
816 if (canRenderDirectToStencil) { 801 if (canRenderDirectToStencil) {
817 *drawState->stencil() = gDrawToStencil; 802 *drawState.stencil() = gDrawToStencil;
818 pr->drawPath(clipPath, stroke, fClipTarget, false); 803 pr->drawPath(fClipTarget, &drawState, clipPath, stro ke, false);
819 } else { 804 } else {
820 pr->stencilPath(clipPath, stroke, fClipTarget); 805 pr->stencilPath(fClipTarget, &drawState, clipPath, s troke);
821 } 806 }
822 } 807 }
823 } 808 }
824 } 809 }
825 810
826 // now we modify the clip bit by rendering either the clip 811 // now we modify the clip bit by rendering either the clip
827 // element directly or a bounding rect of the entire clip. 812 // element directly or a bounding rect of the entire clip.
828 fClipMode = kModifyClip_StencilClipMode; 813 fClipMode = kModifyClip_StencilClipMode;
829 for (int p = 0; p < passes; ++p) { 814 for (int p = 0; p < passes; ++p) {
830 *drawState->stencil() = stencilSettings[p]; 815 GrDrawState drawState(matrix);
816 // if the target is MSAA then we want MSAA enabled when the clip is soft
817 if (rt->isMultisampled()) {
818 drawState.setState(GrDrawState::kHWAntialias_StateBit, eleme nt->isAA());
819 }
820
821 drawState.setRenderTarget(rt);
822 drawState.enableState(GrDrawState::kClip_StateBit);
823 #if !VISUALIZE_COMPLEX_CLIP
824 drawState.enableState(GrDrawState::kNoColorWrites_StateBit);
825 #endif
826
827 *drawState.stencil() = stencilSettings[p];
828
831 if (canDrawDirectToClip) { 829 if (canDrawDirectToClip) {
832 if (Element::kRect_Type == element->getType()) { 830 if (Element::kRect_Type == element->getType()) {
833 SET_RANDOM_COLOR 831 SET_RANDOM_COLOR
834 fClipTarget->drawSimpleRect(element->getRect()); 832 fClipTarget->drawSimpleRect(&drawState, element->getRect ());
835 } else { 833 } else {
836 SET_RANDOM_COLOR 834 SET_RANDOM_COLOR
837 pr->drawPath(clipPath, stroke, fClipTarget, false); 835 GrDrawTarget::AutoGeometryPush agp(fClipTarget);
836 pr->drawPath(fClipTarget, &drawState, clipPath, stroke, false);
838 } 837 }
839 } else { 838 } else {
840 SET_RANDOM_COLOR 839 SET_RANDOM_COLOR
841 // The view matrix is setup to do clip space -> stencil spac e translation, so 840 // The view matrix is setup to do clip space -> stencil spac e translation, so
842 // draw rect in clip space. 841 // draw rect in clip space.
843 fClipTarget->drawSimpleRect(SkRect::Make(clipSpaceIBounds)); 842 fClipTarget->drawSimpleRect(&drawState, SkRect::Make(clipSpa ceIBounds));
844 } 843 }
845 } 844 }
846 } 845 }
847 } 846 }
848 // set this last because recursive draws may overwrite it back to kNone. 847 // set this last because recursive draws may overwrite it back to kNone.
849 SkASSERT(kNone_ClipMaskType == fCurrClipMaskType); 848 SkASSERT(kNone_ClipMaskType == fCurrClipMaskType);
850 fCurrClipMaskType = kStencil_ClipMaskType; 849 fCurrClipMaskType = kStencil_ClipMaskType;
851 fClipMode = kRespectClip_StencilClipMode; 850 fClipMode = kRespectClip_StencilClipMode;
852 return true; 851 return true;
853 } 852 }
854 853
855
856 // mapping of clip-respecting stencil funcs to normal stencil funcs 854 // mapping of clip-respecting stencil funcs to normal stencil funcs
857 // mapping depends on whether stencil-clipping is in effect. 855 // mapping depends on whether stencil-clipping is in effect.
858 static const GrStencilFunc 856 static const GrStencilFunc
859 gSpecialToBasicStencilFunc[2][kClipStencilFuncCount] = { 857 gSpecialToBasicStencilFunc[2][kClipStencilFuncCount] = {
860 {// Stencil-Clipping is DISABLED, we are effectively always inside the clip 858 {// Stencil-Clipping is DISABLED, we are effectively always inside the clip
861 // In the Clip Funcs 859 // In the Clip Funcs
862 kAlways_StencilFunc, // kAlwaysIfInClip_StencilFunc 860 kAlways_StencilFunc, // kAlwaysIfInClip_StencilFunc
863 kEqual_StencilFunc, // kEqualIfInClip_StencilFunc 861 kEqual_StencilFunc, // kEqualIfInClip_StencilFunc
864 kLess_StencilFunc, // kLessIfInClip_StencilFunc 862 kLess_StencilFunc, // kLessIfInClip_StencilFunc
865 kLEqual_StencilFunc, // kLEqualIfInClip_StencilFunc 863 kLEqual_StencilFunc, // kLEqualIfInClip_StencilFunc
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 kKeep_StencilOp, 896 kKeep_StencilOp,
899 kKeep_StencilOp, 897 kKeep_StencilOp,
900 kAlwaysIfInClip_StencilFunc, 898 kAlwaysIfInClip_StencilFunc,
901 0x0000, 899 0x0000,
902 0x0000, 900 0x0000,
903 0x0000); 901 0x0000);
904 return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings); 902 return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings);
905 } 903 }
906 } 904 }
907 905
908 void GrClipMaskManager::setDrawStateStencil(GrDrawState::AutoRestoreStencil* ars ) { 906 void GrClipMaskManager::setDrawStateStencil(GrDrawState* drawState,
907 GrDrawState::AutoRestoreStencil* ars ) {
909 // We make two copies of the StencilSettings here (except in the early 908 // We make two copies of the StencilSettings here (except in the early
910 // exit scenario. One copy from draw state to the stack var. Then another 909 // exit scenario. One copy from draw state to the stack var. Then another
911 // from the stack var to the gpu. We could make this class hold a ptr to 910 // from the stack var to the gpu. We could make this class hold a ptr to
912 // GrGpu's fStencilSettings and eliminate the stack copy here. 911 // GrGpu's fStencilSettings and eliminate the stack copy here.
913 912
914 const GrDrawState& drawState = fClipTarget->getDrawState();
915
916 // use stencil for clipping if clipping is enabled and the clip 913 // use stencil for clipping if clipping is enabled and the clip
917 // has been written into the stencil. 914 // has been written into the stencil.
915 GrStencilSettings settings;
918 916
919 GrStencilSettings settings;
920 // The GrGpu client may not be using the stencil buffer but we may need to 917 // The GrGpu client may not be using the stencil buffer but we may need to
921 // enable it in order to respect a stencil clip. 918 // enable it in order to respect a stencil clip.
922 if (drawState.getStencil().isDisabled()) { 919 if (drawState->getStencil().isDisabled()) {
923 if (GrClipMaskManager::kRespectClip_StencilClipMode == fClipMode) { 920 if (GrClipMaskManager::kRespectClip_StencilClipMode == fClipMode) {
924 settings = basic_apply_stencil_clip_settings(); 921 settings = basic_apply_stencil_clip_settings();
925 } else { 922 } else {
926 return; 923 return;
927 } 924 }
928 } else { 925 } else {
929 settings = drawState.getStencil(); 926 settings = drawState->getStencil();
930 } 927 }
931 928
932 // TODO: dynamically attach a stencil buffer 929 // TODO: dynamically attach a stencil buffer
933 int stencilBits = 0; 930 int stencilBits = 0;
934 GrStencilBuffer* stencilBuffer = drawState.getRenderTarget()->getStencilBuff er(); 931 GrStencilBuffer* stencilBuffer = drawState->getRenderTarget()->getStencilBuf fer();
935 if (stencilBuffer) { 932 if (stencilBuffer) {
936 stencilBits = stencilBuffer->bits(); 933 stencilBits = stencilBuffer->bits();
937 } 934 }
938 935
939 SkASSERT(fClipTarget->caps()->stencilWrapOpsSupport() || !settings.usesWrapO p()); 936 SkASSERT(fClipTarget->caps()->stencilWrapOpsSupport() || !settings.usesWrapO p());
940 SkASSERT(fClipTarget->caps()->twoSidedStencilSupport() || !settings.isTwoSid ed()); 937 SkASSERT(fClipTarget->caps()->twoSidedStencilSupport() || !settings.isTwoSid ed());
941 this->adjustStencilParams(&settings, fClipMode, stencilBits); 938 this->adjustStencilParams(&settings, fClipMode, stencilBits);
942 ars->set(fClipTarget->drawState()); 939 ars->set(drawState);
943 fClipTarget->drawState()->setStencil(settings); 940 drawState->setStencil(settings);
944 } 941 }
945 942
946 void GrClipMaskManager::adjustStencilParams(GrStencilSettings* settings, 943 void GrClipMaskManager::adjustStencilParams(GrStencilSettings* settings,
947 StencilClipMode mode, 944 StencilClipMode mode,
948 int stencilBitCnt) { 945 int stencilBitCnt) {
949 SkASSERT(stencilBitCnt > 0); 946 SkASSERT(stencilBitCnt > 0);
950 947
951 if (kModifyClip_StencilClipMode == mode) { 948 if (kModifyClip_StencilClipMode == mode) {
952 // We assume that this clip manager itself is drawing to the GrGpu and 949 // We assume that this clip manager itself is drawing to the GrGpu and
953 // has already setup the correct values. 950 // has already setup the correct values.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 1035
1039 // The mask texture may be larger than necessary. We round out the clip spac e bounds and pin 1036 // The mask texture may be larger than necessary. We round out the clip spac e bounds and pin
1040 // the top left corner of the resulting rect to the top left of the texture. 1037 // the top left corner of the resulting rect to the top left of the texture.
1041 SkIRect maskSpaceIBounds = SkIRect::MakeWH(clipSpaceIBounds.width(), clipSpa ceIBounds.height()); 1038 SkIRect maskSpaceIBounds = SkIRect::MakeWH(clipSpaceIBounds.width(), clipSpa ceIBounds.height());
1042 1039
1043 GrSWMaskHelper helper(this->getContext()); 1040 GrSWMaskHelper helper(this->getContext());
1044 1041
1045 SkMatrix matrix; 1042 SkMatrix matrix;
1046 matrix.setTranslate(SkIntToScalar(-clipSpaceIBounds.fLeft), 1043 matrix.setTranslate(SkIntToScalar(-clipSpaceIBounds.fLeft),
1047 SkIntToScalar(-clipSpaceIBounds.fTop)); 1044 SkIntToScalar(-clipSpaceIBounds.fTop));
1045
1048 helper.init(maskSpaceIBounds, &matrix, false); 1046 helper.init(maskSpaceIBounds, &matrix, false);
1049
1050 helper.clear(GrReducedClip::kAllIn_InitialState == initialState ? 0xFF : 0x0 0); 1047 helper.clear(GrReducedClip::kAllIn_InitialState == initialState ? 0xFF : 0x0 0);
1051
1052 SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle); 1048 SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle);
1053 1049
1054 for (GrReducedClip::ElementList::Iter iter(elements.headIter()) ; iter.get() ; iter.next()) { 1050 for (GrReducedClip::ElementList::Iter iter(elements.headIter()) ; iter.get() ; iter.next()) {
1055
1056 const Element* element = iter.get(); 1051 const Element* element = iter.get();
1057 SkRegion::Op op = element->getOp(); 1052 SkRegion::Op op = element->getOp();
1058 1053
1059 if (SkRegion::kIntersect_Op == op || SkRegion::kReverseDifference_Op == op) { 1054 if (SkRegion::kIntersect_Op == op || SkRegion::kReverseDifference_Op == op) {
1060 // Intersect and reverse difference require modifying pixels outside of the geometry 1055 // Intersect and reverse difference require modifying pixels outside of the geometry
1061 // that is being "drawn". In both cases we erase all the pixels outs ide of the geometry 1056 // that is being "drawn". In both cases we erase all the pixels outs ide of the geometry
1062 // but leave the pixels inside the geometry alone. For reverse diffe rence we invert all 1057 // but leave the pixels inside the geometry alone. For reverse diffe rence we invert all
1063 // the pixels before clearing the ones outside the geometry. 1058 // the pixels before clearing the ones outside the geometry.
1064 if (SkRegion::kReverseDifference_Op == op) { 1059 if (SkRegion::kReverseDifference_Op == op) {
1065 SkRect temp = SkRect::Make(clipSpaceIBounds); 1060 SkRect temp = SkRect::Make(clipSpaceIBounds);
1066 // invert the entire scene 1061 // invert the entire scene
1067 helper.draw(temp, SkRegion::kXOR_Op, false, 0xFF); 1062 helper.draw(temp, SkRegion::kXOR_Op, false, 0xFF);
1068 } 1063 }
1069
1070 SkPath clipPath; 1064 SkPath clipPath;
1071 element->asPath(&clipPath); 1065 element->asPath(&clipPath);
1072 clipPath.toggleInverseFillType(); 1066 clipPath.toggleInverseFillType();
1073 helper.draw(clipPath, stroke, SkRegion::kReplace_Op, element->isAA() , 0x00); 1067 helper.draw(clipPath, stroke, SkRegion::kReplace_Op, element->isAA() , 0x00);
1074
1075 continue; 1068 continue;
1076 } 1069 }
1077 1070
1078 // The other ops (union, xor, diff) only affect pixels inside 1071 // The other ops (union, xor, diff) only affect pixels inside
1079 // the geometry so they can just be drawn normally 1072 // the geometry so they can just be drawn normally
1080 if (Element::kRect_Type == element->getType()) { 1073 if (Element::kRect_Type == element->getType()) {
1081 helper.draw(element->getRect(), op, element->isAA(), 0xFF); 1074 helper.draw(element->getRect(), op, element->isAA(), 0xFF);
1082 } else { 1075 } else {
1083 SkPath path; 1076 SkPath path;
1084 element->asPath(&path); 1077 element->asPath(&path);
(...skipping 16 matching lines...) Expand all
1101 //////////////////////////////////////////////////////////////////////////////// 1094 ////////////////////////////////////////////////////////////////////////////////
1102 void GrClipMaskManager::purgeResources() { 1095 void GrClipMaskManager::purgeResources() {
1103 fAACache.purgeResources(); 1096 fAACache.purgeResources();
1104 } 1097 }
1105 1098
1106 void GrClipMaskManager::setClipTarget(GrClipTarget* clipTarget) { 1099 void GrClipMaskManager::setClipTarget(GrClipTarget* clipTarget) {
1107 fClipTarget = clipTarget; 1100 fClipTarget = clipTarget;
1108 fAACache.setContext(clipTarget->getContext()); 1101 fAACache.setContext(clipTarget->getContext());
1109 } 1102 }
1110 1103
1111 void GrClipMaskManager::adjustPathStencilParams(GrStencilSettings* settings) { 1104 void GrClipMaskManager::adjustPathStencilParams(const GrStencilBuffer* stencilBu ffer,
1112 const GrDrawState& drawState = fClipTarget->getDrawState(); 1105 GrStencilSettings* settings) {
1113
1114 // TODO: dynamically attach a stencil buffer 1106 // TODO: dynamically attach a stencil buffer
1115 int stencilBits = 0;
1116 GrStencilBuffer* stencilBuffer = drawState.getRenderTarget()->getStencilBuff er();
1117 if (stencilBuffer) { 1107 if (stencilBuffer) {
1118 stencilBits = stencilBuffer->bits(); 1108 int stencilBits = stencilBuffer->bits();
1119 this->adjustStencilParams(settings, fClipMode, stencilBits); 1109 this->adjustStencilParams(settings, fClipMode, stencilBits);
1120 } 1110 }
1121 } 1111 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698