diff options
author | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-31 20:11:41 +0000 |
---|---|---|
committer | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-31 20:11:41 +0000 |
commit | 30de8559a38a47d368e0869f86b27651e277fbfe (patch) | |
tree | 13da1014dd77e9019e4e8abba24ceb8447e8ce78 | |
parent | a6e595833d7affc272d620c5e75b22fde5371720 (diff) | |
download | chromium_src-30de8559a38a47d368e0869f86b27651e277fbfe.zip chromium_src-30de8559a38a47d368e0869f86b27651e277fbfe.tar.gz chromium_src-30de8559a38a47d368e0869f86b27651e277fbfe.tar.bz2 |
pepper: simplify context creation/initialization
This saves a round-trip. We don't need client-side info (e.g. shm buffer) any
more before context initialization, so we can do the initialization completely
on the renderer side before returning the resource, saving one sync round-trip.
A side benefit is that now we can guarantee we only call SetParent after
initialization, simplifying transient states.
BUG=164095
Review URL: https://chromiumcodereview.appspot.com/15679013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203464 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/common/gpu/gpu_command_buffer_stub.cc | 18 | ||||
-rw-r--r-- | content/common/gpu/gpu_command_buffer_stub.h | 5 | ||||
-rw-r--r-- | content/renderer/pepper/pepper_platform_context_3d_impl.cc | 2 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_command_buffer_proxy.cc | 3 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_messages.h | 2 | ||||
-rw-r--r-- | ppapi/proxy/ppb_graphics_3d_proxy.cc | 19 | ||||
-rw-r--r-- | ppapi/proxy/ppb_graphics_3d_proxy.h | 2 | ||||
-rw-r--r-- | ppapi/thunk/ppb_graphics_3d_api.h | 1 | ||||
-rw-r--r-- | ppapi/thunk/ppb_graphics_3d_trusted_thunk.cc | 2 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_graphics_3d_impl.cc | 4 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_graphics_3d_impl.h | 1 |
11 files changed, 5 insertions, 54 deletions
diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc index 893d8ee..582802d 100644 --- a/content/common/gpu/gpu_command_buffer_stub.cc +++ b/content/common/gpu/gpu_command_buffer_stub.cc @@ -128,8 +128,6 @@ GpuCommandBufferStub::GpuCommandBufferStub( software_(software), last_flush_count_(0), last_memory_allocation_valid_(false), - parent_stub_for_initialization_(), - parent_texture_for_initialization_(0), watchdog_(watchdog), sync_point_wait_count_(0), delayed_work_scheduled_(false), @@ -548,13 +546,6 @@ void GpuCommandBufferStub::OnInitialize( decoder_->SetStreamTextureManager(channel_->stream_texture_manager()); #endif - if (parent_stub_for_initialization_) { - decoder_->SetParent(parent_stub_for_initialization_->decoder_.get(), - parent_texture_for_initialization_); - parent_stub_for_initialization_.reset(); - parent_texture_for_initialization_ = 0; - } - if (!command_buffer_->SetSharedStateBuffer(shared_state_shm.Pass())) { DLOG(ERROR) << "Failed to map shared stae buffer."; OnInitializeFailed(reply_message); @@ -599,18 +590,11 @@ void GpuCommandBufferStub::OnSetParent(int32 parent_route_id, parent_stub = channel_->LookupCommandBuffer(parent_route_id); } - bool result = true; + bool result = false; if (scheduler_) { gpu::gles2::GLES2Decoder* parent_decoder = parent_stub ? parent_stub->decoder_.get() : NULL; result = decoder_->SetParent(parent_decoder, parent_texture_id); - } else { - // If we don't have a scheduler, it means that Initialize hasn't been called - // yet. Keep around the requested parent stub and texture so that we can set - // it in Initialize(). - parent_stub_for_initialization_ = parent_stub ? - parent_stub->AsWeakPtr() : base::WeakPtr<GpuCommandBufferStub>(); - parent_texture_for_initialization_ = parent_texture_id; } GpuCommandBufferMsg_SetParent::WriteReplyParams(reply_message, result); Send(reply_message); diff --git a/content/common/gpu/gpu_command_buffer_stub.h b/content/common/gpu/gpu_command_buffer_stub.h index 7700a6b..a7ed075 100644 --- a/content/common/gpu/gpu_command_buffer_stub.h +++ b/content/common/gpu/gpu_command_buffer_stub.h @@ -229,11 +229,6 @@ class GpuCommandBufferStub bool last_memory_allocation_valid_; GpuMemoryAllocation last_memory_allocation_; - // SetParent may be called before Initialize, in which case we need to keep - // around the parent stub, so that Initialize can set the parent correctly. - base::WeakPtr<GpuCommandBufferStub> parent_stub_for_initialization_; - uint32 parent_texture_for_initialization_; - GpuWatchdog* watchdog_; ObserverList<DestructionObserver> destruction_observers_; diff --git a/content/renderer/pepper/pepper_platform_context_3d_impl.cc b/content/renderer/pepper/pepper_platform_context_3d_impl.cc index 09e5935..ffa3d2d8 100644 --- a/content/renderer/pepper/pepper_platform_context_3d_impl.cc +++ b/content/renderer/pepper/pepper_platform_context_3d_impl.cc @@ -106,6 +106,8 @@ bool PlatformContext3DImpl::Init(const int32* attrib_list, gpu_preference); if (!command_buffer_) return false; + if (!command_buffer_->Initialize()) + return false; command_buffer_->SetChannelErrorCallback( base::Bind(&PlatformContext3DImpl::OnContextLost, diff --git a/ppapi/proxy/ppapi_command_buffer_proxy.cc b/ppapi/proxy/ppapi_command_buffer_proxy.cc index 98c2353..04c4468 100644 --- a/ppapi/proxy/ppapi_command_buffer_proxy.cc +++ b/ppapi/proxy/ppapi_command_buffer_proxy.cc @@ -60,8 +60,7 @@ void PpapiCommandBufferProxy::SetChannelErrorCallback( } bool PpapiCommandBufferProxy::Initialize() { - return Send(new PpapiHostMsg_PPBGraphics3D_InitCommandBuffer( - ppapi::API_ID_PPB_GRAPHICS_3D, resource_)); + return true; } gpu::CommandBuffer::State PpapiCommandBufferProxy::GetState() { diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index 14312dc..8d9abe6 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -843,8 +843,6 @@ IPC_SYNC_MESSAGE_ROUTED3_1(PpapiHostMsg_PPBGraphics3D_Create, ppapi::HostResource /* share_context */, std::vector<int32_t> /* attrib_list */, ppapi::HostResource /* result */) -IPC_SYNC_MESSAGE_ROUTED1_0(PpapiHostMsg_PPBGraphics3D_InitCommandBuffer, - ppapi::HostResource /* context */) IPC_SYNC_MESSAGE_ROUTED2_0(PpapiHostMsg_PPBGraphics3D_SetGetBuffer, ppapi::HostResource /* context */, int32 /* transfer_buffer_id */) diff --git a/ppapi/proxy/ppb_graphics_3d_proxy.cc b/ppapi/proxy/ppb_graphics_3d_proxy.cc index ddacde6..9bb90e6 100644 --- a/ppapi/proxy/ppb_graphics_3d_proxy.cc +++ b/ppapi/proxy/ppb_graphics_3d_proxy.cc @@ -206,17 +206,10 @@ bool Graphics3D::Init(gpu::gles2::GLES2Implementation* share_gles2) { new LockingCommandBuffer(command_buffer_.get())); ScopedNoLocking already_locked(this); - if (!command_buffer_->Initialize()) - return false; - return CreateGLES2Impl(kCommandBufferSize, kTransferBufferSize, share_gles2); } -PP_Bool Graphics3D::InitCommandBuffer() { - return PP_FALSE; -} - PP_Bool Graphics3D::SetGetBuffer(int32_t /* transfer_buffer_id */) { return PP_FALSE; } @@ -351,8 +344,6 @@ bool PPB_Graphics3D_Proxy::OnMessageReceived(const IPC::Message& msg) { #if !defined(OS_NACL) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_Create, OnMsgCreate) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_InitCommandBuffer, - OnMsgInitCommandBuffer) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_SetGetBuffer, OnMsgSetGetBuffer) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_GetState, @@ -403,16 +394,6 @@ void PPB_Graphics3D_Proxy::OnMsgCreate(PP_Instance instance, } } -void PPB_Graphics3D_Proxy::OnMsgInitCommandBuffer( - const HostResource& context) { - EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); - if (enter.failed()) - return; - - if (!enter.object()->InitCommandBuffer()) - return; -} - void PPB_Graphics3D_Proxy::OnMsgSetGetBuffer( const HostResource& context, int32 transfer_buffer_id) { diff --git a/ppapi/proxy/ppb_graphics_3d_proxy.h b/ppapi/proxy/ppb_graphics_3d_proxy.h index f07d2c4..06fb308 100644 --- a/ppapi/proxy/ppb_graphics_3d_proxy.h +++ b/ppapi/proxy/ppb_graphics_3d_proxy.h @@ -33,7 +33,6 @@ class Graphics3D : public PPB_Graphics3D_Shared { bool Init(gpu::gles2::GLES2Implementation* share_gles2); // Graphics3DTrusted API. These are not implemented in the proxy. - virtual PP_Bool InitCommandBuffer() OVERRIDE; virtual PP_Bool SetGetBuffer(int32_t shm_id) OVERRIDE; virtual PP_Graphics3DTrustedState GetState() OVERRIDE; virtual PP_Bool Flush(int32_t put_offset) OVERRIDE; @@ -84,7 +83,6 @@ class PPB_Graphics3D_Proxy : public InterfaceProxy { HostResource share_context, const std::vector<int32_t>& attribs, HostResource* result); - void OnMsgInitCommandBuffer(const HostResource& context); void OnMsgSetGetBuffer(const HostResource& context, int32 id); void OnMsgGetState(const HostResource& context, diff --git a/ppapi/thunk/ppb_graphics_3d_api.h b/ppapi/thunk/ppb_graphics_3d_api.h index dc53b13..e7b98d2 100644 --- a/ppapi/thunk/ppb_graphics_3d_api.h +++ b/ppapi/thunk/ppb_graphics_3d_api.h @@ -30,7 +30,6 @@ class PPAPI_THUNK_EXPORT PPB_Graphics3D_API { virtual int32_t GetAttribMaxValue(int32_t attribute, int32_t* value) = 0; // Graphics3DTrusted API. - virtual PP_Bool InitCommandBuffer() = 0; virtual PP_Bool SetGetBuffer(int32_t shm_id) = 0; virtual PP_Graphics3DTrustedState GetState() = 0; virtual int32_t CreateTransferBuffer(uint32_t size) = 0; diff --git a/ppapi/thunk/ppb_graphics_3d_trusted_thunk.cc b/ppapi/thunk/ppb_graphics_3d_trusted_thunk.cc index 48f6ed1..e3fe422 100644 --- a/ppapi/thunk/ppb_graphics_3d_trusted_thunk.cc +++ b/ppapi/thunk/ppb_graphics_3d_trusted_thunk.cc @@ -34,7 +34,7 @@ PP_Bool InitCommandBuffer(PP_Resource context) { EnterGraphics3D enter(context, true); if (enter.failed()) return PP_FALSE; - return enter.object()->InitCommandBuffer(); + return PP_TRUE; } PP_Bool SetGetBuffer(PP_Resource context, int32_t transfer_buffer_id) { diff --git a/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc index f40b95a..047b1cd 100644 --- a/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc +++ b/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc @@ -127,10 +127,6 @@ PP_Resource PPB_Graphics3D_Impl::CreateRaw(PP_Instance instance, return graphics_3d->GetReference(); } -PP_Bool PPB_Graphics3D_Impl::InitCommandBuffer() { - return PP_FromBool(GetCommandBuffer()->Initialize()); -} - PP_Bool PPB_Graphics3D_Impl::SetGetBuffer(int32_t transfer_buffer_id) { GetCommandBuffer()->SetGetBuffer(transfer_buffer_id); return PP_TRUE; diff --git a/webkit/plugins/ppapi/ppb_graphics_3d_impl.h b/webkit/plugins/ppapi/ppb_graphics_3d_impl.h index d242e4f..5d5d1fb 100644 --- a/webkit/plugins/ppapi/ppb_graphics_3d_impl.h +++ b/webkit/plugins/ppapi/ppb_graphics_3d_impl.h @@ -25,7 +25,6 @@ class PPB_Graphics3D_Impl : public ::ppapi::PPB_Graphics3D_Shared { const int32_t* attrib_list); // PPB_Graphics3D_API trusted implementation. - virtual PP_Bool InitCommandBuffer() OVERRIDE; virtual PP_Bool SetGetBuffer(int32_t transfer_buffer_id) OVERRIDE; virtual PP_Graphics3DTrustedState GetState() OVERRIDE; virtual int32_t CreateTransferBuffer(uint32_t size) OVERRIDE; |