Index: content/renderer/gpu/command_buffer_proxy.cc |
diff --git a/content/renderer/gpu/command_buffer_proxy.cc b/content/renderer/gpu/command_buffer_proxy.cc |
index 86420ae10dbdaf0693310553bb6a9ac82d1518ed..d51f840c8166cae9a6af178c13456ed6f6f159af 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(); |