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 "../GrGpuGL.h" |
| 10 |
| 11 GrGLLegacyNvprProgramBuilder::GrGLLegacyNvprProgramBuilder(GrGpuGL* gpu, |
| 12 const GrOptDrawState&
optState, |
| 13 const GrGLProgramDesc
& desc) |
| 14 : INHERITED(gpu, optState, desc) |
| 15 , fTexCoordSetCnt(0) { |
| 16 SkASSERT(GrGLProgramDesc::kAttribute_ColorInput != desc.getHeader().fColorIn
put); |
| 17 SkASSERT(GrGLProgramDesc::kAttribute_ColorInput != desc.getHeader().fCoverag
eInput); |
| 18 } |
| 19 |
| 20 int GrGLLegacyNvprProgramBuilder::addTexCoordSets(int count) { |
| 21 int firstFreeCoordSet = fTexCoordSetCnt; |
| 22 fTexCoordSetCnt += count; |
| 23 SkASSERT(gpu()->glCaps().maxFixedFunctionTextureCoords() >= fTexCoordSetCnt)
; |
| 24 return firstFreeCoordSet; |
| 25 } |
| 26 |
| 27 void GrGLLegacyNvprProgramBuilder::emitTransforms(const GrProcessorStage& proces
sorStage, |
| 28 GrGLProcessor::TransformedCoordsArra
y* outCoords, |
| 29 GrGLInstalledProcessors* installedPr
ocessors) { |
| 30 int numTransforms = processorStage.getProcessor()->numTransforms(); |
| 31 int texCoordIndex = this->addTexCoordSets(numTransforms); |
| 32 |
| 33 SkTArray<GrGLInstalledProcessors::Transform, true>& transforms = |
| 34 installedProcessors->addTransforms(); |
| 35 |
| 36 // Use the first uniform location as the texcoord index. This may seem a bi
t hacky but it |
| 37 // allows us to use one program effects object for all of our programs which
really simplifies |
| 38 // the code overall |
| 39 transforms.push_back_n(1); |
| 40 transforms[0].fHandle = GrGLInstalledProcessors::ShaderVarHandle(texCoordInd
ex); |
| 41 |
| 42 SkString name; |
| 43 for (int t = 0; t < numTransforms; ++t) { |
| 44 GrSLType type = processorStage.isPerspectiveCoordTransform(t, false) ? k
Vec3f_GrSLType : |
| 45 k
Vec2f_GrSLType; |
| 46 |
| 47 name.printf("%s(gl_TexCoord[%i])", GrGLSLTypeString(type), texCoordIndex
++); |
| 48 SkNEW_APPEND_TO_TARRAY(outCoords, GrGLProcessor::TransformedCoords, (nam
e, type)); |
| 49 } |
| 50 } |
| 51 |
| 52 GrGLProgram* GrGLLegacyNvprProgramBuilder::createProgram(GrGLuint programID) { |
| 53 return SkNEW_ARGS(GrGLLegacyNvprProgram, (fGpu, fDesc, fUniformHandles, prog
ramID, fUniforms, |
| 54 fColorEffects, fCoverageEffects, fTexCo
ordSetCnt)); |
| 55 } |
OLD | NEW |