| 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/GrGLSLColorSpaceXformHelper.h" | 10 #include "glsl/GrGLSLColorSpaceXformHelper.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 68 |
| 69 static const GrGLSLShaderVar gCubicBlendArgs[] = { | 69 static const GrGLSLShaderVar gCubicBlendArgs[] = { |
| 70 GrGLSLShaderVar("coefficients", kMat44f_GrSLType), | 70 GrGLSLShaderVar("coefficients", kMat44f_GrSLType), |
| 71 GrGLSLShaderVar("t", kFloat_GrSLType), | 71 GrGLSLShaderVar("t", kFloat_GrSLType), |
| 72 GrGLSLShaderVar("c0", kVec4f_GrSLType), | 72 GrGLSLShaderVar("c0", kVec4f_GrSLType), |
| 73 GrGLSLShaderVar("c1", kVec4f_GrSLType), | 73 GrGLSLShaderVar("c1", kVec4f_GrSLType), |
| 74 GrGLSLShaderVar("c2", kVec4f_GrSLType), | 74 GrGLSLShaderVar("c2", kVec4f_GrSLType), |
| 75 GrGLSLShaderVar("c3", kVec4f_GrSLType), | 75 GrGLSLShaderVar("c3", kVec4f_GrSLType), |
| 76 }; | 76 }; |
| 77 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; | 77 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; |
| 78 SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0); | 78 SkString coords2D = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]); |
| 79 fragBuilder->emitFunction(kVec4f_GrSLType, | 79 fragBuilder->emitFunction(kVec4f_GrSLType, |
| 80 "cubicBlend", | 80 "cubicBlend", |
| 81 SK_ARRAY_COUNT(gCubicBlendArgs), | 81 SK_ARRAY_COUNT(gCubicBlendArgs), |
| 82 gCubicBlendArgs, | 82 gCubicBlendArgs, |
| 83 "\tvec4 ts = vec4(1.0, t, t * t, t * t * t);\n" | 83 "\tvec4 ts = vec4(1.0, t, t * t, t * t * t);\n" |
| 84 "\tvec4 c = coefficients * ts;\n" | 84 "\tvec4 c = coefficients * ts;\n" |
| 85 "\treturn c.x * c0 + c.y * c1 + c.z * c2 + c.w * c
3;\n", | 85 "\treturn c.x * c0 + c.y * c1 + c.z * c2 + c.w * c
3;\n", |
| 86 &cubicBlendName); | 86 &cubicBlendName); |
| 87 fragBuilder->codeAppendf("\tvec2 coord = %s - %s * vec2(0.5);\n", coords2D.c
_str(), imgInc); | 87 fragBuilder->codeAppendf("\tvec2 coord = %s - %s * vec2(0.5);\n", coords2D.c
_str(), imgInc); |
| 88 // We unnormalize the coord in order to determine our fractional offset (f)
within the texel | 88 // We unnormalize the coord in order to determine our fractional offset (f)
within the texel |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 // Use bilerp to handle rotation or fractional translation. | 233 // Use bilerp to handle rotation or fractional translation. |
| 234 *filterMode = GrTextureParams::kBilerp_FilterMode; | 234 *filterMode = GrTextureParams::kBilerp_FilterMode; |
| 235 } | 235 } |
| 236 return false; | 236 return false; |
| 237 } | 237 } |
| 238 // When we use the bicubic filtering effect each sample is read from the tex
ture using | 238 // When we use the bicubic filtering effect each sample is read from the tex
ture using |
| 239 // nearest neighbor sampling. | 239 // nearest neighbor sampling. |
| 240 *filterMode = GrTextureParams::kNone_FilterMode; | 240 *filterMode = GrTextureParams::kNone_FilterMode; |
| 241 return true; | 241 return true; |
| 242 } | 242 } |
| OLD | NEW |