| 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 21 matching lines...) Expand all Loading... |
| 32 fChain[i]->unref(); | 32 fChain[i]->unref(); |
| 33 } | 33 } |
| 34 } | 34 } |
| 35 | 35 |
| 36 GrPathRenderer* GrPathRendererChain::addPathRenderer(GrPathRenderer* pr) { | 36 GrPathRenderer* GrPathRendererChain::addPathRenderer(GrPathRenderer* pr) { |
| 37 fChain.push_back() = pr; | 37 fChain.push_back() = pr; |
| 38 pr->ref(); | 38 pr->ref(); |
| 39 return pr; | 39 return pr; |
| 40 } | 40 } |
| 41 | 41 |
| 42 GrPathRenderer* GrPathRendererChain::getPathRenderer(const GrShaderCaps* shaderC
aps, | 42 GrPathRenderer* GrPathRendererChain::getPathRenderer(const GrPathRenderer::CanDr
awPathArgs& args, |
| 43 const GrPipelineBuilder& pi
pelineBuilder, | |
| 44 const SkMatrix& viewMatrix, | |
| 45 const SkPath& path, | |
| 46 const GrStrokeInfo& stroke, | |
| 47 DrawType drawType, | 43 DrawType drawType, |
| 48 StencilSupport* stencilSupp
ort) { | 44 GrPathRenderer::StencilSupp
ort* stencilSupport) { |
| 49 if (!fInit) { | 45 if (!fInit) { |
| 50 this->init(); | 46 this->init(); |
| 51 } | 47 } |
| 52 bool antiAlias = (kColorAntiAlias_DrawType == drawType || | |
| 53 kStencilAndColorAntiAlias_DrawType == drawType); | |
| 54 | 48 |
| 55 GR_STATIC_ASSERT(GrPathRenderer::kNoSupport_StencilSupport < | 49 GR_STATIC_ASSERT(GrPathRenderer::kNoSupport_StencilSupport < |
| 56 GrPathRenderer::kStencilOnly_StencilSupport); | 50 GrPathRenderer::kStencilOnly_StencilSupport); |
| 57 GR_STATIC_ASSERT(GrPathRenderer::kStencilOnly_StencilSupport < | 51 GR_STATIC_ASSERT(GrPathRenderer::kStencilOnly_StencilSupport < |
| 58 GrPathRenderer::kNoRestriction_StencilSupport); | 52 GrPathRenderer::kNoRestriction_StencilSupport); |
| 59 GrPathRenderer::StencilSupport minStencilSupport; | 53 GrPathRenderer::StencilSupport minStencilSupport; |
| 60 if (kStencilOnly_DrawType == drawType) { | 54 if (kStencilOnly_DrawType == drawType) { |
| 61 minStencilSupport = GrPathRenderer::kStencilOnly_StencilSupport; | 55 minStencilSupport = GrPathRenderer::kStencilOnly_StencilSupport; |
| 62 } else if (kStencilAndColor_DrawType == drawType || | 56 } else if (kStencilAndColor_DrawType == drawType || |
| 63 kStencilAndColorAntiAlias_DrawType == drawType) { | 57 kStencilAndColorAntiAlias_DrawType == drawType) { |
| 64 minStencilSupport = GrPathRenderer::kNoRestriction_StencilSupport; | 58 minStencilSupport = GrPathRenderer::kNoRestriction_StencilSupport; |
| 65 } else { | 59 } else { |
| 66 minStencilSupport = GrPathRenderer::kNoSupport_StencilSupport; | 60 minStencilSupport = GrPathRenderer::kNoSupport_StencilSupport; |
| 67 } | 61 } |
| 68 | 62 |
| 69 | 63 |
| 70 for (int i = 0; i < fChain.count(); ++i) { | 64 for (int i = 0; i < fChain.count(); ++i) { |
| 71 GrPathRenderer::CanDrawPathArgs args; | |
| 72 args.fShaderCaps = shaderCaps; | |
| 73 args.fPipelineBuilder = &pipelineBuilder; | |
| 74 args.fViewMatrix = &viewMatrix; | |
| 75 args.fPath = &path; | |
| 76 args.fStroke = &stroke; | |
| 77 args.fAntiAlias = antiAlias; | |
| 78 if (fChain[i]->canDrawPath(args)) { | 65 if (fChain[i]->canDrawPath(args)) { |
| 79 if (GrPathRenderer::kNoSupport_StencilSupport != minStencilSupport)
{ | 66 if (GrPathRenderer::kNoSupport_StencilSupport != minStencilSupport)
{ |
| 80 GrPathRenderer::StencilSupport support = | 67 GrPathRenderer::StencilSupport support = |
| 81 fChain[i]->getStencilSupp
ort(path, stroke); | 68 fChain[i]->getStencilSupport(*args.fPath
, *args.fStroke); |
| 82 if (support < minStencilSupport) { | 69 if (support < minStencilSupport) { |
| 83 continue; | 70 continue; |
| 84 } else if (stencilSupport) { | 71 } else if (stencilSupport) { |
| 85 *stencilSupport = support; | 72 *stencilSupport = support; |
| 86 } | 73 } |
| 87 } | 74 } |
| 88 return fChain[i]; | 75 return fChain[i]; |
| 89 } | 76 } |
| 90 } | 77 } |
| 91 return nullptr; | 78 return nullptr; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 102 } | 89 } |
| 103 this->addPathRenderer(new GrTessellatingPathRenderer)->unref(); | 90 this->addPathRenderer(new GrTessellatingPathRenderer)->unref(); |
| 104 this->addPathRenderer(new GrAAHairLinePathRenderer)->unref(); | 91 this->addPathRenderer(new GrAAHairLinePathRenderer)->unref(); |
| 105 this->addPathRenderer(new GrAAConvexPathRenderer)->unref(); | 92 this->addPathRenderer(new GrAAConvexPathRenderer)->unref(); |
| 106 this->addPathRenderer(new GrAALinearizingConvexPathRenderer)->unref(); | 93 this->addPathRenderer(new GrAALinearizingConvexPathRenderer)->unref(); |
| 107 this->addPathRenderer(new GrAADistanceFieldPathRenderer)->unref(); | 94 this->addPathRenderer(new GrAADistanceFieldPathRenderer)->unref(); |
| 108 this->addPathRenderer(new GrDefaultPathRenderer(caps.twoSidedStencilSupport(
), | 95 this->addPathRenderer(new GrDefaultPathRenderer(caps.twoSidedStencilSupport(
), |
| 109 caps.stencilWrapOpsSupport()
))->unref(); | 96 caps.stencilWrapOpsSupport()
))->unref(); |
| 110 fInit = true; | 97 fInit = true; |
| 111 } | 98 } |
| OLD | NEW |