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

Unified Diff: include/gpu/GrTextureAccess.h

Issue 1569393002: Revert of Add a class representing texture swizzle. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | include/gpu/GrTypesPriv.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/gpu/GrTextureAccess.h
diff --git a/include/gpu/GrTextureAccess.h b/include/gpu/GrTextureAccess.h
index 124a75aabc065da64c9360592fb5cfeaaf8ca994..e3ded34ff8c54ebb5ee9d5caef890d7ef3a82137 100644
--- a/include/gpu/GrTextureAccess.h
+++ b/include/gpu/GrTextureAccess.h
@@ -14,33 +14,60 @@
#include "SkRefCnt.h"
#include "SkShader.h"
-/**
- * Used to represent a texture that is required by a GrProcessor. It holds a GrTexture along with
- * an associated GrTextureParams
+/** A class representing the swizzle access pattern for a texture. Note that if the texture is
+ * an alpha-only texture then the alpha channel is substituted for other components. Any mangling
+ * to handle the r,g,b->a conversions for alpha textures is automatically included in the stage
+ * key. However, if a GrProcessor uses different swizzles based on its input then it must
+ * consider that variation in its key-generation.
*/
class GrTextureAccess : public SkNoncopyable {
public:
/**
- * Must be initialized before adding to a GrProcessor's texture access list.
+ * A default GrTextureAccess must have reset() called on it in a GrProcessor subclass's
+ * constructor if it will be accessible via GrProcessor::textureAccess().
*/
GrTextureAccess();
+ /**
+ * Uses the default swizzle, "rgba".
+ */
GrTextureAccess(GrTexture*, const GrTextureParams&);
-
explicit GrTextureAccess(GrTexture*,
GrTextureParams::FilterMode = GrTextureParams::kNone_FilterMode,
SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode);
+
+ /**
+ * swizzle must be a string between one and four (inclusive) characters containing only 'r',
+ * 'g', 'b', and/or 'a'.
+ */
+ GrTextureAccess(GrTexture*, const char* swizzle, const GrTextureParams&);
+ GrTextureAccess(GrTexture*,
+ const char* swizzle,
+ GrTextureParams::FilterMode = GrTextureParams::kNone_FilterMode,
+ SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode);
void reset(GrTexture*, const GrTextureParams&);
void reset(GrTexture*,
GrTextureParams::FilterMode = GrTextureParams::kNone_FilterMode,
SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode);
+ void reset(GrTexture*, const char* swizzle, const GrTextureParams&);
+ void reset(GrTexture*,
+ const char* swizzle,
+ GrTextureParams::FilterMode = GrTextureParams::kNone_FilterMode,
+ SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode);
- bool operator==(const GrTextureAccess& that) const {
- return this->getTexture() == that.getTexture() && fParams == that.fParams;
+ bool operator== (const GrTextureAccess& other) const {
+#ifdef SK_DEBUG
+ // below assumes all chars in fSwizzle are initialized even if string is < 4 chars long.
+ SkASSERT(memcmp(fSwizzle, other.fSwizzle, sizeof(fSwizzle)-1) ==
+ strcmp(fSwizzle, other.fSwizzle));
+#endif
+ return fParams == other.fParams &&
+ (this->getTexture() == other.getTexture()) &&
+ (0 == memcmp(fSwizzle, other.fSwizzle, sizeof(fSwizzle)-1));
}
- bool operator!=(const GrTextureAccess& other) const { return !(*this == other); }
+ bool operator!= (const GrTextureAccess& other) const { return !(*this == other); }
GrTexture* getTexture() const { return fTexture.get(); }
@@ -49,14 +76,26 @@
*/
const GrGpuResourceRef* getProgramTexture() const { return &fTexture; }
+ /**
+ * Returns a string representing the swizzle. The string is is null-terminated.
+ */
+ const char* getSwizzle() const { return fSwizzle; }
+
+ /** Returns a mask indicating which components are referenced in the swizzle. The return
+ is a bitfield of GrColorComponentFlags. */
+ uint32_t swizzleMask() const { return fSwizzleMask; }
+
const GrTextureParams& getParams() const { return fParams; }
private:
+ void setSwizzle(const char*);
typedef GrTGpuResourceRef<GrTexture> ProgramTexture;
ProgramTexture fTexture;
GrTextureParams fParams;
+ uint32_t fSwizzleMask;
+ char fSwizzle[5];
typedef SkNoncopyable INHERITED;
};
« no previous file with comments | « no previous file | include/gpu/GrTypesPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698