| 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" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 for (int t = 0; t < numTransforms; ++t) { | 99 for (int t = 0; t < numTransforms; ++t) { |
| 100 SkASSERT(procTransforms[t].fHandle.isValid()); | 100 SkASSERT(procTransforms[t].fHandle.isValid()); |
| 101 const SkMatrix& transform = GetTransformMatrix(primProc.localMatrix(), *
transforms[t]); | 101 const SkMatrix& transform = GetTransformMatrix(primProc.localMatrix(), *
transforms[t]); |
| 102 if (!procTransforms[t].fCurrentValue.cheapEqualTo(transform)) { | 102 if (!procTransforms[t].fCurrentValue.cheapEqualTo(transform)) { |
| 103 pdman.setSkMatrix(procTransforms[t].fHandle.convertToUniformHandle()
, transform); | 103 pdman.setSkMatrix(procTransforms[t].fHandle.convertToUniformHandle()
, transform); |
| 104 procTransforms[t].fCurrentValue = transform; | 104 procTransforms[t].fCurrentValue = transform; |
| 105 } | 105 } |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 | 108 |
| 109 void GrGLGeometryProcessor::SetupPosition(GrGLVertexBuilder* vsBuilder, | 109 void GrGLGeometryProcessor::setupPosition(GrGLGPBuilder* pb, |
| 110 GrGPArgs* gpArgs, | 110 GrGPArgs* gpArgs, |
| 111 const char* posName, | 111 const char* posName, |
| 112 const SkMatrix& mat, | 112 const SkMatrix& mat) { |
| 113 const char* matName) { | 113 GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder(); |
| 114 if (mat.isIdentity()) { | 114 if (mat.isIdentity()) { |
| 115 gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2"); | 115 gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2"); |
| 116 | 116 |
| 117 vsBuilder->codeAppendf("vec2 %s = %s;", gpArgs->fPositionVar.c_str(), po
sName); | 117 vsBuilder->codeAppendf("vec2 %s = %s;", gpArgs->fPositionVar.c_str(), po
sName); |
| 118 } else if (!mat.hasPerspective()) { | 118 } else if (!mat.hasPerspective()) { |
| 119 this->addUniformViewMatrix(pb); |
| 119 gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2"); | 120 gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2"); |
| 120 | 121 |
| 121 vsBuilder->codeAppendf("vec2 %s = vec2(%s * vec3(%s, 1));", | 122 vsBuilder->codeAppendf("vec2 %s = vec2(%s * vec3(%s, 1));", |
| 122 gpArgs->fPositionVar.c_str(), matName, posName); | 123 gpArgs->fPositionVar.c_str(), this->uViewM(), pos
Name); |
| 123 } else { | 124 } else { |
| 125 this->addUniformViewMatrix(pb); |
| 124 gpArgs->fPositionVar.set(kVec3f_GrSLType, "pos3"); | 126 gpArgs->fPositionVar.set(kVec3f_GrSLType, "pos3"); |
| 125 | 127 |
| 126 vsBuilder->codeAppendf("vec3 %s = %s * vec3(%s, 1);", | 128 vsBuilder->codeAppendf("vec3 %s = %s * vec3(%s, 1);", |
| 127 gpArgs->fPositionVar.c_str(), matName, posName); | 129 gpArgs->fPositionVar.c_str(), this->uViewM(), pos
Name); |
| 128 } | 130 } |
| 129 } | 131 } |
| OLD | NEW |