| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 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 | 9 |
| 10 #include "GrPathRendererChain.h" | 10 #include "GrPathRendererChain.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 GrPathRenderer* GrPathRendererChain::addPathRenderer(GrPathRenderer* pr) { | 30 GrPathRenderer* GrPathRendererChain::addPathRenderer(GrPathRenderer* pr) { |
| 31 fChain.push_back() = pr; | 31 fChain.push_back() = pr; |
| 32 pr->ref(); | 32 pr->ref(); |
| 33 return pr; | 33 return pr; |
| 34 } | 34 } |
| 35 | 35 |
| 36 GrPathRenderer* GrPathRendererChain::getPathRenderer(const SkPath& path, | 36 GrPathRenderer* GrPathRendererChain::getPathRenderer(const SkPath& path, |
| 37 const SkStrokeRec& stroke, | 37 const SkStrokeRec& stroke, |
| 38 const GrDrawTarget* target, | 38 const GrDrawTarget* target, |
| 39 DrawType drawType, | 39 DrawType drawType, |
| 40 SkPath::FillType fillType, |
| 40 StencilSupport* stencilSupp
ort) { | 41 StencilSupport* stencilSupp
ort) { |
| 41 if (!fInit) { | 42 if (!fInit) { |
| 42 this->init(); | 43 this->init(); |
| 43 } | 44 } |
| 44 bool antiAlias = (kColorAntiAlias_DrawType == drawType || | 45 bool antiAlias = (kColorAntiAlias_DrawType == drawType || |
| 45 kStencilAndColorAntiAlias_DrawType == drawType); | 46 kStencilAndColorAntiAlias_DrawType == drawType); |
| 46 | 47 |
| 47 GR_STATIC_ASSERT(GrPathRenderer::kNoSupport_StencilSupport < | 48 GR_STATIC_ASSERT(GrPathRenderer::kNoSupport_StencilSupport < |
| 48 GrPathRenderer::kStencilOnly_StencilSupport); | 49 GrPathRenderer::kStencilOnly_StencilSupport); |
| 49 GR_STATIC_ASSERT(GrPathRenderer::kStencilOnly_StencilSupport < | 50 GR_STATIC_ASSERT(GrPathRenderer::kStencilOnly_StencilSupport < |
| 50 GrPathRenderer::kNoRestriction_StencilSupport); | 51 GrPathRenderer::kNoRestriction_StencilSupport); |
| 51 GrPathRenderer::StencilSupport minStencilSupport; | 52 GrPathRenderer::StencilSupport minStencilSupport; |
| 52 if (kStencilOnly_DrawType == drawType) { | 53 if (kStencilOnly_DrawType == drawType) { |
| 53 minStencilSupport = GrPathRenderer::kStencilOnly_StencilSupport; | 54 minStencilSupport = GrPathRenderer::kStencilOnly_StencilSupport; |
| 54 } else if (kStencilAndColor_DrawType == drawType || | 55 } else if (kStencilAndColor_DrawType == drawType || |
| 55 kStencilAndColorAntiAlias_DrawType == drawType) { | 56 kStencilAndColorAntiAlias_DrawType == drawType) { |
| 56 minStencilSupport = GrPathRenderer::kNoRestriction_StencilSupport; | 57 minStencilSupport = GrPathRenderer::kNoRestriction_StencilSupport; |
| 57 } else { | 58 } else { |
| 58 minStencilSupport = GrPathRenderer::kNoSupport_StencilSupport; | 59 minStencilSupport = GrPathRenderer::kNoSupport_StencilSupport; |
| 59 } | 60 } |
| 60 | 61 |
| 61 | 62 |
| 62 for (int i = 0; i < fChain.count(); ++i) { | 63 for (int i = 0; i < fChain.count(); ++i) { |
| 63 if (fChain[i]->canDrawPath(path, stroke, target, antiAlias)) { | 64 fChain[i]->setPath(path, fillType); |
| 65 if (fChain[i]->canDrawPath(stroke, target, antiAlias)) { |
| 64 if (GrPathRenderer::kNoSupport_StencilSupport != minStencilSupport)
{ | 66 if (GrPathRenderer::kNoSupport_StencilSupport != minStencilSupport)
{ |
| 65 GrPathRenderer::StencilSupport support = fChain[i]->getStencilSu
pport(path, | 67 GrPathRenderer::StencilSupport support = fChain[i]->getStencilSu
pport(stroke, |
| 66
stroke, | |
| 67
target); | 68
target); |
| 68 if (support < minStencilSupport) { | 69 if (support < minStencilSupport) { |
| 69 continue; | 70 continue; |
| 70 } else if (NULL != stencilSupport) { | 71 } else if (NULL != stencilSupport) { |
| 71 *stencilSupport = support; | 72 *stencilSupport = support; |
| 72 } | 73 } |
| 73 } | 74 } |
| 74 return fChain[i]; | 75 return fChain[i]; |
| 75 } | 76 } |
| 76 } | 77 } |
| 77 return NULL; | 78 return NULL; |
| 78 } | 79 } |
| 79 | 80 |
| 80 void GrPathRendererChain::init() { | 81 void GrPathRendererChain::init() { |
| 81 SkASSERT(!fInit); | 82 SkASSERT(!fInit); |
| 82 GrGpu* gpu = fOwner->getGpu(); | 83 GrGpu* gpu = fOwner->getGpu(); |
| 83 bool twoSided = gpu->caps()->twoSidedStencilSupport(); | 84 bool twoSided = gpu->caps()->twoSidedStencilSupport(); |
| 84 bool wrapOp = gpu->caps()->stencilWrapOpsSupport(); | 85 bool wrapOp = gpu->caps()->stencilWrapOpsSupport(); |
| 85 GrPathRenderer::AddPathRenderers(fOwner, this); | 86 GrPathRenderer::AddPathRenderers(fOwner, this); |
| 86 this->addPathRenderer(SkNEW_ARGS(GrDefaultPathRenderer, | 87 this->addPathRenderer(SkNEW_ARGS(GrDefaultPathRenderer, |
| 87 (twoSided, wrapOp)))->unref(); | 88 (twoSided, wrapOp)))->unref(); |
| 88 fInit = true; | 89 fInit = true; |
| 89 } | 90 } |
| OLD | NEW |