OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 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 #include "GrGLPath.h" | 9 #include "GrGLPath.h" |
10 #include "GrGLPathRendering.h" | 10 #include "GrGLPathRendering.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 for (size_t i = 0; i < amount; ++i) { | 84 for (size_t i = 0; i < amount; ++i) { |
85 coords[i * 2] = SkScalarToFloat(points[first_point + i].fX); | 85 coords[i * 2] = SkScalarToFloat(points[first_point + i].fX); |
86 coords[i * 2 + 1] = SkScalarToFloat(points[first_point + i].fY); | 86 coords[i * 2 + 1] = SkScalarToFloat(points[first_point + i].fY); |
87 } | 87 } |
88 } | 88 } |
89 } | 89 } |
90 | 90 |
91 void GrGLPath::InitPathObject(GrGLGpu* gpu, | 91 void GrGLPath::InitPathObject(GrGLGpu* gpu, |
92 GrGLuint pathID, | 92 GrGLuint pathID, |
93 const SkPath& skPath, | 93 const SkPath& skPath, |
94 const SkStrokeRec& stroke) { | 94 const GrStrokeInfo& stroke) { |
| 95 SkASSERT(!stroke.isDashed()); |
95 if (!skPath.isEmpty()) { | 96 if (!skPath.isEmpty()) { |
96 int verbCnt = skPath.countVerbs(); | 97 int verbCnt = skPath.countVerbs(); |
97 int pointCnt = skPath.countPoints(); | 98 int pointCnt = skPath.countPoints(); |
98 int minCoordCnt = pointCnt * 2; | 99 int minCoordCnt = pointCnt * 2; |
99 | 100 |
100 SkSTArray<16, GrGLubyte, true> pathCommands(verbCnt); | 101 SkSTArray<16, GrGLubyte, true> pathCommands(verbCnt); |
101 SkSTArray<16, GrGLfloat, true> pathCoords(minCoordCnt); | 102 SkSTArray<16, GrGLfloat, true> pathCoords(minCoordCnt); |
102 | 103 |
103 SkDEBUGCODE(int numCoords = 0); | 104 SkDEBUGCODE(int numCoords = 0); |
104 | 105 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 PathParameterf(pathID, GR_GL_PATH_STROKE_WIDTH, SkScalarToFloat(stro
ke.getWidth()))); | 175 PathParameterf(pathID, GR_GL_PATH_STROKE_WIDTH, SkScalarToFloat(stro
ke.getWidth()))); |
175 GR_GL_CALL(gpu->glInterface(), | 176 GR_GL_CALL(gpu->glInterface(), |
176 PathParameterf(pathID, GR_GL_PATH_MITER_LIMIT, SkScalarToFloat(strok
e.getMiter()))); | 177 PathParameterf(pathID, GR_GL_PATH_MITER_LIMIT, SkScalarToFloat(strok
e.getMiter()))); |
177 GrGLenum join = join_to_gl_join(stroke.getJoin()); | 178 GrGLenum join = join_to_gl_join(stroke.getJoin()); |
178 GR_GL_CALL(gpu->glInterface(), PathParameteri(pathID, GR_GL_PATH_JOIN_ST
YLE, join)); | 179 GR_GL_CALL(gpu->glInterface(), PathParameteri(pathID, GR_GL_PATH_JOIN_ST
YLE, join)); |
179 GrGLenum cap = cap_to_gl_cap(stroke.getCap()); | 180 GrGLenum cap = cap_to_gl_cap(stroke.getCap()); |
180 GR_GL_CALL(gpu->glInterface(), PathParameteri(pathID, GR_GL_PATH_END_CAP
S, cap)); | 181 GR_GL_CALL(gpu->glInterface(), PathParameteri(pathID, GR_GL_PATH_END_CAP
S, cap)); |
181 } | 182 } |
182 } | 183 } |
183 | 184 |
184 GrGLPath::GrGLPath(GrGLGpu* gpu, const SkPath& path, const SkStrokeRec& stroke) | 185 GrGLPath::GrGLPath(GrGLGpu* gpu, const SkPath& origSkPath, const GrStrokeInfo& o
rigStroke) |
185 : INHERITED(gpu, path, stroke), | 186 : INHERITED(gpu, origSkPath, origStroke), |
186 fPathID(gpu->glPathRendering()->genPaths(1)) { | 187 fPathID(gpu->glPathRendering()->genPaths(1)) { |
| 188 // Convert a dashing to either a stroke or a fill. |
| 189 const SkPath* skPath = &origSkPath; |
| 190 SkTLazy<SkPath> tmpPath; |
| 191 const GrStrokeInfo* stroke = &origStroke; |
| 192 GrStrokeInfo tmpStroke(SkStrokeRec::kFill_InitStyle); |
187 | 193 |
188 InitPathObject(gpu, fPathID, fSkPath, stroke); | 194 if (stroke->isDashed()) { |
| 195 if (stroke->applyDashToPath(tmpPath.init(), &tmpStroke, *skPath)) { |
| 196 skPath = tmpPath.get(); |
| 197 stroke = &tmpStroke; |
| 198 } |
| 199 } |
189 | 200 |
190 if (stroke.needToApply()) { | 201 InitPathObject(gpu, fPathID, *skPath, *stroke); |
| 202 |
| 203 fShouldStroke = stroke->needToApply(); |
| 204 fShouldFill = stroke->isFillStyle() || |
| 205 stroke->getStyle() == SkStrokeRec::kStrokeAndFill_Style; |
| 206 |
| 207 if (fShouldStroke) { |
191 // FIXME: try to account for stroking, without rasterizing the stroke. | 208 // FIXME: try to account for stroking, without rasterizing the stroke. |
192 fBounds.outset(stroke.getWidth(), stroke.getWidth()); | 209 fBounds.outset(stroke->getWidth(), stroke->getWidth()); |
193 } | 210 } |
| 211 |
194 this->registerWithCache(); | 212 this->registerWithCache(); |
195 } | 213 } |
196 | 214 |
197 void GrGLPath::onRelease() { | 215 void GrGLPath::onRelease() { |
198 if (0 != fPathID && !this->isWrapped()) { | 216 if (0 != fPathID && !this->isWrapped()) { |
199 static_cast<GrGLGpu*>(this->getGpu())->glPathRendering()->deletePaths(fP
athID, 1); | 217 static_cast<GrGLGpu*>(this->getGpu())->glPathRendering()->deletePaths(fP
athID, 1); |
200 fPathID = 0; | 218 fPathID = 0; |
201 } | 219 } |
202 | 220 |
203 INHERITED::onRelease(); | 221 INHERITED::onRelease(); |
204 } | 222 } |
205 | 223 |
206 void GrGLPath::onAbandon() { | 224 void GrGLPath::onAbandon() { |
207 fPathID = 0; | 225 fPathID = 0; |
208 | 226 |
209 INHERITED::onAbandon(); | 227 INHERITED::onAbandon(); |
210 } | 228 } |
OLD | NEW |