| 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" |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 | 224 |
| 225 // GrDrawTarget should have filtered this for us | 225 // GrDrawTarget should have filtered this for us |
| 226 SkASSERT(rt); | 226 SkASSERT(rt); |
| 227 | 227 |
| 228 SkIRect clipSpaceRTIBounds = SkIRect::MakeWH(rt->width(), rt->height()); | 228 SkIRect clipSpaceRTIBounds = SkIRect::MakeWH(rt->width(), rt->height()); |
| 229 const GrClip& clip = pipelineBuilder->clip(); | 229 const GrClip& clip = pipelineBuilder->clip(); |
| 230 // TODO we shouldn't be ignoring the clip mask manager's clip. This is temp
orary. | 230 // TODO we shouldn't be ignoring the clip mask manager's clip. This is temp
orary. |
| 231 bool ignoreClip = clip.isWideOpen(clipSpaceRTIBounds); | 231 bool ignoreClip = clip.isWideOpen(clipSpaceRTIBounds); |
| 232 if (!ignoreClip) { | 232 if (!ignoreClip) { |
| 233 // The clip mask manager always draws with a single IRect so we special
case that logic here | 233 // The clip mask manager always draws with a single IRect so we special
case that logic here |
| 234 // Image filters just use a rect, so we also special case that logic | 234 if (GrClip::kIRect_ClipType == clip.clipType()) { |
| 235 switch (clip.clipType()) { | 235 initialState = GrReducedClip::kAllIn_InitialState; |
| 236 case GrClip::kWideOpen_ClipType: | 236 clipSpaceIBounds = clip.irect(); |
| 237 // we should have handled this case above | 237 SkNEW_INSERT_AT_LLIST_HEAD(&elements, |
| 238 SkASSERT(false); | 238 Element, |
| 239 case GrClip::kIRect_ClipType: { | 239 (SkRect::Make(clipSpaceIBounds), |
| 240 initialState = GrReducedClip::kAllIn_InitialState; | 240 SkRegion::kIntersect_Op, false)); |
| 241 clipSpaceIBounds = clip.irect(); | 241 } else { |
| 242 SkNEW_INSERT_AT_LLIST_HEAD(&elements, | 242 clipSpaceRTIBounds.offset(clip.origin()); |
| 243 Element, | 243 GrReducedClip::ReduceClipStack(*clip.clipStack(), |
| 244 (SkRect::Make(clipSpaceIBounds), | 244 clipSpaceRTIBounds, |
| 245 SkRegion::kIntersect_Op, false)); | 245 &elements, |
| 246 } break; | 246 &genID, |
| 247 case GrClip::kRect_ClipType: { | 247 &initialState, |
| 248 initialState = GrReducedClip::kAllIn_InitialState; | 248 &clipSpaceIBounds, |
| 249 clipSpaceIBounds.setLTRB(SkScalarCeilToInt(clip.rect().fLeft), | 249 &requiresAA); |
| 250 SkScalarCeilToInt(clip.rect().fTop), | 250 if (elements.isEmpty()) { |
| 251 SkScalarCeilToInt(clip.rect().fRight), | 251 if (GrReducedClip::kAllIn_InitialState == initialState) { |
| 252 SkScalarCeilToInt(clip.rect().fBottom))
; | 252 ignoreClip = clipSpaceIBounds == clipSpaceRTIBounds; |
| 253 SkNEW_INSERT_AT_LLIST_HEAD(&elements, | 253 } else { |
| 254 Element, | 254 return false; |
| 255 (SkRect::Make(clipSpaceIBounds), | |
| 256 SkRegion::kIntersect_Op, false)); | |
| 257 } break; | |
| 258 case GrClip::kClipStack_ClipType: { | |
| 259 clipSpaceRTIBounds.offset(clip.origin()); | |
| 260 GrReducedClip::ReduceClipStack(*clip.clipStack(), | |
| 261 clipSpaceRTIBounds, | |
| 262 &elements, | |
| 263 &genID, | |
| 264 &initialState, | |
| 265 &clipSpaceIBounds, | |
| 266 &requiresAA); | |
| 267 if (elements.isEmpty()) { | |
| 268 if (GrReducedClip::kAllIn_InitialState == initialState) { | |
| 269 ignoreClip = clipSpaceIBounds == clipSpaceRTIBounds; | |
| 270 } else { | |
| 271 return false; | |
| 272 } | |
| 273 } | 255 } |
| 274 } break; | 256 } |
| 275 } | 257 } |
| 276 } | 258 } |
| 277 | 259 |
| 278 if (ignoreClip) { | 260 if (ignoreClip) { |
| 279 this->setPipelineBuilderStencil(pipelineBuilder, ars); | 261 this->setPipelineBuilderStencil(pipelineBuilder, ars); |
| 280 return true; | 262 return true; |
| 281 } | 263 } |
| 282 | 264 |
| 283 // An element count of 4 was chosen because of the common pattern in Blink o
f: | 265 // An element count of 4 was chosen because of the common pattern in Blink o
f: |
| 284 // isect RR | 266 // isect RR |
| (...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1120 fAACache.setContext(clipTarget->getContext()); | 1102 fAACache.setContext(clipTarget->getContext()); |
| 1121 } | 1103 } |
| 1122 | 1104 |
| 1123 void GrClipMaskManager::adjustPathStencilParams(const GrStencilBuffer* stencilBu
ffer, | 1105 void GrClipMaskManager::adjustPathStencilParams(const GrStencilBuffer* stencilBu
ffer, |
| 1124 GrStencilSettings* settings) { | 1106 GrStencilSettings* settings) { |
| 1125 if (stencilBuffer) { | 1107 if (stencilBuffer) { |
| 1126 int stencilBits = stencilBuffer->bits(); | 1108 int stencilBits = stencilBuffer->bits(); |
| 1127 this->adjustStencilParams(settings, fClipMode, stencilBits); | 1109 this->adjustStencilParams(settings, fClipMode, stencilBits); |
| 1128 } | 1110 } |
| 1129 } | 1111 } |
| OLD | NEW |