| 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" |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 bool GrClipMaskManager::setupClipping(const GrClipData* clipDataIn, | 213 bool GrClipMaskManager::setupClipping(const GrClipData* clipDataIn, |
| 214 GrDrawState::AutoRestoreEffects* are, | 214 GrDrawState::AutoRestoreEffects* are, |
| 215 const SkRect* devBounds) { | 215 const SkRect* devBounds) { |
| 216 fCurrClipMaskType = kNone_ClipMaskType; | 216 fCurrClipMaskType = kNone_ClipMaskType; |
| 217 | 217 |
| 218 ElementList elements(16); | 218 ElementList elements(16); |
| 219 int32_t genID; | 219 int32_t genID; |
| 220 InitialState initialState; | 220 InitialState initialState; |
| 221 SkIRect clipSpaceIBounds; | 221 SkIRect clipSpaceIBounds; |
| 222 bool requiresAA; | 222 bool requiresAA; |
| 223 bool isRect = false; | |
| 224 | 223 |
| 225 GrDrawState* drawState = fGpu->drawState(); | 224 GrDrawState* drawState = fGpu->drawState(); |
| 226 | 225 |
| 227 const GrRenderTarget* rt = drawState->getRenderTarget(); | 226 const GrRenderTarget* rt = drawState->getRenderTarget(); |
| 228 // GrDrawTarget should have filtered this for us | 227 // GrDrawTarget should have filtered this for us |
| 229 SkASSERT(NULL != rt); | 228 SkASSERT(NULL != rt); |
| 230 | 229 |
| 231 bool ignoreClip = !drawState->isClipState() || clipDataIn->fClipStack->isWid
eOpen(); | 230 bool ignoreClip = !drawState->isClipState() || clipDataIn->fClipStack->isWid
eOpen(); |
| 232 | 231 |
| 233 if (!ignoreClip) { | 232 if (!ignoreClip) { |
| 234 SkIRect clipSpaceRTIBounds = SkIRect::MakeWH(rt->width(), rt->height()); | 233 SkIRect clipSpaceRTIBounds = SkIRect::MakeWH(rt->width(), rt->height()); |
| 235 clipSpaceRTIBounds.offset(clipDataIn->fOrigin); | 234 clipSpaceRTIBounds.offset(clipDataIn->fOrigin); |
| 236 ReduceClipStack(*clipDataIn->fClipStack, | 235 ReduceClipStack(*clipDataIn->fClipStack, |
| 237 clipSpaceRTIBounds, | 236 clipSpaceRTIBounds, |
| 238 &elements, | 237 &elements, |
| 239 &genID, | 238 &genID, |
| 240 &initialState, | 239 &initialState, |
| 241 &clipSpaceIBounds, | 240 &clipSpaceIBounds, |
| 242 &requiresAA); | 241 &requiresAA); |
| 243 if (elements.isEmpty()) { | 242 if (elements.isEmpty()) { |
| 244 if (kAllIn_InitialState == initialState) { | 243 if (kAllIn_InitialState == initialState) { |
| 245 ignoreClip = clipSpaceIBounds == clipSpaceRTIBounds; | 244 ignoreClip = clipSpaceIBounds == clipSpaceRTIBounds; |
| 246 isRect = true; | |
| 247 } else { | 245 } else { |
| 248 return false; | 246 return false; |
| 249 } | 247 } |
| 250 } | 248 } |
| 251 } | 249 } |
| 252 | 250 |
| 253 if (ignoreClip) { | 251 if (ignoreClip) { |
| 254 fGpu->disableScissor(); | 252 fGpu->disableScissor(); |
| 255 this->setGpuStencil(); | 253 this->setGpuStencil(); |
| 256 return true; | 254 return true; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 } | 314 } |
| 317 #endif // GR_AA_CLIP | 315 #endif // GR_AA_CLIP |
| 318 | 316 |
| 319 // 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 |
| 320 // 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. |
| 321 // 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., |
| 322 // 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 |
| 323 // "incorrectly" clearing the AA cache. | 321 // "incorrectly" clearing the AA cache. |
| 324 fAACache.reset(); | 322 fAACache.reset(); |
| 325 | 323 |
| 326 // If the clip is a rectangle then just set the scissor. Otherwise, create | |
| 327 // a stencil mask. | |
| 328 if (isRect) { | |
| 329 SkIRect clipRect = clipSpaceIBounds; | |
| 330 clipRect.offset(-clipDataIn->fOrigin); | |
| 331 fGpu->enableScissor(clipRect); | |
| 332 this->setGpuStencil(); | |
| 333 return true; | |
| 334 } | |
| 335 | |
| 336 // 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. |
| 337 SkIPoint clipSpaceToStencilSpaceOffset = -clipDataIn->fOrigin; | 325 SkIPoint clipSpaceToStencilSpaceOffset = -clipDataIn->fOrigin; |
| 338 this->createStencilClipMask(genID, | 326 this->createStencilClipMask(genID, |
| 339 initialState, | 327 initialState, |
| 340 elements, | 328 elements, |
| 341 clipSpaceIBounds, | 329 clipSpaceIBounds, |
| 342 clipSpaceToStencilSpaceOffset); | 330 clipSpaceToStencilSpaceOffset); |
| 343 | 331 |
| 344 // 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 |
| 345 // 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 |
| (...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1144 | 1132 |
| 1145 // TODO: dynamically attach a stencil buffer | 1133 // TODO: dynamically attach a stencil buffer |
| 1146 int stencilBits = 0; | 1134 int stencilBits = 0; |
| 1147 GrStencilBuffer* stencilBuffer = | 1135 GrStencilBuffer* stencilBuffer = |
| 1148 drawState.getRenderTarget()->getStencilBuffer(); | 1136 drawState.getRenderTarget()->getStencilBuffer(); |
| 1149 if (NULL != stencilBuffer) { | 1137 if (NULL != stencilBuffer) { |
| 1150 stencilBits = stencilBuffer->bits(); | 1138 stencilBits = stencilBuffer->bits(); |
| 1151 this->adjustStencilParams(settings, clipMode, stencilBits); | 1139 this->adjustStencilParams(settings, clipMode, stencilBits); |
| 1152 } | 1140 } |
| 1153 } | 1141 } |
| OLD | NEW |