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 "GrBicubicEffect.h" | 8 #include "GrBicubicEffect.h" |
9 #include "GrInvariantOutput.h" | 9 #include "GrInvariantOutput.h" |
10 #include "gl/builders/GrGLProgramBuilder.h" | 10 #include "gl/builders/GrGLProgramBuilder.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 "Coefficients"); | 55 "Coefficients"); |
56 fImageIncrementUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment
_Visibility, | 56 fImageIncrementUni = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment
_Visibility, |
57 kVec2f_GrSLType, kDefault_GrSLPreci
sion, | 57 kVec2f_GrSLType, kDefault_GrSLPreci
sion, |
58 "ImageIncrement"); | 58 "ImageIncrement"); |
59 | 59 |
60 const char* imgInc = args.fBuilder->getUniformCStr(fImageIncrementUni); | 60 const char* imgInc = args.fBuilder->getUniformCStr(fImageIncrementUni); |
61 const char* coeff = args.fBuilder->getUniformCStr(fCoefficientsUni); | 61 const char* coeff = args.fBuilder->getUniformCStr(fCoefficientsUni); |
62 | 62 |
63 SkString cubicBlendName; | 63 SkString cubicBlendName; |
64 | 64 |
65 static const GrGLShaderVar gCubicBlendArgs[] = { | 65 static const GrGLSLShaderVar gCubicBlendArgs[] = { |
66 GrGLShaderVar("coefficients", kMat44f_GrSLType), | 66 GrGLSLShaderVar("coefficients", kMat44f_GrSLType), |
67 GrGLShaderVar("t", kFloat_GrSLType), | 67 GrGLSLShaderVar("t", kFloat_GrSLType), |
68 GrGLShaderVar("c0", kVec4f_GrSLType), | 68 GrGLSLShaderVar("c0", kVec4f_GrSLType), |
69 GrGLShaderVar("c1", kVec4f_GrSLType), | 69 GrGLSLShaderVar("c1", kVec4f_GrSLType), |
70 GrGLShaderVar("c2", kVec4f_GrSLType), | 70 GrGLSLShaderVar("c2", kVec4f_GrSLType), |
71 GrGLShaderVar("c3", kVec4f_GrSLType), | 71 GrGLSLShaderVar("c3", kVec4f_GrSLType), |
72 }; | 72 }; |
73 GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder(); | 73 GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder(); |
74 SkString coords2D = fsBuilder->ensureFSCoords2D(args.fCoords, 0); | 74 SkString coords2D = fsBuilder->ensureFSCoords2D(args.fCoords, 0); |
75 fsBuilder->emitFunction(kVec4f_GrSLType, | 75 fsBuilder->emitFunction(kVec4f_GrSLType, |
76 "cubicBlend", | 76 "cubicBlend", |
77 SK_ARRAY_COUNT(gCubicBlendArgs), | 77 SK_ARRAY_COUNT(gCubicBlendArgs), |
78 gCubicBlendArgs, | 78 gCubicBlendArgs, |
79 "\tvec4 ts = vec4(1.0, t, t * t, t * t * t);\n" | 79 "\tvec4 ts = vec4(1.0, t, t * t, t * t * t);\n" |
80 "\tvec4 c = coefficients * ts;\n" | 80 "\tvec4 c = coefficients * ts;\n" |
81 "\treturn c.x * c0 + c.y * c1 + c.z * c2 + c.w * c3;
\n", | 81 "\treturn c.x * c0 + c.y * c1 + c.z * c2 + c.w * c3;
\n", |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 // Use bilerp to handle rotation or fractional translation. | 207 // Use bilerp to handle rotation or fractional translation. |
208 *filterMode = GrTextureParams::kBilerp_FilterMode; | 208 *filterMode = GrTextureParams::kBilerp_FilterMode; |
209 } | 209 } |
210 return false; | 210 return false; |
211 } | 211 } |
212 // When we use the bicubic filtering effect each sample is read from the tex
ture using | 212 // When we use the bicubic filtering effect each sample is read from the tex
ture using |
213 // nearest neighbor sampling. | 213 // nearest neighbor sampling. |
214 *filterMode = GrTextureParams::kNone_FilterMode; | 214 *filterMode = GrTextureParams::kNone_FilterMode; |
215 return true; | 215 return true; |
216 } | 216 } |
OLD | NEW |