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 | 9 |
10 #include "gl/GrGLShaderBuilder.h" | 10 #include "gl/GrGLShaderBuilder.h" |
11 | 11 |
12 #define DS(x) SkDoubleToScalar(x) | 12 #define DS(x) SkDoubleToScalar(x) |
13 | 13 |
14 const SkScalar GrBicubicEffect::gMitchellCoefficients[16] = { | 14 const SkScalar GrBicubicEffect::gMitchellCoefficients[16] = { |
15 DS( 1.0 / 18.0), DS(-9.0 / 18.0), DS( 15.0 / 18.0), DS( -7.0 / 18.0), | 15 DS( 1.0 / 18.0), DS(-9.0 / 18.0), DS( 15.0 / 18.0), DS( -7.0 / 18.0), |
16 DS(16.0 / 18.0), DS( 0.0 / 18.0), DS(-36.0 / 18.0), DS( 21.0 / 18.0), | 16 DS(16.0 / 18.0), DS( 0.0 / 18.0), DS(-36.0 / 18.0), DS( 21.0 / 18.0), |
17 DS( 1.0 / 18.0), DS( 9.0 / 18.0), DS( 27.0 / 18.0), DS(-21.0 / 18.0), | 17 DS( 1.0 / 18.0), DS( 9.0 / 18.0), DS( 27.0 / 18.0), DS(-21.0 / 18.0), |
18 DS( 0.0 / 18.0), DS( 0.0 / 18.0), DS( -6.0 / 18.0), DS( 7.0 / 18.0), | 18 DS( 0.0 / 18.0), DS( 0.0 / 18.0), DS( -6.0 / 18.0), DS( 7.0 / 18.0), |
19 }; | 19 }; |
20 | 20 |
21 | 21 |
22 class GrGLBicubicEffect : public GrGLEffect { | 22 class GrGLBicubicEffect : public GrGLEffect { |
23 public: | 23 public: |
24 GrGLBicubicEffect(const GrBackendEffectFactory& factory, | 24 GrGLBicubicEffect(const GrBackendEffectFactory& factory, |
25 const GrDrawEffect&); | 25 const GrDrawEffect&); |
26 | 26 |
27 virtual void emitCode(GrGLShaderBuilder*, | 27 virtual void emitCode(GrGLShaderBuilder*, |
28 const GrDrawEffect&, | 28 const GrDrawEffect&, |
29 EffectKey, | 29 const GrEffectKey&, |
30 const char* outputColor, | 30 const char* outputColor, |
31 const char* inputColor, | 31 const char* inputColor, |
32 const TransformedCoordsArray&, | 32 const TransformedCoordsArray&, |
33 const TextureSamplerArray&) SK_OVERRIDE; | 33 const TextureSamplerArray&) SK_OVERRIDE; |
34 | 34 |
35 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER
RIDE; | 35 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER
RIDE; |
36 | 36 |
37 static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCap
s&) { | 37 static inline void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&, |
| 38 GrEffectKeyBuilder* b) { |
38 const GrTextureDomain& domain = drawEffect.castEffect<GrBicubicEffect>()
.domain(); | 39 const GrTextureDomain& domain = drawEffect.castEffect<GrBicubicEffect>()
.domain(); |
39 return GrTextureDomain::GLDomain::DomainKey(domain); | 40 b->add32(GrTextureDomain::GLDomain::DomainKey(domain)); |
40 } | 41 } |
41 | 42 |
42 private: | 43 private: |
43 typedef GrGLUniformManager::UniformHandle UniformHandle; | 44 typedef GrGLUniformManager::UniformHandle UniformHandle; |
44 | 45 |
45 UniformHandle fCoefficientsUni; | 46 UniformHandle fCoefficientsUni; |
46 UniformHandle fImageIncrementUni; | 47 UniformHandle fImageIncrementUni; |
47 GrTextureDomain::GLDomain fDomain; | 48 GrTextureDomain::GLDomain fDomain; |
48 | 49 |
49 typedef GrGLEffect INHERITED; | 50 typedef GrGLEffect INHERITED; |
50 }; | 51 }; |
51 | 52 |
52 GrGLBicubicEffect::GrGLBicubicEffect(const GrBackendEffectFactory& factory, cons
t GrDrawEffect&) | 53 GrGLBicubicEffect::GrGLBicubicEffect(const GrBackendEffectFactory& factory, cons
t GrDrawEffect&) |
53 : INHERITED(factory) { | 54 : INHERITED(factory) { |
54 } | 55 } |
55 | 56 |
56 void GrGLBicubicEffect::emitCode(GrGLShaderBuilder* builder, | 57 void GrGLBicubicEffect::emitCode(GrGLShaderBuilder* builder, |
57 const GrDrawEffect& drawEffect, | 58 const GrDrawEffect& drawEffect, |
58 EffectKey key, | 59 const GrEffectKey& key, |
59 const char* outputColor, | 60 const char* outputColor, |
60 const char* inputColor, | 61 const char* inputColor, |
61 const TransformedCoordsArray& coords, | 62 const TransformedCoordsArray& coords, |
62 const TextureSamplerArray& samplers) { | 63 const TextureSamplerArray& samplers) { |
63 const GrTextureDomain& domain = drawEffect.castEffect<GrBicubicEffect>().dom
ain(); | 64 const GrTextureDomain& domain = drawEffect.castEffect<GrBicubicEffect>().dom
ain(); |
64 | 65 |
65 SkString coords2D = builder->ensureFSCoords2D(coords, 0); | 66 SkString coords2D = builder->ensureFSCoords2D(coords, 0); |
66 fCoefficientsUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibili
ty, | 67 fCoefficientsUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibili
ty, |
67 kMat44f_GrSLType, "Coefficients"); | 68 kMat44f_GrSLType, "Coefficients"); |
68 fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibi
lity, | 69 fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibi
lity, |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 // Use bilerp to handle rotation or fractional translation. | 213 // Use bilerp to handle rotation or fractional translation. |
213 *filterMode = GrTextureParams::kBilerp_FilterMode; | 214 *filterMode = GrTextureParams::kBilerp_FilterMode; |
214 } | 215 } |
215 return false; | 216 return false; |
216 } | 217 } |
217 // When we use the bicubic filtering effect each sample is read from the tex
ture using | 218 // When we use the bicubic filtering effect each sample is read from the tex
ture using |
218 // nearest neighbor sampling. | 219 // nearest neighbor sampling. |
219 *filterMode = GrTextureParams::kNone_FilterMode; | 220 *filterMode = GrTextureParams::kNone_FilterMode; |
220 return true; | 221 return true; |
221 } | 222 } |
OLD | NEW |