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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 SkString cubicBlendName; | 72 SkString cubicBlendName; |
73 | 73 |
74 static const GrGLShaderVar gCubicBlendArgs[] = { | 74 static const GrGLShaderVar gCubicBlendArgs[] = { |
75 GrGLShaderVar("coefficients", kMat44f_GrSLType), | 75 GrGLShaderVar("coefficients", kMat44f_GrSLType), |
76 GrGLShaderVar("t", kFloat_GrSLType), | 76 GrGLShaderVar("t", kFloat_GrSLType), |
77 GrGLShaderVar("c0", kVec4f_GrSLType), | 77 GrGLShaderVar("c0", kVec4f_GrSLType), |
78 GrGLShaderVar("c1", kVec4f_GrSLType), | 78 GrGLShaderVar("c1", kVec4f_GrSLType), |
79 GrGLShaderVar("c2", kVec4f_GrSLType), | 79 GrGLShaderVar("c2", kVec4f_GrSLType), |
80 GrGLShaderVar("c3", kVec4f_GrSLType), | 80 GrGLShaderVar("c3", kVec4f_GrSLType), |
81 }; | 81 }; |
82 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); | 82 GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); |
83 SkString coords2D = fsBuilder->ensureFSCoords2D(coords, 0); | 83 SkString coords2D = fsBuilder->ensureFSCoords2D(coords, 0); |
84 fsBuilder->emitFunction(kVec4f_GrSLType, | 84 fsBuilder->emitFunction(kVec4f_GrSLType, |
85 "cubicBlend", | 85 "cubicBlend", |
86 SK_ARRAY_COUNT(gCubicBlendArgs), | 86 SK_ARRAY_COUNT(gCubicBlendArgs), |
87 gCubicBlendArgs, | 87 gCubicBlendArgs, |
88 "\tvec4 ts = vec4(1.0, t, t * t, t * t * t);\n" | 88 "\tvec4 ts = vec4(1.0, t, t * t, t * t * t);\n" |
89 "\tvec4 c = coefficients * ts;\n" | 89 "\tvec4 c = coefficients * ts;\n" |
90 "\treturn c.x * c0 + c.y * c1 + c.z * c2 + c.w * c3;
\n", | 90 "\treturn c.x * c0 + c.y * c1 + c.z * c2 + c.w * c3;
\n", |
91 &cubicBlendName); | 91 &cubicBlendName); |
92 fsBuilder->codeAppendf("\tvec2 coord = %s - %s * vec2(0.5);\n", coords2D.c_s
tr(), imgInc); | 92 fsBuilder->codeAppendf("\tvec2 coord = %s - %s * vec2(0.5);\n", coords2D.c_s
tr(), imgInc); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 // Use bilerp to handle rotation or fractional translation. | 218 // Use bilerp to handle rotation or fractional translation. |
219 *filterMode = GrTextureParams::kBilerp_FilterMode; | 219 *filterMode = GrTextureParams::kBilerp_FilterMode; |
220 } | 220 } |
221 return false; | 221 return false; |
222 } | 222 } |
223 // When we use the bicubic filtering effect each sample is read from the tex
ture using | 223 // When we use the bicubic filtering effect each sample is read from the tex
ture using |
224 // nearest neighbor sampling. | 224 // nearest neighbor sampling. |
225 *filterMode = GrTextureParams::kNone_FilterMode; | 225 *filterMode = GrTextureParams::kNone_FilterMode; |
226 return true; | 226 return true; |
227 } | 227 } |
OLD | NEW |