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 15 matching lines...) Expand all Loading... |
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 GrDrawState* drawStat
e, |
| 36 const SkMatrix& viewMatrix, |
36 const SkPath& path, | 37 const SkPath& path, |
37 const SkStrokeRec& stroke, | 38 const SkStrokeRec& stroke, |
38 DrawType drawType, | 39 DrawType drawType, |
39 StencilSupport* stencilSupp
ort) { | 40 StencilSupport* stencilSupp
ort) { |
40 if (!fInit) { | 41 if (!fInit) { |
41 this->init(); | 42 this->init(); |
42 } | 43 } |
43 bool antiAlias = (kColorAntiAlias_DrawType == drawType || | 44 bool antiAlias = (kColorAntiAlias_DrawType == drawType || |
44 kStencilAndColorAntiAlias_DrawType == drawType); | 45 kStencilAndColorAntiAlias_DrawType == drawType); |
45 | 46 |
46 GR_STATIC_ASSERT(GrPathRenderer::kNoSupport_StencilSupport < | 47 GR_STATIC_ASSERT(GrPathRenderer::kNoSupport_StencilSupport < |
47 GrPathRenderer::kStencilOnly_StencilSupport); | 48 GrPathRenderer::kStencilOnly_StencilSupport); |
48 GR_STATIC_ASSERT(GrPathRenderer::kStencilOnly_StencilSupport < | 49 GR_STATIC_ASSERT(GrPathRenderer::kStencilOnly_StencilSupport < |
49 GrPathRenderer::kNoRestriction_StencilSupport); | 50 GrPathRenderer::kNoRestriction_StencilSupport); |
50 GrPathRenderer::StencilSupport minStencilSupport; | 51 GrPathRenderer::StencilSupport minStencilSupport; |
51 if (kStencilOnly_DrawType == drawType) { | 52 if (kStencilOnly_DrawType == drawType) { |
52 minStencilSupport = GrPathRenderer::kStencilOnly_StencilSupport; | 53 minStencilSupport = GrPathRenderer::kStencilOnly_StencilSupport; |
53 } else if (kStencilAndColor_DrawType == drawType || | 54 } else if (kStencilAndColor_DrawType == drawType || |
54 kStencilAndColorAntiAlias_DrawType == drawType) { | 55 kStencilAndColorAntiAlias_DrawType == drawType) { |
55 minStencilSupport = GrPathRenderer::kNoRestriction_StencilSupport; | 56 minStencilSupport = GrPathRenderer::kNoRestriction_StencilSupport; |
56 } else { | 57 } else { |
57 minStencilSupport = GrPathRenderer::kNoSupport_StencilSupport; | 58 minStencilSupport = GrPathRenderer::kNoSupport_StencilSupport; |
58 } | 59 } |
59 | 60 |
60 | 61 |
61 for (int i = 0; i < fChain.count(); ++i) { | 62 for (int i = 0; i < fChain.count(); ++i) { |
62 if (fChain[i]->canDrawPath(target, drawState, path, stroke, antiAlias))
{ | 63 if (fChain[i]->canDrawPath(target, drawState, viewMatrix, path, stroke,
antiAlias)) { |
63 if (GrPathRenderer::kNoSupport_StencilSupport != minStencilSupport)
{ | 64 if (GrPathRenderer::kNoSupport_StencilSupport != minStencilSupport)
{ |
64 GrPathRenderer::StencilSupport support = fChain[i]->getStencilSu
pport(target, | 65 GrPathRenderer::StencilSupport support = fChain[i]->getStencilSu
pport(target, |
65
drawState, | 66
drawState, |
66
path, | 67
path, |
67
stroke); | 68
stroke); |
68 if (support < minStencilSupport) { | 69 if (support < minStencilSupport) { |
69 continue; | 70 continue; |
70 } else if (stencilSupport) { | 71 } else if (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 |