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 #ifndef GrPathRenderer_DEFINED | 9 #ifndef GrPathRenderer_DEFINED |
10 #define GrPathRenderer_DEFINED | 10 #define GrPathRenderer_DEFINED |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 GrPathRendererChain::kNoSupport_StencilSupport; | 70 GrPathRendererChain::kNoSupport_StencilSupport; |
71 static const StencilSupport kStencilOnly_StencilSupport = | 71 static const StencilSupport kStencilOnly_StencilSupport = |
72 GrPathRendererChain::kStencilOnly_StencilSupport; | 72 GrPathRendererChain::kStencilOnly_StencilSupport; |
73 static const StencilSupport kNoRestriction_StencilSupport = | 73 static const StencilSupport kNoRestriction_StencilSupport = |
74 GrPathRendererChain::kNoRestriction_StencilSupport; | 74 GrPathRendererChain::kNoRestriction_StencilSupport; |
75 | 75 |
76 /** | 76 /** |
77 * This function is to get the stencil support for a particular path. The pa th's fill must | 77 * This function is to get the stencil support for a particular path. The pa th's fill must |
78 * not be an inverse type. | 78 * not be an inverse type. |
79 * | 79 * |
80 * @param target target that the path will be rendered to | |
81 * @param path the path that will be drawn | 80 * @param path the path that will be drawn |
82 * @param stroke the stroke information (width, join, cap). | 81 * @param stroke the stroke information (width, join, cap). |
83 */ | 82 */ |
84 StencilSupport getStencilSupport(const GrDrawTarget* target, | 83 StencilSupport getStencilSupport(const SkPath& path, const GrStrokeInfo& str oke) const { |
85 const GrPipelineBuilder* pipelineBuilder, | |
86 const SkPath& path, | |
87 const GrStrokeInfo& stroke) const { | |
88 SkASSERT(!path.isInverseFillType()); | 84 SkASSERT(!path.isInverseFillType()); |
89 return this->onGetStencilSupport(target, pipelineBuilder, path, stroke); | 85 return this->onGetStencilSupport(path, stroke); |
90 } | 86 } |
91 | 87 |
92 /** Args to canDrawPath() | 88 /** Args to canDrawPath() |
93 * | 89 * |
94 * fTarget The target that the path will be rendered to | 90 * fShaderCaps The shader caps |
95 * fPipelineBuilder The pipelineBuilder | 91 * fPipelineBuilder The pipelineBuilder |
96 * fViewMatrix The viewMatrix | 92 * fViewMatrix The viewMatrix |
97 * fPath The path to draw | 93 * fPath The path to draw |
98 * fStroke The stroke information (width, join, cap) | 94 * fStroke The stroke information (width, join, cap) |
99 * fAntiAlias True if anti-aliasing is required. | 95 * fAntiAlias True if anti-aliasing is required. |
100 */ | 96 */ |
101 struct CanDrawPathArgs { | 97 struct CanDrawPathArgs { |
102 const GrDrawTarget* fTarget; | 98 SkAutoTUnref<const GrShaderCaps> fShaderCaps; |
bsalomon
2015/08/13 13:49:35
I don't think we need the ref/unref for this. We a
robertphillips
2015/08/13 14:57:00
Done.
| |
103 const GrPipelineBuilder* fPipelineBuilder; | 99 const GrPipelineBuilder* fPipelineBuilder;// only used by GrStencilAn dCoverPathRenderer |
104 const SkMatrix* fViewMatrix; | 100 const SkMatrix* fViewMatrix; |
105 const SkPath* fPath; | 101 const SkPath* fPath; |
106 const GrStrokeInfo* fStroke; | 102 const GrStrokeInfo* fStroke; |
107 bool fAntiAlias; | 103 bool fAntiAlias; |
108 }; | 104 }; |
109 | 105 |
110 /** | 106 /** |
111 * Returns true if this path renderer is able to render the path. Returning false allows the | 107 * Returns true if this path renderer is able to render the path. Returning false allows the |
112 * caller to fallback to another path renderer This function is called when searching for a path | 108 * caller to fallback to another path renderer This function is called when searching for a path |
113 * renderer capable of rendering a path. | 109 * renderer capable of rendering a path. |
114 * | 110 * |
115 * @return true if the path can be drawn by this object, false otherwise. | 111 * @return true if the path can be drawn by this object, false otherwise. |
116 */ | 112 */ |
117 bool canDrawPath(const CanDrawPathArgs& args) const { | 113 bool canDrawPath(const CanDrawPathArgs& args) const { |
118 SkASSERT(args.fTarget); | 114 SkASSERT(args.fShaderCaps); |
119 SkASSERT(args.fPipelineBuilder); | 115 SkASSERT(args.fPipelineBuilder); |
120 SkASSERT(args.fViewMatrix); | 116 SkASSERT(args.fViewMatrix); |
121 SkASSERT(args.fPath); | 117 SkASSERT(args.fPath); |
122 SkASSERT(args.fStroke); | 118 SkASSERT(args.fStroke); |
123 SkASSERT(!args.fPath->isEmpty()); | 119 SkASSERT(!args.fPath->isEmpty()); |
124 return this->onCanDrawPath(args); | 120 return this->onCanDrawPath(args); |
125 } | 121 } |
126 | 122 |
127 /** | 123 /** |
128 * Args to drawPath() | 124 * Args to drawPath() |
(...skipping 24 matching lines...) Expand all Loading... | |
153 bool drawPath(const DrawPathArgs& args) { | 149 bool drawPath(const DrawPathArgs& args) { |
154 SkASSERT(args.fTarget); | 150 SkASSERT(args.fTarget); |
155 SkASSERT(args.fPipelineBuilder); | 151 SkASSERT(args.fPipelineBuilder); |
156 SkASSERT(args.fViewMatrix); | 152 SkASSERT(args.fViewMatrix); |
157 SkASSERT(args.fPath); | 153 SkASSERT(args.fPath); |
158 SkASSERT(args.fStroke); | 154 SkASSERT(args.fStroke); |
159 | 155 |
160 SkASSERT(!args.fPath->isEmpty()); | 156 SkASSERT(!args.fPath->isEmpty()); |
161 #ifdef SK_DEBUG | 157 #ifdef SK_DEBUG |
162 CanDrawPathArgs canArgs; | 158 CanDrawPathArgs canArgs; |
163 canArgs.fTarget = args.fTarget; | 159 canArgs.fShaderCaps.reset(SkRef(args.fTarget->caps()->shaderCaps())); |
164 canArgs.fPipelineBuilder = args.fPipelineBuilder; | 160 canArgs.fPipelineBuilder = args.fPipelineBuilder; |
165 canArgs.fViewMatrix = args.fViewMatrix; | 161 canArgs.fViewMatrix = args.fViewMatrix; |
166 canArgs.fPath = args.fPath; | 162 canArgs.fPath = args.fPath; |
167 canArgs.fStroke = args.fStroke; | 163 canArgs.fStroke = args.fStroke; |
168 canArgs.fAntiAlias = args.fAntiAlias; | 164 canArgs.fAntiAlias = args.fAntiAlias; |
169 SkASSERT(this->canDrawPath(canArgs)); | 165 SkASSERT(this->canDrawPath(canArgs)); |
170 SkASSERT(args.fPipelineBuilder->getStencil().isDisabled() || | 166 SkASSERT(args.fPipelineBuilder->getStencil().isDisabled() || |
171 kNoRestriction_StencilSupport == this->getStencilSupport(args.f Target, | 167 kNoRestriction_StencilSupport == this->getStencilSupport(*args. fPath, |
172 args.f PipelineBuilder, | |
173 *args. fPath, | |
174 *args. fStroke)); | 168 *args. fStroke)); |
175 #endif | 169 #endif |
176 return this->onDrawPath(args); | 170 return this->onDrawPath(args); |
177 } | 171 } |
178 | 172 |
179 /* Args to stencilPath(). | 173 /* Args to stencilPath(). |
180 * | 174 * |
181 * fTarget The target that the path will be rendered to. | 175 * fTarget The target that the path will be rendered to. |
182 * fPipelineBuilder The pipeline builder. | 176 * fPipelineBuilder The pipeline builder. |
183 * fViewMatrix Matrix applied to the path. | 177 * fViewMatrix Matrix applied to the path. |
(...skipping 15 matching lines...) Expand all Loading... | |
199 * | 193 * |
200 */ | 194 */ |
201 void stencilPath(const StencilPathArgs& args) { | 195 void stencilPath(const StencilPathArgs& args) { |
202 SkASSERT(args.fTarget); | 196 SkASSERT(args.fTarget); |
203 SkASSERT(args.fPipelineBuilder); | 197 SkASSERT(args.fPipelineBuilder); |
204 SkASSERT(args.fResourceProvider); | 198 SkASSERT(args.fResourceProvider); |
205 SkASSERT(args.fViewMatrix); | 199 SkASSERT(args.fViewMatrix); |
206 SkASSERT(args.fPath); | 200 SkASSERT(args.fPath); |
207 SkASSERT(args.fStroke); | 201 SkASSERT(args.fStroke); |
208 SkASSERT(!args.fPath->isEmpty()); | 202 SkASSERT(!args.fPath->isEmpty()); |
209 SkASSERT(kNoSupport_StencilSupport != | 203 SkASSERT(kNoSupport_StencilSupport != this->getStencilSupport(*args.fPat h, *args.fStroke)); |
210 this->getStencilSupport(args.fTarget, args.fPipelineBuilder, *a rgs.fPath, | |
211 *args.fStroke)); | |
212 this->onStencilPath(args); | 204 this->onStencilPath(args); |
213 } | 205 } |
214 | 206 |
215 // Helper for determining if we can treat a thin stroke as a hairline w/ cov erage. | 207 // Helper for determining if we can treat a thin stroke as a hairline w/ cov erage. |
216 // If we can, we draw lots faster (raster device does this same test). | 208 // If we can, we draw lots faster (raster device does this same test). |
217 static bool IsStrokeHairlineOrEquivalent(const GrStrokeInfo& stroke, const S kMatrix& matrix, | 209 static bool IsStrokeHairlineOrEquivalent(const GrStrokeInfo& stroke, const S kMatrix& matrix, |
218 SkScalar* outCoverage) { | 210 SkScalar* outCoverage) { |
219 if (stroke.isDashed()) { | 211 if (stroke.isDashed()) { |
220 return false; | 212 return false; |
221 } | 213 } |
(...skipping 21 matching lines...) Expand all Loading... | |
243 const GrSurface* device, | 235 const GrSurface* device, |
244 const SkMatrix& matrix, | 236 const SkMatrix& matrix, |
245 SkRect* bounds) { | 237 SkRect* bounds) { |
246 GetPathDevBounds(path, device->width(), device->height(), matrix, bounds ); | 238 GetPathDevBounds(path, device->width(), device->height(), matrix, bounds ); |
247 } | 239 } |
248 | 240 |
249 private: | 241 private: |
250 /** | 242 /** |
251 * Subclass overrides if it has any limitations of stenciling support. | 243 * Subclass overrides if it has any limitations of stenciling support. |
252 */ | 244 */ |
253 virtual StencilSupport onGetStencilSupport(const GrDrawTarget*, | 245 virtual StencilSupport onGetStencilSupport(const SkPath&, const GrStrokeInfo &) const { |
254 const GrPipelineBuilder*, | |
255 const SkPath&, | |
256 const GrStrokeInfo&) const { | |
257 return kNoRestriction_StencilSupport; | 246 return kNoRestriction_StencilSupport; |
258 } | 247 } |
259 | 248 |
260 /** | 249 /** |
261 * Subclass implementation of drawPath() | 250 * Subclass implementation of drawPath() |
262 */ | 251 */ |
263 virtual bool onDrawPath(const DrawPathArgs& args) = 0; | 252 virtual bool onDrawPath(const DrawPathArgs& args) = 0; |
264 | 253 |
265 /** | 254 /** |
266 * Subclass implementation of canDrawPath() | 255 * Subclass implementation of canDrawPath() |
(...skipping 24 matching lines...) Expand all Loading... | |
291 drawArgs.fStroke = args.fStroke; | 280 drawArgs.fStroke = args.fStroke; |
292 drawArgs.fAntiAlias = false; | 281 drawArgs.fAntiAlias = false; |
293 this->drawPath(drawArgs); | 282 this->drawPath(drawArgs); |
294 } | 283 } |
295 | 284 |
296 | 285 |
297 typedef SkRefCnt INHERITED; | 286 typedef SkRefCnt INHERITED; |
298 }; | 287 }; |
299 | 288 |
300 #endif | 289 #endif |
OLD | NEW |