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

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

Issue 542723004: Make GrDrawState and GrEffectStage use the pending io/exec ref mechanisms. (Closed) Base URL: https://skia.googlesource.com/skia.git@complete
Patch Set: rebase again Created 6 years, 3 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
« no previous file with comments | « include/gpu/GrProgramElementRef.h ('k') | src/gpu/GrDrawState.h » ('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 "SkRefCnt.h" 11 #include "SkRefCnt.h"
12 #include "SkShader.h" 12 #include "SkShader.h"
13 #include "SkTypes.h" 13 #include "GrProgramResource.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. The default is clamp tile modes and no filter ing. 21 * be folded into GrTextureAccess. The default is clamp tile modes and no filter ing.
22 */ 22 */
23 class GrTextureParams { 23 class GrTextureParams {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 SkShader::TileMode fTileModes[2]; 105 SkShader::TileMode fTileModes[2];
106 FilterMode fFilterMode; 106 FilterMode fFilterMode;
107 }; 107 };
108 108
109 /** 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
110 * 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
111 * 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
112 * 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
113 * consider that variation in its key-generation. 113 * consider that variation in its key-generation.
114 */ 114 */
115 class GrTextureAccess : SkNoncopyable { 115 class GrTextureAccess : public SkNoncopyable {
116 public: 116 public:
117 SK_DECLARE_INST_COUNT_ROOT(GrTextureAccess);
118
117 /** 119 /**
118 * A default GrTextureAccess must have reset() called on it in a GrEffect su bclass's 120 * A default GrTextureAccess must have reset() called on it in a GrEffect su bclass's
119 * constructor if it will be accessible via GrEffect::textureAccess(). 121 * constructor if it will be accessible via GrEffect::textureAccess().
120 */ 122 */
121 GrTextureAccess(); 123 GrTextureAccess();
122 124
123 /** 125 /**
124 * Uses the default swizzle, "rgba". 126 * Uses the default swizzle, "rgba".
125 */ 127 */
126 GrTextureAccess(GrTexture*, const GrTextureParams&); 128 GrTextureAccess(GrTexture*, const GrTextureParams&);
(...skipping 21 matching lines...) Expand all
148 GrTextureParams::FilterMode = GrTextureParams::kNone_FilterMode, 150 GrTextureParams::FilterMode = GrTextureParams::kNone_FilterMode,
149 SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode); 151 SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode);
150 152
151 bool operator== (const GrTextureAccess& other) const { 153 bool operator== (const GrTextureAccess& other) const {
152 #ifdef SK_DEBUG 154 #ifdef SK_DEBUG
153 // below assumes all chars in fSwizzle are initialized even if string is < 4 chars long. 155 // below assumes all chars in fSwizzle are initialized even if string is < 4 chars long.
154 SkASSERT(memcmp(fSwizzle, other.fSwizzle, sizeof(fSwizzle)-1) == 156 SkASSERT(memcmp(fSwizzle, other.fSwizzle, sizeof(fSwizzle)-1) ==
155 strcmp(fSwizzle, other.fSwizzle)); 157 strcmp(fSwizzle, other.fSwizzle));
156 #endif 158 #endif
157 return fParams == other.fParams && 159 return fParams == other.fParams &&
158 (fTexture.get() == other.fTexture.get()) && 160 (this->getTexture() == other.getTexture()) &&
159 (0 == memcmp(fSwizzle, other.fSwizzle, sizeof(fSwizzle)-1)); 161 (0 == memcmp(fSwizzle, other.fSwizzle, sizeof(fSwizzle)-1));
160 } 162 }
161 163
162 bool operator!= (const GrTextureAccess& other) const { return !(*this == oth er); } 164 bool operator!= (const GrTextureAccess& other) const { return !(*this == oth er); }
163 165
164 GrTexture* getTexture() const { return fTexture.get(); } 166 GrTexture* getTexture() const { return (GrTexture*)fTexture.getResource(); }
167
168 /**
169 * For internal use by GrEffect.
170 */
171 const GrProgramResource* getTextureProgramResource() const { return &fTextur e; }
165 172
166 /** 173 /**
167 * Returns a string representing the swizzle. The string is is null-terminat ed. 174 * Returns a string representing the swizzle. The string is is null-terminat ed.
168 */ 175 */
169 const char* getSwizzle() const { return fSwizzle; } 176 const char* getSwizzle() const { return fSwizzle; }
170 177
171 /** Returns a mask indicating which components are referenced in the swizzle . The return 178 /** Returns a mask indicating which components are referenced in the swizzle . The return
172 is a bitfield of GrColorComponentFlags. */ 179 is a bitfield of GrColorComponentFlags. */
173 uint32_t swizzleMask() const { return fSwizzleMask; } 180 uint32_t swizzleMask() const { return fSwizzleMask; }
174 181
175 const GrTextureParams& getParams() const { return fParams; } 182 const GrTextureParams& getParams() const { return fParams; }
176 183
177 private: 184 private:
178 void setSwizzle(const char*); 185 void setSwizzle(const char*);
179 186
180 GrTextureParams fParams; 187 GrProgramResource fTexture;
181 SkAutoTUnref<GrTexture> fTexture; 188 GrTextureParams fParams;
182 uint32_t fSwizzleMask; 189 uint32_t fSwizzleMask;
183 char fSwizzle[5]; 190 char fSwizzle[5];
184 191
185 typedef SkNoncopyable INHERITED; 192 typedef SkNoncopyable INHERITED;
186 }; 193 };
187 194
188 #endif 195 #endif
OLDNEW
« no previous file with comments | « include/gpu/GrProgramElementRef.h ('k') | src/gpu/GrDrawState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698