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 "GrGLSLPrimitiveProcessor.h" |
9 | 9 |
10 #include "glsl/GrGLSLProgramBuilder.h" | 10 #include "glsl/GrGLSLProgramBuilder.h" |
11 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 11 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
12 | 12 |
13 SkMatrix GrGLPrimitiveProcessor::GetTransformMatrix(const SkMatrix& localMatrix, | 13 SkMatrix GrGLSLPrimitiveProcessor::GetTransformMatrix(const SkMatrix& localMatri
x, |
14 const GrCoordTransform& coor
dTransform) { | 14 const GrCoordTransform& co
ordTransform) { |
15 SkMatrix combined; | 15 SkMatrix combined; |
16 // We only apply the localmatrix to localcoords | 16 // We only apply the localmatrix to localcoords |
17 if (kLocal_GrCoordSet == coordTransform.sourceCoords()) { | 17 if (kLocal_GrCoordSet == coordTransform.sourceCoords()) { |
18 combined.setConcat(coordTransform.getMatrix(), localMatrix); | 18 combined.setConcat(coordTransform.getMatrix(), localMatrix); |
19 } else { | 19 } else { |
20 combined = coordTransform.getMatrix(); | 20 combined = coordTransform.getMatrix(); |
21 } | 21 } |
22 if (coordTransform.reverseY()) { | 22 if (coordTransform.reverseY()) { |
23 // combined.postScale(1,-1); | 23 // combined.postScale(1,-1); |
24 // combined.postTranslate(0,1); | 24 // combined.postTranslate(0,1); |
25 combined.set(SkMatrix::kMSkewY, | 25 combined.set(SkMatrix::kMSkewY, |
26 combined[SkMatrix::kMPersp0] - combined[SkMatrix::kMSkewY]); | 26 combined[SkMatrix::kMPersp0] - combined[SkMatrix::kMSkewY]); |
27 combined.set(SkMatrix::kMScaleY, | 27 combined.set(SkMatrix::kMScaleY, |
28 combined[SkMatrix::kMPersp1] - combined[SkMatrix::kMScaleY]); | 28 combined[SkMatrix::kMPersp1] - combined[SkMatrix::kMScaleY]); |
29 combined.set(SkMatrix::kMTransY, | 29 combined.set(SkMatrix::kMTransY, |
30 combined[SkMatrix::kMPersp2] - combined[SkMatrix::kMTransY]); | 30 combined[SkMatrix::kMPersp2] - combined[SkMatrix::kMTransY]); |
31 } | 31 } |
32 return combined; | 32 return combined; |
33 } | 33 } |
34 | 34 |
35 void GrGLPrimitiveProcessor::setupUniformColor(GrGLSLGPBuilder* pb, | 35 void GrGLSLPrimitiveProcessor::setupUniformColor(GrGLSLGPBuilder* pb, |
36 const char* outputName, | 36 const char* outputName, |
37 UniformHandle* colorUniform) { | 37 UniformHandle* colorUniform) { |
38 GrGLSLFragmentBuilder* fs = pb->getFragmentShaderBuilder(); | 38 GrGLSLFragmentBuilder* fs = pb->getFragmentShaderBuilder(); |
39 SkASSERT(colorUniform); | 39 SkASSERT(colorUniform); |
40 const char* stagedLocalVarName; | 40 const char* stagedLocalVarName; |
41 *colorUniform = pb->addUniform(GrGLSLProgramBuilder::kFragment_Visibility, | 41 *colorUniform = pb->addUniform(GrGLSLProgramBuilder::kFragment_Visibility, |
42 kVec4f_GrSLType, | 42 kVec4f_GrSLType, |
43 kDefault_GrSLPrecision, | 43 kDefault_GrSLPrecision, |
44 "Color", | 44 "Color", |
45 &stagedLocalVarName); | 45 &stagedLocalVarName); |
46 fs->codeAppendf("%s = %s;", outputName, stagedLocalVarName); | 46 fs->codeAppendf("%s = %s;", outputName, stagedLocalVarName); |
47 } | 47 } |
OLD | NEW |