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

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

Issue 12531015: Adds local coords to GrEffect system. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/gpu/effects/GrEllipseEdgeEffect.cpp ('k') | src/gpu/effects/GrSimpleTextureEffect.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 GrSimpleTextureEffect_DEFINED 8 #ifndef GrSimpleTextureEffect_DEFINED
9 #define GrSimpleTextureEffect_DEFINED 9 #define GrSimpleTextureEffect_DEFINED
10 10
11 #include "GrSingleTextureEffect.h" 11 #include "GrSingleTextureEffect.h"
12 12
13 class GrGLSimpleTextureEffect; 13 class GrGLSimpleTextureEffect;
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 a samp le from a texture.
17 * The coord to sample the texture is determine by a matrix. It allows explicit specification of 17 * It allows explicit specification of the filtering and wrap modes (GrTexturePa rams). It can use
18 * the filtering and wrap modes (GrTextureParams). 18 * 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
20 * attribute coords at this time. It will add a varying to input interpolate tex ture coords to the
21 * FS.
19 */ 22 */
20 class GrSimpleTextureEffect : public GrSingleTextureEffect { 23 class GrSimpleTextureEffect : public GrSingleTextureEffect {
21 public: 24 public:
22 /* unfiltered, clamp mode */ 25 /* unfiltered, clamp mode */
23 static GrEffectRef* Create(GrTexture* tex, const SkMatrix& matrix) { 26 static GrEffectRef* Create(GrTexture* tex,
24 AutoEffectUnref effect(SkNEW_ARGS(GrSimpleTextureEffect, (tex, matrix))) ; 27 const SkMatrix& matrix,
28 CoordsType coordsType = kLocal_CoordsType) {
29 GrAssert(kLocal_CoordsType == coordsType || kPosition_CoordsType == coor dsType);
30 AutoEffectUnref effect(SkNEW_ARGS(GrSimpleTextureEffect, (tex, matrix, f alse, coordsType)));
25 return CreateEffectRef(effect); 31 return CreateEffectRef(effect);
26 } 32 }
27 33
28 /* clamp mode */ 34 /* clamp mode */
29 static GrEffectRef* Create(GrTexture* tex, const SkMatrix& matrix, bool bile rp) { 35 static GrEffectRef* Create(GrTexture* tex,
30 AutoEffectUnref effect(SkNEW_ARGS(GrSimpleTextureEffect, (tex, matrix, b ilerp))); 36 const SkMatrix& matrix,
37 bool bilerp,
38 CoordsType coordsType = kLocal_CoordsType) {
39 GrAssert(kLocal_CoordsType == coordsType || kPosition_CoordsType == coor dsType);
40 AutoEffectUnref effect(
41 SkNEW_ARGS(GrSimpleTextureEffect, (tex, matrix, bilerp, coordsType)) );
31 return CreateEffectRef(effect); 42 return CreateEffectRef(effect);
32 } 43 }
33 44
34 static GrEffectRef* Create(GrTexture* tex, const SkMatrix& matrix, const GrT extureParams& p) { 45 static GrEffectRef* Create(GrTexture* tex,
35 AutoEffectUnref effect(SkNEW_ARGS(GrSimpleTextureEffect, (tex, matrix, p ))); 46 const SkMatrix& matrix,
47 const GrTextureParams& p,
48 CoordsType coordsType = kLocal_CoordsType) {
49 GrAssert(kLocal_CoordsType == coordsType || kPosition_CoordsType == coor dsType);
50 AutoEffectUnref effect(SkNEW_ARGS(GrSimpleTextureEffect, (tex, matrix, p , coordsType)));
51 return CreateEffectRef(effect);
52 }
53
54 /** 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. */
56 static GrEffectRef* CreateWithCustomCoords(GrTexture* tex, const GrTexturePa rams& p) {
57 AutoEffectUnref effect(SkNEW_ARGS(GrSimpleTextureEffect, (tex,
58 SkMatrix::I(),
59 p,
60 kCustom_Coords Type)));
36 return CreateEffectRef(effect); 61 return CreateEffectRef(effect);
37 } 62 }
38 63
39 virtual ~GrSimpleTextureEffect() {} 64 virtual ~GrSimpleTextureEffect() {}
40 65
41 static const char* Name() { return "Texture"; } 66 static const char* Name() { return "Texture"; }
42 67
43 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags ) const SK_OVERRIDE; 68 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags ) const SK_OVERRIDE;
44 69
45 typedef GrGLSimpleTextureEffect GLEffect; 70 typedef GrGLSimpleTextureEffect GLEffect;
46 71
47 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; 72 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
48 73
49 private: 74 private:
50 GrSimpleTextureEffect(GrTexture* texture, const SkMatrix& matrix) 75 GrSimpleTextureEffect(GrTexture* texture,
51 : GrSingleTextureEffect(texture, matrix) {} 76 const SkMatrix& matrix,
52 GrSimpleTextureEffect(GrTexture* texture, const SkMatrix& matrix, bool biler p) 77 bool bilerp,
53 : GrSingleTextureEffect(texture, matrix, bilerp) {} 78 CoordsType coordsType)
54 GrSimpleTextureEffect(GrTexture* texture, const SkMatrix& matrix, const GrTe xtureParams& params) 79 : GrSingleTextureEffect(texture, matrix, bilerp, coordsType) {
55 : GrSingleTextureEffect(texture, matrix, params) {} 80 GrAssert(kLocal_CoordsType == coordsType || kPosition_CoordsType == coor dsType);
81 }
82
83 GrSimpleTextureEffect(GrTexture* texture,
84 const SkMatrix& matrix,
85 const GrTextureParams& params,
86 CoordsType coordsType)
87 : GrSingleTextureEffect(texture, matrix, params, coordsType) {
88 if (kCustom_CoordsType == coordsType) {
89 GrAssert(matrix.isIdentity());
90 this->addVertexAttrib(kVec2f_GrSLType);
91 }
92 }
56 93
57 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE { 94 virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE {
58 const GrSimpleTextureEffect& ste = CastEffect<GrSimpleTextureEffect>(oth er); 95 const GrSimpleTextureEffect& ste = CastEffect<GrSimpleTextureEffect>(oth er);
59 return this->hasSameTextureParamsAndMatrix(ste); 96 return this->hasSameTextureParamsMatrixAndCoordsType(ste);
60 } 97 }
61 98
62 GR_DECLARE_EFFECT_TEST; 99 GR_DECLARE_EFFECT_TEST;
63 100
64 typedef GrSingleTextureEffect INHERITED; 101 typedef GrSingleTextureEffect INHERITED;
65 }; 102 };
66 103
67 #endif 104 #endif
OLDNEW
« no previous file with comments | « src/gpu/effects/GrEllipseEdgeEffect.cpp ('k') | src/gpu/effects/GrSimpleTextureEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698