summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbsalomon@google.com <bsalomon@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-18 11:20:04 +0000
committerbsalomon@google.com <bsalomon@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-18 11:20:04 +0000
commitc01ab130e0a681458e0fee41d6261c7ea37e1743 (patch)
tree823ee340378891a9902a252a3267931b753dacff
parent8be161672d8d89525050cb678ecc4ea554f18c00 (diff)
downloadchromium_src-c01ab130e0a681458e0fee41d6261c7ea37e1743.zip
chromium_src-c01ab130e0a681458e0fee41d6261c7ea37e1743.tar.gz
chromium_src-c01ab130e0a681458e0fee41d6261c7ea37e1743.tar.bz2
Add renderbuffer BGRA8 format extension and support in cmd buffer for desktop GL. This enables development of a canvas2d msaa flag on desktop systems that use BGRA for canvas2d.
BUG=308277 Review URL: https://codereview.chromium.org/27542003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@229359 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--gpu/GLES2/extensions/CHROMIUM/CHROMIUM_renderbuffer_format_BGRA8888.txt58
-rw-r--r--gpu/command_buffer/service/feature_info.cc10
-rw-r--r--gpu/command_buffer/service/feature_info_unittest.cc10
-rw-r--r--ui/gl/gl_gl_api_implementation.cc31
4 files changed, 104 insertions, 5 deletions
diff --git a/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_renderbuffer_format_BGRA8888.txt b/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_renderbuffer_format_BGRA8888.txt
new file mode 100644
index 0000000..75a1471
--- /dev/null
+++ b/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_renderbuffer_format_BGRA8888.txt
@@ -0,0 +1,58 @@
+Name
+
+ CHROMIUM_renderbuffer_format_BGRA8888
+
+Name Strings
+
+ GL_CHROMIUM_renderbuffer_format_BGRA8888
+
+Version
+
+ Last Modifed Date: Oct 16, 2013
+
+Dependencies
+
+ OpenGL ES 2.0 is required.
+ GL_EXT_texture_format_BGRA8888 is required.
+
+Overview
+
+ EXT_texture_format_BGRA8888 adds a BGRA8_EXT as a legal internal texture
+ format. This extension also allows BGRA8_EXT as a renderbuffer internal
+ format. It is particularly useful when ANGLE_framebuffer_multisample or
+ a similar extension is also present as it allows creating a multisampled
+ BGRA8 renderbuffer that can be downsampled into a BGRA8 texture.
+
+New Tokens
+
+ None
+
+Additions to the OpenGL ES 2.0 Specification
+
+ Modifications to Table 4.5 (Renderbuffer image formats)
+
+ Add the following entry:
+ Sized Internal Format Renderable Type R bits G bits B bits A bits D bits S bits
+ ===================== =============== ====== ====== ====== ====== ====== ======
+ BGRA8_EXT color-renderable 8 8 8 8
+
+Interactions with GL_ANGLE_framebuffer_multisample
+
+ If ANGLE_framebuffer_multisample is also present then BGRA8_EXT is a
+ legal parameter to RenderbufferStrorageMultisampleANGLE.
+
+New Procedures and Functions
+
+ None
+
+Errors
+
+ None
+
+New State
+
+ None
+
+Revision History
+
+ 10/16/2013 Initial version
diff --git a/gpu/command_buffer/service/feature_info.cc b/gpu/command_buffer/service/feature_info.cc
index cddf0a5..6e6b363 100644
--- a/gpu/command_buffer/service/feature_info.cc
+++ b/gpu/command_buffer/service/feature_info.cc
@@ -360,6 +360,8 @@ void FeatureInfo::InitializeFeatures() {
bool enable_texture_format_bgra8888 = false;
bool enable_read_format_bgra = false;
+ bool enable_render_buffer_bgra = false;
+
// Check if we should allow GL_EXT_texture_format_BGRA8888
if (extensions.Contains("GL_EXT_texture_format_BGRA8888") ||
extensions.Contains("GL_APPLE_texture_format_BGRA8888") ||
@@ -368,8 +370,7 @@ void FeatureInfo::InitializeFeatures() {
}
if (extensions.Contains("GL_EXT_bgra")) {
- enable_texture_format_bgra8888 = true;
- enable_read_format_bgra = true;
+ enable_render_buffer_bgra = true;
}
if (extensions.Contains("GL_EXT_read_format_bgra") ||
@@ -389,6 +390,11 @@ void FeatureInfo::InitializeFeatures() {
validators_.read_pixel_format.AddValue(GL_BGRA_EXT);
}
+ if (enable_render_buffer_bgra) {
+ AddExtensionString("GL_CHROMIUM_renderbuffer_format_BGRA8888");
+ validators_.render_buffer_format.AddValue(GL_BGRA8_EXT);
+ }
+
if (extensions.Contains("GL_OES_rgb8_rgba8") || gfx::HasDesktopGLFeatures()) {
AddExtensionString("GL_OES_rgb8_rgba8");
validators_.render_buffer_format.AddValue(GL_RGB8_OES);
diff --git a/gpu/command_buffer/service/feature_info_unittest.cc b/gpu/command_buffer/service/feature_info_unittest.cc
index 97cc76b..c5e8301 100644
--- a/gpu/command_buffer/service/feature_info_unittest.cc
+++ b/gpu/command_buffer/service/feature_info_unittest.cc
@@ -341,6 +341,8 @@ TEST_F(FeatureInfoTest, InitializeEXT_texture_format_BGRA8888GLES2) {
GL_BGRA_EXT));
EXPECT_TRUE(info_->GetTextureFormatValidator(GL_BGRA_EXT).IsValid(
GL_UNSIGNED_BYTE));
+ EXPECT_FALSE(info_->validators()->render_buffer_format.IsValid(
+ GL_BGRA8_EXT));
}
TEST_F(FeatureInfoTest, InitializeEXT_texture_format_BGRA8888GL) {
@@ -349,6 +351,8 @@ TEST_F(FeatureInfoTest, InitializeEXT_texture_format_BGRA8888GL) {
HasSubstr("GL_EXT_texture_format_BGRA8888"));
EXPECT_THAT(info_->extensions(),
HasSubstr("GL_EXT_read_format_bgra"));
+ EXPECT_THAT(info_->extensions(),
+ HasSubstr("GL_CHROMIUM_renderbuffer_format_BGRA8888"));
EXPECT_TRUE(info_->validators()->texture_format.IsValid(
GL_BGRA_EXT));
EXPECT_TRUE(info_->validators()->texture_internal_format.IsValid(
@@ -357,6 +361,8 @@ TEST_F(FeatureInfoTest, InitializeEXT_texture_format_BGRA8888GL) {
GL_BGRA_EXT));
EXPECT_TRUE(info_->GetTextureFormatValidator(GL_BGRA_EXT).IsValid(
GL_UNSIGNED_BYTE));
+ EXPECT_TRUE(info_->validators()->render_buffer_format.IsValid(
+ GL_BGRA8_EXT));
}
TEST_F(FeatureInfoTest, InitializeEXT_texture_format_BGRA8888Apple) {
@@ -369,6 +375,8 @@ TEST_F(FeatureInfoTest, InitializeEXT_texture_format_BGRA8888Apple) {
GL_BGRA_EXT));
EXPECT_TRUE(info_->GetTextureFormatValidator(GL_BGRA_EXT).IsValid(
GL_UNSIGNED_BYTE));
+ EXPECT_FALSE(info_->validators()->render_buffer_format.IsValid(
+ GL_BGRA8_EXT));
}
TEST_F(FeatureInfoTest, InitializeEXT_read_format_bgra) {
@@ -381,6 +389,8 @@ TEST_F(FeatureInfoTest, InitializeEXT_read_format_bgra) {
GL_BGRA_EXT));
EXPECT_TRUE(info_->validators()->read_pixel_format.IsValid(
GL_BGRA_EXT));
+ EXPECT_FALSE(info_->validators()->render_buffer_format.IsValid(
+ GL_BGRA8_EXT));
}
TEST_F(FeatureInfoTest, InitializeOES_texture_floatGLES2) {
diff --git a/ui/gl/gl_gl_api_implementation.cc b/ui/gl/gl_gl_api_implementation.cc
index 03d1302..eade3ce 100644
--- a/ui/gl/gl_gl_api_implementation.cc
+++ b/ui/gl/gl_gl_api_implementation.cc
@@ -26,7 +26,7 @@ static TraceGLApi* g_trace_gl;
namespace {
-static inline GLenum GetTexInternalFormat(GLenum internal_format) {
+static inline GLenum GetInternalFormat(GLenum internal_format) {
if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
if (internal_format == GL_BGRA_EXT || internal_format == GL_BGRA8_EXT)
return GL_RGBA8;
@@ -38,7 +38,7 @@ static inline GLenum GetTexInternalFormat(GLenum internal_format) {
static inline GLenum GetTexInternalFormat(GLenum internal_format,
GLenum format,
GLenum type) {
- GLenum gl_internal_format = GetTexInternalFormat(internal_format);
+ GLenum gl_internal_format = GetInternalFormat(internal_format);
if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2)
return gl_internal_format;
@@ -120,11 +120,30 @@ static void GL_BINDING_CALL CustomTexSubImage2D(
static void GL_BINDING_CALL CustomTexStorage2DEXT(
GLenum target, GLsizei levels, GLenum internalformat, GLsizei width,
GLsizei height) {
- GLenum gl_internal_format = GetTexInternalFormat(internalformat);
+ GLenum gl_internal_format = GetInternalFormat(internalformat);
return g_driver_gl.orig_fn.glTexStorage2DEXTFn(
target, levels, gl_internal_format, width, height);
}
+static void GL_BINDING_CALL CustomRenderbufferStorageEXT(
+ GLenum target, GLenum internalformat, GLsizei width, GLsizei height) {
+ GLenum gl_internal_format = GetInternalFormat(internalformat);
+ return g_driver_gl.orig_fn.glRenderbufferStorageEXTFn(
+ target, gl_internal_format, width, height);
+}
+
+// The ANGLE and IMG variants of glRenderbufferStorageMultisample currently do
+// not support BGRA render buffers so only the EXT one is customized. If
+// GL_CHROMIUM_renderbuffer_format_BGRA8888 support is added to ANGLE then the
+// ANGLE version should also be customized.
+static void GL_BINDING_CALL CustomRenderbufferStorageMultisampleEXT(
+ GLenum target, GLsizei samples, GLenum internalformat, GLsizei width,
+ GLsizei height) {
+ GLenum gl_internal_format = GetInternalFormat(internalformat);
+ return g_driver_gl.orig_fn.glRenderbufferStorageMultisampleEXTFn(
+ target, samples, gl_internal_format, width, height);
+}
+
} // anonymous namespace
void DriverGL::Initialize() {
@@ -140,6 +159,12 @@ void DriverGL::InitializeExtensions(GLContext* context) {
reinterpret_cast<glTexSubImage2DProc>(CustomTexSubImage2D);
fn.glTexStorage2DEXTFn =
reinterpret_cast<glTexStorage2DEXTProc>(CustomTexStorage2DEXT);
+ fn.glRenderbufferStorageEXTFn =
+ reinterpret_cast<glRenderbufferStorageEXTProc>(
+ CustomRenderbufferStorageEXT);
+ fn.glRenderbufferStorageMultisampleEXTFn =
+ reinterpret_cast<glRenderbufferStorageMultisampleEXTProc>(
+ CustomRenderbufferStorageMultisampleEXT);
}
void InitializeGLBindingsGL() {