| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 return true; | 99 return true; |
| 100 } | 100 } |
| 101 } | 101 } |
| 102 return false; | 102 return false; |
| 103 } | 103 } |
| 104 | 104 |
| 105 //////////////////////////////////////////////////////////////////////////////// | 105 //////////////////////////////////////////////////////////////////////////////// |
| 106 // sort out what kind of clip mask needs to be created: alpha, stencil, | 106 // sort out what kind of clip mask needs to be created: alpha, stencil, |
| 107 // scissor, or entirely software | 107 // scissor, or entirely software |
| 108 bool GrClipMaskManager::setupClipping(const GrClipData* clipDataIn, | 108 bool GrClipMaskManager::setupClipping(const GrClipData* clipDataIn, |
| 109 GrDrawState::AutoRestoreEffects* are) { | 109 GrDrawState::AutoRestoreEffects* are, |
| 110 const SkRect* devBounds) { |
| 110 fCurrClipMaskType = kNone_ClipMaskType; | 111 fCurrClipMaskType = kNone_ClipMaskType; |
| 111 | 112 |
| 112 ElementList elements(16); | 113 ElementList elements(16); |
| 113 int32_t genID; | 114 int32_t genID; |
| 114 InitialState initialState; | 115 InitialState initialState; |
| 115 SkIRect clipSpaceIBounds; | 116 SkIRect clipSpaceIBounds; |
| 116 bool requiresAA; | 117 bool requiresAA; |
| 117 bool isRect = false; | 118 bool isRect = false; |
| 118 | 119 |
| 119 GrDrawState* drawState = fGpu->drawState(); | 120 GrDrawState* drawState = fGpu->drawState(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 143 } | 144 } |
| 144 } | 145 } |
| 145 } | 146 } |
| 146 | 147 |
| 147 if (ignoreClip) { | 148 if (ignoreClip) { |
| 148 fGpu->disableScissor(); | 149 fGpu->disableScissor(); |
| 149 this->setGpuStencil(); | 150 this->setGpuStencil(); |
| 150 return true; | 151 return true; |
| 151 } | 152 } |
| 152 | 153 |
| 153 // If there is only one clip element and it is a convex polygon we just inst
all an effect that | 154 // If there is only one clip element we check whether the draw's bounds are
contained |
| 154 // clips against the edges. | 155 // fully within the clip. If not, we install an effect that handles the clip
for some |
| 156 // cases. |
| 155 if (1 == elements.count() && SkRegion::kReplace_Op == elements.tail()->getOp
()) { | 157 if (1 == elements.count() && SkRegion::kReplace_Op == elements.tail()->getOp
()) { |
| 158 if (NULL != devBounds) { |
| 159 SkRect boundsInClipSpace = *devBounds; |
| 160 boundsInClipSpace.offset(SkIntToScalar(clipDataIn->fOrigin.fX), |
| 161 SkIntToScalar(clipDataIn->fOrigin.fY)); |
| 162 if (elements.tail()->contains(boundsInClipSpace)) { |
| 163 fGpu->disableScissor(); |
| 164 this->setGpuStencil(); |
| 165 return true; |
| 166 } |
| 167 } |
| 156 SkAutoTUnref<GrEffectRef> effect; | 168 SkAutoTUnref<GrEffectRef> effect; |
| 157 if (SkClipStack::Element::kPath_Type == elements.tail()->getType()) { | 169 if (SkClipStack::Element::kPath_Type == elements.tail()->getType()) { |
| 158 const SkPath& path = elements.tail()->getPath(); | 170 const SkPath& path = elements.tail()->getPath(); |
| 159 bool isAA = GR_AA_CLIP && elements.tail()->isAA(); | 171 bool isAA = GR_AA_CLIP && elements.tail()->isAA(); |
| 160 if (rt->isMultisampled()) { | 172 if (rt->isMultisampled()) { |
| 161 // A coverage effect for AA clipping won't play nicely with MSAA
. | 173 // A coverage effect for AA clipping won't play nicely with MSAA
. |
| 162 if (!isAA) { | 174 if (!isAA) { |
| 163 SkVector offset = { SkIntToScalar(-clipDataIn->fOrigin.fX), | 175 SkVector offset = { SkIntToScalar(-clipDataIn->fOrigin.fX), |
| 164 SkIntToScalar(-clipDataIn->fOrigin.fY) }
; | 176 SkIntToScalar(-clipDataIn->fOrigin.fY) }
; |
| 165 effect.reset(GrConvexPolyEffect::Create(GrConvexPolyEffect::
kFillNoAA_EdgeType, | 177 effect.reset(GrConvexPolyEffect::Create(GrConvexPolyEffect::
kFillNoAA_EdgeType, |
| (...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1084 | 1096 |
| 1085 // TODO: dynamically attach a stencil buffer | 1097 // TODO: dynamically attach a stencil buffer |
| 1086 int stencilBits = 0; | 1098 int stencilBits = 0; |
| 1087 GrStencilBuffer* stencilBuffer = | 1099 GrStencilBuffer* stencilBuffer = |
| 1088 drawState.getRenderTarget()->getStencilBuffer(); | 1100 drawState.getRenderTarget()->getStencilBuffer(); |
| 1089 if (NULL != stencilBuffer) { | 1101 if (NULL != stencilBuffer) { |
| 1090 stencilBits = stencilBuffer->bits(); | 1102 stencilBits = stencilBuffer->bits(); |
| 1091 this->adjustStencilParams(settings, clipMode, stencilBits); | 1103 this->adjustStencilParams(settings, clipMode, stencilBits); |
| 1092 } | 1104 } |
| 1093 } | 1105 } |
| OLD | NEW |