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 |
11 | 11 |
12 #include "GrDrawTarget.h" | 12 #include "GrDrawTarget.h" |
13 #include "GrPathRendererChain.h" | 13 #include "GrPathRendererChain.h" |
14 #include "GrStencil.h" | 14 #include "GrStencil.h" |
15 | 15 |
| 16 #include "SkDrawProcs.h" |
16 #include "SkStrokeRec.h" | 17 #include "SkStrokeRec.h" |
17 #include "SkTArray.h" | 18 #include "SkTArray.h" |
18 | 19 |
19 class SkPath; | 20 class SkPath; |
20 | 21 |
21 struct GrPoint; | 22 struct GrPoint; |
22 | 23 |
23 /** | 24 /** |
24 * Base class for drawing paths into a GrDrawTarget. | 25 * Base class for drawing paths into a GrDrawTarget. |
25 * | 26 * |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 * @param path the path to draw. | 131 * @param path the path to draw. |
131 * @param stroke the stroke information (width, join, cap) | 132 * @param stroke the stroke information (width, join, cap) |
132 * @param target target that the path will be rendered to | 133 * @param target target that the path will be rendered to |
133 */ | 134 */ |
134 void stencilPath(const SkPath& path, const SkStrokeRec& stroke, GrDrawTarget
* target) { | 135 void stencilPath(const SkPath& path, const SkStrokeRec& stroke, GrDrawTarget
* target) { |
135 SkASSERT(!path.isEmpty()); | 136 SkASSERT(!path.isEmpty()); |
136 SkASSERT(kNoSupport_StencilSupport != this->getStencilSupport(path, stro
ke, target)); | 137 SkASSERT(kNoSupport_StencilSupport != this->getStencilSupport(path, stro
ke, target)); |
137 this->onStencilPath(path, stroke, target); | 138 this->onStencilPath(path, stroke, target); |
138 } | 139 } |
139 | 140 |
| 141 // Helper for determining if we can treat a thin stroke as a hairline w/ cov
erage. |
| 142 // If we can, we draw lots faster (raster device does this same test). |
| 143 static bool IsStrokeHairlineOrEquivalent(const SkStrokeRec& stroke, const Sk
Matrix& matrix, |
| 144 SkScalar* outCoverage) { |
| 145 if (stroke.isHairlineStyle()) { |
| 146 if (NULL != outCoverage) { |
| 147 *outCoverage = SK_Scalar1; |
| 148 } |
| 149 return true; |
| 150 } |
| 151 return stroke.getStyle() == SkStrokeRec::kStroke_Style && |
| 152 SkDrawTreatAAStrokeAsHairline(stroke.getWidth(), matrix, outCoverage
); |
| 153 } |
| 154 |
140 protected: | 155 protected: |
141 /** | 156 /** |
142 * Subclass overrides if it has any limitations of stenciling support. | 157 * Subclass overrides if it has any limitations of stenciling support. |
143 */ | 158 */ |
144 virtual StencilSupport onGetStencilSupport(const SkPath&, | 159 virtual StencilSupport onGetStencilSupport(const SkPath&, |
145 const SkStrokeRec&, | 160 const SkStrokeRec&, |
146 const GrDrawTarget*) const { | 161 const GrDrawTarget*) const { |
147 return kNoRestriction_StencilSupport; | 162 return kNoRestriction_StencilSupport; |
148 } | 163 } |
149 | 164 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 SkRect* bounds) { | 204 SkRect* bounds) { |
190 GetPathDevBounds(path, device->width(), device->height(), matrix, bounds
); | 205 GetPathDevBounds(path, device->width(), device->height(), matrix, bounds
); |
191 } | 206 } |
192 | 207 |
193 private: | 208 private: |
194 | 209 |
195 typedef SkRefCnt INHERITED; | 210 typedef SkRefCnt INHERITED; |
196 }; | 211 }; |
197 | 212 |
198 #endif | 213 #endif |
OLD | NEW |