| 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 "gl/GrGLShaderBuilder.h" | 8 #include "gl/builders/GrGLProgramBuilder.h" |
| 9 #include "gl/GrGLProgram.h" | 9 #include "gl/GrGLProgram.h" |
| 10 #include "gl/GrGLUniformHandle.h" | 10 #include "gl/GrGLUniformHandle.h" |
| 11 #include "gl/GrGpuGL.h" | 11 #include "gl/GrGpuGL.h" |
| 12 #include "SkMatrix.h" | 12 #include "SkMatrix.h" |
| 13 | 13 |
| 14 #define ASSERT_ARRAY_UPLOAD_IN_BOUNDS(UNI, COUNT) \ | 14 #define ASSERT_ARRAY_UPLOAD_IN_BOUNDS(UNI, COUNT) \ |
| 15 SkASSERT(arrayCount <= uni.fArrayCount || \ | 15 SkASSERT(arrayCount <= uni.fArrayCount || \ |
| 16 (1 == arrayCount && GrGLShaderVar::kNonArray == uni.fArrayCoun
t)) | 16 (1 == arrayCount && GrGLShaderVar::kNonArray == uni.fArrayCoun
t)) |
| 17 | 17 |
| 18 GrGLProgramDataManager::GrGLProgramDataManager(GrGpuGL* gpu, | 18 GrGLProgramDataManager::GrGLProgramDataManager(GrGpuGL* gpu, |
| 19 GrGLProgram*, | 19 GrGLProgram*, |
| 20 const GrGLShaderBuilder& builder) | 20 const GrGLProgramBuilder& builder
) |
| 21 : fGpu(gpu) { | 21 : fGpu(gpu) { |
| 22 int count = builder.getUniformInfos().count(); | 22 int count = builder.getUniformInfos().count(); |
| 23 fUniforms.push_back_n(count); | 23 fUniforms.push_back_n(count); |
| 24 for (int i = 0; i < count; i++) { | 24 for (int i = 0; i < count; i++) { |
| 25 Uniform& uniform = fUniforms[i]; | 25 Uniform& uniform = fUniforms[i]; |
| 26 const GrGLShaderBuilder::UniformInfo& builderUniform = builder.getUnifor
mInfos()[i]; | 26 const GrGLProgramBuilder::UniformInfo& builderUniform = builder.getUnifo
rmInfos()[i]; |
| 27 SkASSERT(GrGLShaderVar::kNonArray == builderUniform.fVariable.getArrayCo
unt() || | 27 SkASSERT(GrGLShaderVar::kNonArray == builderUniform.fVariable.getArrayCo
unt() || |
| 28 builderUniform.fVariable.getArrayCount() > 0); | 28 builderUniform.fVariable.getArrayCount() > 0); |
| 29 SkDEBUGCODE( | 29 SkDEBUGCODE( |
| 30 uniform.fArrayCount = builderUniform.fVariable.getArrayCount(); | 30 uniform.fArrayCount = builderUniform.fVariable.getArrayCount(); |
| 31 uniform.fType = builderUniform.fVariable.getType(); | 31 uniform.fType = builderUniform.fVariable.getType(); |
| 32 ); | 32 ); |
| 33 // TODO: Move the Xoom uniform array in both FS and VS bug workaround he
re. | 33 // TODO: Move the Xoom uniform array in both FS and VS bug workaround he
re. |
| 34 | 34 |
| 35 if (GrGLShaderBuilder::kVertex_Visibility & builderUniform.fVisibility)
{ | 35 if (GrGLProgramBuilder::kVertex_Visibility & builderUniform.fVisibility)
{ |
| 36 uniform.fVSLocation = builderUniform.fLocation; | 36 uniform.fVSLocation = builderUniform.fLocation; |
| 37 } else { | 37 } else { |
| 38 uniform.fVSLocation = kUnusedUniform; | 38 uniform.fVSLocation = kUnusedUniform; |
| 39 } | 39 } |
| 40 if (GrGLShaderBuilder::kFragment_Visibility & builderUniform.fVisibility
) { | 40 if (GrGLProgramBuilder::kFragment_Visibility & builderUniform.fVisibilit
y) { |
| 41 uniform.fFSLocation = builderUniform.fLocation; | 41 uniform.fFSLocation = builderUniform.fLocation; |
| 42 } else { | 42 } else { |
| 43 uniform.fFSLocation = kUnusedUniform; | 43 uniform.fFSLocation = kUnusedUniform; |
| 44 } | 44 } |
| 45 } | 45 } |
| 46 } | 46 } |
| 47 | 47 |
| 48 void GrGLProgramDataManager::setSampler(UniformHandle u, GrGLint texUnit) const
{ | 48 void GrGLProgramDataManager::setSampler(UniformHandle u, GrGLint texUnit) const
{ |
| 49 const Uniform& uni = fUniforms[u.toProgramDataIndex()]; | 49 const Uniform& uni = fUniforms[u.toProgramDataIndex()]; |
| 50 SkASSERT(uni.fType == kSampler2D_GrSLType); | 50 SkASSERT(uni.fType == kSampler2D_GrSLType); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 matrix.get(SkMatrix::kMPersp0), | 254 matrix.get(SkMatrix::kMPersp0), |
| 255 matrix.get(SkMatrix::kMSkewX), | 255 matrix.get(SkMatrix::kMSkewX), |
| 256 matrix.get(SkMatrix::kMScaleY), | 256 matrix.get(SkMatrix::kMScaleY), |
| 257 matrix.get(SkMatrix::kMPersp1), | 257 matrix.get(SkMatrix::kMPersp1), |
| 258 matrix.get(SkMatrix::kMTransX), | 258 matrix.get(SkMatrix::kMTransX), |
| 259 matrix.get(SkMatrix::kMTransY), | 259 matrix.get(SkMatrix::kMTransY), |
| 260 matrix.get(SkMatrix::kMPersp2), | 260 matrix.get(SkMatrix::kMPersp2), |
| 261 }; | 261 }; |
| 262 this->setMatrix3f(u, mt); | 262 this->setMatrix3f(u, mt); |
| 263 } | 263 } |
| OLD | NEW |