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

Side by Side Diff: src/gpu/gl/builders/GrGLLegacyNvprProgramBuilder.cpp

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

Powered by Google App Engine
This is Rietveld 408576698