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

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

Issue 367643004: Implement NVPR on GLES (Closed) Base URL: https://skia.googlesource.com/skia.git@02-path-program-fragment
Patch Set: rebse Created 6 years, 4 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 GrGLPathRendering::GrGLPathRendering(GrGpuGL* gpu) 48 GrGLPathRendering::GrGLPathRendering(GrGpuGL* gpu)
49 : fGpu(gpu) { 49 : fGpu(gpu) {
50 const GrGLInterface* glInterface = gpu->glInterface(); 50 const GrGLInterface* glInterface = gpu->glInterface();
51 fCaps.stencilThenCoverSupport = 51 fCaps.stencilThenCoverSupport =
52 NULL != glInterface->fFunctions.fStencilThenCoverFillPath && 52 NULL != glInterface->fFunctions.fStencilThenCoverFillPath &&
53 NULL != glInterface->fFunctions.fStencilThenCoverStrokePath && 53 NULL != glInterface->fFunctions.fStencilThenCoverStrokePath &&
54 NULL != glInterface->fFunctions.fStencilThenCoverFillPathInstanced && 54 NULL != glInterface->fFunctions.fStencilThenCoverFillPathInstanced &&
55 NULL != glInterface->fFunctions.fStencilThenCoverStrokePathInstanced; 55 NULL != glInterface->fFunctions.fStencilThenCoverStrokePathInstanced;
56 fCaps.fragmentInputGenSupport = 56 fCaps.fragmentInputGenSupport =
57 kGLES_GrGLStandard == glInterface->fStandard &&
57 NULL != glInterface->fFunctions.fProgramPathFragmentInputGen; 58 NULL != glInterface->fFunctions.fProgramPathFragmentInputGen;
58 fHWPathTexGenSettings.reset(fGpu->glCaps().maxFixedFunctionTextureCoords()); 59
60 if (!fCaps.fragmentInputGenSupport) {
61 fHWPathTexGenSettings.reset(fGpu->glCaps().maxFixedFunctionTextureCoords ());
62 }
59 } 63 }
60 64
61 GrGLPathRendering::~GrGLPathRendering() { 65 GrGLPathRendering::~GrGLPathRendering() {
62 } 66 }
63 67
64 void GrGLPathRendering::abandonGpuResources() { 68 void GrGLPathRendering::abandonGpuResources() {
65 fPathNameAllocator.reset(NULL); 69 fPathNameAllocator.reset(NULL);
66 } 70 }
67 71
68 void GrGLPathRendering::resetContext() { 72 void GrGLPathRendering::resetContext() {
69 fHWProjectionMatrixState.invalidate(); 73 fHWProjectionMatrixState.invalidate();
70 // we don't use the model view matrix. 74 // we don't use the model view matrix.
71 GL_CALL(MatrixLoadIdentity(GR_GL_MODELVIEW)); 75 GrGLenum matrixMode =
76 fGpu->glStandard() == kGLES_GrGLStandard ? GR_GL_PATH_MODELVIEW : GR_GL_ MODELVIEW;
77 GL_CALL(MatrixLoadIdentity(matrixMode));
72 78
73 for (int i = 0; i < fGpu->glCaps().maxFixedFunctionTextureCoords(); ++i) { 79 if (!caps().fragmentInputGenSupport) {
74 GL_CALL(PathTexGen(GR_GL_TEXTURE0 + i, GR_GL_NONE, 0, NULL)); 80 for (int i = 0; i < fGpu->glCaps().maxFixedFunctionTextureCoords(); ++i) {
75 fHWPathTexGenSettings[i].fMode = GR_GL_NONE; 81 GL_CALL(PathTexGen(GR_GL_TEXTURE0 + i, GR_GL_NONE, 0, NULL));
76 fHWPathTexGenSettings[i].fNumComponents = 0; 82 fHWPathTexGenSettings[i].fMode = GR_GL_NONE;
83 fHWPathTexGenSettings[i].fNumComponents = 0;
84 }
85 fHWActivePathTexGenSets = 0;
77 } 86 }
78 fHWActivePathTexGenSets = 0;
79 fHWPathStencilSettings.invalidate(); 87 fHWPathStencilSettings.invalidate();
80 } 88 }
81 89
82 GrPath* GrGLPathRendering::createPath(const SkPath& inPath, const SkStrokeRec& s troke) { 90 GrPath* GrGLPathRendering::createPath(const SkPath& inPath, const SkStrokeRec& s troke) {
83 return SkNEW_ARGS(GrGLPath, (fGpu, inPath, stroke)); 91 return SkNEW_ARGS(GrGLPath, (fGpu, inPath, stroke));
84 } 92 }
85 93
86 GrPathRange* GrGLPathRendering::createPathRange(size_t size, const SkStrokeRec& stroke) { 94 GrPathRange* GrGLPathRendering::createPathRange(size_t size, const SkStrokeRec& stroke) {
87 return SkNEW_ARGS(GrGLPathRange, (fGpu, size, stroke)); 95 return SkNEW_ARGS(GrGLPathRange, (fGpu, size, stroke));
88 } 96 }
89 97
90 void GrGLPathRendering::stencilPath(const GrPath* path, SkPath::FillType fill) { 98 void GrGLPathRendering::stencilPath(const GrPath* path, SkPath::FillType fill) {
91 GrGLuint id = static_cast<const GrGLPath*>(path)->pathID(); 99 GrGLuint id = static_cast<const GrGLPath*>(path)->pathID();
92 SkASSERT(NULL != fGpu->drawState()->getRenderTarget()); 100 SkASSERT(NULL != fGpu->drawState()->getRenderTarget());
93 SkASSERT(NULL != fGpu->drawState()->getRenderTarget()->getStencilBuffer()); 101 SkASSERT(NULL != fGpu->drawState()->getRenderTarget()->getStencilBuffer());
94 102
95 this->flushPathStencilSettings(fill); 103 this->flushPathStencilSettings(fill);
96 SkASSERT(!fHWPathStencilSettings.isTwoSided()); 104 SkASSERT(!fHWPathStencilSettings.isTwoSided());
97 105
98 GrGLenum fillMode = 106 GrGLenum fillMode =
99 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.pass Op(GrStencilSettings::kFront_Face)); 107 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.pass Op(GrStencilSettings::kFront_Face));
100 GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFro nt_Face); 108 GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFro nt_Face);
101 GL_CALL(StencilFillPath(id, fillMode, writeMask)); 109 GL_CALL(StencilFillPath(id, fillMode, writeMask));
102 } 110 }
103 111
104 void GrGLPathRendering::drawPath(const GrPath* path, SkPath::FillType fill) { 112 void GrGLPathRendering::drawPath(const GrPath* path, SkPath::FillType fill) {
105 GrGLuint id = static_cast<const GrGLPath*>(path)->pathID(); 113 GrGLuint id = static_cast<const GrGLPath*>(path)->pathID();
106 SkASSERT(NULL != fGpu->drawState()->getRenderTarget()); 114 SkASSERT(NULL != fGpu->drawState()->getRenderTarget());
107 SkASSERT(NULL != fGpu->drawState()->getRenderTarget()->getStencilBuffer()); 115 SkASSERT(NULL != fGpu->drawState()->getRenderTarget()->getStencilBuffer());
108 SkASSERT(!fGpu->fCurrentProgram->hasVertexShader());
109 116
110 this->flushPathStencilSettings(fill); 117 this->flushPathStencilSettings(fill);
111 SkASSERT(!fHWPathStencilSettings.isTwoSided()); 118 SkASSERT(!fHWPathStencilSettings.isTwoSided());
112 119
113 const SkStrokeRec& stroke = path->getStroke(); 120 const SkStrokeRec& stroke = path->getStroke();
114 121
115 SkPath::FillType nonInvertedFill = SkPath::ConvertToNonInverseFillType(fill) ; 122 SkPath::FillType nonInvertedFill = SkPath::ConvertToNonInverseFillType(fill) ;
116 123
117 GrGLenum fillMode = 124 GrGLenum fillMode =
118 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.pass Op(GrStencilSettings::kFront_Face)); 125 gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.pass Op(GrStencilSettings::kFront_Face));
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 fGpu->drawSimpleRect(bounds); 162 fGpu->drawSimpleRect(bounds);
156 } 163 }
157 } 164 }
158 165
159 void GrGLPathRendering::drawPaths(const GrPathRange* pathRange, const uint32_t i ndices[], int count, 166 void GrGLPathRendering::drawPaths(const GrPathRange* pathRange, const uint32_t i ndices[], int count,
160 const float transforms[], PathTransformType tr ansformsType, 167 const float transforms[], PathTransformType tr ansformsType,
161 SkPath::FillType fill) { 168 SkPath::FillType fill) {
162 SkASSERT(fGpu->caps()->pathRenderingSupport()); 169 SkASSERT(fGpu->caps()->pathRenderingSupport());
163 SkASSERT(NULL != fGpu->drawState()->getRenderTarget()); 170 SkASSERT(NULL != fGpu->drawState()->getRenderTarget());
164 SkASSERT(NULL != fGpu->drawState()->getRenderTarget()->getStencilBuffer()); 171 SkASSERT(NULL != fGpu->drawState()->getRenderTarget()->getStencilBuffer());
165 SkASSERT(!fGpu->fCurrentProgram->hasVertexShader());
166 172
167 GrGLuint baseID = static_cast<const GrGLPathRange*>(pathRange)->basePathID() ; 173 GrGLuint baseID = static_cast<const GrGLPathRange*>(pathRange)->basePathID() ;
168 174
169 this->flushPathStencilSettings(fill); 175 this->flushPathStencilSettings(fill);
170 SkASSERT(!fHWPathStencilSettings.isTwoSided()); 176 SkASSERT(!fHWPathStencilSettings.isTwoSided());
171 177
172 const SkStrokeRec& stroke = pathRange->getStroke(); 178 const SkStrokeRec& stroke = pathRange->getStroke();
173 179
174 SkPath::FillType nonInvertedFill = 180 SkPath::FillType nonInvertedFill =
175 SkPath::ConvertToNonInverseFillType(fill); 181 SkPath::ConvertToNonInverseFillType(fill);
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 matrix.cheapEqualTo(fHWProjectionMatrixState.fViewMatrix)) { 346 matrix.cheapEqualTo(fHWProjectionMatrixState.fViewMatrix)) {
341 return; 347 return;
342 } 348 }
343 349
344 fHWProjectionMatrixState.fViewMatrix = matrix; 350 fHWProjectionMatrixState.fViewMatrix = matrix;
345 fHWProjectionMatrixState.fRenderTargetSize = renderTargetSize; 351 fHWProjectionMatrixState.fRenderTargetSize = renderTargetSize;
346 fHWProjectionMatrixState.fRenderTargetOrigin = renderTargetOrigin; 352 fHWProjectionMatrixState.fRenderTargetOrigin = renderTargetOrigin;
347 353
348 GrGLfloat glMatrix[4 * 4]; 354 GrGLfloat glMatrix[4 * 4];
349 fHWProjectionMatrixState.getRTAdjustedGLMatrix<4>(glMatrix); 355 fHWProjectionMatrixState.getRTAdjustedGLMatrix<4>(glMatrix);
350 GL_CALL(MatrixLoadf(GR_GL_PROJECTION, glMatrix)); 356 GrGLenum matrixMode =
357 fGpu->glStandard() == kGLES_GrGLStandard ? GR_GL_PATH_PROJECTION : GR_G L_PROJECTION;
358 GL_CALL(MatrixLoadf(matrixMode, glMatrix));
351 } 359 }
352 360
353 GrGLuint GrGLPathRendering::genPaths(GrGLsizei range) { 361 GrGLuint GrGLPathRendering::genPaths(GrGLsizei range) {
354 if (range > 1) { 362 if (range > 1) {
355 GrGLuint name; 363 GrGLuint name;
356 GL_CALL_RET(name, GenPaths(range)); 364 GL_CALL_RET(name, GenPaths(range));
357 return name; 365 return name;
358 } 366 }
359 367
360 if (NULL == fPathNameAllocator.get()) { 368 if (NULL == fPathNameAllocator.get()) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 reference, mask, coverMode, transformType, 468 reference, mask, coverMode, transformType,
461 transformValues)); 469 transformValues));
462 return; 470 return;
463 } 471 }
464 472
465 GL_CALL(StencilStrokePathInstanced(numPaths, pathNameType, paths, pathBase, 473 GL_CALL(StencilStrokePathInstanced(numPaths, pathNameType, paths, pathBase,
466 reference, mask, transformType, transform Values)); 474 reference, mask, transformType, transform Values));
467 GL_CALL(CoverStrokePathInstanced(numPaths, pathNameType, paths, pathBase, 475 GL_CALL(CoverStrokePathInstanced(numPaths, pathNameType, paths, pathBase,
468 coverMode, transformType, transformValues)) ; 476 coverMode, transformType, transformValues)) ;
469 } 477 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698