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/builders/GrGLProgramBuilder.h" | 8 #include "gl/builders/GrGLProgramBuilder.h" |
| 9 #include "gl/GrGLPathRendering.h" |
9 #include "gl/GrGLProgram.h" | 10 #include "gl/GrGLProgram.h" |
10 #include "gl/GrGLUniformHandle.h" | 11 #include "gl/GrGLUniformHandle.h" |
11 #include "gl/GrGpuGL.h" | 12 #include "gl/GrGpuGL.h" |
12 #include "SkMatrix.h" | 13 #include "SkMatrix.h" |
13 | 14 |
14 #define ASSERT_ARRAY_UPLOAD_IN_BOUNDS(UNI, COUNT) \ | 15 #define ASSERT_ARRAY_UPLOAD_IN_BOUNDS(UNI, COUNT) \ |
15 SkASSERT(arrayCount <= uni.fArrayCount || \ | 16 SkASSERT(arrayCount <= uni.fArrayCount || \ |
16 (1 == arrayCount && GrGLShaderVar::kNonArray == uni.fArrayCoun
t)) | 17 (1 == arrayCount && GrGLShaderVar::kNonArray == uni.fArrayCoun
t)) |
17 | 18 |
18 GrGLProgramDataManager::GrGLProgramDataManager(GrGpuGL* gpu, | 19 GrGLProgramDataManager::GrGLProgramDataManager(GrGpuGL* gpu, |
19 GrGLProgram*, | 20 GrGLProgram* program, |
20 const GrGLProgramBuilder& builder
) | 21 const GrGLProgramBuilder& builder
) |
21 : fGpu(gpu) { | 22 : fGpu(gpu), |
| 23 fProgram(program) { |
22 int count = builder.getUniformInfos().count(); | 24 int count = builder.getUniformInfos().count(); |
23 fUniforms.push_back_n(count); | 25 fUniforms.push_back_n(count); |
24 for (int i = 0; i < count; i++) { | 26 for (int i = 0; i < count; i++) { |
25 Uniform& uniform = fUniforms[i]; | 27 Uniform& uniform = fUniforms[i]; |
26 const GrGLProgramBuilder::UniformInfo& builderUniform = builder.getUnifo
rmInfos()[i]; | 28 const GrGLProgramBuilder::UniformInfo& builderUniform = builder.getUnifo
rmInfos()[i]; |
27 SkASSERT(GrGLShaderVar::kNonArray == builderUniform.fVariable.getArrayCo
unt() || | 29 SkASSERT(GrGLShaderVar::kNonArray == builderUniform.fVariable.getArrayCo
unt() || |
28 builderUniform.fVariable.getArrayCount() > 0); | 30 builderUniform.fVariable.getArrayCount() > 0); |
29 SkDEBUGCODE( | 31 SkDEBUGCODE( |
30 uniform.fArrayCount = builderUniform.fVariable.getArrayCount(); | 32 uniform.fArrayCount = builderUniform.fVariable.getArrayCount(); |
31 uniform.fType = builderUniform.fVariable.getType(); | 33 uniform.fType = builderUniform.fVariable.getType(); |
32 ); | 34 ); |
33 // TODO: Move the Xoom uniform array in both FS and VS bug workaround he
re. | 35 // TODO: Move the Xoom uniform array in both FS and VS bug workaround he
re. |
34 | 36 |
35 if (GrGLProgramBuilder::kVertex_Visibility & builderUniform.fVisibility)
{ | 37 if (GrGLProgramBuilder::kVertex_Visibility & builderUniform.fVisibility)
{ |
36 uniform.fVSLocation = builderUniform.fLocation; | 38 uniform.fVSLocation = builderUniform.fLocation; |
37 } else { | 39 } else { |
38 uniform.fVSLocation = kUnusedUniform; | 40 uniform.fVSLocation = kUnusedUniform; |
39 } | 41 } |
40 if (GrGLProgramBuilder::kFragment_Visibility & builderUniform.fVisibilit
y) { | 42 if (GrGLProgramBuilder::kFragment_Visibility & builderUniform.fVisibilit
y) { |
41 uniform.fFSLocation = builderUniform.fLocation; | 43 uniform.fFSLocation = builderUniform.fLocation; |
42 } else { | 44 } else { |
43 uniform.fFSLocation = kUnusedUniform; | 45 uniform.fFSLocation = kUnusedUniform; |
44 } | 46 } |
45 } | 47 } |
| 48 |
| 49 count = builder.getSeparableVaryingInfos().count(); |
| 50 fVaryings.push_back_n(count); |
| 51 for (int i = 0; i < count; i++) { |
| 52 Varying& varying = fVaryings[i]; |
| 53 const GrGLProgramBuilder::SeparableVaryingInfo& builderVarying = |
| 54 builder.getSeparableVaryingInfos()[i]; |
| 55 SkASSERT(GrGLShaderVar::kNonArray == builderVarying.fVariable.getArrayCo
unt()); |
| 56 SkDEBUGCODE( |
| 57 varying.fType = builderVarying.fVariable.getType(); |
| 58 ); |
| 59 varying.fLocation = builderVarying.fLocation; |
| 60 } |
46 } | 61 } |
47 | 62 |
48 void GrGLProgramDataManager::setSampler(UniformHandle u, GrGLint texUnit) const
{ | 63 void GrGLProgramDataManager::setSampler(UniformHandle u, GrGLint texUnit) const
{ |
49 const Uniform& uni = fUniforms[u.toProgramDataIndex()]; | 64 const Uniform& uni = fUniforms[u.toProgramDataIndex()]; |
50 SkASSERT(uni.fType == kSampler2D_GrSLType); | 65 SkASSERT(uni.fType == kSampler2D_GrSLType); |
51 SkASSERT(GrGLShaderVar::kNonArray == uni.fArrayCount); | 66 SkASSERT(GrGLShaderVar::kNonArray == uni.fArrayCount); |
52 // FIXME: We still insert a single sampler uniform for every stage. If the s
hader does not | 67 // FIXME: We still insert a single sampler uniform for every stage. If the s
hader does not |
53 // reference the sampler then the compiler may have optimized it out. Uncomm
ent this assert | 68 // reference the sampler then the compiler may have optimized it out. Uncomm
ent this assert |
54 // once stages insert their own samplers. | 69 // once stages insert their own samplers. |
55 // SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLo
cation); | 70 // SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLo
cation); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 matrix.get(SkMatrix::kMPersp0), | 269 matrix.get(SkMatrix::kMPersp0), |
255 matrix.get(SkMatrix::kMSkewX), | 270 matrix.get(SkMatrix::kMSkewX), |
256 matrix.get(SkMatrix::kMScaleY), | 271 matrix.get(SkMatrix::kMScaleY), |
257 matrix.get(SkMatrix::kMPersp1), | 272 matrix.get(SkMatrix::kMPersp1), |
258 matrix.get(SkMatrix::kMTransX), | 273 matrix.get(SkMatrix::kMTransX), |
259 matrix.get(SkMatrix::kMTransY), | 274 matrix.get(SkMatrix::kMTransY), |
260 matrix.get(SkMatrix::kMPersp2), | 275 matrix.get(SkMatrix::kMPersp2), |
261 }; | 276 }; |
262 this->setMatrix3f(u, mt); | 277 this->setMatrix3f(u, mt); |
263 } | 278 } |
| 279 |
| 280 void GrGLProgramDataManager::setProgramPathFragmentInputTransform(VaryingHandle
i, |
| 281 unsigned compo
nents, |
| 282 const SkMatrix
& matrix) const { |
| 283 const Varying& fragmentInput = fVaryings[i.toProgramDataIndex()]; |
| 284 fGpu->glPathRendering()->setProgramPathFragmentInputTransform(fProgram->prog
ramID(), |
| 285 fragmentInput.
fLocation, |
| 286 GR_GL_OBJECT_L
INEAR, |
| 287 components, |
| 288 matrix); |
| 289 } |
OLD | NEW |