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

Unified Diff: src/gpu/gl/GrGpuGL.cpp

Issue 23128009: Use ES3 texture swizzling. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 4 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/gl/GrGLCaps.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGpuGL.cpp
===================================================================
--- src/gpu/gl/GrGpuGL.cpp (revision 10811)
+++ src/gpu/gl/GrGpuGL.cpp (working copy)
@@ -1975,15 +1975,8 @@
}
}
}
-namespace {
-inline void set_tex_swizzle(GrGLenum swizzle[4], const GrGLInterface* gl) {
- GR_GL_CALL(gl, TexParameteriv(GR_GL_TEXTURE_2D,
- GR_GL_TEXTURE_SWIZZLE_RGBA,
- reinterpret_cast<const GrGLint*>(swizzle)));
-}
-
-inline GrGLenum tile_to_gl_wrap(SkShader::TileMode tm) {
+static inline GrGLenum tile_to_gl_wrap(SkShader::TileMode tm) {
static const GrGLenum gWrapModes[] = {
GR_GL_CLAMP_TO_EDGE,
GR_GL_REPEAT,
@@ -1996,8 +1989,6 @@
return gWrapModes[tm];
}
-}
-
void GrGpuGL::bindTexture(int unitIdx, const GrTextureParams& params, GrGLTexture* texture) {
SkASSERT(NULL != texture);
@@ -2076,8 +2067,18 @@
oldTexParams.fSwizzleRGBA,
sizeof(newTexParams.fSwizzleRGBA)))) {
this->setTextureUnit(unitIdx);
- set_tex_swizzle(newTexParams.fSwizzleRGBA,
- this->glInterface());
+ if (this->glBinding() == kES_GrGLBinding) {
+ // ES3 added swizzle support but not GL_TEXTURE_SWIZZLE_RGBA.
+ const GrGLenum* swizzle = newTexParams.fSwizzleRGBA;
+ GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_SWIZZLE_R, swizzle[0]));
+ GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_SWIZZLE_G, swizzle[1]));
+ GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_SWIZZLE_B, swizzle[2]));
+ GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_SWIZZLE_A, swizzle[3]));
+ } else {
+ GR_STATIC_ASSERT(sizeof(newTexParams.fSwizzleRGBA[0]) == sizeof(GrGLint));
+ const GrGLint* swizzle = reinterpret_cast<const GrGLint*>(newTexParams.fSwizzleRGBA);
+ GL_CALL(TexParameteriv(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_SWIZZLE_RGBA, swizzle));
+ }
}
texture->setCachedTexParams(newTexParams, this->getResetTimestamp());
}
« no previous file with comments | « src/gpu/gl/GrGLCaps.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698