| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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() && SkClipStack::Element::kPath_Type == elements.ta
il()->getType() && |
| 160 SkRegion::kReplace_Op == elements.tail()->getOp()) { | 160 SkRegion::kReplace_Op == elements.tail()->getOp()) { |
| 161 const SkPath& p = elements.tail()->getPath(); | 161 const SkPath& path = elements.tail()->getPath(); |
| 162 bool isAA = GR_AA_CLIP && elements.tail()->isAA(); | 162 bool isAA = GR_AA_CLIP && elements.tail()->isAA(); |
| 163 SkAutoTUnref<GrEffectRef> effect; | 163 SkAutoTUnref<GrEffectRef> effect; |
| 164 if (rt->isMultisampled()) { | 164 if (rt->isMultisampled()) { |
| 165 // A coverage effect for AA clipping won't play nicely with MSAA. | 165 // A coverage effect for AA clipping won't play nicely with MSAA. |
| 166 if (!isAA) { | 166 if (!isAA) { |
| 167 effect.reset(GrConvexPolyEffect::Create(GrConvexPolyEffect::kFil
lNoAA_EdgeType, p)); | 167 SkVector offset = { SkIntToScalar(-clipDataIn->fOrigin.fX), |
| 168 SkIntToScalar(-clipDataIn->fOrigin.fY) }; |
| 169 effect.reset(GrConvexPolyEffect::Create(GrConvexPolyEffect::kFil
lNoAA_EdgeType, |
| 170 path, &offset)); |
| 168 } | 171 } |
| 169 } else { | 172 } else { |
| 173 SkVector offset = { SkIntToScalar(-clipDataIn->fOrigin.fX), |
| 174 SkIntToScalar(-clipDataIn->fOrigin.fY) }; |
| 170 GrConvexPolyEffect::EdgeType type = isAA ? GrConvexPolyEffect::kFill
AA_EdgeType : | 175 GrConvexPolyEffect::EdgeType type = isAA ? GrConvexPolyEffect::kFill
AA_EdgeType : |
| 171 GrConvexPolyEffect::kFill
NoAA_EdgeType; | 176 GrConvexPolyEffect::kFill
NoAA_EdgeType; |
| 172 effect.reset(GrConvexPolyEffect::Create(type, p)); | 177 effect.reset(GrConvexPolyEffect::Create(type, path, &offset)); |
| 173 } | 178 } |
| 174 if (effect) { | 179 if (effect) { |
| 175 are->set(fGpu->drawState()); | 180 are->set(fGpu->drawState()); |
| 176 fGpu->drawState()->addCoverageEffect(effect); | 181 fGpu->drawState()->addCoverageEffect(effect); |
| 177 SkIRect scissorSpaceIBounds(clipSpaceIBounds); | 182 SkIRect scissorSpaceIBounds(clipSpaceIBounds); |
| 178 scissorSpaceIBounds.offset(-clipDataIn->fOrigin); | 183 scissorSpaceIBounds.offset(-clipDataIn->fOrigin); |
| 179 fGpu->enableScissor(scissorSpaceIBounds); | 184 fGpu->enableScissor(scissorSpaceIBounds); |
| 180 this->setGpuStencil(); | 185 this->setGpuStencil(); |
| 181 return true; | 186 return true; |
| 182 } | 187 } |
| (...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1062 | 1067 |
| 1063 // TODO: dynamically attach a stencil buffer | 1068 // TODO: dynamically attach a stencil buffer |
| 1064 int stencilBits = 0; | 1069 int stencilBits = 0; |
| 1065 GrStencilBuffer* stencilBuffer = | 1070 GrStencilBuffer* stencilBuffer = |
| 1066 drawState.getRenderTarget()->getStencilBuffer(); | 1071 drawState.getRenderTarget()->getStencilBuffer(); |
| 1067 if (NULL != stencilBuffer) { | 1072 if (NULL != stencilBuffer) { |
| 1068 stencilBits = stencilBuffer->bits(); | 1073 stencilBits = stencilBuffer->bits(); |
| 1069 this->adjustStencilParams(settings, clipMode, stencilBits); | 1074 this->adjustStencilParams(settings, clipMode, stencilBits); |
| 1070 } | 1075 } |
| 1071 } | 1076 } |
| OLD | NEW |