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

Side by Side Diff: src/gpu/gl/GrGLGeometryProcessor.cpp

Issue 1243583002: Add support for transformedLocalCoords to GrDefaultGeoProc (Closed) Base URL: https://skia.googlesource.com/skia.git@pipelinetobatch2
Patch Set: tweaks Created 5 years, 4 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
« no previous file with comments | « src/gpu/gl/GrGLGeometryProcessor.h ('k') | src/gpu/gl/builders/GrGLProgramBuilder.cpp » ('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 "GrGLGeometryProcessor.h" 8 #include "GrGLGeometryProcessor.h"
9 9
10 #include "builders/GrGLProgramBuilder.h" 10 #include "builders/GrGLProgramBuilder.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 if (kVec2f_GrSLType == varyingType) { 82 if (kVec2f_GrSLType == varyingType) {
83 vb->codeAppendf("%s = (%s * vec3(%s, 1)).xy;", v.vsOut(), un iName, localCoords); 83 vb->codeAppendf("%s = (%s * vec3(%s, 1)).xy;", v.vsOut(), un iName, localCoords);
84 } else { 84 } else {
85 vb->codeAppendf("%s = %s * vec3(%s, 1);", v.vsOut(), uniName , localCoords); 85 vb->codeAppendf("%s = %s * vec3(%s, 1);", v.vsOut(), uniName , localCoords);
86 } 86 }
87 } 87 }
88 } 88 }
89 } 89 }
90 } 90 }
91 91
92 void GrGLGeometryProcessor::emitTransforms(GrGLGPBuilder* pb,
93 const char* localCoords,
94 const TransformsIn& tin,
95 TransformsOut* tout) {
96 GrGLVertexBuilder* vb = pb->getVertexShaderBuilder();
97 tout->push_back_n(tin.count());
98 for (int i = 0; i < tin.count(); i++) {
99 const ProcCoords& coordTransforms = tin[i];
100 for (int t = 0; t < coordTransforms.count(); t++) {
101 GrSLType varyingType = kVec2f_GrSLType;
102
103 // Device coords aren't supported
104 SkASSERT(kDevice_GrCoordSet != coordTransforms[t]->sourceCoords());
105 GrSLPrecision precision = coordTransforms[t]->precision();
106
107 SkString strVaryingName("MatrixCoord");
108 strVaryingName.appendf("_%i_%i", i, t);
109
110 GrGLVertToFrag v(varyingType);
111 pb->addVarying(strVaryingName.c_str(), &v, precision);
112 vb->codeAppendf("%s = %s;", v.vsOut(), localCoords);
113
114 SkNEW_APPEND_TO_TARRAY(&(*tout)[i],
115 GrGLProcessor::TransformedCoords,
116 (SkString(v.fsIn()), varyingType));
117 }
118 }
119 }
120
92 void GrGLGeometryProcessor::setupPosition(GrGLGPBuilder* pb, 121 void GrGLGeometryProcessor::setupPosition(GrGLGPBuilder* pb,
93 GrGPArgs* gpArgs, 122 GrGPArgs* gpArgs,
94 const char* posName) { 123 const char* posName) {
95 GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder(); 124 GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
96 gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2"); 125 gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2");
97 vsBuilder->codeAppendf("vec2 %s = %s;", gpArgs->fPositionVar.c_str(), posNam e); 126 vsBuilder->codeAppendf("vec2 %s = %s;", gpArgs->fPositionVar.c_str(), posNam e);
98 } 127 }
99 128
100 void GrGLGeometryProcessor::setupPosition(GrGLGPBuilder* pb, 129 void GrGLGeometryProcessor::setupPosition(GrGLGPBuilder* pb,
101 GrGPArgs* gpArgs, 130 GrGPArgs* gpArgs,
(...skipping 14 matching lines...) Expand all
116 gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2"); 145 gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2");
117 vsBuilder->codeAppendf("vec2 %s = vec2(%s * vec3(%s, 1));", 146 vsBuilder->codeAppendf("vec2 %s = vec2(%s * vec3(%s, 1));",
118 gpArgs->fPositionVar.c_str(), viewMatrixName, posName); 147 gpArgs->fPositionVar.c_str(), viewMatrixName, posName);
119 } else { 148 } else {
120 gpArgs->fPositionVar.set(kVec3f_GrSLType, "pos3"); 149 gpArgs->fPositionVar.set(kVec3f_GrSLType, "pos3");
121 vsBuilder->codeAppendf("vec3 %s = %s * vec3(%s, 1);", 150 vsBuilder->codeAppendf("vec3 %s = %s * vec3(%s, 1);",
122 gpArgs->fPositionVar.c_str(), viewMatrixName, posName); 151 gpArgs->fPositionVar.c_str(), viewMatrixName, posName);
123 } 152 }
124 } 153 }
125 } 154 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLGeometryProcessor.h ('k') | src/gpu/gl/builders/GrGLProgramBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698