diff options
author | backer@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-11 14:15:28 +0000 |
---|---|---|
committer | backer@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-11 14:15:28 +0000 |
commit | 1c75a370ce5ea49e230cae711a0b1d17dc072763 (patch) | |
tree | b3612370e93b34c7ce4d631cf22cafb4d71329ea /gpu | |
parent | 9e814828186b00d3ead0edd3884e3185067875d5 (diff) | |
download | chromium_src-1c75a370ce5ea49e230cae711a0b1d17dc072763.zip chromium_src-1c75a370ce5ea49e230cae711a0b1d17dc072763.tar.gz chromium_src-1c75a370ce5ea49e230cae711a0b1d17dc072763.tar.bz2 |
Plumb through EGL_NV_post_sub_buffer and GLX_MESA_copy_sub_buffer.
These two extensions allow a partial swap: just pushing part of the backbuffer to the front buffer. This will allow the WK compositor to push a partial update to the screen instead of a full frame update (https://bugs.webkit.org/show_bug.cgi?id=70533).
We should be able to do something similar for TOUCHUI ImageTransportSurfaces (hence the hooks into GLSurface and the glPostSubBufferCHROMIUM command).
Review URL: http://codereview.chromium.org/8512005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109625 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r-- | gpu/GLES2/gl2ext.h | 13 | ||||
-rwxr-xr-x | gpu/command_buffer/build_gles2_cmd_buffer.py | 9 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_c_lib_autogen.h | 3 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_cmd_helper_autogen.h | 6 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_implementation.cc | 16 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_implementation_autogen.h | 2 | ||||
-rw-r--r-- | gpu/command_buffer/common/gles2_cmd_format_autogen.h | 46 | ||||
-rw-r--r-- | gpu/command_buffer/common/gles2_cmd_format_test_autogen.h | 19 | ||||
-rw-r--r-- | gpu/command_buffer/common/gles2_cmd_ids_autogen.h | 1 | ||||
-rw-r--r-- | gpu/command_buffer/service/feature_info.cc | 7 | ||||
-rw-r--r-- | gpu/command_buffer/service/gles2_cmd_decoder.cc | 14 | ||||
-rw-r--r-- | gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h | 1 |
12 files changed, 137 insertions, 0 deletions
diff --git a/gpu/GLES2/gl2ext.h b/gpu/GLES2/gl2ext.h index 71a3df0..28b3119 100644 --- a/gpu/GLES2/gl2ext.h +++ b/gpu/GLES2/gl2ext.h @@ -1349,6 +1349,19 @@ typedef void (GL_APIENTRYP PFNGLENABLEFEATURECHROMIUM) (const GLchar *feature); #endif #endif +/* GL_CHROMIUM_post_sub_buffer */ +#ifndef GL_CHROMIUM_post_sub_buffer +#define GL_CHROMIUM_post_sub_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +#define glPostSubBufferCHROMIUM GLES2_GET_FUN(PostSubBufferCHROMIUM) +#if !defined(GLES2_USE_CPP_BINDINGS) +GL_APICALL void GL_APIENTRY glPostSubBufferCHROMIUM (GLint x, GLint y, GLint width, GLint height); +#endif +#else +typedef void (GL_APIENTRYP PFNGLPOSTSUBBUFFERCHROMIUM) (GLint x, GLint y, GLint width, GLint height); +#endif +#endif + /* GL_ARB_robustness */ /* This extension is subsetted for the moment, incorporating only the * enums necessary to describe the reasons that we might encounter for diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py index e1051b4..36dad3f 100755 --- a/gpu/command_buffer/build_gles2_cmd_buffer.py +++ b/gpu/command_buffer/build_gles2_cmd_buffer.py @@ -224,6 +224,7 @@ GL_APICALL GLuint GL_APIENTRY glCreateStreamTextureCHROMIUM (GLuint textur GL_APICALL void GL_APIENTRY glDestroyStreamTextureCHROMIUM (GLuint texture); GL_APICALL void GL_APIENTRY glPlaceholder453CHROMIUM (void); GL_APICALL void GL_APIENTRY glGetTranslatedShaderSourceANGLE (GLidShader shader, GLsizeiNotNegative bufsize, GLsizei* length, char* source); +GL_APICALL void GL_APIENTRY glPostSubBufferCHROMIUM (GLint x, GLint y, GLint width, GLint height); """ # This is the list of all commmands that will be generated and their Id. @@ -433,6 +434,7 @@ _CMD_ID_TABLE = { 'GetMultipleIntegervCHROMIUM': 454, 'GetProgramInfoCHROMIUM': 455, 'GetTranslatedShaderSourceANGLE': 456, + 'PostSubBufferCHROMIUM': 457, } # This is a list of enum names and their valid values. It is used to map @@ -1517,6 +1519,13 @@ _FUNCTION_INFO = { 'chromium': True, }, 'PixelStorei': {'type': 'Manual'}, + 'PostSubBufferCHROMIUM': { + 'type': 'Custom', + 'impl_func': False, + 'unit_test': False, + 'extension': True, + 'chromium': True, + }, 'RenderbufferStorage': { 'decoder_func': 'DoRenderbufferStorage', 'gl_test_func': 'glRenderbufferStorageEXT', diff --git a/gpu/command_buffer/client/gles2_c_lib_autogen.h b/gpu/command_buffer/client/gles2_c_lib_autogen.h index e046662..40c7102 100644 --- a/gpu/command_buffer/client/gles2_c_lib_autogen.h +++ b/gpu/command_buffer/client/gles2_c_lib_autogen.h @@ -586,6 +586,9 @@ void GLES2GetTranslatedShaderSourceANGLE( gles2::GetGLContext()->GetTranslatedShaderSourceANGLE( shader, bufsize, length, source); } +void GLES2PostSubBufferCHROMIUM(GLint x, GLint y, GLint width, GLint height) { + gles2::GetGLContext()->PostSubBufferCHROMIUM(x, y, width, height); +} #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_C_LIB_AUTOGEN_H_ diff --git a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h index 0705fb3..2a5d6d7 100644 --- a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h +++ b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h @@ -1247,5 +1247,11 @@ c.Init(shader, bucket_id); } + void PostSubBufferCHROMIUM(GLint x, GLint y, GLint width, GLint height) { + gles2::PostSubBufferCHROMIUM& c = + GetCmdSpace<gles2::PostSubBufferCHROMIUM>(); + c.Init(x, y, width, height); + } + #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_CMD_HELPER_AUTOGEN_H_ diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc index 5fce838..6d402c5 100644 --- a/gpu/command_buffer/client/gles2_implementation.cc +++ b/gpu/command_buffer/client/gles2_implementation.cc @@ -2649,5 +2649,21 @@ void GLES2Implementation::DestroyStreamTextureCHROMIUM(GLuint texture) { helper_->DestroyStreamTextureCHROMIUM(texture); } +void GLES2Implementation::PostSubBufferCHROMIUM( + GLint x, GLint y, GLint width, GLint height) { + GPU_CLIENT_LOG("[" << this << "] PostSubBufferCHROMIUM(" + << x << ", " << y << ", " << width << ", " << height << ")"); + TRACE_EVENT0("gpu", "GLES2::PostSubBufferCHROMIUM"); + + // Same flow control as GLES2Implementation::SwapBuffers (see comments there). + swap_buffers_tokens_.push(helper_->InsertToken()); + helper_->PostSubBufferCHROMIUM(x, y, width, height); + helper_->CommandBufferHelper::Flush(); + if (swap_buffers_tokens_.size() > kMaxSwapBuffers + 1) { + helper_->WaitForToken(swap_buffers_tokens_.front()); + swap_buffers_tokens_.pop(); + } +} + } // namespace gles2 } // namespace gpu diff --git a/gpu/command_buffer/client/gles2_implementation_autogen.h b/gpu/command_buffer/client/gles2_implementation_autogen.h index d8f6a5c..0721c79 100644 --- a/gpu/command_buffer/client/gles2_implementation_autogen.h +++ b/gpu/command_buffer/client/gles2_implementation_autogen.h @@ -1303,5 +1303,7 @@ void GetTranslatedShaderSourceANGLE( *length = max_size; } } +void PostSubBufferCHROMIUM(GLint x, GLint y, GLint width, GLint height); + #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_AUTOGEN_H_ diff --git a/gpu/command_buffer/common/gles2_cmd_format_autogen.h b/gpu/command_buffer/common/gles2_cmd_format_autogen.h index ef34bad..cb54dda 100644 --- a/gpu/command_buffer/common/gles2_cmd_format_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_format_autogen.h @@ -9165,6 +9165,52 @@ COMPILE_ASSERT(offsetof(GetTranslatedShaderSourceANGLE, shader) == 4, COMPILE_ASSERT(offsetof(GetTranslatedShaderSourceANGLE, bucket_id) == 8, OffsetOf_GetTranslatedShaderSourceANGLE_bucket_id_not_8); +struct PostSubBufferCHROMIUM { + typedef PostSubBufferCHROMIUM ValueType; + static const CommandId kCmdId = kPostSubBufferCHROMIUM; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLint _x, GLint _y, GLint _width, GLint _height) { + SetHeader(); + x = _x; + y = _y; + width = _width; + height = _height; + } + + void* Set(void* cmd, GLint _x, GLint _y, GLint _width, GLint _height) { + static_cast<ValueType*>(cmd)->Init(_x, _y, _width, _height); + return NextCmdAddress<ValueType>(cmd); + } + + gpu::CommandHeader header; + int32 x; + int32 y; + int32 width; + int32 height; +}; + +COMPILE_ASSERT(sizeof(PostSubBufferCHROMIUM) == 20, + Sizeof_PostSubBufferCHROMIUM_is_not_20); +COMPILE_ASSERT(offsetof(PostSubBufferCHROMIUM, header) == 0, + OffsetOf_PostSubBufferCHROMIUM_header_not_0); +COMPILE_ASSERT(offsetof(PostSubBufferCHROMIUM, x) == 4, + OffsetOf_PostSubBufferCHROMIUM_x_not_4); +COMPILE_ASSERT(offsetof(PostSubBufferCHROMIUM, y) == 8, + OffsetOf_PostSubBufferCHROMIUM_y_not_8); +COMPILE_ASSERT(offsetof(PostSubBufferCHROMIUM, width) == 12, + OffsetOf_PostSubBufferCHROMIUM_width_not_12); +COMPILE_ASSERT(offsetof(PostSubBufferCHROMIUM, height) == 16, + OffsetOf_PostSubBufferCHROMIUM_height_not_16); + #endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_AUTOGEN_H_ diff --git a/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h b/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h index a150a58..9c414a9 100644 --- a/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h @@ -3559,5 +3559,24 @@ TEST_F(GLES2FormatTest, GetTranslatedShaderSourceANGLE) { next_cmd, sizeof(cmd)); } +TEST_F(GLES2FormatTest, PostSubBufferCHROMIUM) { + PostSubBufferCHROMIUM& cmd = *GetBufferAs<PostSubBufferCHROMIUM>(); + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLint>(11), + static_cast<GLint>(12), + static_cast<GLint>(13), + static_cast<GLint>(14)); + EXPECT_EQ(static_cast<uint32>(PostSubBufferCHROMIUM::kCmdId), + cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); + EXPECT_EQ(static_cast<GLint>(11), cmd.x); + EXPECT_EQ(static_cast<GLint>(12), cmd.y); + EXPECT_EQ(static_cast<GLint>(13), cmd.width); + EXPECT_EQ(static_cast<GLint>(14), cmd.height); + CheckBytesWrittenMatchesExpectedSize( + next_cmd, sizeof(cmd)); +} + #endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_TEST_AUTOGEN_H_ diff --git a/gpu/command_buffer/common/gles2_cmd_ids_autogen.h b/gpu/command_buffer/common/gles2_cmd_ids_autogen.h index 0c9aa01..498c625 100644 --- a/gpu/command_buffer/common/gles2_cmd_ids_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_ids_autogen.h @@ -211,6 +211,7 @@ OP(GetMultipleIntegervCHROMIUM) /* 454 */ \ OP(GetProgramInfoCHROMIUM) /* 455 */ \ OP(GetTranslatedShaderSourceANGLE) /* 456 */ \ + OP(PostSubBufferCHROMIUM) /* 457 */ \ enum CommandId { kStartPoint = cmd::kLastCommonId, // All GLES2 commands start after this. diff --git a/gpu/command_buffer/service/feature_info.cc b/gpu/command_buffer/service/feature_info.cc index 5d6fe74..64c7222 100644 --- a/gpu/command_buffer/service/feature_info.cc +++ b/gpu/command_buffer/service/feature_info.cc @@ -7,6 +7,7 @@ #include "gpu/command_buffer/service/feature_info.h" #include "gpu/command_buffer/service/gl_utils.h" #include "ui/gfx/gl/gl_implementation.h" +#include "ui/gfx/gl/gl_surface.h" namespace gpu { namespace gles2 { @@ -357,6 +358,12 @@ void FeatureInfo::AddFeatures(const char* desired_features) { feature_flags_.enable_texture_half_float_linear = enable_texture_half_float_linear; feature_flags_.npot_ok = npot_ok; + + if (ext.Desire("GL_CHROMIUM_post_sub_buffer") && + gfx::GLSurface::GetCurrent() && + gfx::GLSurface::GetCurrent()->SupportsPostSubBuffer()) { + AddExtensionString("GL_CHROMIUM_post_sub_buffer"); + } } void FeatureInfo::AddExtensionString(const std::string& str) { diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index f31effa..fc12352 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -5740,6 +5740,20 @@ error::Error GLES2DecoderImpl::HandlePixelStorei( return error::kNoError; } +error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM( + uint32 immediate_data_size, const gles2::PostSubBufferCHROMIUM& c) { + TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandlePostSubBufferCHROMIUM"); + if (!surface_->SupportsPostSubBuffer()) { + SetGLError(GL_INVALID_OPERATION, + "glPostSubBufferCHROMIUM: command not supported by surface"); + return error::kNoError; + } + if (surface_->PostSubBuffer(c.x, c.y, c.width, c.height)) + return error::kNoError; + else + return error::kLostContext; +} + error::Error GLES2DecoderImpl::GetAttribLocationHelper( GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, const std::string& name_str) { diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h index e5b9d40..c60e869 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_3_autogen.h @@ -15,5 +15,6 @@ // TODO(gman): DestroyStreamTextureCHROMIUM // TODO(gman): GetTranslatedShaderSourceANGLE +// TODO(gman): PostSubBufferCHROMIUM #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_3_AUTOGEN_H_ |