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

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

Issue 637003003: Opt state takes a GP instead of a GeometryStage (Closed) Base URL: https://skia.googlesource.com/skia.git@builder_cleanup
Patch Set: memory leaks fixed 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/GrGLProgramDesc.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 "GrAllocator.h" 10 #include "GrAllocator.h"
11 #include "GrProcessor.h" 11 #include "GrProcessor.h"
12 #include "GrCoordTransform.h" 12 #include "GrCoordTransform.h"
13 #include "GrGLGeometryProcessor.h"
13 #include "GrGLProcessor.h" 14 #include "GrGLProcessor.h"
14 #include "GrGpuGL.h" 15 #include "GrGpuGL.h"
15 #include "GrGLPathRendering.h" 16 #include "GrGLPathRendering.h"
16 #include "GrGLShaderVar.h" 17 #include "GrGLShaderVar.h"
17 #include "GrGLSL.h" 18 #include "GrGLSL.h"
18 #include "GrOptDrawState.h" 19 #include "GrOptDrawState.h"
19 #include "SkXfermode.h" 20 #include "SkXfermode.h"
20 21
21 #define GL_CALL(X) GR_GL_CALL(fGpu->glInterface(), X) 22 #define GL_CALL(X) GR_GL_CALL(fGpu->glInterface(), X)
22 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(fGpu->glInterface(), R, X) 23 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(fGpu->glInterface(), R, X)
23 24
24 /** 25 /**
25 * Retrieves the final matrix that a transform needs to apply to its source coor ds. 26 * Retrieves the final matrix that a transform needs to apply to its source coor ds.
26 */ 27 */
27 static SkMatrix get_transform_matrix(const GrProcessorStage& processorStage, 28 static SkMatrix get_transform_matrix(const GrFragmentStage& processorStage,
28 bool useExplicitLocalCoords, 29 bool useExplicitLocalCoords,
29 int transformIdx) { 30 int transformIdx) {
30 const GrCoordTransform& coordTransform = 31 const GrCoordTransform& coordTransform =
31 processorStage.getProcessor()->coordTransform(transformIdx); 32 processorStage.getProcessor()->coordTransform(transformIdx);
32 SkMatrix combined; 33 SkMatrix combined;
33 34
34 if (kLocal_GrCoordSet == coordTransform.sourceCoords()) { 35 if (kLocal_GrCoordSet == coordTransform.sourceCoords()) {
35 // If we have explicit local coords then we shouldn't need a coord chang e. 36 // If we have explicit local coords then we shouldn't need a coord chang e.
36 const SkMatrix& ccm = 37 const SkMatrix& ccm =
37 useExplicitLocalCoords ? SkMatrix::I() : processorStage.getCoord ChangeMatrix(); 38 useExplicitLocalCoords ? SkMatrix::I() : processorStage.getCoord ChangeMatrix();
(...skipping 14 matching lines...) Expand all
52 return combined; 53 return combined;
53 } 54 }
54 55
55 //////////////////////////////////////////////////////////////////////////////// /////////////////// 56 //////////////////////////////////////////////////////////////////////////////// ///////////////////
56 57
57 GrGLProgram::GrGLProgram(GrGpuGL* gpu, 58 GrGLProgram::GrGLProgram(GrGpuGL* gpu,
58 const GrGLProgramDesc& desc, 59 const GrGLProgramDesc& desc,
59 const BuiltinUniformHandles& builtinUniforms, 60 const BuiltinUniformHandles& builtinUniforms,
60 GrGLuint programID, 61 GrGLuint programID,
61 const UniformInfoArray& uniforms, 62 const UniformInfoArray& uniforms,
62 GrGLInstalledProcessors* geometryProcessor, 63 GrGLInstalledGeoProc* geometryProcessor,
63 GrGLInstalledProcessors* colorProcessors, 64 GrGLInstalledFragProcs* fragmentProcessors)
64 GrGLInstalledProcessors* coverageProcessors)
65 : fColor(GrColor_ILLEGAL) 65 : fColor(GrColor_ILLEGAL)
66 , fCoverage(GrColor_ILLEGAL) 66 , fCoverage(GrColor_ILLEGAL)
67 , fDstCopyTexUnit(-1) 67 , fDstCopyTexUnit(-1)
68 , fBuiltinUniformHandles(builtinUniforms) 68 , fBuiltinUniformHandles(builtinUniforms)
69 , fProgramID(programID) 69 , fProgramID(programID)
70 , fGeometryProcessor(SkSafeRef(geometryProcessor)) 70 , fGeometryProcessor(geometryProcessor)
71 , fColorEffects(SkRef(colorProcessors)) 71 , fFragmentProcessors(SkRef(fragmentProcessors))
72 , fCoverageEffects(SkRef(coverageProcessors))
73 , fDesc(desc) 72 , fDesc(desc)
74 , fGpu(gpu) 73 , fGpu(gpu)
75 , fProgramDataManager(gpu, uniforms) { 74 , fProgramDataManager(gpu, uniforms) {
76 this->initSamplerUniforms(); 75 this->initSamplerUniforms();
77 } 76 }
78 77
79 GrGLProgram::~GrGLProgram() { 78 GrGLProgram::~GrGLProgram() {
80 if (fProgramID) { 79 if (fProgramID) {
81 GL_CALL(DeleteProgram(fProgramID)); 80 GL_CALL(DeleteProgram(fProgramID));
82 } 81 }
83 } 82 }
84 83
85 void GrGLProgram::abandon() { 84 void GrGLProgram::abandon() {
86 fProgramID = 0; 85 fProgramID = 0;
87 } 86 }
88 87
89 void GrGLProgram::initSamplerUniforms() { 88 void GrGLProgram::initSamplerUniforms() {
90 GL_CALL(UseProgram(fProgramID)); 89 GL_CALL(UseProgram(fProgramID));
91 GrGLint texUnitIdx = 0; 90 GrGLint texUnitIdx = 0;
92 if (fBuiltinUniformHandles.fDstCopySamplerUni.isValid()) { 91 if (fBuiltinUniformHandles.fDstCopySamplerUni.isValid()) {
93 fProgramDataManager.setSampler(fBuiltinUniformHandles.fDstCopySamplerUni , texUnitIdx); 92 fProgramDataManager.setSampler(fBuiltinUniformHandles.fDstCopySamplerUni , texUnitIdx);
94 fDstCopyTexUnit = texUnitIdx++; 93 fDstCopyTexUnit = texUnitIdx++;
95 } 94 }
96 if (fGeometryProcessor.get()) { 95 if (fGeometryProcessor.get()) {
97 this->initSamplers(fGeometryProcessor.get(), &texUnitIdx); 96 this->initSamplers(fGeometryProcessor.get(), &texUnitIdx);
98 } 97 }
99 this->initSamplers(fColorEffects.get(), &texUnitIdx); 98 int numProcs = fFragmentProcessors->fProcs.count();
100 this->initSamplers(fCoverageEffects.get(), &texUnitIdx); 99 for (int i = 0; i < numProcs; i++) {
101 } 100 this->initSamplers(fFragmentProcessors->fProcs[i], &texUnitIdx);
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 } 101 }
115 } 102 }
116 103
117 void GrGLProgram::bindTextures(const GrGLInstalledProcessors* ip, 104 void GrGLProgram::initSamplers(GrGLInstalledProc* ip, int* texUnitIdx) {
118 const GrProcessor& processor, 105 SkTArray<GrGLInstalledProc::Sampler, true>& samplers = ip->fSamplers;
119 int effectIdx) { 106 int numSamplers = samplers.count();
120 const SkTArray<GrGLInstalledProcessors::Sampler, true>& samplers = ip->fSamp lers[effectIdx]; 107 for (int s = 0; s < numSamplers; ++s) {
108 SkASSERT(samplers[s].fUniform.isValid());
109 fProgramDataManager.setSampler(samplers[s].fUniform, *texUnitIdx);
110 samplers[s].fTextureUnit = (*texUnitIdx)++;
111 }
112 }
113
114 void GrGLProgram::bindTextures(const GrGLInstalledProc* ip, const GrProcessor& p rocessor) {
115 const SkTArray<GrGLInstalledProc::Sampler, true>& samplers = ip->fSamplers;
121 int numSamplers = samplers.count(); 116 int numSamplers = samplers.count();
122 SkASSERT(numSamplers == processor.numTextures()); 117 SkASSERT(numSamplers == processor.numTextures());
123 for (int s = 0; s < numSamplers; ++s) { 118 for (int s = 0; s < numSamplers; ++s) {
124 SkASSERT(samplers[s].fTextureUnit >= 0); 119 SkASSERT(samplers[s].fTextureUnit >= 0);
125 const GrTextureAccess& textureAccess = processor.textureAccess(s); 120 const GrTextureAccess& textureAccess = processor.textureAccess(s);
126 fGpu->bindTexture(samplers[s].fTextureUnit, 121 fGpu->bindTexture(samplers[s].fTextureUnit,
127 textureAccess.getParams(), 122 textureAccess.getParams(),
128 static_cast<GrGLTexture*>(textureAccess.getTexture())) ; 123 static_cast<GrGLTexture*>(textureAccess.getTexture())) ;
129 } 124 }
130 } 125 }
131 126
132 127
133 /////////////////////////////////////////////////////////////////////////////// 128 ///////////////////////////////////////////////////////////////////////////////
134 129
135 void GrGLProgram::setData(const GrOptDrawState& optState, 130 void GrGLProgram::setData(const GrOptDrawState& optState,
136 GrGpu::DrawType drawType, 131 GrGpu::DrawType drawType,
137 const GrGeometryStage* geometryProcessor,
138 const GrFragmentStage* colorStages[],
139 const GrFragmentStage* coverageStages[],
140 const GrDeviceCoordTexture* dstCopy, 132 const GrDeviceCoordTexture* dstCopy,
141 SharedGLState* sharedState) { 133 SharedGLState* sharedState) {
142 GrColor color = optState.getColor(); 134 GrColor color = optState.getColor();
143 GrColor coverage = optState.getCoverageColor(); 135 GrColor coverage = optState.getCoverageColor();
144 136
145 this->setColor(optState, color, sharedState); 137 this->setColor(optState, color, sharedState);
146 this->setCoverage(optState, coverage, sharedState); 138 this->setCoverage(optState, coverage, sharedState);
147 this->setMatrixAndRenderTargetHeight(drawType, optState); 139 this->setMatrixAndRenderTargetHeight(drawType, optState);
148 140
149 if (dstCopy) { 141 if (dstCopy) {
(...skipping 13 matching lines...) Expand all
163 } 155 }
164 } else { 156 } else {
165 SkASSERT(!fBuiltinUniformHandles.fDstCopyTopLeftUni.isValid()); 157 SkASSERT(!fBuiltinUniformHandles.fDstCopyTopLeftUni.isValid());
166 SkASSERT(!fBuiltinUniformHandles.fDstCopyScaleUni.isValid()); 158 SkASSERT(!fBuiltinUniformHandles.fDstCopyScaleUni.isValid());
167 SkASSERT(!fBuiltinUniformHandles.fDstCopySamplerUni.isValid()); 159 SkASSERT(!fBuiltinUniformHandles.fDstCopySamplerUni.isValid());
168 } 160 }
169 161
170 // we set the textures, and uniforms for installed processors in a generic w ay, but subclasses 162 // 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 163 // of GLProgram determine how to set coord transforms
172 if (fGeometryProcessor.get()) { 164 if (fGeometryProcessor.get()) {
173 SkASSERT(geometryProcessor); 165 SkASSERT(optState.hasGeometryProcessor());
174 this->setData<GrGeometryStage>(&geometryProcessor, fGeometryProcessor.ge t()); 166 const GrGeometryProcessor& gp = *optState.getGeometryProcessor();
167 fGeometryProcessor->fGLProc->setData(fProgramDataManager, gp);
168 this->bindTextures(fGeometryProcessor, gp);
175 } 169 }
176 this->setData<GrFragmentStage>(colorStages, fColorEffects.get()); 170 this->setFragmentData(optState);
177 this->setData<GrFragmentStage>(coverageStages, fCoverageEffects.get());
178 171
179 // Some of GrGLProgram subclasses need to update state here 172 // Some of GrGLProgram subclasses need to update state here
180 this->didSetData(drawType); 173 this->didSetData(drawType);
181 } 174 }
182 175
183 void GrGLProgram::setTransformData(const GrProcessorStage& processor, 176 void GrGLProgram::setFragmentData(const GrOptDrawState& optState) {
184 int effectIdx, 177 int numProcessors = fFragmentProcessors->fProcs.count();
185 GrGLInstalledProcessors* ip) { 178 for (int e = 0; e < numProcessors; ++e) {
186 SkTArray<GrGLInstalledProcessors::Transform, true>& transforms = ip->fTransf orms[effectIdx]; 179 const GrFragmentStage& stage = optState.getFragmentStage(e);
180 const GrProcessor& processor = *stage.getProcessor();
181 fFragmentProcessors->fProcs[e]->fGLProc->setData(fProgramDataManager, pr ocessor);
182 this->setTransformData(stage, fFragmentProcessors->fProcs[e]);
183 this->bindTextures(fFragmentProcessors->fProcs[e], processor);
184 }
185 }
186 void GrGLProgram::setTransformData(const GrFragmentStage& processor, GrGLInstall edFragProc* ip) {
187 SkTArray<GrGLInstalledFragProc::Transform, true>& transforms = ip->fTransfor ms;
187 int numTransforms = transforms.count(); 188 int numTransforms = transforms.count();
188 SkASSERT(numTransforms == processor.getProcessor()->numTransforms()); 189 SkASSERT(numTransforms == processor.getProcessor()->numTransforms());
189 for (int t = 0; t < numTransforms; ++t) { 190 for (int t = 0; t < numTransforms; ++t) {
190 SkASSERT(transforms[t].fHandle.isValid()); 191 SkASSERT(transforms[t].fHandle.isValid());
191 const SkMatrix& matrix = get_transform_matrix(processor, ip->fHasExplici tLocalCoords, t); 192 const SkMatrix& matrix = get_transform_matrix(processor, ip->fLocalCoord Attrib, t);
192 if (!transforms[t].fCurrentValue.cheapEqualTo(matrix)) { 193 if (!transforms[t].fCurrentValue.cheapEqualTo(matrix)) {
193 fProgramDataManager.setSkMatrix(transforms[t].fHandle.convertToUnifo rmHandle(), matrix); 194 fProgramDataManager.setSkMatrix(transforms[t].fHandle.convertToUnifo rmHandle(), matrix);
194 transforms[t].fCurrentValue = matrix; 195 transforms[t].fCurrentValue = matrix;
195 } 196 }
196 } 197 }
197 } 198 }
198 199
199 void GrGLProgram::didSetData(GrGpu::DrawType drawType) { 200 void GrGLProgram::didSetData(GrGpu::DrawType drawType) {
200 SkASSERT(!GrGpu::IsPathRenderingDrawType(drawType)); 201 SkASSERT(!GrGpu::IsPathRenderingDrawType(drawType));
201 } 202 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 } 315 }
315 } 316 }
316 317
317 //////////////////////////////////////////////////////////////////////////////// ///////// 318 //////////////////////////////////////////////////////////////////////////////// /////////
318 319
319 GrGLNvprProgramBase::GrGLNvprProgramBase(GrGpuGL* gpu, 320 GrGLNvprProgramBase::GrGLNvprProgramBase(GrGpuGL* gpu,
320 const GrGLProgramDesc& desc, 321 const GrGLProgramDesc& desc,
321 const BuiltinUniformHandles& builtinUni forms, 322 const BuiltinUniformHandles& builtinUni forms,
322 GrGLuint programID, 323 GrGLuint programID,
323 const UniformInfoArray& uniforms, 324 const UniformInfoArray& uniforms,
324 GrGLInstalledProcessors* colorProcessor s, 325 GrGLInstalledFragProcs* fragmentProcess ors)
325 GrGLInstalledProcessors* coverageProces sors) 326 : INHERITED(gpu, desc, builtinUniforms, programID, uniforms, NULL, fragmentP rocessors) {
326 : INHERITED(gpu, desc, builtinUniforms, programID, uniforms, NULL, colorProc essors,
327 coverageProcessors) {
328 } 327 }
329 328
330 void GrGLNvprProgramBase::onSetMatrixAndRenderTargetHeight(GrGpu::DrawType drawT ype, 329 void GrGLNvprProgramBase::onSetMatrixAndRenderTargetHeight(GrGpu::DrawType drawT ype,
331 const GrOptDrawState& optState) { 330 const GrOptDrawState& optState) {
332 SkASSERT(GrGpu::IsPathRenderingDrawType(drawType)); 331 SkASSERT(GrGpu::IsPathRenderingDrawType(drawType));
333 const GrRenderTarget* rt = optState.getRenderTarget(); 332 const GrRenderTarget* rt = optState.getRenderTarget();
334 SkISize size; 333 SkISize size;
335 size.set(rt->width(), rt->height()); 334 size.set(rt->width(), rt->height());
336 fGpu->glPathRendering()->setProjectionMatrix(optState.getViewMatrix(), size, rt->origin()); 335 fGpu->glPathRendering()->setProjectionMatrix(optState.getViewMatrix(), size, rt->origin());
337 } 336 }
338 337
339 //////////////////////////////////////////////////////////////////////////////// ///////// 338 //////////////////////////////////////////////////////////////////////////////// /////////
340 339
341 GrGLNvprProgram::GrGLNvprProgram(GrGpuGL* gpu, 340 GrGLNvprProgram::GrGLNvprProgram(GrGpuGL* gpu,
342 const GrGLProgramDesc& desc, 341 const GrGLProgramDesc& desc,
343 const BuiltinUniformHandles& builtinUniforms, 342 const BuiltinUniformHandles& builtinUniforms,
344 GrGLuint programID, 343 GrGLuint programID,
345 const UniformInfoArray& uniforms, 344 const UniformInfoArray& uniforms,
346 GrGLInstalledProcessors* colorProcessors, 345 GrGLInstalledFragProcs* fragmentProcessors,
347 GrGLInstalledProcessors* coverageProcessors,
348 const SeparableVaryingInfoArray& separableVaryi ngs) 346 const SeparableVaryingInfoArray& separableVaryi ngs)
349 : INHERITED(gpu, desc, builtinUniforms, programID, uniforms, colorProcessors , 347 : INHERITED(gpu, desc, builtinUniforms, programID, uniforms, fragmentProcess ors) {
350 coverageProcessors) {
351 int count = separableVaryings.count(); 348 int count = separableVaryings.count();
352 fVaryings.push_back_n(count); 349 fVaryings.push_back_n(count);
353 for (int i = 0; i < count; i++) { 350 for (int i = 0; i < count; i++) {
354 Varying& varying = fVaryings[i]; 351 Varying& varying = fVaryings[i];
355 const SeparableVaryingInfo& builderVarying = separableVaryings[i]; 352 const SeparableVaryingInfo& builderVarying = separableVaryings[i];
356 SkASSERT(GrGLShaderVar::kNonArray == builderVarying.fVariable.getArrayCo unt()); 353 SkASSERT(GrGLShaderVar::kNonArray == builderVarying.fVariable.getArrayCo unt());
357 SkDEBUGCODE( 354 SkDEBUGCODE(
358 varying.fType = builderVarying.fVariable.getType(); 355 varying.fType = builderVarying.fVariable.getType();
359 ); 356 );
360 varying.fLocation = builderVarying.fLocation; 357 varying.fLocation = builderVarying.fLocation;
361 } 358 }
362 } 359 }
363 360
364 void GrGLNvprProgram::didSetData(GrGpu::DrawType drawType) { 361 void GrGLNvprProgram::didSetData(GrGpu::DrawType drawType) {
365 SkASSERT(GrGpu::IsPathRenderingDrawType(drawType)); 362 SkASSERT(GrGpu::IsPathRenderingDrawType(drawType));
366 } 363 }
367 364
368 void GrGLNvprProgram::setTransformData(const GrProcessorStage& processor, 365 void GrGLNvprProgram::setTransformData(const GrFragmentStage& proc, GrGLInstalle dFragProc* ip) {
369 int effectIdx, 366 SkTArray<GrGLInstalledFragProc::Transform, true>& transforms = ip->fTransfor ms;
370 GrGLInstalledProcessors* ip) {
371 SkTArray<GrGLInstalledProcessors::Transform, true>& transforms = ip->fTransf orms[effectIdx];
372 int numTransforms = transforms.count(); 367 int numTransforms = transforms.count();
373 SkASSERT(numTransforms == processor.getProcessor()->numTransforms()); 368 SkASSERT(numTransforms == proc.getProcessor()->numTransforms());
374 for (int t = 0; t < numTransforms; ++t) { 369 for (int t = 0; t < numTransforms; ++t) {
375 SkASSERT(transforms[t].fHandle.isValid()); 370 SkASSERT(transforms[t].fHandle.isValid());
376 const SkMatrix& transform = get_transform_matrix(processor, ip->fHasExpl icitLocalCoords, t); 371 const SkMatrix& transform = get_transform_matrix(proc, false, t);
377 if (transforms[t].fCurrentValue.cheapEqualTo(transform)) { 372 if (transforms[t].fCurrentValue.cheapEqualTo(transform)) {
378 continue; 373 continue;
379 } 374 }
380 transforms[t].fCurrentValue = transform; 375 transforms[t].fCurrentValue = transform;
381 const Varying& fragmentInput = fVaryings[transforms[t].fHandle.handle()] ; 376 const Varying& fragmentInput = fVaryings[transforms[t].fHandle.handle()] ;
382 SkASSERT(transforms[t].fType == kVec2f_GrSLType || transforms[t].fType = = kVec3f_GrSLType); 377 SkASSERT(transforms[t].fType == kVec2f_GrSLType || transforms[t].fType = = kVec3f_GrSLType);
383 unsigned components = transforms[t].fType == kVec2f_GrSLType ? 2 : 3; 378 unsigned components = transforms[t].fType == kVec2f_GrSLType ? 2 : 3;
384 fGpu->glPathRendering()->setProgramPathFragmentInputTransform(fProgramID , 379 fGpu->glPathRendering()->setProgramPathFragmentInputTransform(fProgramID ,
385 fragmentIn put.fLocation, 380 fragmentIn put.fLocation,
386 GR_GL_OBJE CT_LINEAR, 381 GR_GL_OBJE CT_LINEAR,
387 components , 382 components ,
388 transform) ; 383 transform) ;
389 } 384 }
390 } 385 }
391 386
392 //////////////////////////////////////////////////////////////////////////////// ////// 387 //////////////////////////////////////////////////////////////////////////////// //////
393 388
394 GrGLLegacyNvprProgram::GrGLLegacyNvprProgram(GrGpuGL* gpu, 389 GrGLLegacyNvprProgram::GrGLLegacyNvprProgram(GrGpuGL* gpu,
395 const GrGLProgramDesc& desc, 390 const GrGLProgramDesc& desc,
396 const BuiltinUniformHandles& builtinUniforms, 391 const BuiltinUniformHandles& builti nUniforms,
397 GrGLuint programID, 392 GrGLuint programID,
398 const UniformInfoArray& uniforms, 393 const UniformInfoArray& uniforms,
399 GrGLInstalledProcessors* colorProcessors, 394 GrGLInstalledFragProcs* fps,
400 GrGLInstalledProcessors* coverageProcessors, 395 int texCoordSetCnt)
401 int texCoordSetCnt) 396 : INHERITED(gpu, desc, builtinUniforms, programID, uniforms, fps)
402 : INHERITED(gpu, desc, builtinUniforms, programID, uniforms, colorProcessors ,
403 coverageProcessors)
404 , fTexCoordSetCnt(texCoordSetCnt) { 397 , fTexCoordSetCnt(texCoordSetCnt) {
405 } 398 }
406 399
407 void GrGLLegacyNvprProgram::didSetData(GrGpu::DrawType drawType) { 400 void GrGLLegacyNvprProgram::didSetData(GrGpu::DrawType drawType) {
408 SkASSERT(GrGpu::IsPathRenderingDrawType(drawType)); 401 SkASSERT(GrGpu::IsPathRenderingDrawType(drawType));
409 fGpu->glPathRendering()->flushPathTexGenSettings(fTexCoordSetCnt); 402 fGpu->glPathRendering()->flushPathTexGenSettings(fTexCoordSetCnt);
410 } 403 }
411 404
412 void GrGLLegacyNvprProgram::setTransformData(const GrProcessorStage& processorSt age, 405 void
413 int effectIdx, 406 GrGLLegacyNvprProgram::setTransformData(const GrFragmentStage& proc, GrGLInstall edFragProc* ip) {
414 GrGLInstalledProcessors* ip) {
415 // We've hidden the texcoord index in the first entry of the transforms arra y for each effect 407 // 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(); 408 int texCoordIndex = ip->fTransforms[0].fHandle.handle();
417 int numTransforms = processorStage.getProcessor()->numTransforms(); 409 int numTransforms = proc.getProcessor()->numTransforms();
418 for (int t = 0; t < numTransforms; ++t) { 410 for (int t = 0; t < numTransforms; ++t) {
419 const SkMatrix& transform = get_transform_matrix(processorStage, false, t); 411 const SkMatrix& transform = get_transform_matrix(proc, false, t);
420 GrGLPathRendering::PathTexGenComponents components = 412 GrGLPathRendering::PathTexGenComponents components =
421 GrGLPathRendering::kST_PathTexGenComponents; 413 GrGLPathRendering::kST_PathTexGenComponents;
422 if (processorStage.isPerspectiveCoordTransform(t, false)) { 414 if (proc.isPerspectiveCoordTransform(t, false)) {
423 components = GrGLPathRendering::kSTR_PathTexGenComponents; 415 components = GrGLPathRendering::kSTR_PathTexGenComponents;
424 } 416 }
425 fGpu->glPathRendering()->enablePathTexGen(texCoordIndex++, components, t ransform); 417 fGpu->glPathRendering()->enablePathTexGen(texCoordIndex++, components, t ransform);
426 } 418 }
427 } 419 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLProgram.h ('k') | src/gpu/gl/GrGLProgramDesc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698