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 |
| 11 #include "GrProgramResource.h" |
| 12 #include "GrTexture.h" |
11 #include "SkRefCnt.h" | 13 #include "SkRefCnt.h" |
12 #include "SkShader.h" | 14 #include "SkShader.h" |
13 #include "GrProgramResource.h" | |
14 | |
15 class GrTexture; | |
16 | 15 |
17 /** | 16 /** |
18 * Represents the filtering and tile modes used to access a texture. It is mostl
y used with | 17 * 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 | 18 * 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 | 19 * filtering and tiling to perform a cache lookup. If it wasn't for this latter
usage this would |
21 * be folded into GrTextureAccess. The default is clamp tile modes and no filter
ing. | 20 * be folded into GrTextureAccess. The default is clamp tile modes and no filter
ing. |
22 */ | 21 */ |
23 class GrTextureParams { | 22 class GrTextureParams { |
24 public: | 23 public: |
25 GrTextureParams() { | 24 GrTextureParams() { |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 SkASSERT(memcmp(fSwizzle, other.fSwizzle, sizeof(fSwizzle)-1) == | 155 SkASSERT(memcmp(fSwizzle, other.fSwizzle, sizeof(fSwizzle)-1) == |
157 strcmp(fSwizzle, other.fSwizzle)); | 156 strcmp(fSwizzle, other.fSwizzle)); |
158 #endif | 157 #endif |
159 return fParams == other.fParams && | 158 return fParams == other.fParams && |
160 (this->getTexture() == other.getTexture()) && | 159 (this->getTexture() == other.getTexture()) && |
161 (0 == memcmp(fSwizzle, other.fSwizzle, sizeof(fSwizzle)-1)); | 160 (0 == memcmp(fSwizzle, other.fSwizzle, sizeof(fSwizzle)-1)); |
162 } | 161 } |
163 | 162 |
164 bool operator!= (const GrTextureAccess& other) const { return !(*this == oth
er); } | 163 bool operator!= (const GrTextureAccess& other) const { return !(*this == oth
er); } |
165 | 164 |
166 GrTexture* getTexture() const { return (GrTexture*)fTexture.getResource(); } | 165 GrTexture* getTexture() const { return fTexture.get(); } |
167 | 166 |
168 /** | 167 /** |
169 * For internal use by GrEffect. | 168 * For internal use by GrEffect. |
170 */ | 169 */ |
171 const GrProgramResource* getTextureProgramResource() const { return &fTextur
e; } | 170 const GrProgramResource* getProgramTexture() const { return &fTexture; } |
172 | 171 |
173 /** | 172 /** |
174 * 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. |
175 */ | 174 */ |
176 const char* getSwizzle() const { return fSwizzle; } | 175 const char* getSwizzle() const { return fSwizzle; } |
177 | 176 |
178 /** 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 |
179 is a bitfield of GrColorComponentFlags. */ | 178 is a bitfield of GrColorComponentFlags. */ |
180 uint32_t swizzleMask() const { return fSwizzleMask; } | 179 uint32_t swizzleMask() const { return fSwizzleMask; } |
181 | 180 |
182 const GrTextureParams& getParams() const { return fParams; } | 181 const GrTextureParams& getParams() const { return fParams; } |
183 | 182 |
184 private: | 183 private: |
185 void setSwizzle(const char*); | 184 void setSwizzle(const char*); |
186 | 185 |
187 GrProgramResource fTexture; | 186 typedef GrProgramTResource<GrTexture> ProgramTexture; |
| 187 |
| 188 ProgramTexture fTexture; |
188 GrTextureParams fParams; | 189 GrTextureParams fParams; |
189 uint32_t fSwizzleMask; | 190 uint32_t fSwizzleMask; |
190 char fSwizzle[5]; | 191 char fSwizzle[5]; |
191 | 192 |
192 typedef SkNoncopyable INHERITED; | 193 typedef SkNoncopyable INHERITED; |
193 }; | 194 }; |
194 | 195 |
195 #endif | 196 #endif |
OLD | NEW |