| 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 if (iter.get()->isAA()) { | 158 if (iter.get()->isAA()) { |
| 159 if (rt->isMultisampled()) { | 159 if (rt->isMultisampled()) { |
| 160 // Coverage based AA clips don't place nicely with MSAA. | 160 // Coverage based AA clips don't place nicely with MSAA. |
| 161 failed = true; | 161 failed = true; |
| 162 break; | 162 break; |
| 163 } | 163 } |
| 164 edgeType = | 164 edgeType = |
| 165 invert ? kInverseFillAA_GrProcessorEdgeType : kFillAA_Gr
ProcessorEdgeType; | 165 invert ? kInverseFillAA_GrProcessorEdgeType : kFillAA_Gr
ProcessorEdgeType; |
| 166 } else { | 166 } else { |
| 167 edgeType = | 167 edgeType = |
| 168 invert ? kInverseFillBW_GrProcessorEdgeType : kFillBW_Gr
ProcessorEdgeType; | 168 invert ? kInverseFillBW_GrProcessorEdgeType : kFillBW_GrProcessorEdgeType; |
| 169 } | 169 } |
| 170 SkAutoTUnref<GrFragmentProcessor> fp; | 170 SkAutoTUnref<GrFragmentProcessor> fp; |
| 171 switch (iter.get()->getType()) { | 171 switch (iter.get()->getType()) { |
| 172 case SkClipStack::Element::kPath_Type: | 172 case SkClipStack::Element::kPath_Type: |
| 173 fp.reset(GrConvexPolyEffect::Create(edgeType, iter.get()->ge
tPath(), | 173 fp.reset(GrConvexPolyEffect::Create(edgeType, iter.get()->ge
tPath(), |
| 174 &clipToRTOffset)); | 174 &clipToRTOffset)); |
| 175 break; | 175 break; |
| 176 case SkClipStack::Element::kRRect_Type: { | 176 case SkClipStack::Element::kRRect_Type: { |
| 177 SkRRect rrect = iter.get()->getRRect(); | 177 SkRRect rrect = iter.get()->getRRect(); |
| 178 rrect.offset(clipToRTOffset.fX, clipToRTOffset.fY); | 178 rrect.offset(clipToRTOffset.fX, clipToRTOffset.fY); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 GrReducedClip::InitialState initialState = GrReducedClip::kAllIn_InitialStat
e; | 222 GrReducedClip::InitialState initialState = GrReducedClip::kAllIn_InitialStat
e; |
| 223 SkIRect clipSpaceIBounds; | 223 SkIRect clipSpaceIBounds; |
| 224 bool requiresAA = false; | 224 bool requiresAA = false; |
| 225 GrRenderTarget* rt = pipelineBuilder->getRenderTarget(); | 225 GrRenderTarget* rt = pipelineBuilder->getRenderTarget(); |
| 226 | 226 |
| 227 // GrDrawTarget should have filtered this for us | 227 // GrDrawTarget should have filtered this for us |
| 228 SkASSERT(rt); | 228 SkASSERT(rt); |
| 229 | 229 |
| 230 SkIRect clipSpaceRTIBounds = SkIRect::MakeWH(rt->width(), rt->height()); | 230 SkIRect clipSpaceRTIBounds = SkIRect::MakeWH(rt->width(), rt->height()); |
| 231 const GrClip& clip = pipelineBuilder->clip(); | 231 const GrClip& clip = pipelineBuilder->clip(); |
| 232 // TODO we shouldn't be ignoring the clip mask manager's clip. This is temp
orary. | 232 if (clip.isWideOpen(clipSpaceRTIBounds)) { |
| 233 bool ignoreClip = clip.isWideOpen(clipSpaceRTIBounds); | 233 this->setPipelineBuilderStencil(pipelineBuilder, ars); |
| 234 if (!ignoreClip) { | 234 return true; |
| 235 // The clip mask manager always draws with a single IRect so we special
case that logic here | |
| 236 // Image filters just use a rect, so we also special case that logic | |
| 237 switch (clip.clipType()) { | |
| 238 case GrClip::kWideOpen_ClipType: | |
| 239 // we should have handled this case above | |
| 240 SkASSERT(false); | |
| 241 case GrClip::kIRect_ClipType: { | |
| 242 clipSpaceIBounds = clip.irect(); | |
| 243 SkNEW_INSERT_AT_LLIST_HEAD(&elements, | |
| 244 Element, | |
| 245 (SkRect::Make(clipSpaceIBounds), | |
| 246 SkRegion::kIntersect_Op, false)); | |
| 247 } break; | |
| 248 case GrClip::kRect_ClipType: { | |
| 249 clipSpaceIBounds.setLTRB(SkScalarCeilToInt(clip.rect().fLeft), | |
| 250 SkScalarCeilToInt(clip.rect().fTop), | |
| 251 SkScalarCeilToInt(clip.rect().fRight), | |
| 252 SkScalarCeilToInt(clip.rect().fBottom))
; | |
| 253 SkNEW_INSERT_AT_LLIST_HEAD(&elements, | |
| 254 Element, | |
| 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 } | |
| 274 } break; | |
| 275 } | |
| 276 } | 235 } |
| 277 | 236 |
| 278 if (ignoreClip) { | 237 // The clip mask manager always draws with a single IRect so we special case
that logic here |
| 279 this->setPipelineBuilderStencil(pipelineBuilder, ars); | 238 // Image filters just use a rect, so we also special case that logic |
| 280 return true; | 239 switch (clip.clipType()) { |
| 240 case GrClip::kWideOpen_ClipType: |
| 241 SkFAIL("Should have caught this with clip.isWideOpen()"); |
| 242 return true; |
| 243 case GrClip::kIRect_ClipType: |
| 244 scissorState->set(clip.irect()); |
| 245 this->setPipelineBuilderStencil(pipelineBuilder, ars); |
| 246 return true; |
| 247 case GrClip::kRect_ClipType: { |
| 248 const SkRect& rect = clip.rect(); |
| 249 SkIRect scissor; |
| 250 scissor.fLeft = SkScalarRoundToInt(rect.fLeft); |
| 251 scissor.fTop = SkScalarRoundToInt(rect.fTop); |
| 252 scissor.fRight = SkScalarRoundToInt(rect.fRight); |
| 253 scissor.fBottom = SkScalarRoundToInt(rect.fBottom); |
| 254 scissorState->set(scissor); |
| 255 this->setPipelineBuilderStencil(pipelineBuilder, ars); |
| 256 } return true; |
| 257 case GrClip::kClipStack_ClipType: { |
| 258 clipSpaceRTIBounds.offset(clip.origin()); |
| 259 GrReducedClip::ReduceClipStack(*clip.clipStack(), |
| 260 clipSpaceRTIBounds, |
| 261 &elements, |
| 262 &genID, |
| 263 &initialState, |
| 264 &clipSpaceIBounds, |
| 265 &requiresAA); |
| 266 if (elements.isEmpty()) { |
| 267 if (GrReducedClip::kAllIn_InitialState == initialState) { |
| 268 if (clipSpaceIBounds == clipSpaceRTIBounds) { |
| 269 this->setPipelineBuilderStencil(pipelineBuilder, ars); |
| 270 return true; |
| 271 } |
| 272 } else { |
| 273 return false; |
| 274 } |
| 275 } |
| 276 } break; |
| 281 } | 277 } |
| 282 | 278 |
| 283 // An element count of 4 was chosen because of the common pattern in Blink o
f: | 279 // An element count of 4 was chosen because of the common pattern in Blink o
f: |
| 284 // isect RR | 280 // isect RR |
| 285 // diff RR | 281 // diff RR |
| 286 // isect convex_poly | 282 // isect convex_poly |
| 287 // isect convex_poly | 283 // isect convex_poly |
| 288 // when drawing rounded div borders. This could probably be tuned based on a | 284 // when drawing rounded div borders. This could probably be tuned based on a |
| 289 // configuration's relative costs of switching RTs to generate a mask vs | 285 // configuration's relative costs of switching RTs to generate a mask vs |
| 290 // longer shaders. | 286 // longer shaders. |
| (...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1122 fAACache.setContext(clipTarget->getContext()); | 1118 fAACache.setContext(clipTarget->getContext()); |
| 1123 } | 1119 } |
| 1124 | 1120 |
| 1125 void GrClipMaskManager::adjustPathStencilParams(const GrStencilBuffer* stencilBu
ffer, | 1121 void GrClipMaskManager::adjustPathStencilParams(const GrStencilBuffer* stencilBu
ffer, |
| 1126 GrStencilSettings* settings) { | 1122 GrStencilSettings* settings) { |
| 1127 if (stencilBuffer) { | 1123 if (stencilBuffer) { |
| 1128 int stencilBits = stencilBuffer->bits(); | 1124 int stencilBits = stencilBuffer->bits(); |
| 1129 this->adjustStencilParams(settings, fClipMode, stencilBits); | 1125 this->adjustStencilParams(settings, fClipMode, stencilBits); |
| 1130 } | 1126 } |
| 1131 } | 1127 } |
| OLD | NEW |