OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * 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 |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "GrClipMaskManager.h" | 8 #include "GrClipMaskManager.h" |
9 #include "GrAAConvexPathRenderer.h" | 9 #include "GrAAConvexPathRenderer.h" |
10 #include "GrAAHairLinePathRenderer.h" | 10 #include "GrAAHairLinePathRenderer.h" |
11 #include "GrAARectRenderer.h" | 11 #include "GrAARectRenderer.h" |
12 #include "GrDrawTargetCaps.h" | 12 #include "GrDrawTargetCaps.h" |
13 #include "GrPaint.h" | 13 #include "GrPaint.h" |
14 #include "GrPathRenderer.h" | 14 #include "GrPathRenderer.h" |
15 #include "GrRenderTarget.h" | 15 #include "GrRenderTarget.h" |
16 #include "GrStencilBuffer.h" | 16 #include "GrStencilBuffer.h" |
17 #include "GrSWMaskHelper.h" | 17 #include "GrSWMaskHelper.h" |
18 #include "SkRasterClip.h" | 18 #include "SkRasterClip.h" |
19 #include "SkStrokeRec.h" | 19 #include "SkStrokeRec.h" |
20 #include "SkTLazy.h" | 20 #include "SkTLazy.h" |
21 #include "effects/GrConvexPolyEffect.h" | 21 #include "effects/GrConvexPolyEffect.h" |
22 #include "effects/GrPorterDuffXferProcessor.h" | 22 #include "effects/GrPorterDuffXferProcessor.h" |
23 #include "effects/GrRRectEffect.h" | 23 #include "effects/GrRRectEffect.h" |
24 #include "effects/GrTextureDomain.h" | 24 #include "effects/GrTextureDomain.h" |
25 | 25 |
26 #define GR_AA_CLIP 1 | |
27 typedef SkClipStack::Element Element; | 26 typedef SkClipStack::Element Element; |
28 | 27 |
29 //////////////////////////////////////////////////////////////////////////////// | 28 //////////////////////////////////////////////////////////////////////////////// |
30 namespace { | 29 namespace { |
31 // 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 |
32 // stage matrix this also alters the vertex layout | 31 // stage matrix this also alters the vertex layout |
33 void setup_drawstate_aaclip(const SkIRect &devBound, | 32 void setup_drawstate_aaclip(const SkIRect &devBound, |
34 GrPipelineBuilder* pipelineBuilder, | 33 GrPipelineBuilder* pipelineBuilder, |
35 GrTexture* result) { | 34 GrTexture* result) { |
36 SkASSERT(pipelineBuilder); | 35 SkASSERT(pipelineBuilder); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 default: | 145 default: |
147 failed = true; | 146 failed = true; |
148 break; | 147 break; |
149 } | 148 } |
150 if (failed) { | 149 if (failed) { |
151 break; | 150 break; |
152 } | 151 } |
153 | 152 |
154 if (!skip) { | 153 if (!skip) { |
155 GrPrimitiveEdgeType edgeType; | 154 GrPrimitiveEdgeType edgeType; |
156 if (GR_AA_CLIP && iter.get()->isAA()) { | 155 if (iter.get()->isAA()) { |
157 if (rt->isMultisampled()) { | 156 if (rt->isMultisampled()) { |
158 // Coverage based AA clips don't place nicely with MSAA. | 157 // Coverage based AA clips don't place nicely with MSAA. |
159 failed = true; | 158 failed = true; |
160 break; | 159 break; |
161 } | 160 } |
162 edgeType = | 161 edgeType = |
163 invert ? kInverseFillAA_GrProcessorEdgeType : kFillAA_Gr
ProcessorEdgeType; | 162 invert ? kInverseFillAA_GrProcessorEdgeType : kFillAA_Gr
ProcessorEdgeType; |
164 } else { | 163 } else { |
165 edgeType = | 164 edgeType = |
166 invert ? kInverseFillBW_GrProcessorEdgeType : kFillBW_Gr
ProcessorEdgeType; | 165 invert ? kInverseFillBW_GrProcessorEdgeType : kFillBW_Gr
ProcessorEdgeType; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 scissorSpaceIBounds.offset(-clipDataIn->fOrigin); | 268 scissorSpaceIBounds.offset(-clipDataIn->fOrigin); |
270 if (NULL == devBounds || | 269 if (NULL == devBounds || |
271 !SkRect::Make(scissorSpaceIBounds).contains(*devBounds)) { | 270 !SkRect::Make(scissorSpaceIBounds).contains(*devBounds)) { |
272 scissorState->set(scissorSpaceIBounds); | 271 scissorState->set(scissorSpaceIBounds); |
273 } | 272 } |
274 this->setPipelineBuilderStencil(pipelineBuilder, ars); | 273 this->setPipelineBuilderStencil(pipelineBuilder, ars); |
275 return true; | 274 return true; |
276 } | 275 } |
277 } | 276 } |
278 | 277 |
279 #if GR_AA_CLIP | |
280 // If MSAA is enabled we can do everything in the stencil buffer. | 278 // If MSAA is enabled we can do everything in the stencil buffer. |
281 if (0 == rt->numSamples() && requiresAA) { | 279 if (0 == rt->numSamples() && requiresAA) { |
282 GrTexture* result = NULL; | 280 GrTexture* result = NULL; |
283 | 281 |
284 // The top-left of the mask corresponds to the top-left corner of the bo
unds. | 282 // The top-left of the mask corresponds to the top-left corner of the bo
unds. |
285 SkVector clipToMaskOffset = { | 283 SkVector clipToMaskOffset = { |
286 SkIntToScalar(-clipSpaceIBounds.fLeft), | 284 SkIntToScalar(-clipSpaceIBounds.fLeft), |
287 SkIntToScalar(-clipSpaceIBounds.fTop) | 285 SkIntToScalar(-clipSpaceIBounds.fTop) |
288 }; | 286 }; |
289 | 287 |
(...skipping 17 matching lines...) Expand all Loading... |
307 // The mask's top left coord should be pinned to the rounded-out top
left corner of | 305 // The mask's top left coord should be pinned to the rounded-out top
left corner of |
308 // clipSpace bounds. We determine the mask's position WRT to the ren
der target here. | 306 // clipSpace bounds. We determine the mask's position WRT to the ren
der target here. |
309 SkIRect rtSpaceMaskBounds = clipSpaceIBounds; | 307 SkIRect rtSpaceMaskBounds = clipSpaceIBounds; |
310 rtSpaceMaskBounds.offset(-clipDataIn->fOrigin); | 308 rtSpaceMaskBounds.offset(-clipDataIn->fOrigin); |
311 setup_drawstate_aaclip(rtSpaceMaskBounds, pipelineBuilder, result); | 309 setup_drawstate_aaclip(rtSpaceMaskBounds, pipelineBuilder, result); |
312 this->setPipelineBuilderStencil(pipelineBuilder, ars); | 310 this->setPipelineBuilderStencil(pipelineBuilder, ars); |
313 return true; | 311 return true; |
314 } | 312 } |
315 // if alpha clip mask creation fails fall through to the non-AA code pat
hs | 313 // if alpha clip mask creation fails fall through to the non-AA code pat
hs |
316 } | 314 } |
317 #endif // GR_AA_CLIP | |
318 | 315 |
319 // Either a hard (stencil buffer) clip was explicitly requested or an anti-a
liased clip couldn't | 316 // Either a hard (stencil buffer) clip was explicitly requested or an anti-a
liased clip couldn't |
320 // be created. In either case, free up the texture in the anti-aliased mask
cache. | 317 // be created. In either case, free up the texture in the anti-aliased mask
cache. |
321 // TODO: this may require more investigation. Ganesh performs a lot of utili
ty draws (e.g., | 318 // TODO: this may require more investigation. Ganesh performs a lot of utili
ty draws (e.g., |
322 // clears, InOrderDrawBuffer playbacks) that hit the stencil buffer path. Th
ese may be | 319 // clears, InOrderDrawBuffer playbacks) that hit the stencil buffer path. Th
ese may be |
323 // "incorrectly" clearing the AA cache. | 320 // "incorrectly" clearing the AA cache. |
324 fAACache.reset(); | 321 fAACache.reset(); |
325 | 322 |
326 // use the stencil clip if we can't represent the clip as a rectangle. | 323 // use the stencil clip if we can't represent the clip as a rectangle. |
327 SkIPoint clipSpaceToStencilSpaceOffset = -clipDataIn->fOrigin; | 324 SkIPoint clipSpaceToStencilSpaceOffset = -clipDataIn->fOrigin; |
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1086 } | 1083 } |
1087 | 1084 |
1088 void GrClipMaskManager::adjustPathStencilParams(const GrStencilBuffer* stencilBu
ffer, | 1085 void GrClipMaskManager::adjustPathStencilParams(const GrStencilBuffer* stencilBu
ffer, |
1089 GrStencilSettings* settings) { | 1086 GrStencilSettings* settings) { |
1090 // TODO: dynamically attach a stencil buffer | 1087 // TODO: dynamically attach a stencil buffer |
1091 if (stencilBuffer) { | 1088 if (stencilBuffer) { |
1092 int stencilBits = stencilBuffer->bits(); | 1089 int stencilBits = stencilBuffer->bits(); |
1093 this->adjustStencilParams(settings, fClipMode, stencilBits); | 1090 this->adjustStencilParams(settings, fClipMode, stencilBits); |
1094 } | 1091 } |
1095 } | 1092 } |
OLD | NEW |