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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 GrGLfloat coords[]) { | 83 GrGLfloat coords[]) { |
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 static const bool kIsWrapped = false; // The constructor creates the GL path obj
ect. | 91 static const bool kIsWrapped = false; // The constructor creates the GL path obj
ect. |
92 | 92 |
93 void GrGLPath::InitPathObject(GrGpuGL* gpu, | 93 void GrGLPath::InitPathObject(GrGLGpu* gpu, |
94 GrGLuint pathID, | 94 GrGLuint pathID, |
95 const SkPath& skPath, | 95 const SkPath& skPath, |
96 const SkStrokeRec& stroke) { | 96 const SkStrokeRec& stroke) { |
97 if (!skPath.isEmpty()) { | 97 if (!skPath.isEmpty()) { |
98 int verbCnt = skPath.countVerbs(); | 98 int verbCnt = skPath.countVerbs(); |
99 int pointCnt = skPath.countPoints(); | 99 int pointCnt = skPath.countPoints(); |
100 int minCoordCnt = pointCnt * 2; | 100 int minCoordCnt = pointCnt * 2; |
101 | 101 |
102 SkSTArray<16, GrGLubyte, true> pathCommands(verbCnt); | 102 SkSTArray<16, GrGLubyte, true> pathCommands(verbCnt); |
103 SkSTArray<16, GrGLfloat, true> pathCoords(minCoordCnt); | 103 SkSTArray<16, GrGLfloat, true> pathCoords(minCoordCnt); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 PathParameterf(pathID, GR_GL_PATH_STROKE_WIDTH, SkScalarToFloat(stro
ke.getWidth()))); | 176 PathParameterf(pathID, GR_GL_PATH_STROKE_WIDTH, SkScalarToFloat(stro
ke.getWidth()))); |
177 GR_GL_CALL(gpu->glInterface(), | 177 GR_GL_CALL(gpu->glInterface(), |
178 PathParameterf(pathID, GR_GL_PATH_MITER_LIMIT, SkScalarToFloat(strok
e.getMiter()))); | 178 PathParameterf(pathID, GR_GL_PATH_MITER_LIMIT, SkScalarToFloat(strok
e.getMiter()))); |
179 GrGLenum join = join_to_gl_join(stroke.getJoin()); | 179 GrGLenum join = join_to_gl_join(stroke.getJoin()); |
180 GR_GL_CALL(gpu->glInterface(), PathParameteri(pathID, GR_GL_PATH_JOIN_ST
YLE, join)); | 180 GR_GL_CALL(gpu->glInterface(), PathParameteri(pathID, GR_GL_PATH_JOIN_ST
YLE, join)); |
181 GrGLenum cap = cap_to_gl_cap(stroke.getCap()); | 181 GrGLenum cap = cap_to_gl_cap(stroke.getCap()); |
182 GR_GL_CALL(gpu->glInterface(), PathParameteri(pathID, GR_GL_PATH_END_CAP
S, cap)); | 182 GR_GL_CALL(gpu->glInterface(), PathParameteri(pathID, GR_GL_PATH_END_CAP
S, cap)); |
183 } | 183 } |
184 } | 184 } |
185 | 185 |
186 GrGLPath::GrGLPath(GrGpuGL* gpu, const SkPath& path, const SkStrokeRec& stroke) | 186 GrGLPath::GrGLPath(GrGLGpu* gpu, const SkPath& path, const SkStrokeRec& stroke) |
187 : INHERITED(gpu, kIsWrapped, path, stroke), | 187 : INHERITED(gpu, kIsWrapped, path, stroke), |
188 fPathID(gpu->glPathRendering()->genPaths(1)) { | 188 fPathID(gpu->glPathRendering()->genPaths(1)) { |
189 | 189 |
190 InitPathObject(gpu, fPathID, fSkPath, stroke); | 190 InitPathObject(gpu, fPathID, fSkPath, stroke); |
191 | 191 |
192 if (stroke.needToApply()) { | 192 if (stroke.needToApply()) { |
193 // FIXME: try to account for stroking, without rasterizing the stroke. | 193 // FIXME: try to account for stroking, without rasterizing the stroke. |
194 fBounds.outset(stroke.getWidth(), stroke.getWidth()); | 194 fBounds.outset(stroke.getWidth(), stroke.getWidth()); |
195 } | 195 } |
196 this->registerWithCache(); | 196 this->registerWithCache(); |
197 } | 197 } |
198 | 198 |
199 void GrGLPath::onRelease() { | 199 void GrGLPath::onRelease() { |
200 if (0 != fPathID && !this->isWrapped()) { | 200 if (0 != fPathID && !this->isWrapped()) { |
201 static_cast<GrGpuGL*>(this->getGpu())->glPathRendering()->deletePaths(fP
athID, 1); | 201 static_cast<GrGLGpu*>(this->getGpu())->glPathRendering()->deletePaths(fP
athID, 1); |
202 fPathID = 0; | 202 fPathID = 0; |
203 } | 203 } |
204 | 204 |
205 INHERITED::onRelease(); | 205 INHERITED::onRelease(); |
206 } | 206 } |
207 | 207 |
208 void GrGLPath::onAbandon() { | 208 void GrGLPath::onAbandon() { |
209 fPathID = 0; | 209 fPathID = 0; |
210 | 210 |
211 INHERITED::onAbandon(); | 211 INHERITED::onAbandon(); |
212 } | 212 } |
OLD | NEW |