OLD | NEW |
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 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 101 |
102 private: | 102 private: |
103 | 103 |
104 SkShader::TileMode fTileModes[2]; | 104 SkShader::TileMode fTileModes[2]; |
105 FilterMode fFilterMode; | 105 FilterMode fFilterMode; |
106 }; | 106 }; |
107 | 107 |
108 /** A class representing the swizzle access pattern for a texture. Note that if
the texture is | 108 /** A class representing the swizzle access pattern for a texture. Note that if
the texture is |
109 * an alpha-only texture then the alpha channel is substituted for other compon
ents. Any mangling | 109 * an alpha-only texture then the alpha channel is substituted for other compon
ents. Any mangling |
110 * to handle the r,g,b->a conversions for alpha textures is automatically inclu
ded in the stage | 110 * to handle the r,g,b->a conversions for alpha textures is automatically inclu
ded in the stage |
111 * key. However, if a GrEffect uses different swizzles based on its input then
it must | 111 * key. However, if a GrProcessor uses different swizzles based on its input th
en it must |
112 * consider that variation in its key-generation. | 112 * consider that variation in its key-generation. |
113 */ | 113 */ |
114 class GrTextureAccess : public SkNoncopyable { | 114 class GrTextureAccess : public SkNoncopyable { |
115 public: | 115 public: |
116 SK_DECLARE_INST_COUNT_ROOT(GrTextureAccess); | 116 SK_DECLARE_INST_COUNT_ROOT(GrTextureAccess); |
117 | 117 |
118 /** | 118 /** |
119 * A default GrTextureAccess must have reset() called on it in a GrEffect su
bclass's | 119 * A default GrTextureAccess must have reset() called on it in a GrProcessor
subclass's |
120 * constructor if it will be accessible via GrEffect::textureAccess(). | 120 * constructor if it will be accessible via GrProcessor::textureAccess(). |
121 */ | 121 */ |
122 GrTextureAccess(); | 122 GrTextureAccess(); |
123 | 123 |
124 /** | 124 /** |
125 * Uses the default swizzle, "rgba". | 125 * Uses the default swizzle, "rgba". |
126 */ | 126 */ |
127 GrTextureAccess(GrTexture*, const GrTextureParams&); | 127 GrTextureAccess(GrTexture*, const GrTextureParams&); |
128 explicit GrTextureAccess(GrTexture*, | 128 explicit GrTextureAccess(GrTexture*, |
129 GrTextureParams::FilterMode = GrTextureParams::kNon
e_FilterMode, | 129 GrTextureParams::FilterMode = GrTextureParams::kNon
e_FilterMode, |
130 SkShader::TileMode tileXAndY = SkShader::kClamp_Til
eMode); | 130 SkShader::TileMode tileXAndY = SkShader::kClamp_Til
eMode); |
(...skipping 27 matching lines...) Expand all Loading... |
158 return fParams == other.fParams && | 158 return fParams == other.fParams && |
159 (this->getTexture() == other.getTexture()) && | 159 (this->getTexture() == other.getTexture()) && |
160 (0 == memcmp(fSwizzle, other.fSwizzle, sizeof(fSwizzle)-1)); | 160 (0 == memcmp(fSwizzle, other.fSwizzle, sizeof(fSwizzle)-1)); |
161 } | 161 } |
162 | 162 |
163 bool operator!= (const GrTextureAccess& other) const { return !(*this == oth
er); } | 163 bool operator!= (const GrTextureAccess& other) const { return !(*this == oth
er); } |
164 | 164 |
165 GrTexture* getTexture() const { return fTexture.get(); } | 165 GrTexture* getTexture() const { return fTexture.get(); } |
166 | 166 |
167 /** | 167 /** |
168 * For internal use by GrEffect. | 168 * For internal use by GrProcessor. |
169 */ | 169 */ |
170 const GrGpuResourceRef* getProgramTexture() const { return &fTexture; } | 170 const GrGpuResourceRef* getProgramTexture() const { return &fTexture; } |
171 | 171 |
172 /** | 172 /** |
173 * Returns a string representing the swizzle. The string is is null-terminat
ed. | 173 * Returns a string representing the swizzle. The string is is null-terminat
ed. |
174 */ | 174 */ |
175 const char* getSwizzle() const { return fSwizzle; } | 175 const char* getSwizzle() const { return fSwizzle; } |
176 | 176 |
177 /** Returns a mask indicating which components are referenced in the swizzle
. The return | 177 /** Returns a mask indicating which components are referenced in the swizzle
. The return |
178 is a bitfield of GrColorComponentFlags. */ | 178 is a bitfield of GrColorComponentFlags. */ |
179 uint32_t swizzleMask() const { return fSwizzleMask; } | 179 uint32_t swizzleMask() const { return fSwizzleMask; } |
180 | 180 |
181 const GrTextureParams& getParams() const { return fParams; } | 181 const GrTextureParams& getParams() const { return fParams; } |
182 | 182 |
183 private: | 183 private: |
184 void setSwizzle(const char*); | 184 void setSwizzle(const char*); |
185 | 185 |
186 typedef GrTGpuResourceRef<GrTexture> ProgramTexture; | 186 typedef GrTGpuResourceRef<GrTexture> ProgramTexture; |
187 | 187 |
188 ProgramTexture fTexture; | 188 ProgramTexture fTexture; |
189 GrTextureParams fParams; | 189 GrTextureParams fParams; |
190 uint32_t fSwizzleMask; | 190 uint32_t fSwizzleMask; |
191 char fSwizzle[5]; | 191 char fSwizzle[5]; |
192 | 192 |
193 typedef SkNoncopyable INHERITED; | 193 typedef SkNoncopyable INHERITED; |
194 }; | 194 }; |
195 | 195 |
196 #endif | 196 #endif |
OLD | NEW |