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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } | 78 } |
79 | 79 |
80 } | 80 } |
81 | 81 |
82 static const bool kIsWrapped = false; // The constructor creates the GL path obj
ect. | 82 static const bool kIsWrapped = false; // The constructor creates the GL path obj
ect. |
83 | 83 |
84 void GrGLPath::InitPathObject(GrGpuGL* gpu, | 84 void GrGLPath::InitPathObject(GrGpuGL* gpu, |
85 GrGLuint pathID, | 85 GrGLuint pathID, |
86 const SkPath& skPath, | 86 const SkPath& skPath, |
87 const SkStrokeRec& stroke) { | 87 const SkStrokeRec& stroke) { |
88 GrGLPathRendering* pr = gpu->pathRendering(); | 88 GrGLPathRendering* pr = gpu->glPathRendering(); |
89 SkSTArray<16, GrGLubyte, true> pathCommands; | 89 SkSTArray<16, GrGLubyte, true> pathCommands; |
90 SkSTArray<16, SkPoint, true> pathPoints; | 90 SkSTArray<16, SkPoint, true> pathPoints; |
91 | 91 |
92 int verbCnt = skPath.countVerbs(); | 92 int verbCnt = skPath.countVerbs(); |
93 int pointCnt = skPath.countPoints(); | 93 int pointCnt = skPath.countPoints(); |
94 pathCommands.resize_back(verbCnt); | 94 pathCommands.resize_back(verbCnt); |
95 pathPoints.resize_back(pointCnt); | 95 pathPoints.resize_back(pointCnt); |
96 | 96 |
97 // TODO: Direct access to path points since we could pass them on directly. | 97 // TODO: Direct access to path points since we could pass them on directly. |
98 skPath.getPoints(&pathPoints[0], pointCnt); | 98 skPath.getPoints(&pathPoints[0], pointCnt); |
(...skipping 15 matching lines...) Expand all Loading... |
114 GrGLenum join = join_to_gl_join(stroke.getJoin()); | 114 GrGLenum join = join_to_gl_join(stroke.getJoin()); |
115 pr->pathParameteri(pathID, GR_GL_PATH_JOIN_STYLE, join); | 115 pr->pathParameteri(pathID, GR_GL_PATH_JOIN_STYLE, join); |
116 GrGLenum cap = cap_to_gl_cap(stroke.getCap()); | 116 GrGLenum cap = cap_to_gl_cap(stroke.getCap()); |
117 pr->pathParameteri(pathID, GR_GL_PATH_INITIAL_END_CAP, cap); | 117 pr->pathParameteri(pathID, GR_GL_PATH_INITIAL_END_CAP, cap); |
118 pr->pathParameteri(pathID, GR_GL_PATH_TERMINAL_END_CAP, cap); | 118 pr->pathParameteri(pathID, GR_GL_PATH_TERMINAL_END_CAP, cap); |
119 } | 119 } |
120 } | 120 } |
121 | 121 |
122 GrGLPath::GrGLPath(GrGpuGL* gpu, const SkPath& path, const SkStrokeRec& stroke) | 122 GrGLPath::GrGLPath(GrGpuGL* gpu, const SkPath& path, const SkStrokeRec& stroke) |
123 : INHERITED(gpu, kIsWrapped, path, stroke), | 123 : INHERITED(gpu, kIsWrapped, path, stroke), |
124 fPathID(gpu->pathRendering()->genPaths(1)) { | 124 fPathID(gpu->glPathRendering()->genPaths(1)) { |
125 SkASSERT(!path.isEmpty()); | 125 SkASSERT(!path.isEmpty()); |
126 | 126 |
127 InitPathObject(gpu, fPathID, fSkPath, stroke); | 127 InitPathObject(gpu, fPathID, fSkPath, stroke); |
128 | 128 |
129 if (stroke.needToApply()) { | 129 if (stroke.needToApply()) { |
130 // FIXME: try to account for stroking, without rasterizing the stroke. | 130 // FIXME: try to account for stroking, without rasterizing the stroke. |
131 fBounds.outset(stroke.getWidth(), stroke.getWidth()); | 131 fBounds.outset(stroke.getWidth(), stroke.getWidth()); |
132 } | 132 } |
133 } | 133 } |
134 | 134 |
135 GrGLPath::~GrGLPath() { | 135 GrGLPath::~GrGLPath() { |
136 this->release(); | 136 this->release(); |
137 } | 137 } |
138 | 138 |
139 void GrGLPath::onRelease() { | 139 void GrGLPath::onRelease() { |
140 if (0 != fPathID && !this->isWrapped()) { | 140 if (0 != fPathID && !this->isWrapped()) { |
141 static_cast<GrGpuGL*>(this->getGpu())->pathRendering()->deletePaths(fPat
hID, 1); | 141 static_cast<GrGpuGL*>(this->getGpu())->glPathRendering()->deletePaths(fP
athID, 1); |
142 fPathID = 0; | 142 fPathID = 0; |
143 } | 143 } |
144 | 144 |
145 INHERITED::onRelease(); | 145 INHERITED::onRelease(); |
146 } | 146 } |
147 | 147 |
148 void GrGLPath::onAbandon() { | 148 void GrGLPath::onAbandon() { |
149 fPathID = 0; | 149 fPathID = 0; |
150 | 150 |
151 INHERITED::onAbandon(); | 151 INHERITED::onAbandon(); |
152 } | 152 } |
OLD | NEW |