| OLD | NEW |
| 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" |
| 11 #include "glsl/GrGLSLProcessorTypes.h" |
| 11 | 12 |
| 12 void GrGLGeometryProcessor::emitCode(EmitArgs& args) { | 13 void GrGLGeometryProcessor::emitCode(EmitArgs& args) { |
| 13 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 14 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
| 14 GrGPArgs gpArgs; | 15 GrGPArgs gpArgs; |
| 15 this->onEmitCode(args, &gpArgs); | 16 this->onEmitCode(args, &gpArgs); |
| 16 vsBuilder->transformToNormalizedDeviceSpace(gpArgs.fPositionVar); | 17 vsBuilder->transformToNormalizedDeviceSpace(gpArgs.fPositionVar); |
| 17 } | 18 } |
| 18 | 19 |
| 19 void GrGLGeometryProcessor::emitTransforms(GrGLGPBuilder* pb, | 20 void GrGLGeometryProcessor::emitTransforms(GrGLGPBuilder* pb, |
| 20 const GrShaderVar& posVar, | 21 const GrShaderVar& posVar, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 49 strUniName.c_str(), | 50 strUniName.c_str(), |
| 50 &uniName).toIndex(); | 51 &uniName).toIndex(); |
| 51 | 52 |
| 52 SkString strVaryingName("MatrixCoord"); | 53 SkString strVaryingName("MatrixCoord"); |
| 53 strVaryingName.appendf("_%i_%i", i, t); | 54 strVaryingName.appendf("_%i_%i", i, t); |
| 54 | 55 |
| 55 GrGLVertToFrag v(varyingType); | 56 GrGLVertToFrag v(varyingType); |
| 56 pb->addVarying(strVaryingName.c_str(), &v, precision); | 57 pb->addVarying(strVaryingName.c_str(), &v, precision); |
| 57 | 58 |
| 58 SkASSERT(kVec2f_GrSLType == varyingType || kVec3f_GrSLType == varyin
gType); | 59 SkASSERT(kVec2f_GrSLType == varyingType || kVec3f_GrSLType == varyin
gType); |
| 59 SkNEW_APPEND_TO_TARRAY(&(*tout)[i], GrGLProcessor::TransformedCoords
, | 60 SkNEW_APPEND_TO_TARRAY(&(*tout)[i], GrGLSLTransformedCoords, |
| 60 (SkString(v.fsIn()), varyingType)); | 61 (SkString(v.fsIn()), varyingType)); |
| 61 | 62 |
| 62 // varying = matrix * coords (logically) | 63 // varying = matrix * coords (logically) |
| 63 if (kDevice_GrCoordSet == coordType) { | 64 if (kDevice_GrCoordSet == coordType) { |
| 64 if (kVec2f_GrSLType == varyingType) { | 65 if (kVec2f_GrSLType == varyingType) { |
| 65 if (kVec2f_GrSLType == posVar.getType()) { | 66 if (kVec2f_GrSLType == posVar.getType()) { |
| 66 vb->codeAppendf("%s = (%s * vec3(%s, 1)).xy;", | 67 vb->codeAppendf("%s = (%s * vec3(%s, 1)).xy;", |
| 67 v.vsOut(), uniName, posVar.c_str()); | 68 v.vsOut(), uniName, posVar.c_str()); |
| 68 } else { | 69 } else { |
| 69 // The brackets here are just to scope the temp variable | 70 // The brackets here are just to scope the temp variable |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 GrSLPrecision precision = coordTransforms[t]->precision(); | 106 GrSLPrecision precision = coordTransforms[t]->precision(); |
| 106 | 107 |
| 107 SkString strVaryingName("MatrixCoord"); | 108 SkString strVaryingName("MatrixCoord"); |
| 108 strVaryingName.appendf("_%i_%i", i, t); | 109 strVaryingName.appendf("_%i_%i", i, t); |
| 109 | 110 |
| 110 GrGLVertToFrag v(varyingType); | 111 GrGLVertToFrag v(varyingType); |
| 111 pb->addVarying(strVaryingName.c_str(), &v, precision); | 112 pb->addVarying(strVaryingName.c_str(), &v, precision); |
| 112 vb->codeAppendf("%s = %s;", v.vsOut(), localCoords); | 113 vb->codeAppendf("%s = %s;", v.vsOut(), localCoords); |
| 113 | 114 |
| 114 SkNEW_APPEND_TO_TARRAY(&(*tout)[i], | 115 SkNEW_APPEND_TO_TARRAY(&(*tout)[i], |
| 115 GrGLProcessor::TransformedCoords, | 116 GrGLSLTransformedCoords, |
| 116 (SkString(v.fsIn()), varyingType)); | 117 (SkString(v.fsIn()), varyingType)); |
| 117 } | 118 } |
| 118 } | 119 } |
| 119 } | 120 } |
| 120 | 121 |
| 121 void GrGLGeometryProcessor::setupPosition(GrGLGPBuilder* pb, | 122 void GrGLGeometryProcessor::setupPosition(GrGLGPBuilder* pb, |
| 122 GrGPArgs* gpArgs, | 123 GrGPArgs* gpArgs, |
| 123 const char* posName) { | 124 const char* posName) { |
| 124 GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder(); | 125 GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder(); |
| 125 gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2"); | 126 gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2"); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 145 gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2"); | 146 gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2"); |
| 146 vsBuilder->codeAppendf("vec2 %s = vec2(%s * vec3(%s, 1));", | 147 vsBuilder->codeAppendf("vec2 %s = vec2(%s * vec3(%s, 1));", |
| 147 gpArgs->fPositionVar.c_str(), viewMatrixName,
posName); | 148 gpArgs->fPositionVar.c_str(), viewMatrixName,
posName); |
| 148 } else { | 149 } else { |
| 149 gpArgs->fPositionVar.set(kVec3f_GrSLType, "pos3"); | 150 gpArgs->fPositionVar.set(kVec3f_GrSLType, "pos3"); |
| 150 vsBuilder->codeAppendf("vec3 %s = %s * vec3(%s, 1);", | 151 vsBuilder->codeAppendf("vec3 %s = %s * vec3(%s, 1);", |
| 151 gpArgs->fPositionVar.c_str(), viewMatrixName,
posName); | 152 gpArgs->fPositionVar.c_str(), viewMatrixName,
posName); |
| 152 } | 153 } |
| 153 } | 154 } |
| 154 } | 155 } |
| OLD | NEW |