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 "glsl/GrGLSLFragmentShaderBuilder.h" | 10 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 SkString cubicBlendName; | 61 SkString cubicBlendName; |
62 | 62 |
63 static const GrGLSLShaderVar gCubicBlendArgs[] = { | 63 static const GrGLSLShaderVar gCubicBlendArgs[] = { |
64 GrGLSLShaderVar("coefficients", kMat44f_GrSLType), | 64 GrGLSLShaderVar("coefficients", kMat44f_GrSLType), |
65 GrGLSLShaderVar("t", kFloat_GrSLType), | 65 GrGLSLShaderVar("t", kFloat_GrSLType), |
66 GrGLSLShaderVar("c0", kVec4f_GrSLType), | 66 GrGLSLShaderVar("c0", kVec4f_GrSLType), |
67 GrGLSLShaderVar("c1", kVec4f_GrSLType), | 67 GrGLSLShaderVar("c1", kVec4f_GrSLType), |
68 GrGLSLShaderVar("c2", kVec4f_GrSLType), | 68 GrGLSLShaderVar("c2", kVec4f_GrSLType), |
69 GrGLSLShaderVar("c3", kVec4f_GrSLType), | 69 GrGLSLShaderVar("c3", kVec4f_GrSLType), |
70 }; | 70 }; |
71 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; | 71 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; |
72 SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0); | 72 SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0); |
73 fragBuilder->emitFunction(kVec4f_GrSLType, | 73 fragBuilder->emitFunction(kVec4f_GrSLType, |
74 "cubicBlend", | 74 "cubicBlend", |
75 SK_ARRAY_COUNT(gCubicBlendArgs), | 75 SK_ARRAY_COUNT(gCubicBlendArgs), |
76 gCubicBlendArgs, | 76 gCubicBlendArgs, |
77 "\tvec4 ts = vec4(1.0, t, t * t, t * t * t);\n" | 77 "\tvec4 ts = vec4(1.0, t, t * t, t * t * t);\n" |
78 "\tvec4 c = coefficients * ts;\n" | 78 "\tvec4 c = coefficients * ts;\n" |
79 "\treturn c.x * c0 + c.y * c1 + c.z * c2 + c.w * c
3;\n", | 79 "\treturn c.x * c0 + c.y * c1 + c.z * c2 + c.w * c
3;\n", |
80 &cubicBlendName); | 80 &cubicBlendName); |
81 fragBuilder->codeAppendf("\tvec2 coord = %s - %s * vec2(0.5);\n", coords2D.c
_str(), imgInc); | 81 fragBuilder->codeAppendf("\tvec2 coord = %s - %s * vec2(0.5);\n", coords2D.c
_str(), imgInc); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 // Use bilerp to handle rotation or fractional translation. | 214 // Use bilerp to handle rotation or fractional translation. |
215 *filterMode = GrTextureParams::kBilerp_FilterMode; | 215 *filterMode = GrTextureParams::kBilerp_FilterMode; |
216 } | 216 } |
217 return false; | 217 return false; |
218 } | 218 } |
219 // When we use the bicubic filtering effect each sample is read from the tex
ture using | 219 // When we use the bicubic filtering effect each sample is read from the tex
ture using |
220 // nearest neighbor sampling. | 220 // nearest neighbor sampling. |
221 *filterMode = GrTextureParams::kNone_FilterMode; | 221 *filterMode = GrTextureParams::kNone_FilterMode; |
222 return true; | 222 return true; |
223 } | 223 } |
OLD | NEW |