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 22 matching lines...) Expand all Loading... |
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 GrShaderCaps* shaderC
aps, |
43 const GrPipelineBuilder* pi
pelineBuilder, | 43 const GrPipelineBuilder& pi
pelineBuilder, |
44 const SkMatrix& viewMatrix, | 44 const SkMatrix& viewMatrix, |
45 const SkPath& path, | 45 const SkPath& path, |
46 const GrStrokeInfo& stroke, | 46 const GrStrokeInfo& stroke, |
47 DrawType drawType, | 47 DrawType drawType, |
48 StencilSupport* stencilSupp
ort) { | 48 StencilSupport* stencilSupp
ort) { |
49 if (!fInit) { | 49 if (!fInit) { |
50 this->init(); | 50 this->init(); |
51 } | 51 } |
52 bool antiAlias = (kColorAntiAlias_DrawType == drawType || | 52 bool antiAlias = (kColorAntiAlias_DrawType == drawType || |
53 kStencilAndColorAntiAlias_DrawType == drawType); | 53 kStencilAndColorAntiAlias_DrawType == drawType); |
54 | 54 |
55 GR_STATIC_ASSERT(GrPathRenderer::kNoSupport_StencilSupport < | 55 GR_STATIC_ASSERT(GrPathRenderer::kNoSupport_StencilSupport < |
56 GrPathRenderer::kStencilOnly_StencilSupport); | 56 GrPathRenderer::kStencilOnly_StencilSupport); |
57 GR_STATIC_ASSERT(GrPathRenderer::kStencilOnly_StencilSupport < | 57 GR_STATIC_ASSERT(GrPathRenderer::kStencilOnly_StencilSupport < |
58 GrPathRenderer::kNoRestriction_StencilSupport); | 58 GrPathRenderer::kNoRestriction_StencilSupport); |
59 GrPathRenderer::StencilSupport minStencilSupport; | 59 GrPathRenderer::StencilSupport minStencilSupport; |
60 if (kStencilOnly_DrawType == drawType) { | 60 if (kStencilOnly_DrawType == drawType) { |
61 minStencilSupport = GrPathRenderer::kStencilOnly_StencilSupport; | 61 minStencilSupport = GrPathRenderer::kStencilOnly_StencilSupport; |
62 } else if (kStencilAndColor_DrawType == drawType || | 62 } else if (kStencilAndColor_DrawType == drawType || |
63 kStencilAndColorAntiAlias_DrawType == drawType) { | 63 kStencilAndColorAntiAlias_DrawType == drawType) { |
64 minStencilSupport = GrPathRenderer::kNoRestriction_StencilSupport; | 64 minStencilSupport = GrPathRenderer::kNoRestriction_StencilSupport; |
65 } else { | 65 } else { |
66 minStencilSupport = GrPathRenderer::kNoSupport_StencilSupport; | 66 minStencilSupport = GrPathRenderer::kNoSupport_StencilSupport; |
67 } | 67 } |
68 | 68 |
69 | 69 |
70 for (int i = 0; i < fChain.count(); ++i) { | 70 for (int i = 0; i < fChain.count(); ++i) { |
71 GrPathRenderer::CanDrawPathArgs args; | 71 GrPathRenderer::CanDrawPathArgs args; |
72 args.fShaderCaps = shaderCaps; | 72 args.fShaderCaps = shaderCaps; |
73 args.fPipelineBuilder = pipelineBuilder; | 73 args.fPipelineBuilder = &pipelineBuilder; |
74 args.fViewMatrix = &viewMatrix; | 74 args.fViewMatrix = &viewMatrix; |
75 args.fPath = &path; | 75 args.fPath = &path; |
76 args.fStroke = &stroke; | 76 args.fStroke = &stroke; |
77 args.fAntiAlias = antiAlias; | 77 args.fAntiAlias = antiAlias; |
78 if (fChain[i]->canDrawPath(args)) { | 78 if (fChain[i]->canDrawPath(args)) { |
79 if (GrPathRenderer::kNoSupport_StencilSupport != minStencilSupport)
{ | 79 if (GrPathRenderer::kNoSupport_StencilSupport != minStencilSupport)
{ |
80 GrPathRenderer::StencilSupport support = | 80 GrPathRenderer::StencilSupport support = |
81 fChain[i]->getStencilSupp
ort(path, stroke); | 81 fChain[i]->getStencilSupp
ort(path, stroke); |
82 if (support < minStencilSupport) { | 82 if (support < minStencilSupport) { |
83 continue; | 83 continue; |
(...skipping 18 matching lines...) Expand all Loading... |
102 } | 102 } |
103 this->addPathRenderer(new GrTessellatingPathRenderer)->unref(); | 103 this->addPathRenderer(new GrTessellatingPathRenderer)->unref(); |
104 this->addPathRenderer(new GrAAHairLinePathRenderer)->unref(); | 104 this->addPathRenderer(new GrAAHairLinePathRenderer)->unref(); |
105 this->addPathRenderer(new GrAAConvexPathRenderer)->unref(); | 105 this->addPathRenderer(new GrAAConvexPathRenderer)->unref(); |
106 this->addPathRenderer(new GrAALinearizingConvexPathRenderer)->unref(); | 106 this->addPathRenderer(new GrAALinearizingConvexPathRenderer)->unref(); |
107 this->addPathRenderer(new GrAADistanceFieldPathRenderer)->unref(); | 107 this->addPathRenderer(new GrAADistanceFieldPathRenderer)->unref(); |
108 this->addPathRenderer(new GrDefaultPathRenderer(caps.twoSidedStencilSupport(
), | 108 this->addPathRenderer(new GrDefaultPathRenderer(caps.twoSidedStencilSupport(
), |
109 caps.stencilWrapOpsSupport()
))->unref(); | 109 caps.stencilWrapOpsSupport()
))->unref(); |
110 fInit = true; | 110 fInit = true; |
111 } | 111 } |
OLD | NEW |