| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright 2014 Google Inc. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license that can be | |
| 5 * found in the LICENSE file. | |
| 6 */ | |
| 7 | |
| 8 #include "GrGLLegacyNvprProgramBuilder.h" | |
| 9 #include "../GrGLGpu.h" | |
| 10 | |
| 11 GrGLLegacyNvprProgramBuilder::GrGLLegacyNvprProgramBuilder(GrGLGpu* gpu, | |
| 12 const GrOptDrawState&
optState) | |
| 13 : INHERITED(gpu, optState) | |
| 14 , fTexCoordSetCnt(0) { | |
| 15 } | |
| 16 | |
| 17 int GrGLLegacyNvprProgramBuilder::addTexCoordSets(int count) { | |
| 18 int firstFreeCoordSet = fTexCoordSetCnt; | |
| 19 fTexCoordSetCnt += count; | |
| 20 SkASSERT(gpu()->glCaps().maxFixedFunctionTextureCoords() >= fTexCoordSetCnt)
; | |
| 21 return firstFreeCoordSet; | |
| 22 } | |
| 23 | |
| 24 void GrGLLegacyNvprProgramBuilder::emitTransforms(const GrPendingFragmentStage&
processorStage, | |
| 25 GrGLProcessor::TransformedCoordsArra
y* outCoords, | |
| 26 GrGLInstalledFragProc* ifp) { | |
| 27 int numTransforms = processorStage.processor()->numTransforms(); | |
| 28 int texCoordIndex = this->addTexCoordSets(numTransforms); | |
| 29 | |
| 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 | |
| 32 // the code overall | |
| 33 ifp->fTransforms.push_back_n(1); | |
| 34 ifp->fTransforms[0].fHandle = GrGLInstalledFragProc::ShaderVarHandle(texCoor
dIndex); | |
| 35 | |
| 36 SkString name; | |
| 37 for (int t = 0; t < numTransforms; ++t) { | |
| 38 GrSLType type = processorStage.isPerspectiveCoordTransform(t) ? kVec3f_G
rSLType : | |
| 39 kVec2f_G
rSLType; | |
| 40 | |
| 41 name.printf("%s(gl_TexCoord[%i])", GrGLSLTypeString(type), texCoordIndex
++); | |
| 42 SkNEW_APPEND_TO_TARRAY(outCoords, GrGLProcessor::TransformedCoords, (nam
e, type)); | |
| 43 } | |
| 44 } | |
| 45 | |
| 46 GrGLProgram* GrGLLegacyNvprProgramBuilder::createProgram(GrGLuint programID) { | |
| 47 return SkNEW_ARGS(GrGLLegacyNvprProgram, (fGpu, fDesc, fUniformHandles, prog
ramID, fUniforms, | |
| 48 fGeometryProcessor, fXferProcessor, fFragmentProcessors.get(), | |
| 49 fTexCoordSetCnt)); | |
| 50 } | |
| OLD | NEW |