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 "GrGLPrimitiveProcessor.h" | 8 #include "GrGLPrimitiveProcessor.h" |
9 | 9 |
10 #include "builders/GrGLProgramBuilder.h" | 10 #include "builders/GrGLProgramBuilder.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 combined.set(SkMatrix::kMSkewY, | 24 combined.set(SkMatrix::kMSkewY, |
25 combined[SkMatrix::kMPersp0] - combined[SkMatrix::kMSkewY]); | 25 combined[SkMatrix::kMPersp0] - combined[SkMatrix::kMSkewY]); |
26 combined.set(SkMatrix::kMScaleY, | 26 combined.set(SkMatrix::kMScaleY, |
27 combined[SkMatrix::kMPersp1] - combined[SkMatrix::kMScaleY]); | 27 combined[SkMatrix::kMPersp1] - combined[SkMatrix::kMScaleY]); |
28 combined.set(SkMatrix::kMTransY, | 28 combined.set(SkMatrix::kMTransY, |
29 combined[SkMatrix::kMPersp2] - combined[SkMatrix::kMTransY]); | 29 combined[SkMatrix::kMPersp2] - combined[SkMatrix::kMTransY]); |
30 } | 30 } |
31 return combined; | 31 return combined; |
32 } | 32 } |
33 | 33 |
34 void | 34 void GrGLPrimitiveProcessor::setupUniformColor(GrGLGPBuilder* pb, |
35 GrGLPrimitiveProcessor::setupColorPassThrough(GrGLGPBuilder* pb, | 35 const char* outputName, |
36 GrGPInput inputType, | 36 UniformHandle* colorUniform) { |
37 const char* outputName, | |
38 const GrGeometryProcessor::Attribu
te* colorAttr, | |
39 UniformHandle* colorUniform) { | |
40 GrGLFragmentBuilder* fs = pb->getFragmentShaderBuilder(); | 37 GrGLFragmentBuilder* fs = pb->getFragmentShaderBuilder(); |
41 if (kUniform_GrGPInput == inputType) { | 38 SkASSERT(colorUniform); |
42 SkASSERT(colorUniform); | 39 const char* stagedLocalVarName; |
43 const char* stagedLocalVarName; | 40 *colorUniform = pb->addUniform(GrGLProgramBuilder::kFragment_Visibility, |
44 *colorUniform = pb->addUniform(GrGLProgramBuilder::kFragment_Visibility, | 41 kVec4f_GrSLType, |
45 kVec4f_GrSLType, | 42 kDefault_GrSLPrecision, |
46 kDefault_GrSLPrecision, | 43 "Color", |
47 "Color", | 44 &stagedLocalVarName); |
48 &stagedLocalVarName); | 45 fs->codeAppendf("%s = %s;", outputName, stagedLocalVarName); |
49 fs->codeAppendf("%s = %s;", outputName, stagedLocalVarName); | |
50 } else if (kAttribute_GrGPInput == inputType) { | |
51 SkASSERT(colorAttr); | |
52 pb->addPassThroughAttribute(colorAttr, outputName); | |
53 } else if (kAllOnes_GrGPInput == inputType) { | |
54 fs->codeAppendf("%s = vec4(1);", outputName); | |
55 } | |
56 } | 46 } |
57 | 47 |
58 void GrGLPrimitiveProcessor::addUniformViewMatrix(GrGLGPBuilder* pb) { | 48 void GrGLPrimitiveProcessor::addUniformViewMatrix(GrGLGPBuilder* pb) { |
59 fViewMatrixUniform = pb->addUniform(GrGLProgramBuilder::kVertex_Visibility, | 49 fViewMatrixUniform = pb->addUniform(GrGLProgramBuilder::kVertex_Visibility, |
60 kMat33f_GrSLType, kDefault_GrSLPrecision
, | 50 kMat33f_GrSLType, kDefault_GrSLPrecision
, |
61 "uViewM", | 51 "uViewM", |
62 &fViewMatrixName); | 52 &fViewMatrixName); |
63 } | 53 } |
64 | 54 |
65 void GrGLPrimitiveProcessor::setUniformViewMatrix(const GrGLProgramDataManager&
pdman, | 55 void GrGLPrimitiveProcessor::setUniformViewMatrix(const GrGLProgramDataManager&
pdman, |
66 const SkMatrix& viewMatrix) { | 56 const SkMatrix& viewMatrix) { |
67 if (!viewMatrix.isIdentity() && !fViewMatrix.cheapEqualTo(viewMatrix)) { | 57 if (!viewMatrix.isIdentity() && !fViewMatrix.cheapEqualTo(viewMatrix)) { |
68 SkASSERT(fViewMatrixUniform.isValid()); | 58 SkASSERT(fViewMatrixUniform.isValid()); |
69 fViewMatrix = viewMatrix; | 59 fViewMatrix = viewMatrix; |
70 | 60 |
71 GrGLfloat viewMatrix[3 * 3]; | 61 GrGLfloat viewMatrix[3 * 3]; |
72 GrGLGetMatrix<3>(viewMatrix, fViewMatrix); | 62 GrGLGetMatrix<3>(viewMatrix, fViewMatrix); |
73 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); | 63 pdman.setMatrix3f(fViewMatrixUniform, viewMatrix); |
74 } | 64 } |
75 } | 65 } |
OLD | NEW |