| OLD | NEW |
| 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 "SkRasterClip.h" |
| 21 #include "SkStrokeRec.h" |
| 22 #include "SkTLazy.h" |
| 20 #include "effects/GrTextureDomain.h" | 23 #include "effects/GrTextureDomain.h" |
| 21 #include "effects/GrConvexPolyEffect.h" | 24 #include "effects/GrConvexPolyEffect.h" |
| 22 #include "effects/GrRRectEffect.h" | 25 #include "effects/GrRRectEffect.h" |
| 23 #include "SkRasterClip.h" | |
| 24 #include "SkStrokeRec.h" | |
| 25 #include "SkTLazy.h" | |
| 26 | 26 |
| 27 #define GR_AA_CLIP 1 | 27 #define GR_AA_CLIP 1 |
| 28 | 28 |
| 29 typedef SkClipStack::Element Element; | 29 typedef SkClipStack::Element Element; |
| 30 | 30 |
| 31 //////////////////////////////////////////////////////////////////////////////// | 31 //////////////////////////////////////////////////////////////////////////////// |
| 32 namespace { | 32 namespace { |
| 33 // set up the draw state to enable the aa clipping mask. Besides setting up the | 33 // set up the draw state to enable the aa clipping mask. Besides setting up the |
| 34 // stage matrix this also alters the vertex layout | 34 // stage matrix this also alters the vertex layout |
| 35 void setup_drawstate_aaclip(GrGpu* gpu, | 35 void setup_drawstate_aaclip(GrGpu* gpu, |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 } | 205 } |
| 206 | 206 |
| 207 return !failed; | 207 return !failed; |
| 208 } | 208 } |
| 209 | 209 |
| 210 //////////////////////////////////////////////////////////////////////////////// | 210 //////////////////////////////////////////////////////////////////////////////// |
| 211 // sort out what kind of clip mask needs to be created: alpha, stencil, | 211 // sort out what kind of clip mask needs to be created: alpha, stencil, |
| 212 // scissor, or entirely software | 212 // scissor, or entirely software |
| 213 bool GrClipMaskManager::setupClipping(const GrClipData* clipDataIn, | 213 bool GrClipMaskManager::setupClipping(const GrClipData* clipDataIn, |
| 214 GrDrawState::AutoRestoreEffects* are, | 214 GrDrawState::AutoRestoreEffects* are, |
| 215 GrDrawState::AutoRestoreStencil* asr, |
| 215 const SkRect* devBounds) { | 216 const SkRect* devBounds) { |
| 216 fCurrClipMaskType = kNone_ClipMaskType; | 217 fCurrClipMaskType = kNone_ClipMaskType; |
| 217 | 218 |
| 218 GrReducedClip::ElementList elements(16); | 219 GrReducedClip::ElementList elements(16); |
| 219 int32_t genID; | 220 int32_t genID; |
| 220 GrReducedClip::InitialState initialState; | 221 GrReducedClip::InitialState initialState; |
| 221 SkIRect clipSpaceIBounds; | 222 SkIRect clipSpaceIBounds; |
| 222 bool requiresAA; | 223 bool requiresAA; |
| 223 | 224 |
| 224 GrDrawState* drawState = fGpu->drawState(); | 225 GrDrawState* drawState = fGpu->drawState(); |
| 225 | 226 |
| 226 const GrRenderTarget* rt = drawState->getRenderTarget(); | 227 const GrRenderTarget* rt = drawState->getRenderTarget(); |
| 227 // GrDrawTarget should have filtered this for us | 228 // GrDrawTarget should have filtered this for us |
| 228 SkASSERT(rt); | 229 SkASSERT(rt); |
| 229 | 230 |
| 230 bool ignoreClip = !drawState->isClipState() || clipDataIn->fClipStack->isWid
eOpen(); | 231 bool ignoreClip = !drawState->isClipState() || clipDataIn->fClipStack->isWid
eOpen(); |
| 231 | |
| 232 if (!ignoreClip) { | 232 if (!ignoreClip) { |
| 233 SkIRect clipSpaceRTIBounds = SkIRect::MakeWH(rt->width(), rt->height()); | 233 SkIRect clipSpaceRTIBounds = SkIRect::MakeWH(rt->width(), rt->height()); |
| 234 clipSpaceRTIBounds.offset(clipDataIn->fOrigin); | 234 clipSpaceRTIBounds.offset(clipDataIn->fOrigin); |
| 235 GrReducedClip::ReduceClipStack(*clipDataIn->fClipStack, | 235 GrReducedClip::ReduceClipStack(*clipDataIn->fClipStack, |
| 236 clipSpaceRTIBounds, | 236 clipSpaceRTIBounds, |
| 237 &elements, | 237 &elements, |
| 238 &genID, | 238 &genID, |
| 239 &initialState, | 239 &initialState, |
| 240 &clipSpaceIBounds, | 240 &clipSpaceIBounds, |
| 241 &requiresAA); | 241 &requiresAA); |
| 242 if (elements.isEmpty()) { | 242 if (elements.isEmpty()) { |
| 243 if (GrReducedClip::kAllIn_InitialState == initialState) { | 243 if (GrReducedClip::kAllIn_InitialState == initialState) { |
| 244 ignoreClip = clipSpaceIBounds == clipSpaceRTIBounds; | 244 ignoreClip = clipSpaceIBounds == clipSpaceRTIBounds; |
| 245 } else { | 245 } else { |
| 246 return false; | 246 return false; |
| 247 } | 247 } |
| 248 } | 248 } |
| 249 } | 249 } |
| 250 | 250 |
| 251 if (ignoreClip) { | 251 if (ignoreClip) { |
| 252 fGpu->disableScissor(); | 252 fGpu->disableScissor(); |
| 253 this->setGpuStencil(); | 253 this->setDrawStateStencil(asr); |
| 254 return true; | 254 return true; |
| 255 } | 255 } |
| 256 | 256 |
| 257 // An element count of 4 was chosen because of the common pattern in Blink o
f: | 257 // An element count of 4 was chosen because of the common pattern in Blink o
f: |
| 258 // isect RR | 258 // isect RR |
| 259 // diff RR | 259 // diff RR |
| 260 // isect convex_poly | 260 // isect convex_poly |
| 261 // isect convex_poly | 261 // isect convex_poly |
| 262 // when drawing rounded div borders. This could probably be tuned based on a | 262 // when drawing rounded div borders. This could probably be tuned based on a |
| 263 // configuration's relative costs of switching RTs to generate a mask vs | 263 // configuration's relative costs of switching RTs to generate a mask vs |
| 264 // longer shaders. | 264 // longer shaders. |
| 265 if (elements.count() <= 4) { | 265 if (elements.count() <= 4) { |
| 266 SkVector clipToRTOffset = { SkIntToScalar(-clipDataIn->fOrigin.fX), | 266 SkVector clipToRTOffset = { SkIntToScalar(-clipDataIn->fOrigin.fX), |
| 267 SkIntToScalar(-clipDataIn->fOrigin.fY) }; | 267 SkIntToScalar(-clipDataIn->fOrigin.fY) }; |
| 268 if (elements.isEmpty() || | 268 if (elements.isEmpty() || |
| 269 (requiresAA && this->installClipEffects(elements, are, clipToRTOffse
t, devBounds))) { | 269 (requiresAA && this->installClipEffects(elements, are, clipToRTOffse
t, devBounds))) { |
| 270 SkIRect scissorSpaceIBounds(clipSpaceIBounds); | 270 SkIRect scissorSpaceIBounds(clipSpaceIBounds); |
| 271 scissorSpaceIBounds.offset(-clipDataIn->fOrigin); | 271 scissorSpaceIBounds.offset(-clipDataIn->fOrigin); |
| 272 if (NULL == devBounds || | 272 if (NULL == devBounds || |
| 273 !SkRect::Make(scissorSpaceIBounds).contains(*devBounds)) { | 273 !SkRect::Make(scissorSpaceIBounds).contains(*devBounds)) { |
| 274 fGpu->enableScissor(scissorSpaceIBounds); | 274 fGpu->enableScissor(scissorSpaceIBounds); |
| 275 } else { | 275 } else { |
| 276 fGpu->disableScissor(); | 276 fGpu->disableScissor(); |
| 277 } | 277 } |
| 278 this->setGpuStencil(); | 278 this->setDrawStateStencil(asr); |
| 279 return true; | 279 return true; |
| 280 } | 280 } |
| 281 } | 281 } |
| 282 | 282 |
| 283 #if GR_AA_CLIP | 283 #if GR_AA_CLIP |
| 284 // If MSAA is enabled we can do everything in the stencil buffer. | 284 // If MSAA is enabled we can do everything in the stencil buffer. |
| 285 if (0 == rt->numSamples() && requiresAA) { | 285 if (0 == rt->numSamples() && requiresAA) { |
| 286 GrTexture* result = NULL; | 286 GrTexture* result = NULL; |
| 287 | 287 |
| 288 if (this->useSWOnlyPath(elements)) { | 288 if (this->useSWOnlyPath(elements)) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 300 } | 300 } |
| 301 | 301 |
| 302 if (result) { | 302 if (result) { |
| 303 // The mask's top left coord should be pinned to the rounded-out top
left corner of | 303 // The mask's top left coord should be pinned to the rounded-out top
left corner of |
| 304 // clipSpace bounds. We determine the mask's position WRT to the ren
der target here. | 304 // clipSpace bounds. We determine the mask's position WRT to the ren
der target here. |
| 305 SkIRect rtSpaceMaskBounds = clipSpaceIBounds; | 305 SkIRect rtSpaceMaskBounds = clipSpaceIBounds; |
| 306 rtSpaceMaskBounds.offset(-clipDataIn->fOrigin); | 306 rtSpaceMaskBounds.offset(-clipDataIn->fOrigin); |
| 307 are->set(fGpu->drawState()); | 307 are->set(fGpu->drawState()); |
| 308 setup_drawstate_aaclip(fGpu, result, rtSpaceMaskBounds); | 308 setup_drawstate_aaclip(fGpu, result, rtSpaceMaskBounds); |
| 309 fGpu->disableScissor(); | 309 fGpu->disableScissor(); |
| 310 this->setGpuStencil(); | 310 this->setDrawStateStencil(asr); |
| 311 return true; | 311 return true; |
| 312 } | 312 } |
| 313 // 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 |
| 314 } | 314 } |
| 315 #endif // GR_AA_CLIP | 315 #endif // GR_AA_CLIP |
| 316 | 316 |
| 317 // Either a hard (stencil buffer) clip was explicitly requested or an anti-a
liased clip couldn't | 317 // 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. | 318 // 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., | 319 // 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 | 320 // clears, InOrderDrawBuffer playbacks) that hit the stencil buffer path. Th
ese may be |
| 321 // "incorrectly" clearing the AA cache. | 321 // "incorrectly" clearing the AA cache. |
| 322 fAACache.reset(); | 322 fAACache.reset(); |
| 323 | 323 |
| 324 // use the stencil clip if we can't represent the clip as a rectangle. | 324 // use the stencil clip if we can't represent the clip as a rectangle. |
| 325 SkIPoint clipSpaceToStencilSpaceOffset = -clipDataIn->fOrigin; | 325 SkIPoint clipSpaceToStencilSpaceOffset = -clipDataIn->fOrigin; |
| 326 this->createStencilClipMask(genID, | 326 this->createStencilClipMask(genID, |
| 327 initialState, | 327 initialState, |
| 328 elements, | 328 elements, |
| 329 clipSpaceIBounds, | 329 clipSpaceIBounds, |
| 330 clipSpaceToStencilSpaceOffset); | 330 clipSpaceToStencilSpaceOffset); |
| 331 | 331 |
| 332 // This must occur after createStencilClipMask. That function may change the
scissor. Also, it | 332 // 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 | 333 // 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. | 334 // use both stencil and scissor test to the bounds for the final draw. |
| 335 SkIRect scissorSpaceIBounds(clipSpaceIBounds); | 335 SkIRect scissorSpaceIBounds(clipSpaceIBounds); |
| 336 scissorSpaceIBounds.offset(clipSpaceToStencilSpaceOffset); | 336 scissorSpaceIBounds.offset(clipSpaceToStencilSpaceOffset); |
| 337 fGpu->enableScissor(scissorSpaceIBounds); | 337 fGpu->enableScissor(scissorSpaceIBounds); |
| 338 this->setGpuStencil(); | 338 this->setDrawStateStencil(asr); |
| 339 return true; | 339 return true; |
| 340 } | 340 } |
| 341 | 341 |
| 342 #define VISUALIZE_COMPLEX_CLIP 0 | 342 #define VISUALIZE_COMPLEX_CLIP 0 |
| 343 | 343 |
| 344 #if VISUALIZE_COMPLEX_CLIP | 344 #if VISUALIZE_COMPLEX_CLIP |
| 345 #include "SkRandom.h" | 345 #include "SkRandom.h" |
| 346 SkRandom gRandom; | 346 SkRandom gRandom; |
| 347 #define SET_RANDOM_COLOR drawState->setColor(0xff000000 | gRandom.nextU()); | 347 #define SET_RANDOM_COLOR drawState->setColor(0xff000000 | gRandom.nextU()); |
| 348 #else | 348 #else |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 | 393 |
| 394 // TODO: Draw rrects directly here. | 394 // TODO: Draw rrects directly here. |
| 395 switch (element->getType()) { | 395 switch (element->getType()) { |
| 396 case Element::kEmpty_Type: | 396 case Element::kEmpty_Type: |
| 397 SkDEBUGFAIL("Should never get here with an empty element."); | 397 SkDEBUGFAIL("Should never get here with an empty element."); |
| 398 break; | 398 break; |
| 399 case Element::kRect_Type: | 399 case Element::kRect_Type: |
| 400 // TODO: Do rects directly to the accumulator using a aa-rect GrProc
essor that covers | 400 // 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. | 401 // the entire mask bounds and writes 0 outside the rect. |
| 402 if (element->isAA()) { | 402 if (element->isAA()) { |
| 403 getContext()->getAARectRenderer()->fillAARect(fGpu, | 403 this->getContext()->getAARectRenderer()->fillAARect(fGpu, |
| 404 fGpu, | 404 fGpu, |
| 405 element->getRect()
, | 405 element->get
Rect(), |
| 406 SkMatrix::I(), | 406 SkMatrix::I(
), |
| 407 element->getRect()
); | 407 element->get
Rect()); |
| 408 } else { | 408 } else { |
| 409 fGpu->drawSimpleRect(element->getRect()); | 409 fGpu->drawSimpleRect(element->getRect()); |
| 410 } | 410 } |
| 411 return true; | 411 return true; |
| 412 default: { | 412 default: { |
| 413 SkPath path; | 413 SkPath path; |
| 414 element->asPath(&path); | 414 element->asPath(&path); |
| 415 path.setIsVolatile(true); | 415 path.setIsVolatile(true); |
| 416 if (path.isInverseFillType()) { | 416 if (path.isInverseFillType()) { |
| 417 path.toggleInverseFillType(); | 417 path.toggleInverseFillType(); |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 GrRenderTarget* rt = drawState->getRenderTarget(); | 700 GrRenderTarget* rt = drawState->getRenderTarget(); |
| 701 SkASSERT(rt); | 701 SkASSERT(rt); |
| 702 | 702 |
| 703 // TODO: dynamically attach a SB when needed. | 703 // TODO: dynamically attach a SB when needed. |
| 704 GrStencilBuffer* stencilBuffer = rt->getStencilBuffer(); | 704 GrStencilBuffer* stencilBuffer = rt->getStencilBuffer(); |
| 705 if (NULL == stencilBuffer) { | 705 if (NULL == stencilBuffer) { |
| 706 return false; | 706 return false; |
| 707 } | 707 } |
| 708 | 708 |
| 709 if (stencilBuffer->mustRenderClip(elementsGenID, clipSpaceIBounds, clipSpace
ToStencilOffset)) { | 709 if (stencilBuffer->mustRenderClip(elementsGenID, clipSpaceIBounds, clipSpace
ToStencilOffset)) { |
| 710 | |
| 711 stencilBuffer->setLastClip(elementsGenID, clipSpaceIBounds, clipSpaceToS
tencilOffset); | 710 stencilBuffer->setLastClip(elementsGenID, clipSpaceIBounds, clipSpaceToS
tencilOffset); |
| 712 | 711 |
| 713 // Set the matrix so that rendered clip elements are transformed from cl
ip to stencil space. | 712 // Set the matrix so that rendered clip elements are transformed from cl
ip to stencil space. |
| 714 SkVector translate = { | 713 SkVector translate = { |
| 715 SkIntToScalar(clipSpaceToStencilOffset.fX), | 714 SkIntToScalar(clipSpaceToStencilOffset.fX), |
| 716 SkIntToScalar(clipSpaceToStencilOffset.fY) | 715 SkIntToScalar(clipSpaceToStencilOffset.fY) |
| 717 }; | 716 }; |
| 718 SkMatrix matrix; | 717 SkMatrix matrix; |
| 719 matrix.setTranslate(translate); | 718 matrix.setTranslate(translate); |
| 720 GrDrawTarget::AutoGeometryAndStatePush agasp(fGpu, GrDrawTarget::kReset_
ASRInit, &matrix); | 719 GrDrawTarget::AutoGeometryAndStatePush agasp(fGpu, GrDrawTarget::kReset_
ASRInit, &matrix); |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 kKeep_StencilOp, | 895 kKeep_StencilOp, |
| 897 kKeep_StencilOp, | 896 kKeep_StencilOp, |
| 898 kAlwaysIfInClip_StencilFunc, | 897 kAlwaysIfInClip_StencilFunc, |
| 899 0x0000, | 898 0x0000, |
| 900 0x0000, | 899 0x0000, |
| 901 0x0000); | 900 0x0000); |
| 902 return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings); | 901 return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings); |
| 903 } | 902 } |
| 904 } | 903 } |
| 905 | 904 |
| 906 void GrClipMaskManager::setGpuStencil() { | 905 void GrClipMaskManager::setDrawStateStencil(GrDrawState::AutoRestoreStencil* ars
) { |
| 907 // We make two copies of the StencilSettings here (except in the early | 906 // We make two copies of the StencilSettings here (except in the early |
| 908 // exit scenario. One copy from draw state to the stack var. Then another | 907 // exit scenario. One copy from draw state to the stack var. Then another |
| 909 // from the stack var to the gpu. We could make this class hold a ptr to | 908 // from the stack var to the gpu. We could make this class hold a ptr to |
| 910 // GrGpu's fStencilSettings and eliminate the stack copy here. | 909 // GrGpu's fStencilSettings and eliminate the stack copy here. |
| 911 | 910 |
| 912 const GrDrawState& drawState = fGpu->getDrawState(); | 911 const GrDrawState& drawState = fGpu->getDrawState(); |
| 913 | 912 |
| 914 // use stencil for clipping if clipping is enabled and the clip | 913 // use stencil for clipping if clipping is enabled and the clip |
| 915 // has been written into the stencil. | 914 // has been written into the stencil. |
| 916 GrClipMaskManager::StencilClipMode clipMode; | 915 GrClipMaskManager::StencilClipMode clipMode; |
| 917 if (this->isClipInStencil() && drawState.isClipState()) { | 916 if (this->isClipInStencil() && drawState.isClipState()) { |
| 918 clipMode = GrClipMaskManager::kRespectClip_StencilClipMode; | 917 clipMode = GrClipMaskManager::kRespectClip_StencilClipMode; |
| 919 // We can't be modifying the clip and respecting it at the same time. | 918 // We can't be modifying the clip and respecting it at the same time. |
| 920 SkASSERT(!drawState.isStateFlagEnabled( | 919 SkASSERT(!drawState.isStateFlagEnabled( |
| 921 GrGpu::kModifyStencilClip_StateBit)); | 920 GrGpu::kModifyStencilClip_StateBit)); |
| 922 } else if (drawState.isStateFlagEnabled( | 921 } else if (drawState.isStateFlagEnabled( |
| 923 GrGpu::kModifyStencilClip_StateBit)) { | 922 GrGpu::kModifyStencilClip_StateBit)) { |
| 924 clipMode = GrClipMaskManager::kModifyClip_StencilClipMode; | 923 clipMode = GrClipMaskManager::kModifyClip_StencilClipMode; |
| 925 } else { | 924 } else { |
| 926 clipMode = GrClipMaskManager::kIgnoreClip_StencilClipMode; | 925 clipMode = GrClipMaskManager::kIgnoreClip_StencilClipMode; |
| 927 } | 926 } |
| 928 | 927 |
| 929 GrStencilSettings settings; | 928 GrStencilSettings settings; |
| 930 // The GrGpu client may not be using the stencil buffer but we may need to | 929 // The GrGpu client may not be using the stencil buffer but we may need to |
| 931 // enable it in order to respect a stencil clip. | 930 // enable it in order to respect a stencil clip. |
| 932 if (drawState.getStencil().isDisabled()) { | 931 if (drawState.getStencil().isDisabled()) { |
| 933 if (GrClipMaskManager::kRespectClip_StencilClipMode == clipMode) { | 932 if (GrClipMaskManager::kRespectClip_StencilClipMode == clipMode) { |
| 934 settings = basic_apply_stencil_clip_settings(); | 933 settings = basic_apply_stencil_clip_settings(); |
| 935 } else { | 934 } else { |
| 936 fGpu->disableStencil(); | |
| 937 return; | 935 return; |
| 938 } | 936 } |
| 939 } else { | 937 } else { |
| 940 settings = drawState.getStencil(); | 938 settings = drawState.getStencil(); |
| 941 } | 939 } |
| 942 | 940 |
| 943 // TODO: dynamically attach a stencil buffer | 941 // TODO: dynamically attach a stencil buffer |
| 944 int stencilBits = 0; | 942 int stencilBits = 0; |
| 945 GrStencilBuffer* stencilBuffer = | 943 GrStencilBuffer* stencilBuffer = drawState.getRenderTarget()->getStencilBuff
er(); |
| 946 drawState.getRenderTarget()->getStencilBuffer(); | |
| 947 if (stencilBuffer) { | 944 if (stencilBuffer) { |
| 948 stencilBits = stencilBuffer->bits(); | 945 stencilBits = stencilBuffer->bits(); |
| 949 } | 946 } |
| 950 | 947 |
| 951 SkASSERT(fGpu->caps()->stencilWrapOpsSupport() || !settings.usesWrapOp()); | 948 SkASSERT(fGpu->caps()->stencilWrapOpsSupport() || !settings.usesWrapOp()); |
| 952 SkASSERT(fGpu->caps()->twoSidedStencilSupport() || !settings.isTwoSided()); | 949 SkASSERT(fGpu->caps()->twoSidedStencilSupport() || !settings.isTwoSided()); |
| 953 this->adjustStencilParams(&settings, clipMode, stencilBits); | 950 this->adjustStencilParams(&settings, clipMode, stencilBits); |
| 954 fGpu->setStencilSettings(settings); | 951 ars->set(fGpu->drawState()); |
| 952 fGpu->drawState()->setStencil(settings); |
| 955 } | 953 } |
| 956 | 954 |
| 957 void GrClipMaskManager::adjustStencilParams(GrStencilSettings* settings, | 955 void GrClipMaskManager::adjustStencilParams(GrStencilSettings* settings, |
| 958 StencilClipMode mode, | 956 StencilClipMode mode, |
| 959 int stencilBitCnt) { | 957 int stencilBitCnt) { |
| 960 SkASSERT(stencilBitCnt > 0); | 958 SkASSERT(stencilBitCnt > 0); |
| 961 | 959 |
| 962 if (kModifyClip_StencilClipMode == mode) { | 960 if (kModifyClip_StencilClipMode == mode) { |
| 963 // We assume that this clip manager itself is drawing to the GrGpu and | 961 // We assume that this clip manager itself is drawing to the GrGpu and |
| 964 // has already setup the correct values. | 962 // has already setup the correct values. |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1136 | 1134 |
| 1137 // TODO: dynamically attach a stencil buffer | 1135 // TODO: dynamically attach a stencil buffer |
| 1138 int stencilBits = 0; | 1136 int stencilBits = 0; |
| 1139 GrStencilBuffer* stencilBuffer = | 1137 GrStencilBuffer* stencilBuffer = |
| 1140 drawState.getRenderTarget()->getStencilBuffer(); | 1138 drawState.getRenderTarget()->getStencilBuffer(); |
| 1141 if (stencilBuffer) { | 1139 if (stencilBuffer) { |
| 1142 stencilBits = stencilBuffer->bits(); | 1140 stencilBits = stencilBuffer->bits(); |
| 1143 this->adjustStencilParams(settings, clipMode, stencilBits); | 1141 this->adjustStencilParams(settings, clipMode, stencilBits); |
| 1144 } | 1142 } |
| 1145 } | 1143 } |
| OLD | NEW |