diff options
author | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-16 19:19:39 +0000 |
---|---|---|
committer | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-16 19:19:39 +0000 |
commit | 43ecf3770972226c55ec7b813ce6dece8f4fc259 (patch) | |
tree | 842372a2747ac9854cbd1197554609b47cbff10d /gpu | |
parent | 61f5d33b82980dbd74167a7f81f9a379678f8096 (diff) | |
download | chromium_src-43ecf3770972226c55ec7b813ce6dece8f4fc259.zip chromium_src-43ecf3770972226c55ec7b813ce6dece8f4fc259.tar.gz chromium_src-43ecf3770972226c55ec7b813ce6dece8f4fc259.tar.bz2 |
Added glResizeCHRM to resize the drawable associated with the command buffer.
This new command is used to pipe resize requests to the GPU process. It will allow is to synchronize the resize with the drawing. Specifically, if we resize at the wrong time, we will damage the backbuffer, causing visual artefacts (http://code.google.com/p/chromium/issues/detail?id=54430).
The resize request gets sent to the GLContext. Each backend will implement it differently. At this point it's set as a NOP.
-I will do an XResizeWindow on Linux.
-Nat will do a resize on Windows.
-Nico (or me?) will refactor the MacOSX code to use this path.
There is one line webkit patch that's necessary to activate this code (removing an #ifdef).
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/4671003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66307 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
14 files changed, 108 insertions, 3 deletions
diff --git a/gpu/GLES2/gl2ext.h b/gpu/GLES2/gl2ext.h index 35ac011..ccfa910 100644 --- a/gpu/GLES2/gl2ext.h +++ b/gpu/GLES2/gl2ext.h @@ -909,6 +909,19 @@ typedef void* (GL_APIENTRYP PFNGLCOPYTEXTURETOPARENTTEXTURE) (GLuint id, GLuint #endif #endif +/* GL_CHROMIUM_resize */ +#ifndef GL_CHROMIUM_resize +#define GL_CHROMIUM_resize 1 +#ifdef GL_GLEXT_PROTOTYPES +#define glResizeCHROMIUM GLES2_GET_FUN(ResizeCHROMIUM) +#if !defined(GLES2_USE_CPP_BINDINGS) +GL_APICALL void GL_APIENTRY glResizeCHROMIUM (GLuint width, GLuint height); +#endif +#else +typedef void (GL_APIENTRYP PFNGLRESIZECHROMIUM) (GLuint width, GLuint height); +#endif +#endif + #ifdef __cplusplus } diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py index cf88bd9..66d15e7 100755 --- a/gpu/command_buffer/build_gles2_cmd_buffer.py +++ b/gpu/command_buffer/build_gles2_cmd_buffer.py @@ -208,6 +208,7 @@ GL_APICALL void GL_APIENTRY glUnmapBufferSubData (const void* mem); GL_APICALL void* GL_APIENTRY glMapTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLenum access); GL_APICALL void GL_APIENTRY glUnmapTexSubImage2D (const void* mem); GL_APICALL void GL_APIENTRY glCopyTextureToParentTexture (GLidBindTexture client_child_id, GLidBindTexture client_parent_id); +GL_APICALL void GL_APIENTRY glResizeCHROMIUM (GLuint width, GLuint height); """ # This is the list of all commmands that will be generated and their Id. @@ -408,6 +409,7 @@ _CMD_ID_TABLE = { 'RenderbufferStorageMultisampleEXT': 445, 'BlitFramebufferEXT': 446, 'CopyTextureToParentTexture': 447, + 'ResizeCHROMIUM': 448, } # This is a list of enum names and their valid values. It is used to map @@ -1541,6 +1543,10 @@ _FUNCTION_INFO = { 'decoder_func': 'DoCopyTextureToParentTexture', 'unit_test': False }, + 'ResizeCHROMIUM': { + 'decoder_func': 'DoResizeCHROMIUM', + 'unit_test': False + }, } diff --git a/gpu/command_buffer/client/gles2_c_lib_autogen.h b/gpu/command_buffer/client/gles2_c_lib_autogen.h index 0a69471..6107a96 100644 --- a/gpu/command_buffer/client/gles2_c_lib_autogen.h +++ b/gpu/command_buffer/client/gles2_c_lib_autogen.h @@ -837,6 +837,10 @@ void GLES2CopyTextureToParentTexture( gles2::GetGLContext()->CopyTextureToParentTexture( client_child_id, client_parent_id); } +void GLES2ResizeCHROMIUM(GLuint width, GLuint height) { + GPU_CLIENT_LOG("ResizeCHROMIUM" << "(" << width << ", " << height << ")"); + gles2::GetGLContext()->ResizeCHROMIUM(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 7e57558..f319e96 100644 --- a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h +++ b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h @@ -1193,5 +1193,10 @@ c.Init(client_child_id, client_parent_id); } + void ResizeCHROMIUM(GLuint width, GLuint height) { + gles2::ResizeCHROMIUM& c = GetCmdSpace<gles2::ResizeCHROMIUM>(); + c.Init(width, height); + } + #endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_CMD_HELPER_AUTOGEN_H_ diff --git a/gpu/command_buffer/client/gles2_implementation_autogen.h b/gpu/command_buffer/client/gles2_implementation_autogen.h index 16ef2ee..447c5a3 100644 --- a/gpu/command_buffer/client/gles2_implementation_autogen.h +++ b/gpu/command_buffer/client/gles2_implementation_autogen.h @@ -881,5 +881,9 @@ void CopyTextureToParentTexture( helper_->CopyTextureToParentTexture(client_child_id, client_parent_id); } +void ResizeCHROMIUM(GLuint width, GLuint height) { + helper_->ResizeCHROMIUM(width, 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 3eeaf99..6297fdf 100644 --- a/gpu/command_buffer/common/gles2_cmd_format_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_format_autogen.h @@ -8793,6 +8793,44 @@ COMPILE_ASSERT(offsetof(CopyTextureToParentTexture, client_child_id) == 4, COMPILE_ASSERT(offsetof(CopyTextureToParentTexture, client_parent_id) == 8, OffsetOf_CopyTextureToParentTexture_client_parent_id_not_8); +struct ResizeCHROMIUM { + typedef ResizeCHROMIUM ValueType; + static const CommandId kCmdId = kResizeCHROMIUM; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLuint _width, GLuint _height) { + SetHeader(); + width = _width; + height = _height; + } + + void* Set(void* cmd, GLuint _width, GLuint _height) { + static_cast<ValueType*>(cmd)->Init(_width, _height); + return NextCmdAddress<ValueType>(cmd); + } + + gpu::CommandHeader header; + uint32 width; + uint32 height; +}; + +COMPILE_ASSERT(sizeof(ResizeCHROMIUM) == 12, + Sizeof_ResizeCHROMIUM_is_not_12); +COMPILE_ASSERT(offsetof(ResizeCHROMIUM, header) == 0, + OffsetOf_ResizeCHROMIUM_header_not_0); +COMPILE_ASSERT(offsetof(ResizeCHROMIUM, width) == 4, + OffsetOf_ResizeCHROMIUM_width_not_4); +COMPILE_ASSERT(offsetof(ResizeCHROMIUM, height) == 8, + OffsetOf_ResizeCHROMIUM_height_not_8); + #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 8bf6b6d..6b1f78a 100644 --- a/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h @@ -3465,5 +3465,20 @@ TEST(GLES2FormatTest, CopyTextureToParentTexture) { EXPECT_EQ(static_cast<GLuint>(12), cmd.client_parent_id); } +TEST(GLES2FormatTest, ResizeCHROMIUM) { + ResizeCHROMIUM cmd = { { 0 } }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<GLuint>(12)); + EXPECT_EQ(static_cast<uint32>(ResizeCHROMIUM::kCmdId), + cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); + EXPECT_EQ(static_cast<char*>(next_cmd), + reinterpret_cast<char*>(&cmd) + sizeof(cmd)); + EXPECT_EQ(static_cast<GLuint>(11), cmd.width); + EXPECT_EQ(static_cast<GLuint>(12), cmd.height); +} + #endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_TEST_AUTOGEN_H_ diff --git a/gpu/command_buffer/common/gles2_cmd_id_test_autogen.h b/gpu/command_buffer/common/gles2_cmd_id_test_autogen.h index e0f1544..6ef4d3c 100644 --- a/gpu/command_buffer/common/gles2_cmd_id_test_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_id_test_autogen.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -395,6 +395,8 @@ TEST(GLES2CommandIdTest, CommandIdsMatch) { GLES2_CommandBufferEnable_kCmdId_mismatch); COMPILE_ASSERT(CopyTextureToParentTexture::kCmdId == 447, GLES2_CopyTextureToParentTexture_kCmdId_mismatch); + COMPILE_ASSERT(ResizeCHROMIUM::kCmdId == 448, + GLES2_ResizeCHROMIUM_kCmdId_mismatch); } #endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_ID_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 e7d5708..a41ec24 100644 --- a/gpu/command_buffer/common/gles2_cmd_ids_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_ids_autogen.h @@ -200,6 +200,7 @@ OP(RenderbufferStorageMultisampleEXT) /* 445 */ \ OP(BlitFramebufferEXT) /* 446 */ \ OP(CopyTextureToParentTexture) /* 447 */ \ + OP(ResizeCHROMIUM) /* 448 */ \ 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 71ccb5b..cf755d8 100644 --- a/gpu/command_buffer/service/feature_info.cc +++ b/gpu/command_buffer/service/feature_info.cc @@ -94,6 +94,7 @@ void FeatureInfo::AddFeatures(const char* desired_features) { AddExtensionString("GL_CHROMIUM_map_sub"); AddExtensionString("GL_CHROMIUM_copy_texture_to_parent_texture"); AddExtensionString("GL_CHROMIUM_resource_safe"); + AddExtensionString("GL_CHROMIUM_resize"); AddExtensionString("GL_CHROMIUM_strict_attribs"); // Only turn this feature on if it is requested. Not by default. diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index e0df165..1348f64 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -1171,6 +1171,8 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>, void DoCopyTextureToParentTexture(GLuint client_texture_id, GLuint parent_client_texture_id); + void DoResizeCHROMIUM(GLuint width, GLuint height); + // Gets the number of values that will be returned by glGetXXX. Returns // false if pname is unknown. bool GetNumValuesReturnedForGLGet(GLenum pname, GLsizei* num_values); @@ -2503,6 +2505,11 @@ void GLES2DecoderImpl::DoCopyTextureToParentTexture( } } +void GLES2DecoderImpl::DoResizeCHROMIUM(GLuint width, GLuint height) { + gfx::Size size(width, height); + context_->SetSize(size); +} + const char* GLES2DecoderImpl::GetCommandName(unsigned int command_id) const { if (command_id > kStartPoint && command_id < kNumCommands) { return gles2::GetCommandName(static_cast<CommandId>(command_id)); diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h index 9ca83c5..18daa6a 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h @@ -2670,5 +2670,13 @@ error::Error GLES2DecoderImpl::HandleCopyTextureToParentTexture( return error::kNoError; } +error::Error GLES2DecoderImpl::HandleResizeCHROMIUM( + uint32 immediate_data_size, const gles2::ResizeCHROMIUM& c) { + GLuint width = static_cast<GLuint>(c.width); + GLuint height = static_cast<GLuint>(c.height); + DoResizeCHROMIUM(width, height); + return error::kNoError; +} + #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_AUTOGEN_H_ diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h index 83f11ba..eaa7af3 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h @@ -1753,5 +1753,7 @@ TEST_F(GLES2DecoderTest1, GetTexParameterivInvalidArgs2_1) { // TODO(gman): GetUniformLocationImmediate +// TODO(gman): GetUniformLocationBucket + #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_1_AUTOGEN_H_ diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h index 9b82306..95a1952 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h @@ -8,8 +8,6 @@ #ifndef GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_2_AUTOGEN_H_ #define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_2_AUTOGEN_H_ -// TODO(gman): GetUniformLocationBucket - TEST_F(GLES2DecoderTest2, GetVertexAttribfvValidArgs) { SpecializedSetup<GetVertexAttribfv, 0>(true); @@ -1612,5 +1610,6 @@ TEST_F(GLES2DecoderTest2, ViewportInvalidArgs3_0) { // TODO(gman): CommandBufferEnable // TODO(gman): CopyTextureToParentTexture +// TODO(gman): ResizeCHROMIUM #endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_2_AUTOGEN_H_ |