| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "GrGLEffectMatrix.h" | 8 #include "GrGLEffectMatrix.h" |
| 9 #include "GrDrawEffect.h" | 9 #include "GrDrawEffect.h" |
| 10 #include "GrTexture.h" | 10 #include "GrTexture.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 // TODO: Handle vertexless shaders here before we start enabling them. | 51 // TODO: Handle vertexless shaders here before we start enabling them. |
| 52 GrGLShaderBuilder::VertexBuilder* vertexBuilder = builder->getVertexBuilder(
); | 52 GrGLShaderBuilder::VertexBuilder* vertexBuilder = builder->getVertexBuilder(
); |
| 53 SkASSERT(NULL != vertexBuilder); | 53 SkASSERT(NULL != vertexBuilder); |
| 54 | 54 |
| 55 GrSLType varyingType = kVoid_GrSLType; | 55 GrSLType varyingType = kVoid_GrSLType; |
| 56 const char* uniName; | 56 const char* uniName; |
| 57 key &= kKeyMask; | 57 key &= kKeyMask; |
| 58 switch (key & kMatrixTypeKeyMask) { | 58 switch (key & kMatrixTypeKeyMask) { |
| 59 case kIdentity_MatrixType: | 59 case kIdentity_MatrixType: |
| 60 fUniType = kVoid_GrSLType; | 60 fUniType = kVoid_GrSLType; |
| 61 uniName = NULL; |
| 61 varyingType = kVec2f_GrSLType; | 62 varyingType = kVec2f_GrSLType; |
| 62 break; | 63 break; |
| 63 case kTrans_MatrixType: | 64 case kTrans_MatrixType: |
| 64 fUniType = kVec2f_GrSLType; | 65 fUniType = kVec2f_GrSLType; |
| 65 uniName = "StageTranslate"; | 66 uniName = "StageTranslate"; |
| 66 varyingType = kVec2f_GrSLType; | 67 varyingType = kVec2f_GrSLType; |
| 67 break; | 68 break; |
| 68 case kNoPersp_MatrixType: | 69 case kNoPersp_MatrixType: |
| 69 fUniType = kMat33f_GrSLType; | 70 fUniType = kMat33f_GrSLType; |
| 70 uniName = "StageMatrix"; | 71 uniName = "StageMatrix"; |
| 71 varyingType = kVec2f_GrSLType; | 72 varyingType = kVec2f_GrSLType; |
| 72 break; | 73 break; |
| 73 case kGeneral_MatrixType: | 74 case kGeneral_MatrixType: |
| 74 fUniType = kMat33f_GrSLType; | 75 fUniType = kMat33f_GrSLType; |
| 75 uniName = "StageMatrix"; | 76 uniName = "StageMatrix"; |
| 76 varyingType = kVec3f_GrSLType; | 77 varyingType = kVec3f_GrSLType; |
| 77 break; | 78 break; |
| 78 default: | 79 default: |
| 79 GrCrash("Unexpected key."); | 80 GrCrash("Unexpected key."); |
| 80 } | 81 } |
| 81 SkString suffixedUniName; | 82 SkString suffixedUniName; |
| 82 if (NULL != suffix) { | |
| 83 suffixedUniName.append(uniName); | |
| 84 suffixedUniName.append(suffix); | |
| 85 uniName = suffixedUniName.c_str(); | |
| 86 } | |
| 87 if (kVoid_GrSLType != fUniType) { | 83 if (kVoid_GrSLType != fUniType) { |
| 84 if (NULL != suffix) { |
| 85 suffixedUniName.append(uniName); |
| 86 suffixedUniName.append(suffix); |
| 87 uniName = suffixedUniName.c_str(); |
| 88 } |
| 88 fUni = builder->addUniform(GrGLShaderBuilder::kVertex_Visibility, | 89 fUni = builder->addUniform(GrGLShaderBuilder::kVertex_Visibility, |
| 89 fUniType, | 90 fUniType, |
| 90 uniName, | 91 uniName, |
| 91 &uniName); | 92 &uniName); |
| 92 } | 93 } |
| 93 | 94 |
| 94 const char* varyingName = "MatrixCoord"; | 95 const char* varyingName = "MatrixCoord"; |
| 95 SkString suffixedVaryingName; | 96 SkString suffixedVaryingName; |
| 96 if (NULL != suffix) { | 97 if (NULL != suffix) { |
| 97 suffixedVaryingName.append(varyingName); | 98 suffixedVaryingName.append(varyingName); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 if (!fPrevMatrix.cheapEqualTo(combined)) { | 233 if (!fPrevMatrix.cheapEqualTo(combined)) { |
| 233 uniformManager.setSkMatrix(fUni, combined); | 234 uniformManager.setSkMatrix(fUni, combined); |
| 234 fPrevMatrix = combined; | 235 fPrevMatrix = combined; |
| 235 } | 236 } |
| 236 break; | 237 break; |
| 237 } | 238 } |
| 238 default: | 239 default: |
| 239 GrCrash("Unexpected uniform type."); | 240 GrCrash("Unexpected uniform type."); |
| 240 } | 241 } |
| 241 } | 242 } |
| OLD | NEW |