| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 } | 149 } |
| 150 | 150 |
| 151 if (ignoreClip) { | 151 if (ignoreClip) { |
| 152 fGpu->disableScissor(); | 152 fGpu->disableScissor(); |
| 153 this->setGpuStencil(); | 153 this->setGpuStencil(); |
| 154 return true; | 154 return true; |
| 155 } | 155 } |
| 156 | 156 |
| 157 // If there is only one clip element and it is a convex polygon we just inst
all an effect that | 157 // If there is only one clip element and it is a convex polygon we just inst
all an effect that |
| 158 // clips against the edges. | 158 // clips against the edges. |
| 159 if (1 == elements.count() && SkClipStack::Element::kPath_Type == elements.ta
il()->getType() && | 159 if (1 == elements.count() && SkRegion::kReplace_Op == elements.tail()->getOp
()) { |
| 160 SkRegion::kReplace_Op == elements.tail()->getOp()) { | |
| 161 const SkPath& path = elements.tail()->getPath(); | |
| 162 bool isAA = GR_AA_CLIP && elements.tail()->isAA(); | |
| 163 SkAutoTUnref<GrEffectRef> effect; | 160 SkAutoTUnref<GrEffectRef> effect; |
| 164 if (rt->isMultisampled()) { | 161 if (SkClipStack::Element::kPath_Type == elements.tail()->getType()) { |
| 165 // A coverage effect for AA clipping won't play nicely with MSAA. | 162 const SkPath& path = elements.tail()->getPath(); |
| 166 if (!isAA) { | 163 bool isAA = GR_AA_CLIP && elements.tail()->isAA(); |
| 164 if (rt->isMultisampled()) { |
| 165 // A coverage effect for AA clipping won't play nicely with MSAA
. |
| 166 if (!isAA) { |
| 167 SkVector offset = { SkIntToScalar(-clipDataIn->fOrigin.fX), |
| 168 SkIntToScalar(-clipDataIn->fOrigin.fY) }
; |
| 169 effect.reset(GrConvexPolyEffect::Create(GrConvexPolyEffect::
kFillNoAA_EdgeType, |
| 170 path, &offset)); |
| 171 } |
| 172 } else { |
| 167 SkVector offset = { SkIntToScalar(-clipDataIn->fOrigin.fX), | 173 SkVector offset = { SkIntToScalar(-clipDataIn->fOrigin.fX), |
| 168 SkIntToScalar(-clipDataIn->fOrigin.fY) }; | 174 SkIntToScalar(-clipDataIn->fOrigin.fY) }; |
| 169 effect.reset(GrConvexPolyEffect::Create(GrConvexPolyEffect::kFil
lNoAA_EdgeType, | 175 GrConvexPolyEffect::EdgeType type = isAA ? GrConvexPolyEffect::k
FillAA_EdgeType : |
| 170 path, &offset)); | 176 GrConvexPolyEffect::k
FillNoAA_EdgeType; |
| 177 effect.reset(GrConvexPolyEffect::Create(type, path, &offset)); |
| 171 } | 178 } |
| 172 } else { | 179 } else if (GR_AA_CLIP && elements.tail()->isAA() && !rt->isMultisampled(
)) { |
| 180 // We only handle AA/non-MSAA rects here. Coverage effect AA isn't M
SAA friendly and |
| 181 // non-AA rect clips are handled by the scissor. |
| 182 SkASSERT(SkClipStack::Element::kRect_Type == elements.tail()->getTyp
e()); |
| 183 SkRect rect = elements.tail()->getRect(); |
| 173 SkVector offset = { SkIntToScalar(-clipDataIn->fOrigin.fX), | 184 SkVector offset = { SkIntToScalar(-clipDataIn->fOrigin.fX), |
| 174 SkIntToScalar(-clipDataIn->fOrigin.fY) }; | 185 SkIntToScalar(-clipDataIn->fOrigin.fY) }; |
| 175 GrConvexPolyEffect::EdgeType type = isAA ? GrConvexPolyEffect::kFill
AA_EdgeType : | 186 rect.offset(offset); |
| 176 GrConvexPolyEffect::kFill
NoAA_EdgeType; | 187 effect.reset(GrConvexPolyEffect::CreateForAAFillRect(rect)); |
| 177 effect.reset(GrConvexPolyEffect::Create(type, path, &offset)); | 188 // This should never fail. |
| 189 SkASSERT(effect); |
| 178 } | 190 } |
| 179 if (effect) { | 191 if (effect) { |
| 180 are->set(fGpu->drawState()); | 192 are->set(fGpu->drawState()); |
| 181 fGpu->drawState()->addCoverageEffect(effect); | 193 fGpu->drawState()->addCoverageEffect(effect); |
| 182 SkIRect scissorSpaceIBounds(clipSpaceIBounds); | 194 SkIRect scissorSpaceIBounds(clipSpaceIBounds); |
| 183 scissorSpaceIBounds.offset(-clipDataIn->fOrigin); | 195 scissorSpaceIBounds.offset(-clipDataIn->fOrigin); |
| 184 fGpu->enableScissor(scissorSpaceIBounds); | 196 fGpu->enableScissor(scissorSpaceIBounds); |
| 185 this->setGpuStencil(); | 197 this->setGpuStencil(); |
| 186 return true; | 198 return true; |
| 187 } | 199 } |
| (...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1067 | 1079 |
| 1068 // TODO: dynamically attach a stencil buffer | 1080 // TODO: dynamically attach a stencil buffer |
| 1069 int stencilBits = 0; | 1081 int stencilBits = 0; |
| 1070 GrStencilBuffer* stencilBuffer = | 1082 GrStencilBuffer* stencilBuffer = |
| 1071 drawState.getRenderTarget()->getStencilBuffer(); | 1083 drawState.getRenderTarget()->getStencilBuffer(); |
| 1072 if (NULL != stencilBuffer) { | 1084 if (NULL != stencilBuffer) { |
| 1073 stencilBits = stencilBuffer->bits(); | 1085 stencilBits = stencilBuffer->bits(); |
| 1074 this->adjustStencilParams(settings, clipMode, stencilBits); | 1086 this->adjustStencilParams(settings, clipMode, stencilBits); |
| 1075 } | 1087 } |
| 1076 } | 1088 } |
| OLD | NEW |