| OLD | NEW |
| 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 "GrGLLegacyNvprProgramBuilder.h" | 8 #include "GrGLLegacyNvprProgramBuilder.h" |
| 9 #include "../GrGpuGL.h" | 9 #include "../GrGpuGL.h" |
| 10 | 10 |
| 11 GrGLLegacyNvprProgramBuilder::GrGLLegacyNvprProgramBuilder(GrGpuGL* gpu, | 11 GrGLLegacyNvprProgramBuilder::GrGLLegacyNvprProgramBuilder(GrGpuGL* gpu, |
| 12 const GrOptDrawState&
optState) | 12 const GrOptDrawState&
optState) |
| 13 : INHERITED(gpu, optState) | 13 : INHERITED(gpu, optState) |
| 14 , fTexCoordSetCnt(0) { | 14 , fTexCoordSetCnt(0) { |
| 15 } | 15 } |
| 16 | 16 |
| 17 int GrGLLegacyNvprProgramBuilder::addTexCoordSets(int count) { | 17 int GrGLLegacyNvprProgramBuilder::addTexCoordSets(int count) { |
| 18 int firstFreeCoordSet = fTexCoordSetCnt; | 18 int firstFreeCoordSet = fTexCoordSetCnt; |
| 19 fTexCoordSetCnt += count; | 19 fTexCoordSetCnt += count; |
| 20 SkASSERT(gpu()->glCaps().maxFixedFunctionTextureCoords() >= fTexCoordSetCnt)
; | 20 SkASSERT(gpu()->glCaps().maxFixedFunctionTextureCoords() >= fTexCoordSetCnt)
; |
| 21 return firstFreeCoordSet; | 21 return firstFreeCoordSet; |
| 22 } | 22 } |
| 23 | 23 |
| 24 void GrGLLegacyNvprProgramBuilder::emitTransforms(const GrFragmentStage& process
orStage, | 24 void GrGLLegacyNvprProgramBuilder::emitTransforms(const GrPendingFragmentStage&
processorStage, |
| 25 GrGLProcessor::TransformedCoordsArra
y* outCoords, | 25 GrGLProcessor::TransformedCoordsArra
y* outCoords, |
| 26 GrGLInstalledFragProc* ifp) { | 26 GrGLInstalledFragProc* ifp) { |
| 27 int numTransforms = processorStage.getProcessor()->numTransforms(); | 27 int numTransforms = processorStage.getProcessor()->numTransforms(); |
| 28 int texCoordIndex = this->addTexCoordSets(numTransforms); | 28 int texCoordIndex = this->addTexCoordSets(numTransforms); |
| 29 | 29 |
| 30 // Use the first uniform location as the texcoord index. This may seem a bi
t hacky but it | 30 // Use the first uniform location as the texcoord index. This may seem a bi
t hacky but it |
| 31 // allows us to use one program effects object for all of our programs which
really simplifies | 31 // allows us to use one program effects object for all of our programs which
really simplifies |
| 32 // the code overall | 32 // the code overall |
| 33 ifp->fTransforms.push_back_n(1); | 33 ifp->fTransforms.push_back_n(1); |
| 34 ifp->fTransforms[0].fHandle = GrGLInstalledFragProc::ShaderVarHandle(texCoor
dIndex); | 34 ifp->fTransforms[0].fHandle = GrGLInstalledFragProc::ShaderVarHandle(texCoor
dIndex); |
| 35 | 35 |
| 36 SkString name; | 36 SkString name; |
| 37 for (int t = 0; t < numTransforms; ++t) { | 37 for (int t = 0; t < numTransforms; ++t) { |
| 38 GrSLType type = processorStage.isPerspectiveCoordTransform(t, false) ? k
Vec3f_GrSLType : | 38 GrSLType type = processorStage.isPerspectiveCoordTransform(t) ? kVec3f_G
rSLType : |
| 39 k
Vec2f_GrSLType; | 39 kVec2f_G
rSLType; |
| 40 | 40 |
| 41 name.printf("%s(gl_TexCoord[%i])", GrGLSLTypeString(type), texCoordIndex
++); | 41 name.printf("%s(gl_TexCoord[%i])", GrGLSLTypeString(type), texCoordIndex
++); |
| 42 SkNEW_APPEND_TO_TARRAY(outCoords, GrGLProcessor::TransformedCoords, (nam
e, type)); | 42 SkNEW_APPEND_TO_TARRAY(outCoords, GrGLProcessor::TransformedCoords, (nam
e, type)); |
| 43 } | 43 } |
| 44 } | 44 } |
| 45 | 45 |
| 46 GrGLProgram* GrGLLegacyNvprProgramBuilder::createProgram(GrGLuint programID) { | 46 GrGLProgram* GrGLLegacyNvprProgramBuilder::createProgram(GrGLuint programID) { |
| 47 return SkNEW_ARGS(GrGLLegacyNvprProgram, (fGpu, fDesc, fUniformHandles, prog
ramID, fUniforms, | 47 return SkNEW_ARGS(GrGLLegacyNvprProgram, (fGpu, fDesc, fUniformHandles, prog
ramID, fUniforms, |
| 48 fFragmentProcessors.get(), fTexCo
ordSetCnt)); | 48 fFragmentProcessors.get(), fTexCo
ordSetCnt)); |
| 49 } | 49 } |
| OLD | NEW |