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 GrSimpleTextureEffect_DEFINED | 8 #ifndef GrHQScaleTextureEffect_DEFINED |
bsalomon
2013/09/03 20:55:17
Is this file and the cpp actually used? It looks l
humper
2013/09/03 21:45:53
Nope, this was an unintentional addition.
| |
9 #define GrSimpleTextureEffect_DEFINED | 9 #define GrHQScaleTextureEffect_DEFINED |
10 | 10 |
11 #include "GrSingleTextureEffect.h" | 11 #include "GrSingleTextureEffect.h" |
12 | 12 |
13 class GrGLSimpleTextureEffect; | 13 class GrGLHQScaleTextureEffect; |
14 | 14 |
15 /** | 15 /** |
16 * The output color of this effect is a modulation of the input color and a samp le from a texture. | 16 * The output color of this effect is a modulation of the input color and the fi ltered average of |
17 * several samples from a texture. It is based on Justin Novosad's GPU texture filtering code | |
18 * from GPU Gems 2. | |
19 * | |
17 * It allows explicit specification of the filtering and wrap modes (GrTexturePa rams). It can use | 20 * It allows explicit specification of the filtering and wrap modes (GrTexturePa rams). It can use |
18 * local coords, positions, or a custom vertex attribute as input texture coords . The input coords | 21 * local coords, positions, or a custom vertex attribute as input texture coords . The input coords |
19 * can have a matrix applied in the VS in both the local and position cases but not with a custom | 22 * can have a matrix applied in the VS in both the local and position cases but not with a custom |
20 * attribute coords at this time. It will add a varying to input interpolate tex ture coords to the | 23 * attribute coords at this time. It will add a varying to input interpolate tex ture coords to the |
21 * FS. | 24 * FS. |
22 */ | 25 */ |
23 class GrSimpleTextureEffect : public GrSingleTextureEffect { | 26 class GrHQScaleTextureEffect : public GrSingleTextureEffect { |
24 public: | 27 public: |
25 /* unfiltered, clamp mode */ | 28 /* unfiltered, clamp mode */ |
26 static GrEffectRef* Create(GrTexture* tex, | 29 static GrEffectRef* Create(GrTexture* tex, |
27 const SkMatrix& matrix, | 30 const SkMatrix& matrix, |
28 CoordsType coordsType = kLocal_CoordsType) { | 31 CoordsType coordsType = kLocal_CoordsType) { |
29 SkASSERT(kLocal_CoordsType == coordsType || kPosition_CoordsType == coor dsType); | 32 SkASSERT(kLocal_CoordsType == coordsType || kPosition_CoordsType == coor dsType); |
30 AutoEffectUnref effect(SkNEW_ARGS(GrSimpleTextureEffect, (tex, matrix, G rTextureParams::kNone_FilterMode, coordsType))); | 33 AutoEffectUnref effect(SkNEW_ARGS(GrHQScaleTextureEffect, (tex, matrix, GrTextureParams::kNone_FilterMode, coordsType))); |
31 return CreateEffectRef(effect); | 34 return CreateEffectRef(effect); |
32 } | 35 } |
33 | 36 |
34 /* clamp mode */ | 37 /* clamp mode */ |
35 static GrEffectRef* Create(GrTexture* tex, | 38 static GrEffectRef* Create(GrTexture* tex, |
36 const SkMatrix& matrix, | 39 const SkMatrix& matrix, |
37 GrTextureParams::FilterMode filterMode, | 40 GrTextureParams::FilterMode filterMode, |
38 CoordsType coordsType = kLocal_CoordsType) { | 41 CoordsType coordsType = kLocal_CoordsType) { |
39 SkASSERT(kLocal_CoordsType == coordsType || kPosition_CoordsType == coor dsType); | 42 SkASSERT(kLocal_CoordsType == coordsType || kPosition_CoordsType == coor dsType); |
40 AutoEffectUnref effect( | 43 AutoEffectUnref effect( |
41 SkNEW_ARGS(GrSimpleTextureEffect, (tex, matrix, filterMode, coordsTy pe))); | 44 SkNEW_ARGS(GrHQScaleTextureEffect, (tex, matrix, filterMode, coordsT ype))); |
42 return CreateEffectRef(effect); | 45 return CreateEffectRef(effect); |
43 } | 46 } |
44 | 47 |
45 static GrEffectRef* Create(GrTexture* tex, | 48 static GrEffectRef* Create(GrTexture* tex, |
46 const SkMatrix& matrix, | 49 const SkMatrix& matrix, |
47 const GrTextureParams& p, | 50 const GrTextureParams& p, |
48 CoordsType coordsType = kLocal_CoordsType) { | 51 CoordsType coordsType = kLocal_CoordsType) { |
49 SkASSERT(kLocal_CoordsType == coordsType || kPosition_CoordsType == coor dsType); | 52 SkASSERT(kLocal_CoordsType == coordsType || kPosition_CoordsType == coor dsType); |
50 AutoEffectUnref effect(SkNEW_ARGS(GrSimpleTextureEffect, (tex, matrix, p , coordsType))); | 53 AutoEffectUnref effect(SkNEW_ARGS(GrHQScaleTextureEffect, (tex, matrix, p, coordsType))); |
51 return CreateEffectRef(effect); | 54 return CreateEffectRef(effect); |
52 } | 55 } |
53 | 56 |
54 /** Variant that requires the client to install a custom kVec2 vertex attrib ute that will be | 57 /** Variant that requires the client to install a custom kVec2 vertex attrib ute that will be |
55 the source of the coords. No matrix is allowed in this mode. */ | 58 the source of the coords. No matrix is allowed in this mode. */ |
56 static GrEffectRef* CreateWithCustomCoords(GrTexture* tex, const GrTexturePa rams& p) { | 59 static GrEffectRef* CreateWithCustomCoords(GrTexture* tex, const GrTexturePa rams& p) { |
57 AutoEffectUnref effect(SkNEW_ARGS(GrSimpleTextureEffect, (tex, | 60 AutoEffectUnref effect(SkNEW_ARGS(GrHQScaleTextureEffect, (tex, |
58 SkMatrix::I(), | 61 SkMatrix::I(), |
59 p, | 62 p, |
60 kCustom_Coords Type))); | 63 kCustom_Coords Type))); |
61 return CreateEffectRef(effect); | 64 return CreateEffectRef(effect); |
62 } | 65 } |
63 | 66 |
64 virtual ~GrSimpleTextureEffect() {} | 67 virtual ~GrHQScaleTextureEffect() {} |
65 | 68 |
66 static const char* Name() { return "Texture"; } | 69 static const char* Name() { return "ScaledTexture"; } |
67 | 70 |
68 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags ) const SK_OVERRIDE; | 71 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags ) const SK_OVERRIDE; |
69 | 72 |
70 typedef GrGLSimpleTextureEffect GLEffect; | 73 typedef GrGLHQScaleTextureEffect GLEffect; |
71 | 74 |
72 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; | 75 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; |
73 | 76 |
74 private: | 77 private: |
75 GrSimpleTextureEffect(GrTexture* texture, | 78 GrHQScaleTextureEffect(GrTexture* texture, |
76 const SkMatrix& matrix, | 79 const SkMatrix& matrix, |
77 GrTextureParams::FilterMode filterMode, | 80 GrTextureParams::FilterMode filterMode, |
78 CoordsType coordsType) | 81 CoordsType coordsType) |
79 : GrSingleTextureEffect(texture, matrix, filterMode, coordsType) { | 82 : GrSingleTextureEffect(texture, matrix, filterMode, coordsType) { |
80 SkASSERT(kLocal_CoordsType == coordsType || kPosition_CoordsType == coor dsType); | 83 SkASSERT(kLocal_CoordsType == coordsType || kPosition_CoordsType == coor dsType); |
81 } | 84 } |
82 | 85 |
83 GrSimpleTextureEffect(GrTexture* texture, | 86 GrHQScaleTextureEffect(GrTexture* texture, |
84 const SkMatrix& matrix, | 87 const SkMatrix& matrix, |
85 const GrTextureParams& params, | 88 const GrTextureParams& params, |
86 CoordsType coordsType) | 89 CoordsType coordsType) |
87 : GrSingleTextureEffect(texture, matrix, params, coordsType) { | 90 : GrSingleTextureEffect(texture, matrix, params, coordsType) { |
88 if (kCustom_CoordsType == coordsType) { | 91 if (kCustom_CoordsType == coordsType) { |
89 SkASSERT(matrix.isIdentity()); | 92 SkASSERT(matrix.isIdentity()); |
90 this->addVertexAttrib(kVec2f_GrSLType); | 93 this->addVertexAttrib(kVec2f_GrSLType); |
91 } | 94 } |
92 } | 95 } |
93 | 96 |
94 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE { | 97 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE { |
95 const GrSimpleTextureEffect& ste = CastEffect<GrSimpleTextureEffect>(oth er); | 98 const GrHQScaleTextureEffect& ste = CastEffect<GrHQScaleTextureEffect>(o ther); |
96 return this->hasSameTextureParamsMatrixAndCoordsType(ste); | 99 return this->hasSameTextureParamsMatrixAndCoordsType(ste); |
97 } | 100 } |
98 | 101 |
99 GR_DECLARE_EFFECT_TEST; | 102 GR_DECLARE_EFFECT_TEST; |
100 | 103 |
101 typedef GrSingleTextureEffect INHERITED; | 104 typedef GrSingleTextureEffect INHERITED; |
102 }; | 105 }; |
103 | 106 |
104 #endif | 107 #endif |
OLD | NEW |