| 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 Element::Type type = elements.tail()->getType(); | 173 Element::Type type = elements.tail()->getType(); |
| 174 bool isAA = GR_AA_CLIP && elements.tail()->isAA(); | 174 bool isAA = GR_AA_CLIP && elements.tail()->isAA(); |
| 175 SkAutoTUnref<GrEffectRef> effect; | 175 SkAutoTUnref<GrEffectRef> effect; |
| 176 if (SkClipStack::Element::kPath_Type == type) { | 176 if (SkClipStack::Element::kPath_Type == type) { |
| 177 const SkPath& path = elements.tail()->getPath(); | 177 const SkPath& path = elements.tail()->getPath(); |
| 178 if (rt->isMultisampled()) { | 178 if (rt->isMultisampled()) { |
| 179 // A coverage effect for AA clipping won't play nicely with MSAA
. | 179 // A coverage effect for AA clipping won't play nicely with MSAA
. |
| 180 if (!isAA) { | 180 if (!isAA) { |
| 181 SkVector offset = { SkIntToScalar(-clipDataIn->fOrigin.fX), | 181 SkVector offset = { SkIntToScalar(-clipDataIn->fOrigin.fX), |
| 182 SkIntToScalar(-clipDataIn->fOrigin.fY) }
; | 182 SkIntToScalar(-clipDataIn->fOrigin.fY) }
; |
| 183 effect.reset(GrConvexPolyEffect::Create(GrConvexPolyEffect::
kFillNoAA_EdgeType, | 183 effect.reset(GrConvexPolyEffect::Create(kFillBW_GrEffectEdge
Type, |
| 184 path, &offset)); | 184 path, &offset)); |
| 185 } | 185 } |
| 186 } else { | 186 } else { |
| 187 SkVector offset = { SkIntToScalar(-clipDataIn->fOrigin.fX), | 187 SkVector offset = { SkIntToScalar(-clipDataIn->fOrigin.fX), |
| 188 SkIntToScalar(-clipDataIn->fOrigin.fY) }; | 188 SkIntToScalar(-clipDataIn->fOrigin.fY) }; |
| 189 GrConvexPolyEffect::EdgeType type = isAA ? GrConvexPolyEffect::k
FillAA_EdgeType : | 189 GrEffectEdgeType type = isAA ? kFillAA_GrEffectEdgeType : kFillB
W_GrEffectEdgeType; |
| 190 GrConvexPolyEffect::k
FillNoAA_EdgeType; | |
| 191 effect.reset(GrConvexPolyEffect::Create(type, path, &offset)); | 190 effect.reset(GrConvexPolyEffect::Create(type, path, &offset)); |
| 192 } | 191 } |
| 193 } else if (isAA && SkClipStack::Element::kRRect_Type == type && !rt->isM
ultisampled()) { | 192 } else if (isAA && SkClipStack::Element::kRRect_Type == type && !rt->isM
ultisampled()) { |
| 194 const SkRRect& rrect = elements.tail()->getRRect(); | 193 const SkRRect& rrect = elements.tail()->getRRect(); |
| 195 effect.reset(GrRRectEffect::Create(GrRRectEffect::kFillAA_EdgeType,
rrect)); | 194 effect.reset(GrRRectEffect::Create(kFillAA_GrEffectEdgeType, rrect))
; |
| 196 } else if (isAA && SkClipStack::Element::kRect_Type == type && !rt->isMu
ltisampled()) { | 195 } else if (isAA && SkClipStack::Element::kRect_Type == type && !rt->isMu
ltisampled()) { |
| 197 // We only handle AA/non-MSAA rects here. Coverage effect AA isn't M
SAA friendly and | 196 // We only handle AA/non-MSAA rects here. Coverage effect AA isn't M
SAA friendly and |
| 198 // non-AA rect clips are handled by the scissor. | 197 // non-AA rect clips are handled by the scissor. |
| 199 SkRect rect = elements.tail()->getRect(); | 198 SkRect rect = elements.tail()->getRect(); |
| 200 SkVector offset = { SkIntToScalar(-clipDataIn->fOrigin.fX), | 199 SkVector offset = { SkIntToScalar(-clipDataIn->fOrigin.fX), |
| 201 SkIntToScalar(-clipDataIn->fOrigin.fY) }; | 200 SkIntToScalar(-clipDataIn->fOrigin.fY) }; |
| 202 rect.offset(offset); | 201 rect.offset(offset); |
| 203 effect.reset(GrConvexPolyEffect::Create(GrConvexPolyEffect::kFillAA_
EdgeType, rect)); | 202 effect.reset(GrConvexPolyEffect::Create(kFillAA_GrEffectEdgeType, re
ct)); |
| 204 // This should never fail. | 203 // This should never fail. |
| 205 SkASSERT(effect); | 204 SkASSERT(effect); |
| 206 } | 205 } |
| 207 if (effect) { | 206 if (effect) { |
| 208 are->set(fGpu->drawState()); | 207 are->set(fGpu->drawState()); |
| 209 fGpu->drawState()->addCoverageEffect(effect); | 208 fGpu->drawState()->addCoverageEffect(effect); |
| 210 SkIRect scissorSpaceIBounds(clipSpaceIBounds); | 209 SkIRect scissorSpaceIBounds(clipSpaceIBounds); |
| 211 scissorSpaceIBounds.offset(-clipDataIn->fOrigin); | 210 scissorSpaceIBounds.offset(-clipDataIn->fOrigin); |
| 212 fGpu->enableScissor(scissorSpaceIBounds); | 211 fGpu->enableScissor(scissorSpaceIBounds); |
| 213 this->setGpuStencil(); | 212 this->setGpuStencil(); |
| (...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 | 1076 |
| 1078 // TODO: dynamically attach a stencil buffer | 1077 // TODO: dynamically attach a stencil buffer |
| 1079 int stencilBits = 0; | 1078 int stencilBits = 0; |
| 1080 GrStencilBuffer* stencilBuffer = | 1079 GrStencilBuffer* stencilBuffer = |
| 1081 drawState.getRenderTarget()->getStencilBuffer(); | 1080 drawState.getRenderTarget()->getStencilBuffer(); |
| 1082 if (NULL != stencilBuffer) { | 1081 if (NULL != stencilBuffer) { |
| 1083 stencilBits = stencilBuffer->bits(); | 1082 stencilBits = stencilBuffer->bits(); |
| 1084 this->adjustStencilParams(settings, clipMode, stencilBits); | 1083 this->adjustStencilParams(settings, clipMode, stencilBits); |
| 1085 } | 1084 } |
| 1086 } | 1085 } |
| OLD | NEW |