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

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

Issue 611653002: Cleanup of shader building system (Closed) Base URL: https://skia.googlesource.com/skia.git@solo_gp
Patch Set: Created 6 years, 2 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/GrGLProgram.h ('k') | src/gpu/gl/GrGLProgramDataManager.h » ('j') | 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 2011 Google Inc. 2 * Copyright 2011 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 "GrGLProgram.h" 8 #include "GrGLProgram.h"
9 9
10 #include "builders/GrGLFullProgramBuilder.h"
11 #include "builders/GrGLFragmentOnlyProgramBuilder.h"
12 #include "GrAllocator.h" 10 #include "GrAllocator.h"
13 #include "GrProcessor.h" 11 #include "GrProcessor.h"
14 #include "GrCoordTransform.h" 12 #include "GrCoordTransform.h"
15 #include "GrGLProcessor.h" 13 #include "GrGLProcessor.h"
16 #include "GrGpuGL.h" 14 #include "GrGpuGL.h"
17 #include "GrGLPathRendering.h" 15 #include "GrGLPathRendering.h"
18 #include "GrGLShaderVar.h" 16 #include "GrGLShaderVar.h"
19 #include "GrGLSL.h" 17 #include "GrGLSL.h"
20 #include "GrOptDrawState.h" 18 #include "GrOptDrawState.h"
21 #include "SkXfermode.h" 19 #include "SkXfermode.h"
22 20
23 #define GL_CALL(X) GR_GL_CALL(fGpu->glInterface(), X) 21 #define GL_CALL(X) GR_GL_CALL(fGpu->glInterface(), X)
24 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(fGpu->glInterface(), R, X) 22 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(fGpu->glInterface(), R, X)
25 23
26 GrGLProgram* GrGLProgram::Create(GrGpuGL* gpu, 24 /**
27 const GrOptDrawState& optState, 25 * Retrieves the final matrix that a transform needs to apply to its source coor ds.
28 const GrGLProgramDesc& desc, 26 */
29 const GrGeometryStage* geometryProcessor, 27 static SkMatrix get_transform_matrix(const GrProcessorStage& processorStage,
30 const GrFragmentStage* colorStages[], 28 bool useExplicitLocalCoords,
31 const GrFragmentStage* coverageStages[]) { 29 int transformIdx) {
32 SkAutoTDelete<GrGLProgramBuilder> builder; 30 const GrCoordTransform& coordTransform =
33 if (desc.getHeader().fUseFragShaderOnly) { 31 processorStage.getProcessor()->coordTransform(transformIdx);
34 SkASSERT(gpu->glCaps().pathRenderingSupport()); 32 SkMatrix combined;
35 SkASSERT(gpu->glPathRendering()->texturingMode() == 33
36 GrGLPathRendering::FixedFunction_TexturingMode); 34 if (kLocal_GrCoordSet == coordTransform.sourceCoords()) {
37 SkASSERT(NULL == geometryProcessor); 35 // If we have explicit local coords then we shouldn't need a coord chang e.
38 builder.reset(SkNEW_ARGS(GrGLFragmentOnlyProgramBuilder, (gpu, optState, desc))); 36 const SkMatrix& ccm =
37 useExplicitLocalCoords ? SkMatrix::I() : processorStage.getCoord ChangeMatrix();
38 combined.setConcat(coordTransform.getMatrix(), ccm);
39 } else { 39 } else {
40 builder.reset(SkNEW_ARGS(GrGLFullProgramBuilder, (gpu, optState, desc))) ; 40 combined = coordTransform.getMatrix();
41 } 41 }
42 if (builder->genProgram(geometryProcessor, colorStages, coverageStages)) { 42 if (coordTransform.reverseY()) {
43 SkASSERT(0 != builder->getProgramID()); 43 // combined.postScale(1,-1);
44 return SkNEW_ARGS(GrGLProgram, (gpu, desc, *builder)); 44 // combined.postTranslate(0,1);
45 combined.set(SkMatrix::kMSkewY,
46 combined[SkMatrix::kMPersp0] - combined[SkMatrix::kMSkewY]);
47 combined.set(SkMatrix::kMScaleY,
48 combined[SkMatrix::kMPersp1] - combined[SkMatrix::kMScaleY]);
49 combined.set(SkMatrix::kMTransY,
50 combined[SkMatrix::kMPersp2] - combined[SkMatrix::kMTransY]);
45 } 51 }
46 return NULL; 52 return combined;
47 } 53 }
48 54
55 //////////////////////////////////////////////////////////////////////////////// ///////////////////
56
49 GrGLProgram::GrGLProgram(GrGpuGL* gpu, 57 GrGLProgram::GrGLProgram(GrGpuGL* gpu,
50 const GrGLProgramDesc& desc, 58 const GrGLProgramDesc& desc,
51 const GrGLProgramBuilder& builder) 59 const BuiltinUniformHandles& builtinUniforms,
60 GrGLuint programID,
61 const UniformInfoArray& uniforms,
62 GrGLInstalledProcessors* geometryProcessor,
63 GrGLInstalledProcessors* colorProcessors,
64 GrGLInstalledProcessors* coverageProcessors)
52 : fColor(GrColor_ILLEGAL) 65 : fColor(GrColor_ILLEGAL)
53 , fCoverage(GrColor_ILLEGAL) 66 , fCoverage(GrColor_ILLEGAL)
54 , fDstCopyTexUnit(-1) 67 , fDstCopyTexUnit(-1)
55 , fBuiltinUniformHandles(builder.getBuiltinUniformHandles()) 68 , fBuiltinUniformHandles(builtinUniforms)
56 , fGeometryProcessor(SkSafeRef(builder.getGeometryProcessor())) 69 , fProgramID(programID)
57 , fColorEffects(SkRef(builder.getColorEffects())) 70 , fGeometryProcessor(SkSafeRef(geometryProcessor))
58 , fCoverageEffects(SkRef(builder.getCoverageEffects())) 71 , fColorEffects(SkRef(colorProcessors))
59 , fProgramID(builder.getProgramID()) 72 , fCoverageEffects(SkRef(coverageProcessors))
60 , fHasVertexShader(builder.hasVertexShader())
61 , fTexCoordSetCnt(builder.getTexCoordSetCount())
62 , fDesc(desc) 73 , fDesc(desc)
63 , fGpu(gpu) 74 , fGpu(gpu)
64 , fProgramDataManager(gpu, this, builder) { 75 , fProgramDataManager(gpu, uniforms) {
65 this->initSamplerUniforms(); 76 this->initSamplerUniforms();
66 } 77 }
67 78
68 GrGLProgram::~GrGLProgram() { 79 GrGLProgram::~GrGLProgram() {
69 if (fProgramID) { 80 if (fProgramID) {
70 GL_CALL(DeleteProgram(fProgramID)); 81 GL_CALL(DeleteProgram(fProgramID));
71 } 82 }
72 } 83 }
73 84
74 void GrGLProgram::abandon() { 85 void GrGLProgram::abandon() {
75 fProgramID = 0; 86 fProgramID = 0;
76 } 87 }
77 88
78 void GrGLProgram::initSamplerUniforms() { 89 void GrGLProgram::initSamplerUniforms() {
79 GL_CALL(UseProgram(fProgramID)); 90 GL_CALL(UseProgram(fProgramID));
80 GrGLint texUnitIdx = 0; 91 GrGLint texUnitIdx = 0;
81 if (fBuiltinUniformHandles.fDstCopySamplerUni.isValid()) { 92 if (fBuiltinUniformHandles.fDstCopySamplerUni.isValid()) {
82 fProgramDataManager.setSampler(fBuiltinUniformHandles.fDstCopySamplerUni , texUnitIdx); 93 fProgramDataManager.setSampler(fBuiltinUniformHandles.fDstCopySamplerUni , texUnitIdx);
83 fDstCopyTexUnit = texUnitIdx++; 94 fDstCopyTexUnit = texUnitIdx++;
84 } 95 }
85 if (fGeometryProcessor.get()) { 96 if (fGeometryProcessor.get()) {
86 fGeometryProcessor->initSamplers(fProgramDataManager, &texUnitIdx); 97 this->initSamplers(fGeometryProcessor.get(), &texUnitIdx);
87 } 98 }
88 fColorEffects->initSamplers(fProgramDataManager, &texUnitIdx); 99 this->initSamplers(fColorEffects.get(), &texUnitIdx);
89 fCoverageEffects->initSamplers(fProgramDataManager, &texUnitIdx); 100 this->initSamplers(fCoverageEffects.get(), &texUnitIdx);
90 } 101 }
91 102
103 void GrGLProgram::initSamplers(GrGLInstalledProcessors* ip, int* texUnitIdx) {
104 int numEffects = ip->fGLProcessors.count();
105 SkASSERT(numEffects == ip->fSamplers.count());
106 for (int e = 0; e < numEffects; ++e) {
107 SkTArray<GrGLInstalledProcessors::Sampler, true>& samplers = ip->fSample rs[e];
108 int numSamplers = samplers.count();
109 for (int s = 0; s < numSamplers; ++s) {
110 SkASSERT(samplers[s].fUniform.isValid());
111 fProgramDataManager.setSampler(samplers[s].fUniform, *texUnitIdx);
112 samplers[s].fTextureUnit = (*texUnitIdx)++;
113 }
114 }
115 }
116
117 void GrGLProgram::bindTextures(const GrGLInstalledProcessors* ip,
118 const GrProcessor& processor,
119 int effectIdx) {
120 const SkTArray<GrGLInstalledProcessors::Sampler, true>& samplers = ip->fSamp lers[effectIdx];
121 int numSamplers = samplers.count();
122 SkASSERT(numSamplers == processor.numTextures());
123 for (int s = 0; s < numSamplers; ++s) {
124 SkASSERT(samplers[s].fTextureUnit >= 0);
125 const GrTextureAccess& textureAccess = processor.textureAccess(s);
126 fGpu->bindTexture(samplers[s].fTextureUnit,
127 textureAccess.getParams(),
128 static_cast<GrGLTexture*>(textureAccess.getTexture())) ;
129 }
130 }
131
132
92 /////////////////////////////////////////////////////////////////////////////// 133 ///////////////////////////////////////////////////////////////////////////////
93 134
94 void GrGLProgram::setData(const GrOptDrawState& optState, 135 void GrGLProgram::setData(const GrOptDrawState& optState,
95 GrGpu::DrawType drawType, 136 GrGpu::DrawType drawType,
96 const GrGeometryStage* geometryProcessor, 137 const GrGeometryStage* geometryProcessor,
97 const GrFragmentStage* colorStages[], 138 const GrFragmentStage* colorStages[],
98 const GrFragmentStage* coverageStages[], 139 const GrFragmentStage* coverageStages[],
99 const GrDeviceCoordTexture* dstCopy, 140 const GrDeviceCoordTexture* dstCopy,
100 SharedGLState* sharedState) { 141 SharedGLState* sharedState) {
101 GrColor color = optState.getColor(); 142 GrColor color = optState.getColor();
(...skipping 17 matching lines...) Expand all
119 } else { 160 } else {
120 SkASSERT(!fBuiltinUniformHandles.fDstCopyScaleUni.isValid()); 161 SkASSERT(!fBuiltinUniformHandles.fDstCopyScaleUni.isValid());
121 SkASSERT(!fBuiltinUniformHandles.fDstCopySamplerUni.isValid()); 162 SkASSERT(!fBuiltinUniformHandles.fDstCopySamplerUni.isValid());
122 } 163 }
123 } else { 164 } else {
124 SkASSERT(!fBuiltinUniformHandles.fDstCopyTopLeftUni.isValid()); 165 SkASSERT(!fBuiltinUniformHandles.fDstCopyTopLeftUni.isValid());
125 SkASSERT(!fBuiltinUniformHandles.fDstCopyScaleUni.isValid()); 166 SkASSERT(!fBuiltinUniformHandles.fDstCopyScaleUni.isValid());
126 SkASSERT(!fBuiltinUniformHandles.fDstCopySamplerUni.isValid()); 167 SkASSERT(!fBuiltinUniformHandles.fDstCopySamplerUni.isValid());
127 } 168 }
128 169
170 // we set the textures, and uniforms for installed processors in a generic w ay, but subclasses
171 // of GLProgram determine how to set coord transforms
129 if (fGeometryProcessor.get()) { 172 if (fGeometryProcessor.get()) {
130 SkASSERT(geometryProcessor); 173 SkASSERT(geometryProcessor);
131 fGeometryProcessor->setData(fGpu, drawType, fProgramDataManager, geometr yProcessor); 174 this->setData<GrGeometryStage>(&geometryProcessor, fGeometryProcessor.ge t());
132 } 175 }
133 fColorEffects->setData(fGpu, drawType, fProgramDataManager, colorStages); 176 this->setData<GrFragmentStage>(colorStages, fColorEffects.get());
134 fCoverageEffects->setData(fGpu, drawType, fProgramDataManager, coverageStage s); 177 this->setData<GrFragmentStage>(coverageStages, fCoverageEffects.get());
135 178
136 // PathTexGen state applies to the the fixed function vertex shader. For 179 // Some of GrGLProgram subclasses need to update state here
137 // custom shaders, it's ignored, so we don't need to change the texgen 180 this->didSetData(drawType);
138 // settings in that case. 181 }
139 if (!fHasVertexShader) { 182
140 fGpu->glPathRendering()->flushPathTexGenSettings(fTexCoordSetCnt); 183 void GrGLProgram::setTransformData(const GrProcessorStage& processor,
184 int effectIdx,
185 GrGLInstalledProcessors* ip) {
186 SkTArray<GrGLInstalledProcessors::Transform, true>& transforms = ip->fTransf orms[effectIdx];
187 int numTransforms = transforms.count();
188 SkASSERT(numTransforms == processor.getProcessor()->numTransforms());
189 for (int t = 0; t < numTransforms; ++t) {
190 SkASSERT(transforms[t].fHandle.isValid());
191 const SkMatrix& matrix = get_transform_matrix(processor, ip->fHasExplici tLocalCoords, t);
192 if (!transforms[t].fCurrentValue.cheapEqualTo(matrix)) {
193 fProgramDataManager.setSkMatrix(transforms[t].fHandle.convertToUnifo rmHandle(), matrix);
194 transforms[t].fCurrentValue = matrix;
195 }
141 } 196 }
142 } 197 }
143 198
199 void GrGLProgram::didSetData(GrGpu::DrawType drawType) {
200 SkASSERT(!GrGpu::IsPathRenderingDrawType(drawType));
201 }
202
144 void GrGLProgram::setColor(const GrOptDrawState& optState, 203 void GrGLProgram::setColor(const GrOptDrawState& optState,
145 GrColor color, 204 GrColor color,
146 SharedGLState* sharedState) { 205 SharedGLState* sharedState) {
147 const GrGLProgramDesc::KeyHeader& header = fDesc.getHeader(); 206 const GrGLProgramDesc::KeyHeader& header = fDesc.getHeader();
148 if (!optState.hasColorVertexAttribute()) { 207 if (!optState.hasColorVertexAttribute()) {
149 switch (header.fColorInput) { 208 switch (header.fColorInput) {
150 case GrGLProgramDesc::kAttribute_ColorInput: 209 case GrGLProgramDesc::kAttribute_ColorInput:
151 SkASSERT(-1 != header.fColorAttributeIndex); 210 SkASSERT(-1 != header.fColorAttributeIndex);
152 if (sharedState->fConstAttribColor != color || 211 if (sharedState->fConstAttribColor != color ||
153 sharedState->fConstAttribColorIndex != header.fColorAttribut eIndex) { 212 sharedState->fConstAttribColorIndex != header.fColorAttribut eIndex) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 default: 272 default:
214 SkFAIL("Unexpected coverage type."); 273 SkFAIL("Unexpected coverage type.");
215 } 274 }
216 } else { 275 } else {
217 sharedState->fConstAttribCoverageIndex = -1; 276 sharedState->fConstAttribCoverageIndex = -1;
218 } 277 }
219 } 278 }
220 279
221 void GrGLProgram::setMatrixAndRenderTargetHeight(GrGpu::DrawType drawType, 280 void GrGLProgram::setMatrixAndRenderTargetHeight(GrGpu::DrawType drawType,
222 const GrOptDrawState& optState) { 281 const GrOptDrawState& optState) {
282 // Load the RT height uniform if it is needed to y-flip gl_FragCoord.
283 if (fBuiltinUniformHandles.fRTHeightUni.isValid() &&
284 fMatrixState.fRenderTargetSize.fHeight != optState.getRenderTarget()->he ight()) {
285 fProgramDataManager.set1f(fBuiltinUniformHandles.fRTHeightUni,
286 SkIntToScalar(optState.getRenderTarget()->hei ght()));
287 }
288
289 // call subclasses to set the actual view matrix
290 this->onSetMatrixAndRenderTargetHeight(drawType, optState);
291 }
292
293 void GrGLProgram::onSetMatrixAndRenderTargetHeight(GrGpu::DrawType drawType,
294 const GrOptDrawState& optStat e) {
223 const GrRenderTarget* rt = optState.getRenderTarget(); 295 const GrRenderTarget* rt = optState.getRenderTarget();
224 SkISize size; 296 SkISize size;
225 size.set(rt->width(), rt->height()); 297 size.set(rt->width(), rt->height());
226 298 if (fMatrixState.fRenderTargetOrigin != rt->origin() ||
227 // Load the RT height uniform if it is needed to y-flip gl_FragCoord. 299 fMatrixState.fRenderTargetSize != size ||
228 if (fBuiltinUniformHandles.fRTHeightUni.isValid() && 300 !fMatrixState.fViewMatrix.cheapEqualTo(optState.getViewMatrix())) {
229 fMatrixState.fRenderTargetSize.fHeight != size.fHeight) {
230 fProgramDataManager.set1f(fBuiltinUniformHandles.fRTHeightUni,
231 SkIntToScalar(size.fHeight));
232 }
233
234 if (GrGpu::IsPathRenderingDrawType(drawType)) {
235 fGpu->glPathRendering()->setProjectionMatrix(optState.getViewMatrix(), s ize, rt->origin());
236 } else if (fMatrixState.fRenderTargetOrigin != rt->origin() ||
237 fMatrixState.fRenderTargetSize != size ||
238 !fMatrixState.fViewMatrix.cheapEqualTo(optState.getViewMatrix())) {
239 SkASSERT(fBuiltinUniformHandles.fViewMatrixUni.isValid()); 301 SkASSERT(fBuiltinUniformHandles.fViewMatrixUni.isValid());
240 302
241 fMatrixState.fViewMatrix = optState.getViewMatrix(); 303 fMatrixState.fViewMatrix = optState.getViewMatrix();
242 fMatrixState.fRenderTargetSize = size; 304 fMatrixState.fRenderTargetSize = size;
243 fMatrixState.fRenderTargetOrigin = rt->origin(); 305 fMatrixState.fRenderTargetOrigin = rt->origin();
244 306
245 GrGLfloat viewMatrix[3 * 3]; 307 GrGLfloat viewMatrix[3 * 3];
246 fMatrixState.getGLMatrix<3>(viewMatrix); 308 fMatrixState.getGLMatrix<3>(viewMatrix);
247 fProgramDataManager.setMatrix3f(fBuiltinUniformHandles.fViewMatrixUni, v iewMatrix); 309 fProgramDataManager.setMatrix3f(fBuiltinUniformHandles.fViewMatrixUni, v iewMatrix);
248 310
249 GrGLfloat rtAdjustmentVec[4]; 311 GrGLfloat rtAdjustmentVec[4];
250 fMatrixState.getRTAdjustmentVec(rtAdjustmentVec); 312 fMatrixState.getRTAdjustmentVec(rtAdjustmentVec);
251 fProgramDataManager.set4fv(fBuiltinUniformHandles.fRTAdjustmentUni, 1, r tAdjustmentVec); 313 fProgramDataManager.set4fv(fBuiltinUniformHandles.fRTAdjustmentUni, 1, r tAdjustmentVec);
252 } 314 }
253 } 315 }
316
317 //////////////////////////////////////////////////////////////////////////////// /////////
318
319 GrGLNvprProgramBase::GrGLNvprProgramBase(GrGpuGL* gpu,
320 const GrGLProgramDesc& desc,
321 const BuiltinUniformHandles& builtinUni forms,
322 GrGLuint programID,
323 const UniformInfoArray& uniforms,
324 GrGLInstalledProcessors* colorProcessor s,
325 GrGLInstalledProcessors* coverageProces sors)
326 : INHERITED(gpu, desc, builtinUniforms, programID, uniforms, NULL, colorProc essors,
327 coverageProcessors) {
328 }
329
330 void GrGLNvprProgramBase::onSetMatrixAndRenderTargetHeight(GrGpu::DrawType drawT ype,
331 const GrOptDrawState& optState) {
332 SkASSERT(GrGpu::IsPathRenderingDrawType(drawType));
333 const GrRenderTarget* rt = optState.getRenderTarget();
334 SkISize size;
335 size.set(rt->width(), rt->height());
336 fGpu->glPathRendering()->setProjectionMatrix(optState.getViewMatrix(), size, rt->origin());
337 }
338
339 //////////////////////////////////////////////////////////////////////////////// /////////
340
341 GrGLNvprProgram::GrGLNvprProgram(GrGpuGL* gpu,
342 const GrGLProgramDesc& desc,
343 const BuiltinUniformHandles& builtinUniforms,
344 GrGLuint programID,
345 const UniformInfoArray& uniforms,
346 GrGLInstalledProcessors* colorProcessors,
347 GrGLInstalledProcessors* coverageProcessors,
348 const SeparableVaryingInfoArray& separableVaryi ngs)
349 : INHERITED(gpu, desc, builtinUniforms, programID, uniforms, colorProcessors ,
350 coverageProcessors) {
351 int count = separableVaryings.count();
352 fVaryings.push_back_n(count);
353 for (int i = 0; i < count; i++) {
354 Varying& varying = fVaryings[i];
355 const SeparableVaryingInfo& builderVarying = separableVaryings[i];
356 SkASSERT(GrGLShaderVar::kNonArray == builderVarying.fVariable.getArrayCo unt());
357 SkDEBUGCODE(
358 varying.fType = builderVarying.fVariable.getType();
359 );
360 varying.fLocation = builderVarying.fLocation;
361 }
362 }
363
364 void GrGLNvprProgram::didSetData(GrGpu::DrawType drawType) {
365 SkASSERT(GrGpu::IsPathRenderingDrawType(drawType));
366 }
367
368 void GrGLNvprProgram::setTransformData(const GrProcessorStage& processor,
369 int effectIdx,
370 GrGLInstalledProcessors* ip) {
371 SkTArray<GrGLInstalledProcessors::Transform, true>& transforms = ip->fTransf orms[effectIdx];
372 int numTransforms = transforms.count();
373 SkASSERT(numTransforms == processor.getProcessor()->numTransforms());
374 for (int t = 0; t < numTransforms; ++t) {
375 SkASSERT(transforms[t].fHandle.isValid());
376 const SkMatrix& transform = get_transform_matrix(processor, ip->fHasExpl icitLocalCoords, t);
377 if (transforms[t].fCurrentValue.cheapEqualTo(transform)) {
378 continue;
379 }
380 transforms[t].fCurrentValue = transform;
381 const Varying& fragmentInput = fVaryings[transforms[t].fHandle.handle()] ;
382 SkASSERT(transforms[t].fType == kVec2f_GrSLType || transforms[t].fType = = kVec3f_GrSLType);
383 unsigned components = transforms[t].fType == kVec2f_GrSLType ? 2 : 3;
384 fGpu->glPathRendering()->setProgramPathFragmentInputTransform(fProgramID ,
385 fragmentIn put.fLocation,
386 GR_GL_OBJE CT_LINEAR,
387 components ,
388 transform) ;
389 }
390 }
391
392 //////////////////////////////////////////////////////////////////////////////// //////
393
394 GrGLLegacyNvprProgram::GrGLLegacyNvprProgram(GrGpuGL* gpu,
395 const GrGLProgramDesc& desc,
396 const BuiltinUniformHandles& builtinUniforms,
397 GrGLuint programID,
398 const UniformInfoArray& uniforms,
399 GrGLInstalledProcessors* colorProcessors,
400 GrGLInstalledProcessors* coverageProcessors,
401 int texCoordSetCnt)
402 : INHERITED(gpu, desc, builtinUniforms, programID, uniforms, colorProcessors ,
403 coverageProcessors)
404 , fTexCoordSetCnt(texCoordSetCnt) {
405 }
406
407 void GrGLLegacyNvprProgram::didSetData(GrGpu::DrawType drawType) {
408 SkASSERT(GrGpu::IsPathRenderingDrawType(drawType));
409 fGpu->glPathRendering()->flushPathTexGenSettings(fTexCoordSetCnt);
410 }
411
412 void GrGLLegacyNvprProgram::setTransformData(const GrProcessorStage& processorSt age,
413 int effectIdx,
414 GrGLInstalledProcessors* ip) {
415 // We've hidden the texcoord index in the first entry of the transforms arra y for each effect
416 int texCoordIndex = ip->fTransforms[effectIdx][0].fHandle.handle();
417 int numTransforms = processorStage.getProcessor()->numTransforms();
418 for (int t = 0; t < numTransforms; ++t) {
419 const SkMatrix& transform = get_transform_matrix(processorStage, false, t);
420 GrGLPathRendering::PathTexGenComponents components =
421 GrGLPathRendering::kST_PathTexGenComponents;
422 if (processorStage.isPerspectiveCoordTransform(t, false)) {
423 components = GrGLPathRendering::kSTR_PathTexGenComponents;
424 }
425 fGpu->glPathRendering()->enablePathTexGen(texCoordIndex++, components, t ransform);
426 }
427 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLProgram.h ('k') | src/gpu/gl/GrGLProgramDataManager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698