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 12 matching lines...) Expand all Loading... |
23 | 23 |
24 | 24 |
25 class GrGLBicubicEffect : public GrGLSLFragmentProcessor { | 25 class GrGLBicubicEffect : public GrGLSLFragmentProcessor { |
26 public: | 26 public: |
27 void emitCode(EmitArgs&) override; | 27 void emitCode(EmitArgs&) override; |
28 | 28 |
29 static inline void GenKey(const GrProcessor& effect, const GrGLSLCaps&, | 29 static inline void GenKey(const GrProcessor& effect, const GrGLSLCaps&, |
30 GrProcessorKeyBuilder* b) { | 30 GrProcessorKeyBuilder* b) { |
31 const GrBicubicEffect& bicubicEffect = effect.cast<GrBicubicEffect>(); | 31 const GrBicubicEffect& bicubicEffect = effect.cast<GrBicubicEffect>(); |
32 b->add32(GrTextureDomain::GLDomain::DomainKey(bicubicEffect.domain())); | 32 b->add32(GrTextureDomain::GLDomain::DomainKey(bicubicEffect.domain())); |
33 b->add32(SkToInt(SkToBool(bicubicEffect.colorSpaceXform()))); | 33 b->add32(GrColorSpaceXform::XformKey(bicubicEffect.colorSpaceXform())); |
34 } | 34 } |
35 | 35 |
36 protected: | 36 protected: |
37 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override
; | 37 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override
; |
38 | 38 |
39 private: | 39 private: |
40 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; | 40 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; |
41 | 41 |
42 UniformHandle fCoefficientsUni; | 42 UniformHandle fCoefficientsUni; |
43 UniformHandle fImageIncrementUni; | 43 UniformHandle fImageIncrementUni; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 coord, | 107 coord, |
108 args.fTexSamplers[0]); | 108 args.fTexSamplers[0]); |
109 } | 109 } |
110 fragBuilder->codeAppendf( | 110 fragBuilder->codeAppendf( |
111 "\tvec4 s%d = %s(%s, f.x, rowColors[0], rowColors[1], rowColors[2],
rowColors[3]);\n", | 111 "\tvec4 s%d = %s(%s, f.x, rowColors[0], rowColors[1], rowColors[2],
rowColors[3]);\n", |
112 y, cubicBlendName.c_str(), coeff); | 112 y, cubicBlendName.c_str(), coeff); |
113 } | 113 } |
114 SkString bicubicColor; | 114 SkString bicubicColor; |
115 bicubicColor.printf("%s(%s, f.y, s0, s1, s2, s3)", cubicBlendName.c_str(), c
oeff); | 115 bicubicColor.printf("%s(%s, f.y, s0, s1, s2, s3)", cubicBlendName.c_str(), c
oeff); |
116 if (colorSpaceHelper.getXformMatrix()) { | 116 if (colorSpaceHelper.getXformMatrix()) { |
117 bicubicColor.appendf(" * %s", colorSpaceHelper.getXformMatrix()); | 117 SkString xformedColor; |
| 118 fragBuilder->appendColorGamutXform(&xformedColor, bicubicColor.c_str(),
&colorSpaceHelper); |
| 119 bicubicColor.swap(xformedColor); |
118 } | 120 } |
119 fragBuilder->codeAppendf("\t%s = %s;\n", | 121 fragBuilder->codeAppendf("\t%s = %s;\n", |
120 args.fOutputColor, (GrGLSLExpr4(bicubicColor.c_str(
)) * | 122 args.fOutputColor, (GrGLSLExpr4(bicubicColor.c_str(
)) * |
121 GrGLSLExpr4(args.fInputColor)).
c_str()); | 123 GrGLSLExpr4(args.fInputColor)).
c_str()); |
122 } | 124 } |
123 | 125 |
124 void GrGLBicubicEffect::onSetData(const GrGLSLProgramDataManager& pdman, | 126 void GrGLBicubicEffect::onSetData(const GrGLSLProgramDataManager& pdman, |
125 const GrProcessor& processor) { | 127 const GrProcessor& processor) { |
126 const GrBicubicEffect& bicubicEffect = processor.cast<GrBicubicEffect>(); | 128 const GrBicubicEffect& bicubicEffect = processor.cast<GrBicubicEffect>(); |
127 const GrTexture& texture = *processor.texture(0); | 129 const GrTexture& texture = *processor.texture(0); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 // Use bilerp to handle rotation or fractional translation. | 233 // Use bilerp to handle rotation or fractional translation. |
232 *filterMode = GrTextureParams::kBilerp_FilterMode; | 234 *filterMode = GrTextureParams::kBilerp_FilterMode; |
233 } | 235 } |
234 return false; | 236 return false; |
235 } | 237 } |
236 // 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 |
237 // nearest neighbor sampling. | 239 // nearest neighbor sampling. |
238 *filterMode = GrTextureParams::kNone_FilterMode; | 240 *filterMode = GrTextureParams::kNone_FilterMode; |
239 return true; | 241 return true; |
240 } | 242 } |
OLD | NEW |