diff options
author | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-12 23:29:40 +0000 |
---|---|---|
committer | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-12 23:29:40 +0000 |
commit | 503b3a2ed9be72b3697f1c02cdc7efd29fec987a (patch) | |
tree | f715ec00989bded6c3bdb3919cace05a7d33fc05 /content | |
parent | 6e6f8836c975eebd3620974c3de6d564967821e9 (diff) | |
download | chromium_src-503b3a2ed9be72b3697f1c02cdc7efd29fec987a.zip chromium_src-503b3a2ed9be72b3697f1c02cdc7efd29fec987a.tar.gz chromium_src-503b3a2ed9be72b3697f1c02cdc7efd29fec987a.tar.bz2 |
Revert "Revert 113479 - Revert "Revert 113250 - Add CommandBuffer::SetGetBuffer""
This reverts commit 84677847c10d0319d8d996aea9b310add85c0bd3.
TEST=ran browser tests on OSX
BUG=103989
TBR=apatrick@chromiu.org
Review URL: http://codereview.chromium.org/8919014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114114 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/common/gpu/gpu_command_buffer_stub.cc | 27 | ||||
-rw-r--r-- | content/common/gpu/gpu_command_buffer_stub.h | 5 | ||||
-rw-r--r-- | content/common/gpu/gpu_messages.h | 8 | ||||
-rw-r--r-- | content/renderer/gpu/command_buffer_proxy.cc | 72 | ||||
-rw-r--r-- | content/renderer/gpu/command_buffer_proxy.h | 9 | ||||
-rw-r--r-- | content/renderer/gpu/renderer_gl_context.cc | 2 |
6 files changed, 32 insertions, 91 deletions
diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc index ff2ab82..8d17117 100644 --- a/content/common/gpu/gpu_command_buffer_stub.cc +++ b/content/common/gpu/gpu_command_buffer_stub.cc @@ -87,6 +87,8 @@ bool GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) { IPC_BEGIN_MESSAGE_MAP(GpuCommandBufferStub, message) IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_Initialize, OnInitialize); + IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_SetGetBuffer, + OnSetGetBuffer); IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_SetParent, OnSetParent); IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetState, OnGetState); @@ -163,8 +165,6 @@ void GpuCommandBufferStub::OnInitializeFailed(IPC::Message* reply_message) { } void GpuCommandBufferStub::OnInitialize( - base::SharedMemoryHandle ring_buffer, - int32 size, IPC::Message* reply_message) { DCHECK(!command_buffer_.get()); @@ -172,19 +172,7 @@ void GpuCommandBufferStub::OnInitialize( command_buffer_.reset(new gpu::CommandBufferService); -#if defined(OS_WIN) - // Windows dups the shared memory handle it receives into the current process - // and closes it when this variable goes out of scope. - base::SharedMemory shared_memory(ring_buffer, - false, - channel_->renderer_process()); -#else - // POSIX receives a dup of the shared memory handle and closes the dup when - // this variable goes out of scope. - base::SharedMemory shared_memory(ring_buffer, false); -#endif - - if (!command_buffer_->Initialize(&shared_memory, size)) { + if (!command_buffer_->Initialize()) { DLOG(ERROR) << "CommandBufferService failed to initialize.\n"; OnInitializeFailed(reply_message); return; @@ -266,6 +254,9 @@ void GpuCommandBufferStub::OnInitialize( command_buffer_->SetPutOffsetChangeCallback( base::Bind(&gpu::GpuScheduler::PutChanged, base::Unretained(scheduler_.get()))); + command_buffer_->SetGetBufferChangeCallback( + base::Bind(&gpu::GpuScheduler::SetGetBuffer, + base::Unretained(scheduler_.get()))); command_buffer_->SetParseErrorCallback( base::Bind(&GpuCommandBufferStub::OnParseError, base::Unretained(this))); scheduler_->SetScheduledCallback( @@ -291,6 +282,12 @@ void GpuCommandBufferStub::OnInitialize( "offscreen", surface_->IsOffscreen()); } +void GpuCommandBufferStub::OnSetGetBuffer( + int32 shm_id, IPC::Message* reply_message) { + command_buffer_->SetGetBuffer(shm_id); + Send(reply_message); +} + void GpuCommandBufferStub::OnSetParent(int32 parent_route_id, uint32 parent_texture_id, IPC::Message* reply_message) { diff --git a/content/common/gpu/gpu_command_buffer_stub.h b/content/common/gpu/gpu_command_buffer_stub.h index 50e2b23..8fbfb79 100644 --- a/content/common/gpu/gpu_command_buffer_stub.h +++ b/content/common/gpu/gpu_command_buffer_stub.h @@ -93,9 +93,8 @@ class GpuCommandBufferStub void OnInitializeFailed(IPC::Message* reply_message); // Message handlers: - void OnInitialize(base::SharedMemoryHandle ring_buffer, - int32 size, - IPC::Message* reply_message); + void OnInitialize(IPC::Message* reply_message); + void OnSetGetBuffer(int32 shm_id, IPC::Message* reply_message); void OnSetParent(int32 parent_route_id, uint32 parent_texture_id, IPC::Message* reply_message); diff --git a/content/common/gpu/gpu_messages.h b/content/common/gpu/gpu_messages.h index e5cab60..7099747 100644 --- a/content/common/gpu/gpu_messages.h +++ b/content/common/gpu/gpu_messages.h @@ -311,11 +311,13 @@ IPC_MESSAGE_CONTROL0(GpuChannelMsg_CloseChannel) // Initialize a command buffer with the given number of command entries. // Returns the shared memory handle for the command buffer mapped to the // calling process. -IPC_SYNC_MESSAGE_ROUTED2_1(GpuCommandBufferMsg_Initialize, - base::SharedMemoryHandle /* ring_buffer */, - int32 /* size */, +IPC_SYNC_MESSAGE_ROUTED0_1(GpuCommandBufferMsg_Initialize, bool /* result */) +// Sets the shared memory buffer used for commands. +IPC_SYNC_MESSAGE_ROUTED1_0(GpuCommandBufferMsg_SetGetBuffer, + int32 /* shm_id */) + // Sets the parent command buffer. This allows the parent and child to share // textures. IPC_SYNC_MESSAGE_ROUTED2_1(GpuCommandBufferMsg_SetParent, diff --git a/content/renderer/gpu/command_buffer_proxy.cc b/content/renderer/gpu/command_buffer_proxy.cc index 86420ae..d51f840 100644 --- a/content/renderer/gpu/command_buffer_proxy.cc +++ b/content/renderer/gpu/command_buffer_proxy.cc @@ -25,8 +25,7 @@ using gpu::Buffer; CommandBufferProxy::CommandBufferProxy( GpuChannelHost* channel, int route_id) - : num_entries_(0), - channel_(channel), + : channel_(channel), route_id_(route_id), flush_count_(0) { } @@ -93,41 +92,13 @@ void CommandBufferProxy::SetChannelErrorCallback( channel_error_callback_ = callback; } -bool CommandBufferProxy::Initialize(int32 size) { - DCHECK(!ring_buffer_.get()); - +bool CommandBufferProxy::Initialize() { ChildThread* child_thread = ChildThread::current(); if (!child_thread) return false; - base::SharedMemoryHandle handle; - if (!child_thread->Send(new ChildProcessHostMsg_SyncAllocateSharedMemory( - size, - &handle))) { - return false; - } - - if (!base::SharedMemory::IsHandleValid(handle)) - return false; - -#if defined(OS_POSIX) - handle.auto_close = false; -#endif - - // Take ownership of shared memory. This will close the handle if Send below - // fails. Otherwise, callee takes ownership before this variable - // goes out of scope. - base::SharedMemory shared_memory(handle, false); - - return Initialize(&shared_memory, size); -} - -bool CommandBufferProxy::Initialize(base::SharedMemory* buffer, int32 size) { bool result; - if (!Send(new GpuCommandBufferMsg_Initialize(route_id_, - buffer->handle(), - size, - &result))) { + if (!Send(new GpuCommandBufferMsg_Initialize(route_id_, &result))) { LOG(ERROR) << "Could not send GpuCommandBufferMsg_Initialize."; return false; } @@ -137,39 +108,9 @@ bool CommandBufferProxy::Initialize(base::SharedMemory* buffer, int32 size) { return false; } - base::SharedMemoryHandle handle; - if (!buffer->GiveToProcess(base::GetCurrentProcessHandle(), &handle)) { - LOG(ERROR) << "Failed to duplicate command buffer handle."; - return false; - } - - ring_buffer_.reset(new base::SharedMemory(handle, false)); - if (!ring_buffer_->Map(size)) { - LOG(ERROR) << "Failed to map shared memory for command buffer."; - ring_buffer_.reset(); - return false; - } - - num_entries_ = size / sizeof(gpu::CommandBufferEntry); return true; } -Buffer CommandBufferProxy::GetRingBuffer() { - DCHECK(ring_buffer_.get()); - // Return locally cached ring buffer. - Buffer buffer; - if (ring_buffer_.get()) { - buffer.ptr = ring_buffer_->memory(); - buffer.size = num_entries_ * sizeof(gpu::CommandBufferEntry); - buffer.shared_memory = ring_buffer_.get(); - } else { - buffer.ptr = NULL; - buffer.size = 0; - buffer.shared_memory = NULL; - } - return buffer; -} - gpu::CommandBuffer::State CommandBufferProxy::GetState() { // Send will flag state with lost context if IPC fails. if (last_state_.error == gpu::error::kNoError) { @@ -214,6 +155,13 @@ gpu::CommandBuffer::State CommandBufferProxy::FlushSync(int32 put_offset, return last_state_; } +void CommandBufferProxy::SetGetBuffer(int32 shm_id) { + if (last_state_.error != gpu::error::kNoError) + return; + + Send(new GpuCommandBufferMsg_SetGetBuffer(route_id_, shm_id)); +} + void CommandBufferProxy::SetGetOffset(int32 get_offset) { // Not implemented in proxy. NOTREACHED(); diff --git a/content/renderer/gpu/command_buffer_proxy.h b/content/renderer/gpu/command_buffer_proxy.h index 551e1ca..6591621 100644 --- a/content/renderer/gpu/command_buffer_proxy.h +++ b/content/renderer/gpu/command_buffer_proxy.h @@ -43,13 +43,12 @@ class CommandBufferProxy : public gpu::CommandBuffer, int route_id() const { return route_id_; } // CommandBuffer implementation: - virtual bool Initialize(int32 size) OVERRIDE; - virtual bool Initialize(base::SharedMemory* buffer, int32 size) OVERRIDE; - virtual gpu::Buffer GetRingBuffer() OVERRIDE; + virtual bool Initialize() OVERRIDE; virtual State GetState() OVERRIDE; virtual State GetLastState() OVERRIDE; virtual void Flush(int32 put_offset) OVERRIDE; virtual State FlushSync(int32 put_offset, int32 last_known_get) OVERRIDE; + virtual void SetGetBuffer(int32 shm_id) OVERRIDE; virtual void SetGetOffset(int32 get_offset) OVERRIDE; virtual int32 CreateTransferBuffer(size_t size, int32 id_request) OVERRIDE; virtual int32 RegisterTransferBuffer(base::SharedMemory* shared_memory, @@ -104,10 +103,6 @@ class CommandBufferProxy : public gpu::CommandBuffer, void OnDestroyed(gpu::error::ContextLostReason reason); void OnEchoAck(); - // As with the service, the client takes ownership of the ring buffer. - int32 num_entries_; - scoped_ptr<base::SharedMemory> ring_buffer_; - // Local cache of id to transfer buffer mapping. typedef std::map<int32, gpu::Buffer> TransferBufferMap; TransferBufferMap transfer_buffers_; diff --git a/content/renderer/gpu/renderer_gl_context.cc b/content/renderer/gpu/renderer_gl_context.cc index 03f6715..8fa9262 100644 --- a/content/renderer/gpu/renderer_gl_context.cc +++ b/content/renderer/gpu/renderer_gl_context.cc @@ -380,7 +380,7 @@ bool RendererGLContext::Initialize(bool onscreen, TRACE_EVENT0("gpu", "RendererGLContext::Initialize::InitializeCommandBuffer"); // Initiaize the command buffer. - if (!command_buffer_->Initialize(kCommandBufferSize)) { + if (!command_buffer_->Initialize()) { Destroy(); return false; } |