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

Side by Side Diff: include/gpu/GrTextureAccess.h

Issue 20362002: make the filter mode for GrTextureAccess an enum so we can plumb down (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: fall back to mipmaps for HQ sampling (for now) Created 7 years, 5 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 | « include/gpu/GrTexture.h ('k') | src/core/SkBitmapProcShader.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 2012 Google Inc. 2 * Copyright 2012 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 GrTextureAccess_DEFINED 8 #ifndef GrTextureAccess_DEFINED
9 #define GrTextureAccess_DEFINED 9 #define GrTextureAccess_DEFINED
10 10
11 #include "GrNoncopyable.h" 11 #include "GrNoncopyable.h"
12 #include "SkRefCnt.h" 12 #include "SkRefCnt.h"
13 #include "SkShader.h" 13 #include "SkShader.h"
14 14
15 class GrTexture; 15 class GrTexture;
16 16
17 /** 17 /**
18 * Represents the filtering and tile modes used to access a texture. It is mostl y used with 18 * Represents the filtering and tile modes used to access a texture. It is mostl y used with
19 * GrTextureAccess (defined below). Also, some of the texture cache methods requ ire knowledge about 19 * GrTextureAccess (defined below). Also, some of the texture cache methods requ ire knowledge about
20 * filtering and tiling to perform a cache lookup. If it wasn't for this latter usage this would 20 * filtering and tiling to perform a cache lookup. If it wasn't for this latter usage this would
21 * be folded into GrTextureAccess. 21 * be folded into GrTextureAccess.
22 */ 22 */
23 class GrTextureParams { 23 class GrTextureParams {
24 public: 24 public:
25 GrTextureParams() { 25 GrTextureParams() {
26 this->reset(); 26 this->reset();
27 } 27 }
28
29 enum FilterMode {
30 kNone_FilterMode,
31 kBilerp_FilterMode,
32 kMipMap_FilterMode
33 };
28 34
29 GrTextureParams(SkShader::TileMode tileXAndY, bool bilerp) { 35 GrTextureParams(SkShader::TileMode tileXAndY, FilterMode filterMode) {
30 this->reset(tileXAndY, bilerp); 36 this->reset(tileXAndY, filterMode);
31 } 37 }
32 38
33 GrTextureParams(SkShader::TileMode tileModes[2], bool bilerp) { 39 GrTextureParams(SkShader::TileMode tileModes[2], FilterMode filterMode) {
34 this->reset(tileModes, bilerp); 40 this->reset(tileModes, filterMode);
35 } 41 }
36 42
37 GrTextureParams(const GrTextureParams& params) { 43 GrTextureParams(const GrTextureParams& params) {
38 *this = params; 44 *this = params;
39 } 45 }
40 46
41 GrTextureParams& operator= (const GrTextureParams& params) { 47 GrTextureParams& operator= (const GrTextureParams& params) {
42 fTileModes[0] = params.fTileModes[0]; 48 fTileModes[0] = params.fTileModes[0];
43 fTileModes[1] = params.fTileModes[1]; 49 fTileModes[1] = params.fTileModes[1];
44 fBilerp = params.fBilerp; 50 fFilterMode = params.fFilterMode;
45 return *this; 51 return *this;
46 } 52 }
47 53
48 void reset() { 54 void reset() {
49 this->reset(SkShader::kClamp_TileMode, false); 55 this->reset(SkShader::kClamp_TileMode, kNone_FilterMode);
50 } 56 }
51 57
52 void reset(SkShader::TileMode tileXAndY, bool bilerp) { 58 void reset(SkShader::TileMode tileXAndY, FilterMode filterMode) {
53 fTileModes[0] = fTileModes[1] = tileXAndY; 59 fTileModes[0] = fTileModes[1] = tileXAndY;
54 fBilerp = bilerp; 60 fFilterMode = filterMode;
55 } 61 }
56 62
57 void reset(SkShader::TileMode tileModes[2], bool bilerp) { 63 void reset(SkShader::TileMode tileModes[2], FilterMode filterMode) {
58 fTileModes[0] = tileModes[0]; 64 fTileModes[0] = tileModes[0];
59 fTileModes[1] = tileModes[1]; 65 fTileModes[1] = tileModes[1];
60 fBilerp = bilerp; 66 fFilterMode = filterMode;
61 } 67 }
62 68
63 void setClampNoFilter() { 69 void setClampNoFilter() {
64 fTileModes[0] = fTileModes[1] = SkShader::kClamp_TileMode; 70 fTileModes[0] = fTileModes[1] = SkShader::kClamp_TileMode;
65 fBilerp = false; 71 fFilterMode = kNone_FilterMode;
66 } 72 }
67 73
68 void setClamp() { 74 void setClamp() {
69 fTileModes[0] = fTileModes[1] = SkShader::kClamp_TileMode; 75 fTileModes[0] = fTileModes[1] = SkShader::kClamp_TileMode;
70 } 76 }
71 77
72 void setBilerp(bool bilerp) { fBilerp = bilerp; } 78 void setFilterMode(FilterMode filterMode) { fFilterMode = filterMode; }
73 79
74 void setTileModeX(const SkShader::TileMode tm) { fTileModes[0] = tm; } 80 void setTileModeX(const SkShader::TileMode tm) { fTileModes[0] = tm; }
75 void setTileModeY(const SkShader::TileMode tm) { fTileModes[1] = tm; } 81 void setTileModeY(const SkShader::TileMode tm) { fTileModes[1] = tm; }
76 void setTileModeXAndY(const SkShader::TileMode tm) { fTileModes[0] = fTileMo des[1] = tm; } 82 void setTileModeXAndY(const SkShader::TileMode tm) { fTileModes[0] = fTileMo des[1] = tm; }
77 83
78 SkShader::TileMode getTileModeX() const { return fTileModes[0]; } 84 SkShader::TileMode getTileModeX() const { return fTileModes[0]; }
79 85
80 SkShader::TileMode getTileModeY() const { return fTileModes[1]; } 86 SkShader::TileMode getTileModeY() const { return fTileModes[1]; }
81 87
82 bool isTiled() const { 88 bool isTiled() const {
83 return SkShader::kClamp_TileMode != fTileModes[0] || 89 return SkShader::kClamp_TileMode != fTileModes[0] ||
84 SkShader::kClamp_TileMode != fTileModes[1]; 90 SkShader::kClamp_TileMode != fTileModes[1];
85 } 91 }
86 92
87 bool isBilerp() const { return fBilerp; } 93 FilterMode filterMode() const { return fFilterMode; }
88 94
89 bool operator== (const GrTextureParams& other) const { 95 bool operator== (const GrTextureParams& other) const {
90 return fTileModes[0] == other.fTileModes[0] && 96 return fTileModes[0] == other.fTileModes[0] &&
91 fTileModes[1] == other.fTileModes[1] && 97 fTileModes[1] == other.fTileModes[1] &&
92 fBilerp == other.fBilerp; 98 fFilterMode == other.fFilterMode;
93 } 99 }
94 100
95 bool operator!= (const GrTextureParams& other) const { return !(*this == oth er); } 101 bool operator!= (const GrTextureParams& other) const { return !(*this == oth er); }
96 102
97 private: 103 private:
98 104
99 SkShader::TileMode fTileModes[2]; 105 SkShader::TileMode fTileModes[2];
100 bool fBilerp; 106 FilterMode fFilterMode;
101 }; 107 };
102 108
103 /** A class representing the swizzle access pattern for a texture. Note that if the texture is 109 /** A class representing the swizzle access pattern for a texture. Note that if the texture is
104 * an alpha-only texture then the alpha channel is substituted for other compon ents. Any mangling 110 * an alpha-only texture then the alpha channel is substituted for other compon ents. Any mangling
105 * to handle the r,g,b->a conversions for alpha textures is automatically inclu ded in the stage 111 * to handle the r,g,b->a conversions for alpha textures is automatically inclu ded in the stage
106 * key. However, if a GrEffect uses different swizzles based on its input then it must 112 * key. However, if a GrEffect uses different swizzles based on its input then it must
107 * consider that variation in its key-generation. 113 * consider that variation in its key-generation.
108 */ 114 */
109 class GrTextureAccess : GrNoncopyable { 115 class GrTextureAccess : GrNoncopyable {
110 public: 116 public:
111 /** 117 /**
112 * A default GrTextureAccess must have reset() called on it in a GrEffect su bclass's 118 * A default GrTextureAccess must have reset() called on it in a GrEffect su bclass's
113 * constructor if it will be accessible via GrEffect::textureAccess(). 119 * constructor if it will be accessible via GrEffect::textureAccess().
114 */ 120 */
115 GrTextureAccess(); 121 GrTextureAccess();
116 122
117 /** 123 /**
118 * Uses the default swizzle, "rgba". 124 * Uses the default swizzle, "rgba".
119 */ 125 */
120 GrTextureAccess(GrTexture*, const GrTextureParams&); 126 GrTextureAccess(GrTexture*, const GrTextureParams&);
121 explicit GrTextureAccess(GrTexture*, 127 explicit GrTextureAccess(GrTexture*,
122 bool bilerp = false, 128 GrTextureParams::FilterMode = GrTextureParams::kNon e_FilterMode,
123 SkShader::TileMode tileXAndY = SkShader::kClamp_Til eMode); 129 SkShader::TileMode tileXAndY = SkShader::kClamp_Til eMode);
124 130
125 /** 131 /**
126 * swizzle must be a string between one and four (inclusive) characters cont aining only 'r', 132 * swizzle must be a string between one and four (inclusive) characters cont aining only 'r',
127 * 'g', 'b', and/or 'a'. 133 * 'g', 'b', and/or 'a'.
128 */ 134 */
129 GrTextureAccess(GrTexture*, const char* swizzle, const GrTextureParams&); 135 GrTextureAccess(GrTexture*, const char* swizzle, const GrTextureParams&);
130 GrTextureAccess(GrTexture*, 136 GrTextureAccess(GrTexture*,
131 const char* swizzle, 137 const char* swizzle,
132 bool bilerp = false, 138 GrTextureParams::FilterMode = GrTextureParams::kNone_FilterM ode,
133 SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode); 139 SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode);
134 140
135 void reset(GrTexture*, const GrTextureParams&); 141 void reset(GrTexture*, const GrTextureParams&);
136 void reset(GrTexture*, 142 void reset(GrTexture*,
137 bool bilerp = false, 143 GrTextureParams::FilterMode = GrTextureParams::kNone_FilterMode,
138 SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode); 144 SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode);
139 void reset(GrTexture*, const char* swizzle, const GrTextureParams&); 145 void reset(GrTexture*, const char* swizzle, const GrTextureParams&);
140 void reset(GrTexture*, 146 void reset(GrTexture*,
141 const char* swizzle, 147 const char* swizzle,
142 bool bilerp = false, 148 GrTextureParams::FilterMode = GrTextureParams::kNone_FilterMode,
143 SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode); 149 SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode);
144 150
145 bool operator== (const GrTextureAccess& other) const { 151 bool operator== (const GrTextureAccess& other) const {
146 #if GR_DEBUG 152 #if GR_DEBUG
147 // below assumes all chars in fSwizzle are initialized even if string is < 4 chars long. 153 // below assumes all chars in fSwizzle are initialized even if string is < 4 chars long.
148 GrAssert(memcmp(fSwizzle, other.fSwizzle, sizeof(fSwizzle)-1) == 154 GrAssert(memcmp(fSwizzle, other.fSwizzle, sizeof(fSwizzle)-1) ==
149 strcmp(fSwizzle, other.fSwizzle)); 155 strcmp(fSwizzle, other.fSwizzle));
150 #endif 156 #endif
151 return fParams == other.fParams && 157 return fParams == other.fParams &&
152 (fTexture.get() == other.fTexture.get()) && 158 (fTexture.get() == other.fTexture.get()) &&
(...skipping 20 matching lines...) Expand all
173 179
174 GrTextureParams fParams; 180 GrTextureParams fParams;
175 SkAutoTUnref<GrTexture> fTexture; 181 SkAutoTUnref<GrTexture> fTexture;
176 uint32_t fSwizzleMask; 182 uint32_t fSwizzleMask;
177 char fSwizzle[5]; 183 char fSwizzle[5];
178 184
179 typedef GrNoncopyable INHERITED; 185 typedef GrNoncopyable INHERITED;
180 }; 186 };
181 187
182 #endif 188 #endif
OLDNEW
« no previous file with comments | « include/gpu/GrTexture.h ('k') | src/core/SkBitmapProcShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698