diff options
author | 2011-01-18 16:54:04 +0000 | |
---|---|---|
committer | 2011-01-18 16:54:04 +0000 | |
commit | ed3a06804f2b43b383565694f08f992dd2b326be (patch) | |
tree | 57abb56448b03ee78cfd158b41e3602ec28e5d1f | |
parent | 1572b071a739ea64a0b829bbaafa0b54dfe4bfac (diff) |
Fix BGRA on ES Issue 109.
git-svn-id: http://skia.googlecode.com/svn/trunk@702 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | gpu/include/GrGLConfig.h | 8 | ||||
-rw-r--r-- | gpu/include/GrUserConfig.h | 4 | ||||
-rw-r--r-- | gpu/src/GrGpuGL.cpp | 13 |
3 files changed, 21 insertions, 4 deletions
diff --git a/gpu/include/GrGLConfig.h b/gpu/include/GrGLConfig.h index 2bc535d709..e21adb7578 100644 --- a/gpu/include/GrGLConfig.h +++ b/gpu/include/GrGLConfig.h @@ -182,8 +182,8 @@ // Windows where we match GDI's order). #ifndef GR_GL_32BPP_COLOR_FORMAT #if GR_WIN32_BUILD - #define GR_GL_32BPP_COLOR_FORMAT GL_BGRA - #else + #define GR_GL_32BPP_COLOR_FORMAT GR_BGRA //use GR prefix because this + #else //may be an extension. #define GR_GL_32BPP_COLOR_FORMAT GL_RGBA #endif #endif @@ -247,6 +247,10 @@ struct GrGLExts { }; } +// BGRA format + +#define GR_BGRA 0x80E1 + // FBO #define GR_FRAMEBUFFER 0x8D40 #define GR_FRAMEBUFFER_COMPLETE 0x8CD5 diff --git a/gpu/include/GrUserConfig.h b/gpu/include/GrUserConfig.h index 860d2ccd40..3bb3d75ba6 100644 --- a/gpu/include/GrUserConfig.h +++ b/gpu/include/GrUserConfig.h @@ -33,7 +33,9 @@ /* * The default 32bit pixel config for texture upload is GL_RGBA on all * platforms except on Windows where it is GL_BGRA. If your bitmaps map to a - * different GL enum, specify that with this define. + * different GL enum, specify that with this define. For portability use + * GR_BGRA rather than GL_BGRA for platforms where this format is an + * extension. */ //#define GR_GL_32BPP_COLOR_FORMAT GL_RGBA diff --git a/gpu/src/GrGpuGL.cpp b/gpu/src/GrGpuGL.cpp index 68fedf7f59..ff3519389f 100644 --- a/gpu/src/GrGpuGL.cpp +++ b/gpu/src/GrGpuGL.cpp @@ -299,6 +299,11 @@ GrGpuGL::GrGpuGL() { GrPrintf("RGBA Renderbuffer: %s\n", (fRGBA8Renderbuffer ? "YES" : "NO")); } +#if GR_SUPPORT_GLES + if (GR_GL_32BPP_COLOR_FORMAT == GR_BGRA) { + GrAssert(has_gl_extension("GL_EXT_texture_format_BGRA8888")); + } +#endif #if GR_SUPPORT_GLDESKTOP fBufferLockSupport = true; // we require VBO support and the desktop VBO @@ -1675,7 +1680,13 @@ bool GrGpuGL::canBeTexture(GrTexture::PixelConfig config, case GrTexture::kRGBA_8888_PixelConfig: case GrTexture::kRGBX_8888_PixelConfig: // todo: can we tell it our X? *format = GR_GL_32BPP_COLOR_FORMAT; - *internalFormat = GL_RGBA; +#if GR_SUPPORT_GLES
+ // according to GL_EXT_texture_format_BGRA8888 the *internal*
+ // format for a BGRA is BGRA not RGBA (as on desktop)
+ *internalFormat = GR_GL_32BPP_COLOR_FORMAT;
+#else
+ *internalFormat = GL_RGBA;
+#endif *type = GL_UNSIGNED_BYTE; break; case GrTexture::kRGB_565_PixelConfig: |