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