Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(456)

Side by Side Diff: src/gpu/effects/GrBicubicEffect.h

Issue 582963002: Solo gp (Closed) Base URL: https://skia.googlesource.com/skia.git@no_peb
Patch Set: rebase Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/effects/GrBezierEffect.cpp ('k') | src/gpu/effects/GrBicubicEffect.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include "GrSingleTextureEffect.h" 11 #include "GrSingleTextureEffect.h"
12 #include "GrTextureDomain.h" 12 #include "GrTextureDomain.h"
13 #include "gl/GrGLEffect.h" 13 #include "gl/GrGLProcessor.h"
14 #include "GrTBackendEffectFactory.h" 14 #include "GrTBackendProcessorFactory.h"
15 15
16 class GrGLBicubicEffect; 16 class GrGLBicubicEffect;
17 17
18 class GrBicubicEffect : public GrSingleTextureEffect { 18 class GrBicubicEffect : public GrSingleTextureEffect {
19 public: 19 public:
20 enum { 20 enum {
21 kFilterTexelPad = 2, // Given a src rect in texels to be filtered, this number of 21 kFilterTexelPad = 2, // Given a src rect in texels to be filtered, this number of
22 // surrounding texels are needed by the kernel in x and y. 22 // surrounding texels are needed by the kernel in x and y.
23 }; 23 };
24 virtual ~GrBicubicEffect(); 24 virtual ~GrBicubicEffect();
25 25
26 static const char* Name() { return "Bicubic"; } 26 static const char* Name() { return "Bicubic"; }
27 const float* coefficients() const { return fCoefficients; } 27 const float* coefficients() const { return fCoefficients; }
28 28
29 typedef GrGLBicubicEffect GLEffect; 29 typedef GrGLBicubicEffect GLProcessor;
30 30
31 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; 31 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR IDE;
32 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags ) const SK_OVERRIDE; 32 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags ) const SK_OVERRIDE;
33 33
34 const GrTextureDomain& domain() const { return fDomain; } 34 const GrTextureDomain& domain() const { return fDomain; }
35 35
36 /** 36 /**
37 * Create a simple filter effect with custom bicubic coefficients and option al domain. 37 * Create a simple filter effect with custom bicubic coefficients and option al domain.
38 */ 38 */
39 static GrEffect* Create(GrTexture* tex, const SkScalar coefficients[16], 39 static GrFragmentProcessor* Create(GrTexture* tex, const SkScalar coefficien ts[16],
40 const SkRect* domain = NULL) { 40 const SkRect* domain = NULL) {
41 if (NULL == domain) { 41 if (NULL == domain) {
42 static const SkShader::TileMode kTileModes[] = { SkShader::kClamp_Ti leMode, 42 static const SkShader::TileMode kTileModes[] = { SkShader::kClamp_Ti leMode,
43 SkShader::kClamp_Ti leMode }; 43 SkShader::kClamp_Ti leMode };
44 return Create(tex, coefficients, GrCoordTransform::MakeDivByTextureW HMatrix(tex), 44 return Create(tex, coefficients, GrCoordTransform::MakeDivByTextureW HMatrix(tex),
45 kTileModes); 45 kTileModes);
46 } else { 46 } else {
47 return SkNEW_ARGS(GrBicubicEffect, (tex, coefficients, 47 return SkNEW_ARGS(GrBicubicEffect, (tex, coefficients,
48 GrCoordTransform::MakeDivByTextu reWHMatrix(tex), 48 GrCoordTransform::MakeDivByTextu reWHMatrix(tex),
49 *domain)); 49 *domain));
50 } 50 }
51 } 51 }
52 52
53 /** 53 /**
54 * Create a Mitchell filter effect with specified texture matrix and x/y til e modes. 54 * Create a Mitchell filter effect with specified texture matrix and x/y til e modes.
55 */ 55 */
56 static GrEffect* Create(GrTexture* tex, const SkMatrix& matrix, 56 static GrFragmentProcessor* Create(GrTexture* tex, const SkMatrix& matrix,
57 SkShader::TileMode tileModes[2]) { 57 SkShader::TileMode tileModes[2]) {
58 return Create(tex, gMitchellCoefficients, matrix, tileModes); 58 return Create(tex, gMitchellCoefficients, matrix, tileModes);
59 } 59 }
60 60
61 /** 61 /**
62 * Create a filter effect with custom bicubic coefficients, the texture matr ix, and the x/y 62 * Create a filter effect with custom bicubic coefficients, the texture matr ix, and the x/y
63 * tilemodes. 63 * tilemodes.
64 */ 64 */
65 static GrEffect* Create(GrTexture* tex, const SkScalar coefficients[16], 65 static GrFragmentProcessor* Create(GrTexture* tex, const SkScalar coefficien ts[16],
66 const SkMatrix& matrix, const SkShader::TileMode til eModes[2]) { 66 const SkMatrix& matrix,
67 const SkShader::TileMode tileModes[2]) {
67 return SkNEW_ARGS(GrBicubicEffect, (tex, coefficients, matrix, tileModes )); 68 return SkNEW_ARGS(GrBicubicEffect, (tex, coefficients, matrix, tileModes ));
68 } 69 }
69 70
70 /** 71 /**
71 * Create a Mitchell filter effect with a texture matrix and a domain. 72 * Create a Mitchell filter effect with a texture matrix and a domain.
72 */ 73 */
73 static GrEffect* Create(GrTexture* tex, const SkMatrix& matrix, const SkRect & domain) { 74 static GrFragmentProcessor* Create(GrTexture* tex, const SkMatrix& matrix,
75 const SkRect& domain) {
74 return SkNEW_ARGS(GrBicubicEffect, (tex, gMitchellCoefficients, matrix, domain)); 76 return SkNEW_ARGS(GrBicubicEffect, (tex, gMitchellCoefficients, matrix, domain));
75 } 77 }
76 78
77 /** 79 /**
78 * Determines whether the bicubic effect should be used based on the transfo rmation from the 80 * Determines whether the bicubic effect should be used based on the transfo rmation from the
79 * local coords to the device. Returns true if the bicubic effect should be used. filterMode 81 * local coords to the device. Returns true if the bicubic effect should be used. filterMode
80 * is set to appropriate filtering mode to use regardless of the return resu lt (e.g. when this 82 * is set to appropriate filtering mode to use regardless of the return resu lt (e.g. when this
81 * returns false it may indicate that the best fallback is to use kMipMap, k Bilerp, or 83 * returns false it may indicate that the best fallback is to use kMipMap, k Bilerp, or
82 * kNearest). 84 * kNearest).
83 */ 85 */
84 static bool ShouldUseBicubic(const SkMatrix& localCoordsToDevice, 86 static bool ShouldUseBicubic(const SkMatrix& localCoordsToDevice,
85 GrTextureParams::FilterMode* filterMode); 87 GrTextureParams::FilterMode* filterMode);
86 88
87 private: 89 private:
88 GrBicubicEffect(GrTexture*, const SkScalar coefficients[16], 90 GrBicubicEffect(GrTexture*, const SkScalar coefficients[16],
89 const SkMatrix &matrix, const SkShader::TileMode tileModes[2 ]); 91 const SkMatrix &matrix, const SkShader::TileMode tileModes[2 ]);
90 GrBicubicEffect(GrTexture*, const SkScalar coefficients[16], 92 GrBicubicEffect(GrTexture*, const SkScalar coefficients[16],
91 const SkMatrix &matrix, const SkRect& domain); 93 const SkMatrix &matrix, const SkRect& domain);
92 virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE; 94 virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE;
93 95
94 float fCoefficients[16]; 96 float fCoefficients[16];
95 GrTextureDomain fDomain; 97 GrTextureDomain fDomain;
96 98
97 GR_DECLARE_EFFECT_TEST; 99 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
98 100
99 static const SkScalar gMitchellCoefficients[16]; 101 static const SkScalar gMitchellCoefficients[16];
100 102
101 typedef GrSingleTextureEffect INHERITED; 103 typedef GrSingleTextureEffect INHERITED;
102 }; 104 };
103 105
104 #endif 106 #endif
OLDNEW
« no previous file with comments | « src/gpu/effects/GrBezierEffect.cpp ('k') | src/gpu/effects/GrBicubicEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698