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

Side by Side Diff: src/gpu/glsl/GrGLSLGeometryProcessor.cpp

Issue 1462123003: Create GrGLSLVaryingHandler class for program building (Closed) Base URL: https://skia.googlesource.com/skia.git@putCapsOnArgs
Patch Set: fix release builder Created 5 years, 1 month 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
« no previous file with comments | « src/gpu/glsl/GrGLSLGeometryProcessor.h ('k') | src/gpu/glsl/GrGLSLGeometryShaderBuilder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "GrGLSLGeometryProcessor.h" 8 #include "GrGLSLGeometryProcessor.h"
9 9
10 #include "glsl/GrGLSLFragmentShaderBuilder.h" 10 #include "glsl/GrGLSLFragmentShaderBuilder.h"
11 #include "glsl/GrGLSLProcessorTypes.h" 11 #include "glsl/GrGLSLProcessorTypes.h"
12 #include "glsl/GrGLSLProgramBuilder.h" 12 #include "glsl/GrGLSLProgramBuilder.h"
13 #include "glsl/GrGLSLVarying.h"
13 #include "glsl/GrGLSLVertexShaderBuilder.h" 14 #include "glsl/GrGLSLVertexShaderBuilder.h"
14 15
15 void GrGLSLGeometryProcessor::emitCode(EmitArgs& args) { 16 void GrGLSLGeometryProcessor::emitCode(EmitArgs& args) {
16 GrGLSLVertexBuilder* vBuilder = args.fVertBuilder; 17 GrGLSLVertexBuilder* vBuilder = args.fVertBuilder;
17 GrGPArgs gpArgs; 18 GrGPArgs gpArgs;
18 this->onEmitCode(args, &gpArgs); 19 this->onEmitCode(args, &gpArgs);
19 vBuilder->transformToNormalizedDeviceSpace(gpArgs.fPositionVar); 20 vBuilder->transformToNormalizedDeviceSpace(gpArgs.fPositionVar);
20 } 21 }
21 22
22 void GrGLSLGeometryProcessor::emitTransforms(GrGLSLGPBuilder* pb, 23 void GrGLSLGeometryProcessor::emitTransforms(GrGLSLGPBuilder* pb,
23 GrGLSLVertexBuilder* vb, 24 GrGLSLVertexBuilder* vb,
25 GrGLSLVaryingHandler* varyingHandle r,
24 const GrShaderVar& posVar, 26 const GrShaderVar& posVar,
25 const char* localCoords, 27 const char* localCoords,
26 const SkMatrix& localMatrix, 28 const SkMatrix& localMatrix,
27 const TransformsIn& tin, 29 const TransformsIn& tin,
28 TransformsOut* tout) { 30 TransformsOut* tout) {
29 tout->push_back_n(tin.count()); 31 tout->push_back_n(tin.count());
30 fInstalledTransforms.push_back_n(tin.count()); 32 fInstalledTransforms.push_back_n(tin.count());
31 for (int i = 0; i < tin.count(); i++) { 33 for (int i = 0; i < tin.count(); i++) {
32 const ProcCoords& coordTransforms = tin[i]; 34 const ProcCoords& coordTransforms = tin[i];
33 fInstalledTransforms[i].push_back_n(coordTransforms.count()); 35 fInstalledTransforms[i].push_back_n(coordTransforms.count());
(...skipping 15 matching lines...) Expand all
49 fInstalledTransforms[i][t].fHandle = 51 fInstalledTransforms[i][t].fHandle =
50 pb->addUniform(GrGLSLProgramBuilder::kVertex_Visibility, 52 pb->addUniform(GrGLSLProgramBuilder::kVertex_Visibility,
51 kMat33f_GrSLType, precision, 53 kMat33f_GrSLType, precision,
52 strUniName.c_str(), 54 strUniName.c_str(),
53 &uniName).toIndex(); 55 &uniName).toIndex();
54 56
55 SkString strVaryingName("MatrixCoord"); 57 SkString strVaryingName("MatrixCoord");
56 strVaryingName.appendf("_%i_%i", i, t); 58 strVaryingName.appendf("_%i_%i", i, t);
57 59
58 GrGLSLVertToFrag v(varyingType); 60 GrGLSLVertToFrag v(varyingType);
59 pb->addVarying(strVaryingName.c_str(), &v, precision); 61 varyingHandler->addVarying(strVaryingName.c_str(), &v, precision);
60 62
61 SkASSERT(kVec2f_GrSLType == varyingType || kVec3f_GrSLType == varyin gType); 63 SkASSERT(kVec2f_GrSLType == varyingType || kVec3f_GrSLType == varyin gType);
62 SkNEW_APPEND_TO_TARRAY(&(*tout)[i], GrGLSLTransformedCoords, 64 SkNEW_APPEND_TO_TARRAY(&(*tout)[i], GrGLSLTransformedCoords,
63 (SkString(v.fsIn()), varyingType)); 65 (SkString(v.fsIn()), varyingType));
64 66
65 // varying = matrix * coords (logically) 67 // varying = matrix * coords (logically)
66 if (kDevice_GrCoordSet == coordType) { 68 if (kDevice_GrCoordSet == coordType) {
67 if (kVec2f_GrSLType == varyingType) { 69 if (kVec2f_GrSLType == varyingType) {
68 if (kVec2f_GrSLType == posVar.getType()) { 70 if (kVec2f_GrSLType == posVar.getType()) {
69 vb->codeAppendf("%s = (%s * vec3(%s, 1)).xy;", 71 vb->codeAppendf("%s = (%s * vec3(%s, 1)).xy;",
(...skipping 17 matching lines...) Expand all
87 } else { 89 } else {
88 vb->codeAppendf("%s = %s * vec3(%s, 1);", v.vsOut(), uniName , localCoords); 90 vb->codeAppendf("%s = %s * vec3(%s, 1);", v.vsOut(), uniName , localCoords);
89 } 91 }
90 } 92 }
91 } 93 }
92 } 94 }
93 } 95 }
94 96
95 void GrGLSLGeometryProcessor::emitTransforms(GrGLSLGPBuilder* pb, 97 void GrGLSLGeometryProcessor::emitTransforms(GrGLSLGPBuilder* pb,
96 GrGLSLVertexBuilder* vb, 98 GrGLSLVertexBuilder* vb,
99 GrGLSLVaryingHandler* varyingHandle r,
97 const char* localCoords, 100 const char* localCoords,
98 const TransformsIn& tin, 101 const TransformsIn& tin,
99 TransformsOut* tout) { 102 TransformsOut* tout) {
100 tout->push_back_n(tin.count()); 103 tout->push_back_n(tin.count());
101 for (int i = 0; i < tin.count(); i++) { 104 for (int i = 0; i < tin.count(); i++) {
102 const ProcCoords& coordTransforms = tin[i]; 105 const ProcCoords& coordTransforms = tin[i];
103 for (int t = 0; t < coordTransforms.count(); t++) { 106 for (int t = 0; t < coordTransforms.count(); t++) {
104 GrSLType varyingType = kVec2f_GrSLType; 107 GrSLType varyingType = kVec2f_GrSLType;
105 108
106 // Device coords aren't supported 109 // Device coords aren't supported
107 SkASSERT(kDevice_GrCoordSet != coordTransforms[t]->sourceCoords()); 110 SkASSERT(kDevice_GrCoordSet != coordTransforms[t]->sourceCoords());
108 GrSLPrecision precision = coordTransforms[t]->precision(); 111 GrSLPrecision precision = coordTransforms[t]->precision();
109 112
110 SkString strVaryingName("MatrixCoord"); 113 SkString strVaryingName("MatrixCoord");
111 strVaryingName.appendf("_%i_%i", i, t); 114 strVaryingName.appendf("_%i_%i", i, t);
112 115
113 GrGLSLVertToFrag v(varyingType); 116 GrGLSLVertToFrag v(varyingType);
114 pb->addVarying(strVaryingName.c_str(), &v, precision); 117 varyingHandler->addVarying(strVaryingName.c_str(), &v, precision);
115 vb->codeAppendf("%s = %s;", v.vsOut(), localCoords); 118 vb->codeAppendf("%s = %s;", v.vsOut(), localCoords);
116 119
117 SkNEW_APPEND_TO_TARRAY(&(*tout)[i], 120 SkNEW_APPEND_TO_TARRAY(&(*tout)[i],
118 GrGLSLTransformedCoords, 121 GrGLSLTransformedCoords,
119 (SkString(v.fsIn()), varyingType)); 122 (SkString(v.fsIn()), varyingType));
120 } 123 }
121 } 124 }
122 } 125 }
123 126
124 void GrGLSLGeometryProcessor::setupPosition(GrGLSLGPBuilder* pb, 127 void GrGLSLGeometryProcessor::setupPosition(GrGLSLGPBuilder* pb,
(...skipping 23 matching lines...) Expand all
148 gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2"); 151 gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2");
149 vertBuilder->codeAppendf("vec2 %s = vec2(%s * vec3(%s, 1));", 152 vertBuilder->codeAppendf("vec2 %s = vec2(%s * vec3(%s, 1));",
150 gpArgs->fPositionVar.c_str(), viewMatrixNam e, posName); 153 gpArgs->fPositionVar.c_str(), viewMatrixNam e, posName);
151 } else { 154 } else {
152 gpArgs->fPositionVar.set(kVec3f_GrSLType, "pos3"); 155 gpArgs->fPositionVar.set(kVec3f_GrSLType, "pos3");
153 vertBuilder->codeAppendf("vec3 %s = %s * vec3(%s, 1);", 156 vertBuilder->codeAppendf("vec3 %s = %s * vec3(%s, 1);",
154 gpArgs->fPositionVar.c_str(), viewMatrixNam e, posName); 157 gpArgs->fPositionVar.c_str(), viewMatrixNam e, posName);
155 } 158 }
156 } 159 }
157 } 160 }
OLDNEW
« no previous file with comments | « src/gpu/glsl/GrGLSLGeometryProcessor.h ('k') | src/gpu/glsl/GrGLSLGeometryShaderBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698