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

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

Issue 1110553003: Remove legacy NVPR support (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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
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/GrGLNameAllocator.h" 9 #include "gl/GrGLNameAllocator.h"
10 #include "gl/GrGLUtil.h" 10 #include "gl/GrGLUtil.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 fCaps.stencilThenCoverSupport = 65 fCaps.stencilThenCoverSupport =
66 NULL != glInterface->fFunctions.fStencilThenCoverFillPath && 66 NULL != glInterface->fFunctions.fStencilThenCoverFillPath &&
67 NULL != glInterface->fFunctions.fStencilThenCoverStrokePath && 67 NULL != glInterface->fFunctions.fStencilThenCoverStrokePath &&
68 NULL != glInterface->fFunctions.fStencilThenCoverFillPathInstanced && 68 NULL != glInterface->fFunctions.fStencilThenCoverFillPathInstanced &&
69 NULL != glInterface->fFunctions.fStencilThenCoverStrokePathInstanced; 69 NULL != glInterface->fFunctions.fStencilThenCoverStrokePathInstanced;
70 fCaps.fragmentInputGenSupport = 70 fCaps.fragmentInputGenSupport =
71 NULL != glInterface->fFunctions.fProgramPathFragmentInputGen; 71 NULL != glInterface->fFunctions.fProgramPathFragmentInputGen;
72 fCaps.glyphLoadingSupport = 72 fCaps.glyphLoadingSupport =
73 NULL != glInterface->fFunctions.fPathMemoryGlyphIndexArray; 73 NULL != glInterface->fFunctions.fPathMemoryGlyphIndexArray;
74 74
75 if (!fCaps.fragmentInputGenSupport) { 75 SkASSERT(fCaps.fragmentInputGenSupport);
76 fHWPathTexGenSettings.reset(fGpu->glCaps().maxFixedFunctionTextureCoords ());
77 }
78 } 76 }
79 77
80 GrGLPathRendering::~GrGLPathRendering() { 78 GrGLPathRendering::~GrGLPathRendering() {
81 } 79 }
82 80
83 void GrGLPathRendering::abandonGpuResources() { 81 void GrGLPathRendering::abandonGpuResources() {
84 fPathNameAllocator.reset(NULL); 82 fPathNameAllocator.reset(NULL);
85 } 83 }
86 84
87 void GrGLPathRendering::resetContext() { 85 void GrGLPathRendering::resetContext() {
88 fHWProjectionMatrixState.invalidate(); 86 fHWProjectionMatrixState.invalidate();
89 // we don't use the model view matrix. 87 // we don't use the model view matrix.
90 GrGLenum matrixMode = 88 GrGLenum matrixMode = GR_GL_PATH_MODELVIEW;
bsalomon 2015/04/27 17:10:20 I think this and the next line can be killed since
jvanverth1 2015/04/27 17:20:59 Don't we still want to ensure this matrix is ident
Chris Dalton 2015/04/27 17:33:18 Yeah, for "non-legacy" nvpr we still use the fixed
91 fGpu->glCaps().nvprSupport() == GrGLCaps::kNormal_NvprSupport ? GR_G L_PATH_MODELVIEW : 89
92 GR_G L_MODELVIEW;
93 GL_CALL(MatrixLoadIdentity(matrixMode)); 90 GL_CALL(MatrixLoadIdentity(matrixMode));
94 91
95 if (!caps().fragmentInputGenSupport) { 92 SkASSERT(fCaps.fragmentInputGenSupport);
96 for (int i = 0; i < fGpu->glCaps().maxFixedFunctionTextureCoords(); ++i) {
97 GL_CALL(PathTexGen(GR_GL_TEXTURE0 + i, GR_GL_NONE, 0, NULL));
98 fHWPathTexGenSettings[i].fMode = GR_GL_NONE;
99 fHWPathTexGenSettings[i].fNumComponents = 0;
100 }
101 fHWActivePathTexGenSets = 0;
102 }
103 fHWPathStencilSettings.invalidate(); 93 fHWPathStencilSettings.invalidate();
104 } 94 }
105 95
106 GrPath* GrGLPathRendering::createPath(const SkPath& inPath, const SkStrokeRec& s troke) { 96 GrPath* GrGLPathRendering::createPath(const SkPath& inPath, const SkStrokeRec& s troke) {
107 return SkNEW_ARGS(GrGLPath, (fGpu, inPath, stroke)); 97 return SkNEW_ARGS(GrGLPath, (fGpu, inPath, stroke));
108 } 98 }
109 99
110 GrPathRange* GrGLPathRendering::createPathRange(GrPathRange::PathGenerator* path Generator, 100 GrPathRange* GrGLPathRendering::createPathRange(GrPathRange::PathGenerator* path Generator,
111 const SkStrokeRec& stroke) { 101 const SkStrokeRec& stroke) {
112 return SkNEW_ARGS(GrGLPathRange, (fGpu, pathGenerator, stroke)); 102 return SkNEW_ARGS(GrGLPathRange, (fGpu, pathGenerator, stroke));
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 0xffff, writeMask, GR_GL_BOUNDING_BOX_OF_BOUNDING_BO XES, 225 0xffff, writeMask, GR_GL_BOUNDING_BOX_OF_BOUNDING_BO XES,
236 gXformType2GLType[transformType], transformValues); 226 gXformType2GLType[transformType], transformValues);
237 } else { 227 } else {
238 this->stencilThenCoverFillPathInstanced( 228 this->stencilThenCoverFillPathInstanced(
239 count, gIndexType2GLType[indexType], indices, baseID , 229 count, gIndexType2GLType[indexType], indices, baseID ,
240 fillMode, writeMask, GR_GL_BOUNDING_BOX_OF_BOUNDING_ BOXES, 230 fillMode, writeMask, GR_GL_BOUNDING_BOX_OF_BOUNDING_ BOXES,
241 gXformType2GLType[transformType], transformValues); 231 gXformType2GLType[transformType], transformValues);
242 } 232 }
243 } 233 }
244 234
245 void GrGLPathRendering::enablePathTexGen(int unitIdx, PathTexGenComponents compo nents,
246 const GrGLfloat* coefficients) {
247 SkASSERT(components >= kS_PathTexGenComponents &&
248 components <= kSTR_PathTexGenComponents);
249 SkASSERT(fGpu->glCaps().maxFixedFunctionTextureCoords() >= unitIdx);
250
251 if (GR_GL_OBJECT_LINEAR == fHWPathTexGenSettings[unitIdx].fMode &&
252 components == fHWPathTexGenSettings[unitIdx].fNumComponents &&
253 !memcmp(coefficients, fHWPathTexGenSettings[unitIdx].fCoefficients,
254 3 * components * sizeof(GrGLfloat))) {
255 return;
256 }
257
258 fGpu->setTextureUnit(unitIdx);
259
260 fHWPathTexGenSettings[unitIdx].fNumComponents = components;
261 GL_CALL(PathTexGen(GR_GL_TEXTURE0 + unitIdx, GR_GL_OBJECT_LINEAR, components , coefficients));
262
263 memcpy(fHWPathTexGenSettings[unitIdx].fCoefficients, coefficients,
264 3 * components * sizeof(GrGLfloat));
265 }
266
267 void GrGLPathRendering::enablePathTexGen(int unitIdx, PathTexGenComponents compo nents,
268 const SkMatrix& matrix) {
269 GrGLfloat coefficients[3 * 3];
270 SkASSERT(components >= kS_PathTexGenComponents &&
271 components <= kSTR_PathTexGenComponents);
272
273 coefficients[0] = SkScalarToFloat(matrix[SkMatrix::kMScaleX]);
274 coefficients[1] = SkScalarToFloat(matrix[SkMatrix::kMSkewX]);
275 coefficients[2] = SkScalarToFloat(matrix[SkMatrix::kMTransX]);
276
277 if (components >= kST_PathTexGenComponents) {
278 coefficients[3] = SkScalarToFloat(matrix[SkMatrix::kMSkewY]);
279 coefficients[4] = SkScalarToFloat(matrix[SkMatrix::kMScaleY]);
280 coefficients[5] = SkScalarToFloat(matrix[SkMatrix::kMTransY]);
281 }
282
283 if (components >= kSTR_PathTexGenComponents) {
284 coefficients[6] = SkScalarToFloat(matrix[SkMatrix::kMPersp0]);
285 coefficients[7] = SkScalarToFloat(matrix[SkMatrix::kMPersp1]);
286 coefficients[8] = SkScalarToFloat(matrix[SkMatrix::kMPersp2]);
287 }
288
289 this->enablePathTexGen(unitIdx, components, coefficients);
290 }
291
292 void GrGLPathRendering::flushPathTexGenSettings(int numUsedTexCoordSets) {
293 SkASSERT(fGpu->glCaps().maxFixedFunctionTextureCoords() >= numUsedTexCoordSe ts);
294
295 // Only write the inactive path tex gens, since active path tex gens were
296 // written when they were enabled.
297
298 SkDEBUGCODE(
299 for (int i = 0; i < numUsedTexCoordSets; i++) {
300 SkASSERT(0 != fHWPathTexGenSettings[i].fNumComponents);
301 }
302 );
303
304 for (int i = numUsedTexCoordSets; i < fHWActivePathTexGenSets; i++) {
305 SkASSERT(0 != fHWPathTexGenSettings[i].fNumComponents);
306
307 fGpu->setTextureUnit(i);
308 GL_CALL(PathTexGen(GR_GL_TEXTURE0 + i, GR_GL_NONE, 0, NULL));
309 fHWPathTexGenSettings[i].fNumComponents = 0;
310 }
311
312 fHWActivePathTexGenSets = numUsedTexCoordSets;
313 }
314
315 void GrGLPathRendering::setProgramPathFragmentInputTransform(GrGLuint program, G rGLint location, 235 void GrGLPathRendering::setProgramPathFragmentInputTransform(GrGLuint program, G rGLint location,
316 GrGLenum genMode, G rGLint components, 236 GrGLenum genMode, G rGLint components,
317 const SkMatrix& mat rix) { 237 const SkMatrix& mat rix) {
318 SkASSERT(caps().fragmentInputGenSupport); 238 SkASSERT(caps().fragmentInputGenSupport);
319 GrGLfloat coefficients[3 * 3]; 239 GrGLfloat coefficients[3 * 3];
320 SkASSERT(components >= 1 && components <= 3); 240 SkASSERT(components >= 1 && components <= 3);
321 241
322 coefficients[0] = SkScalarToFloat(matrix[SkMatrix::kMScaleX]); 242 coefficients[0] = SkScalarToFloat(matrix[SkMatrix::kMScaleX]);
323 coefficients[1] = SkScalarToFloat(matrix[SkMatrix::kMSkewX]); 243 coefficients[1] = SkScalarToFloat(matrix[SkMatrix::kMSkewX]);
324 coefficients[2] = SkScalarToFloat(matrix[SkMatrix::kMTransX]); 244 coefficients[2] = SkScalarToFloat(matrix[SkMatrix::kMTransX]);
(...skipping 24 matching lines...) Expand all
349 matrix.cheapEqualTo(fHWProjectionMatrixState.fViewMatrix)) { 269 matrix.cheapEqualTo(fHWProjectionMatrixState.fViewMatrix)) {
350 return; 270 return;
351 } 271 }
352 272
353 fHWProjectionMatrixState.fViewMatrix = matrix; 273 fHWProjectionMatrixState.fViewMatrix = matrix;
354 fHWProjectionMatrixState.fRenderTargetSize = renderTargetSize; 274 fHWProjectionMatrixState.fRenderTargetSize = renderTargetSize;
355 fHWProjectionMatrixState.fRenderTargetOrigin = renderTargetOrigin; 275 fHWProjectionMatrixState.fRenderTargetOrigin = renderTargetOrigin;
356 276
357 GrGLfloat glMatrix[4 * 4]; 277 GrGLfloat glMatrix[4 * 4];
358 fHWProjectionMatrixState.getRTAdjustedGLMatrix<4>(glMatrix); 278 fHWProjectionMatrixState.getRTAdjustedGLMatrix<4>(glMatrix);
359 GrGLenum matrixMode = 279 GrGLenum matrixMode = GR_GL_PATH_PROJECTION;
360 fGpu->glCaps().nvprSupport() == GrGLCaps::kNormal_NvprSupport ? GR_ GL_PATH_PROJECTION : 280 GL_CALL(MatrixLoadf(matrixMode, glMatrix));
361 GR_ GL_PROJECTION;
362 GL_CALL(MatrixLoadf(matrixMode, glMatrix));
363 } 281 }
364 282
365 GrGLuint GrGLPathRendering::genPaths(GrGLsizei range) { 283 GrGLuint GrGLPathRendering::genPaths(GrGLsizei range) {
366 if (range > 1) { 284 if (range > 1) {
367 GrGLuint name; 285 GrGLuint name;
368 GL_CALL_RET(name, GenPaths(range)); 286 GL_CALL_RET(name, GenPaths(range));
369 return name; 287 return name;
370 } 288 }
371 289
372 if (NULL == fPathNameAllocator.get()) { 290 if (NULL == fPathNameAllocator.get()) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 reference, mask, coverMode, transformType, 388 reference, mask, coverMode, transformType,
471 transformValues)); 389 transformValues));
472 return; 390 return;
473 } 391 }
474 392
475 GL_CALL(StencilStrokePathInstanced(numPaths, pathNameType, paths, pathBase, 393 GL_CALL(StencilStrokePathInstanced(numPaths, pathNameType, paths, pathBase,
476 reference, mask, transformType, transform Values)); 394 reference, mask, transformType, transform Values));
477 GL_CALL(CoverStrokePathInstanced(numPaths, pathNameType, paths, pathBase, 395 GL_CALL(CoverStrokePathInstanced(numPaths, pathNameType, paths, pathBase,
478 coverMode, transformType, transformValues)) ; 396 coverMode, transformType, transformValues)) ;
479 } 397 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698