OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "gl/GrGLPathRendering.h" | 8 #include "gl/GrGLPathRendering.h" |
9 #include "gl/GrGLUtil.h" | 9 #include "gl/GrGLUtil.h" |
10 #include "gl/GrGLGpu.h" | 10 #include "gl/GrGLGpu.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFro
nt_Face); | 138 GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFro
nt_Face); |
139 | 139 |
140 if (glPath->shouldFill()) { | 140 if (glPath->shouldFill()) { |
141 GL_CALL(StencilFillPath(glPath->pathID(), fillMode, writeMask)); | 141 GL_CALL(StencilFillPath(glPath->pathID(), fillMode, writeMask)); |
142 } | 142 } |
143 if (glPath->shouldStroke()) { | 143 if (glPath->shouldStroke()) { |
144 GL_CALL(StencilStrokePath(glPath->pathID(), 0xffff, writeMask)); | 144 GL_CALL(StencilStrokePath(glPath->pathID(), 0xffff, writeMask)); |
145 } | 145 } |
146 } | 146 } |
147 | 147 |
148 void GrGLPathRendering::onDrawPath(const GrPipeline& pipeline, | |
149 const GrPrimitiveProcessor& primProc, | |
150 const GrStencilSettings& stencil, | |
151 const GrPath* path) { | |
152 if (!this->gpu()->flushGLState(pipeline, primProc)) { | |
153 return; | |
154 } | |
155 const GrGLPath* glPath = static_cast<const GrGLPath*>(path); | |
156 | |
157 this->flushPathStencilSettings(stencil); | |
158 SkASSERT(!fHWPathStencilSettings.isTwoSided()); | |
159 | |
160 GrGLenum fillMode = gr_stencil_op_to_gl_path_rendering_fill_mode( | |
161 fHWPathStencilSettings.passOp(GrStencilSettings::kFront_Face)); | |
162 GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFro
nt_Face); | |
163 | |
164 if (glPath->shouldStroke()) { | |
165 if (glPath->shouldFill()) { | |
166 GL_CALL(StencilFillPath(glPath->pathID(), fillMode, writeMask)); | |
167 } | |
168 GL_CALL(StencilThenCoverStrokePath(glPath->pathID(), 0xffff, writeMask, | |
169 GR_GL_BOUNDING_BOX)); | |
170 } else { | |
171 GL_CALL(StencilThenCoverFillPath(glPath->pathID(), fillMode, writeMask, | |
172 GR_GL_BOUNDING_BOX)); | |
173 } | |
174 } | |
175 | |
176 void GrGLPathRendering::onDrawPaths(const GrPipeline& pipeline, | 148 void GrGLPathRendering::onDrawPaths(const GrPipeline& pipeline, |
177 const GrPrimitiveProcessor& primProc, | 149 const GrPrimitiveProcessor& primProc, |
178 const GrStencilSettings& stencil, const GrPa
thRange* pathRange, | 150 const GrStencilSettings& stencil, |
| 151 const GrPathRange* pathRange, |
179 const void* indices, PathIndexType indexType
, | 152 const void* indices, PathIndexType indexType
, |
180 const float transformValues[], PathTransform
Type transformType, | 153 const float transformValues[], PathTransform
Type transformType, |
181 int count) { | 154 int count) { |
182 SkDEBUGCODE(verify_floats(transformValues, gXformType2ComponentCount[transfo
rmType] * count)); | 155 SkDEBUGCODE(verify_floats(transformValues, gXformType2ComponentCount[transfo
rmType] * count)); |
183 | 156 |
184 if (!this->gpu()->flushGLState(pipeline, primProc)) { | 157 if (!this->gpu()->flushGLState(pipeline, primProc)) { |
185 return; | 158 return; |
186 } | 159 } |
187 this->flushPathStencilSettings(stencil); | 160 this->flushPathStencilSettings(stencil); |
188 SkASSERT(!fHWPathStencilSettings.isTwoSided()); | 161 SkASSERT(!fHWPathStencilSettings.isTwoSided()); |
(...skipping 19 matching lines...) Expand all Loading... |
208 0xffff, writeMask, GR_GL_BOUNDING_BOX_OF_BOUNDING_BO
XES, | 181 0xffff, writeMask, GR_GL_BOUNDING_BOX_OF_BOUNDING_BO
XES, |
209 gXformType2GLType[transformType], transformValues)); | 182 gXformType2GLType[transformType], transformValues)); |
210 } else { | 183 } else { |
211 GL_CALL(StencilThenCoverFillPathInstanced( | 184 GL_CALL(StencilThenCoverFillPathInstanced( |
212 count, gIndexType2GLType[indexType], indices, glPath
Range->basePathID(), | 185 count, gIndexType2GLType[indexType], indices, glPath
Range->basePathID(), |
213 fillMode, writeMask, GR_GL_BOUNDING_BOX_OF_BOUNDING_
BOXES, | 186 fillMode, writeMask, GR_GL_BOUNDING_BOX_OF_BOUNDING_
BOXES, |
214 gXformType2GLType[transformType], transformValues)); | 187 gXformType2GLType[transformType], transformValues)); |
215 } | 188 } |
216 } | 189 } |
217 | 190 |
| 191 void GrGLPathRendering::onDrawPaths(const GrPipeline& pipeline, |
| 192 const GrPrimitiveProcessor& primProc, |
| 193 const GrStencilSettings& stencil, |
| 194 const GrPath* const* paths, |
| 195 int count) { |
| 196 if (!count) { |
| 197 return; |
| 198 } |
| 199 if (!this->gpu()->flushGLState(pipeline, primProc)) { |
| 200 return; |
| 201 } |
| 202 this->flushPathStencilSettings(stencil); |
| 203 SkASSERT(!fHWPathStencilSettings.isTwoSided()); |
| 204 |
| 205 GrGLenum fillMode = |
| 206 gr_stencil_op_to_gl_path_rendering_fill_mode( |
| 207 fHWPathStencilSettings.passOp(GrStencilSettings::kFront_Face)); |
| 208 GrGLint writeMask = |
| 209 fHWPathStencilSettings.writeMask(GrStencilSettings::kFront_Face); |
| 210 const GrGLPath* path = static_cast<const GrGLPath*>(paths[0]); |
| 211 if (count > 1) { |
| 212 SkAutoSTMalloc<32, GrGLuint> indexStorage(count); |
| 213 for (int i = 0; i < count; ++i) { |
| 214 indexStorage[i] = static_cast<const GrGLPath*>(paths[i])->pathID(); |
| 215 } |
| 216 if (path->shouldStroke()) { |
| 217 if (path->shouldFill()) { |
| 218 GL_CALL(StencilFillPathInstanced( |
| 219 count, GR_GL_UNSIGNED_INT, indexStorage, 0, |
| 220 fillMode, writeMask, GR_GL_NONE, nullptr)); |
| 221 } |
| 222 GL_CALL(StencilThenCoverStrokePathInstanced( |
| 223 count, GR_GL_UNSIGNED_INT, indexStorage, 0, 0xffff, writeMask, |
| 224 GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES, GR_GL_NONE, nullptr)); |
| 225 } else { |
| 226 GL_CALL(StencilThenCoverFillPathInstanced( |
| 227 count, GR_GL_UNSIGNED_INT, indexStorage, 0, |
| 228 fillMode, writeMask, GR_GL_BOUNDING_BOX_OF_BOUNDING_BOXES, |
| 229 GR_GL_NONE, nullptr)); |
| 230 } |
| 231 } else { |
| 232 if (path->shouldStroke()) { |
| 233 if (path->shouldFill()) { |
| 234 GL_CALL(StencilFillPath(path->pathID(), fillMode, writeMask)); |
| 235 } |
| 236 GL_CALL(StencilThenCoverStrokePath(path->pathID(), 0xffff, writeMask
, |
| 237 GR_GL_BOUNDING_BOX)); |
| 238 } else { |
| 239 GL_CALL(StencilThenCoverFillPath(path->pathID(), fillMode, writeMask
, |
| 240 GR_GL_BOUNDING_BOX)); |
| 241 } |
| 242 } |
| 243 } |
| 244 |
218 void GrGLPathRendering::setProgramPathFragmentInputTransform(GrGLuint program, G
rGLint location, | 245 void GrGLPathRendering::setProgramPathFragmentInputTransform(GrGLuint program, G
rGLint location, |
219 GrGLenum genMode, G
rGLint components, | 246 GrGLenum genMode, G
rGLint components, |
220 const SkMatrix& mat
rix) { | 247 const SkMatrix& mat
rix) { |
221 float coefficients[3 * 3]; | 248 float coefficients[3 * 3]; |
222 SkASSERT(components >= 1 && components <= 3); | 249 SkASSERT(components >= 1 && components <= 3); |
223 | 250 |
224 coefficients[0] = SkScalarToFloat(matrix[SkMatrix::kMScaleX]); | 251 coefficients[0] = SkScalarToFloat(matrix[SkMatrix::kMScaleX]); |
225 coefficients[1] = SkScalarToFloat(matrix[SkMatrix::kMSkewX]); | 252 coefficients[1] = SkScalarToFloat(matrix[SkMatrix::kMSkewX]); |
226 coefficients[2] = SkScalarToFloat(matrix[SkMatrix::kMTransX]); | 253 coefficients[2] = SkScalarToFloat(matrix[SkMatrix::kMTransX]); |
227 | 254 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 funcMask != fHWPathStencilSettings.funcMask(kFront_Face)) { | 360 funcMask != fHWPathStencilSettings.funcMask(kFront_Face)) { |
334 GL_CALL(PathStencilFunc(GrToGLStencilFunc(func), funcRef, funcMask))
; | 361 GL_CALL(PathStencilFunc(GrToGLStencilFunc(func), funcRef, funcMask))
; |
335 } | 362 } |
336 fHWPathStencilSettings = stencilSettings; | 363 fHWPathStencilSettings = stencilSettings; |
337 } | 364 } |
338 } | 365 } |
339 | 366 |
340 inline GrGLGpu* GrGLPathRendering::gpu() { | 367 inline GrGLGpu* GrGLPathRendering::gpu() { |
341 return static_cast<GrGLGpu*>(fGpu); | 368 return static_cast<GrGLGpu*>(fGpu); |
342 } | 369 } |
OLD | NEW |