OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 #ifndef GrBicubicTextureEffect_DEFINED | 8 #ifndef GrBicubicTextureEffect_DEFINED |
9 #define GrBicubicTextureEffect_DEFINED | 9 #define GrBicubicTextureEffect_DEFINED |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 /** | 37 /** |
38 * Create a simple filter effect with custom bicubic coefficients and option
al domain. | 38 * Create a simple filter effect with custom bicubic coefficients and option
al domain. |
39 */ | 39 */ |
40 static GrEffectRef* Create(GrTexture* tex, const SkScalar coefficients[16], | 40 static GrEffectRef* Create(GrTexture* tex, const SkScalar coefficients[16], |
41 const SkRect* domain = NULL) { | 41 const SkRect* domain = NULL) { |
42 if (NULL == domain) { | 42 if (NULL == domain) { |
43 static const SkShader::TileMode kTileModes[] = { SkShader::kClamp_Ti
leMode, | 43 static const SkShader::TileMode kTileModes[] = { SkShader::kClamp_Ti
leMode, |
44 SkShader::kClamp_Ti
leMode }; | 44 SkShader::kClamp_Ti
leMode }; |
45 return Create(tex, coefficients, MakeDivByTextureWHMatrix(tex), kTil
eModes); | 45 return Create(tex, coefficients, MakeDivByTextureWHMatrix(tex), kTil
eModes); |
46 } else { | 46 } else { |
47 AutoEffectUnref effect(SkNEW_ARGS(GrBicubicEffect, (tex, coefficient
s, | 47 return SkNEW_ARGS(GrBicubicEffect, (tex, coefficients, |
48 MakeDivByTexture
WHMatrix(tex), | 48 MakeDivByTextureWHMatrix(tex), *
domain)); |
49 *domain))); | |
50 return CreateEffectRef(effect); | |
51 } | 49 } |
52 } | 50 } |
53 | 51 |
54 /** | 52 /** |
55 * Create a Mitchell filter effect with specified texture matrix and x/y til
e modes. | 53 * Create a Mitchell filter effect with specified texture matrix and x/y til
e modes. |
56 */ | 54 */ |
57 static GrEffectRef* Create(GrTexture* tex, const SkMatrix& matrix, | 55 static GrEffectRef* Create(GrTexture* tex, const SkMatrix& matrix, |
58 SkShader::TileMode tileModes[2]) { | 56 SkShader::TileMode tileModes[2]) { |
59 return Create(tex, gMitchellCoefficients, matrix, tileModes); | 57 return Create(tex, gMitchellCoefficients, matrix, tileModes); |
60 } | 58 } |
61 | 59 |
62 /** | 60 /** |
63 * Create a filter effect with custom bicubic coefficients, the texture matr
ix, and the x/y | 61 * Create a filter effect with custom bicubic coefficients, the texture matr
ix, and the x/y |
64 * tilemodes. | 62 * tilemodes. |
65 */ | 63 */ |
66 static GrEffectRef* Create(GrTexture* tex, const SkScalar coefficients[16], | 64 static GrEffectRef* Create(GrTexture* tex, const SkScalar coefficients[16], |
67 const SkMatrix& matrix, const SkShader::TileMode
tileModes[2]) { | 65 const SkMatrix& matrix, const SkShader::TileMode
tileModes[2]) { |
68 AutoEffectUnref effect(SkNEW_ARGS(GrBicubicEffect, (tex, coefficients, m
atrix, tileModes))); | 66 return SkNEW_ARGS(GrBicubicEffect, (tex, coefficients, matrix, tileModes
)); |
69 return CreateEffectRef(effect); | |
70 } | 67 } |
71 | 68 |
72 /** | 69 /** |
73 * Create a Mitchell filter effect with a texture matrix and a domain. | 70 * Create a Mitchell filter effect with a texture matrix and a domain. |
74 */ | 71 */ |
75 static GrEffectRef* Create(GrTexture* tex, const SkMatrix& matrix, const SkR
ect& domain) { | 72 static GrEffectRef* Create(GrTexture* tex, const SkMatrix& matrix, const SkR
ect& domain) { |
76 AutoEffectUnref effect(SkNEW_ARGS(GrBicubicEffect, (tex, gMitchellCoeffi
cients, matrix, | 73 return SkNEW_ARGS(GrBicubicEffect, (tex, gMitchellCoefficients, matrix,
domain)); |
77 domain))); | |
78 return CreateEffectRef(effect); | |
79 } | 74 } |
80 | 75 |
81 /** | 76 /** |
82 * Determines whether the bicubic effect should be used based on the transfo
rmation from the | 77 * Determines whether the bicubic effect should be used based on the transfo
rmation from the |
83 * local coords to the device. Returns true if the bicubic effect should be
used. filterMode | 78 * local coords to the device. Returns true if the bicubic effect should be
used. filterMode |
84 * is set to appropriate filtering mode to use regardless of the return resu
lt (e.g. when this | 79 * is set to appropriate filtering mode to use regardless of the return resu
lt (e.g. when this |
85 * returns false it may indicate that the best fallback is to use kMipMap, k
Bilerp, or | 80 * returns false it may indicate that the best fallback is to use kMipMap, k
Bilerp, or |
86 * kNearest). | 81 * kNearest). |
87 */ | 82 */ |
88 static bool ShouldUseBicubic(const SkMatrix& localCoordsToDevice, | 83 static bool ShouldUseBicubic(const SkMatrix& localCoordsToDevice, |
(...skipping 10 matching lines...) Expand all Loading... |
99 GrTextureDomain fDomain; | 94 GrTextureDomain fDomain; |
100 | 95 |
101 GR_DECLARE_EFFECT_TEST; | 96 GR_DECLARE_EFFECT_TEST; |
102 | 97 |
103 static const SkScalar gMitchellCoefficients[16]; | 98 static const SkScalar gMitchellCoefficients[16]; |
104 | 99 |
105 typedef GrSingleTextureEffect INHERITED; | 100 typedef GrSingleTextureEffect INHERITED; |
106 }; | 101 }; |
107 | 102 |
108 #endif | 103 #endif |
OLD | NEW |