Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: src/gpu/gl/GrGLPathRendering.cpp

Issue 1919843002: Revert of Batch multiple single NVPR draw paths to instanced draws (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/gl/GrGLPathRendering.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
148 void GrGLPathRendering::onDrawPaths(const GrPipeline& pipeline, 176 void GrGLPathRendering::onDrawPaths(const GrPipeline& pipeline,
149 const GrPrimitiveProcessor& primProc, 177 const GrPrimitiveProcessor& primProc,
150 const GrStencilSettings& stencil, 178 const GrStencilSettings& stencil, const GrPa thRange* pathRange,
151 const GrPathRange* pathRange,
152 const void* indices, PathIndexType indexType , 179 const void* indices, PathIndexType indexType ,
153 const float transformValues[], PathTransform Type transformType, 180 const float transformValues[], PathTransform Type transformType,
154 int count) { 181 int count) {
155 SkDEBUGCODE(verify_floats(transformValues, gXformType2ComponentCount[transfo rmType] * count)); 182 SkDEBUGCODE(verify_floats(transformValues, gXformType2ComponentCount[transfo rmType] * count));
156 183
157 if (!this->gpu()->flushGLState(pipeline, primProc)) { 184 if (!this->gpu()->flushGLState(pipeline, primProc)) {
158 return; 185 return;
159 } 186 }
160 this->flushPathStencilSettings(stencil); 187 this->flushPathStencilSettings(stencil);
161 SkASSERT(!fHWPathStencilSettings.isTwoSided()); 188 SkASSERT(!fHWPathStencilSettings.isTwoSided());
(...skipping 19 matching lines...) Expand all
181 0xffff, writeMask, GR_GL_BOUNDING_BOX_OF_BOUNDING_BO XES, 208 0xffff, writeMask, GR_GL_BOUNDING_BOX_OF_BOUNDING_BO XES,
182 gXformType2GLType[transformType], transformValues)); 209 gXformType2GLType[transformType], transformValues));
183 } else { 210 } else {
184 GL_CALL(StencilThenCoverFillPathInstanced( 211 GL_CALL(StencilThenCoverFillPathInstanced(
185 count, gIndexType2GLType[indexType], indices, glPath Range->basePathID(), 212 count, gIndexType2GLType[indexType], indices, glPath Range->basePathID(),
186 fillMode, writeMask, GR_GL_BOUNDING_BOX_OF_BOUNDING_ BOXES, 213 fillMode, writeMask, GR_GL_BOUNDING_BOX_OF_BOUNDING_ BOXES,
187 gXformType2GLType[transformType], transformValues)); 214 gXformType2GLType[transformType], transformValues));
188 } 215 }
189 } 216 }
190 217
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
245 void GrGLPathRendering::setProgramPathFragmentInputTransform(GrGLuint program, G rGLint location, 218 void GrGLPathRendering::setProgramPathFragmentInputTransform(GrGLuint program, G rGLint location,
246 GrGLenum genMode, G rGLint components, 219 GrGLenum genMode, G rGLint components,
247 const SkMatrix& mat rix) { 220 const SkMatrix& mat rix) {
248 float coefficients[3 * 3]; 221 float coefficients[3 * 3];
249 SkASSERT(components >= 1 && components <= 3); 222 SkASSERT(components >= 1 && components <= 3);
250 223
251 coefficients[0] = SkScalarToFloat(matrix[SkMatrix::kMScaleX]); 224 coefficients[0] = SkScalarToFloat(matrix[SkMatrix::kMScaleX]);
252 coefficients[1] = SkScalarToFloat(matrix[SkMatrix::kMSkewX]); 225 coefficients[1] = SkScalarToFloat(matrix[SkMatrix::kMSkewX]);
253 coefficients[2] = SkScalarToFloat(matrix[SkMatrix::kMTransX]); 226 coefficients[2] = SkScalarToFloat(matrix[SkMatrix::kMTransX]);
254 227
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 funcMask != fHWPathStencilSettings.funcMask(kFront_Face)) { 333 funcMask != fHWPathStencilSettings.funcMask(kFront_Face)) {
361 GL_CALL(PathStencilFunc(GrToGLStencilFunc(func), funcRef, funcMask)) ; 334 GL_CALL(PathStencilFunc(GrToGLStencilFunc(func), funcRef, funcMask)) ;
362 } 335 }
363 fHWPathStencilSettings = stencilSettings; 336 fHWPathStencilSettings = stencilSettings;
364 } 337 }
365 } 338 }
366 339
367 inline GrGLGpu* GrGLPathRendering::gpu() { 340 inline GrGLGpu* GrGLPathRendering::gpu() {
368 return static_cast<GrGLGpu*>(fGpu); 341 return static_cast<GrGLGpu*>(fGpu);
369 } 342 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLPathRendering.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698