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