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

Unified Diff: src/gpu/GrTextureAccess.cpp

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 | « src/gpu/GrSwizzle.h ('k') | src/gpu/gl/GrGLCaps.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrTextureAccess.cpp
diff --git a/src/gpu/GrTextureAccess.cpp b/src/gpu/GrTextureAccess.cpp
index 277c0e3833e798d094ebb157266af3a85d98523f..7e1eda6211f5783c0bf8ab7e0b59e781b8e74df0 100644
--- a/src/gpu/GrTextureAccess.cpp
+++ b/src/gpu/GrTextureAccess.cpp
@@ -9,7 +9,12 @@
#include "GrColor.h"
#include "GrTexture.h"
-GrTextureAccess::GrTextureAccess() {}
+GrTextureAccess::GrTextureAccess() {
+#ifdef SK_DEBUG
+ memcpy(fSwizzle, "void", 5);
+ fSwizzleMask = 0xbeeffeed;
+#endif
+}
GrTextureAccess::GrTextureAccess(GrTexture* texture, const GrTextureParams& params) {
this->reset(texture, params);
@@ -21,12 +26,49 @@
this->reset(texture, filterMode, tileXAndY);
}
+GrTextureAccess::GrTextureAccess(GrTexture* texture,
+ const char* swizzle,
+ const GrTextureParams& params) {
+ this->reset(texture, swizzle, params);
+}
+
+GrTextureAccess::GrTextureAccess(GrTexture* texture,
+ const char* swizzle,
+ GrTextureParams::FilterMode filterMode,
+ SkShader::TileMode tileXAndY) {
+ this->reset(texture, swizzle, filterMode, tileXAndY);
+}
+
+void GrTextureAccess::reset(GrTexture* texture,
+ const char* swizzle,
+ const GrTextureParams& params) {
+ SkASSERT(texture);
+ SkASSERT(strlen(swizzle) >= 1 && strlen(swizzle) <= 4);
+
+ fParams = params;
+ fTexture.set(SkRef(texture), kRead_GrIOType);
+ this->setSwizzle(swizzle);
+}
+
+void GrTextureAccess::reset(GrTexture* texture,
+ const char* swizzle,
+ GrTextureParams::FilterMode filterMode,
+ SkShader::TileMode tileXAndY) {
+ SkASSERT(texture);
+ SkASSERT(strlen(swizzle) >= 1 && strlen(swizzle) <= 4);
+
+ fParams.reset(tileXAndY, filterMode);
+ fTexture.set(SkRef(texture), kRead_GrIOType);
+ this->setSwizzle(swizzle);
+}
void GrTextureAccess::reset(GrTexture* texture,
const GrTextureParams& params) {
SkASSERT(texture);
fTexture.set(SkRef(texture), kRead_GrIOType);
fParams = params;
+ memcpy(fSwizzle, "rgba", 5);
+ fSwizzleMask = kRGBA_GrColorComponentFlags;
}
void GrTextureAccess::reset(GrTexture* texture,
@@ -35,4 +77,31 @@
SkASSERT(texture);
fTexture.set(SkRef(texture), kRead_GrIOType);
fParams.reset(tileXAndY, filterMode);
+ memcpy(fSwizzle, "rgba", 5);
+ fSwizzleMask = kRGBA_GrColorComponentFlags;
}
+
+void GrTextureAccess::setSwizzle(const char* swizzle) {
+ fSwizzleMask = 0;
+ memset(fSwizzle, '\0', 5);
+ for (int i = 0; i < 4 && '\0' != swizzle[i]; ++i) {
+ fSwizzle[i] = swizzle[i];
+ switch (swizzle[i]) {
+ case 'r':
+ fSwizzleMask |= kR_GrColorComponentFlag;
+ break;
+ case 'g':
+ fSwizzleMask |= kG_GrColorComponentFlag;
+ break;
+ case 'b':
+ fSwizzleMask |= kB_GrColorComponentFlag;
+ break;
+ case 'a':
+ fSwizzleMask |= kA_GrColorComponentFlag;
+ break;
+ default:
+ SkFAIL("Unexpected swizzle string character.");
+ break;
+ }
+ }
+}
« no previous file with comments | « src/gpu/GrSwizzle.h ('k') | src/gpu/gl/GrGLCaps.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698