| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/gpu/command_buffer_proxy.h" | 5 #include "content/renderer/gpu/command_buffer_proxy.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
| 10 #include "base/shared_memory.h" | 10 #include "base/shared_memory.h" |
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "base/task.h" | 12 #include "base/task.h" |
| 13 #include "content/common/child_process_messages.h" |
| 13 #include "content/common/child_thread.h" | 14 #include "content/common/child_thread.h" |
| 14 #include "content/common/gpu/gpu_messages.h" | 15 #include "content/common/gpu/gpu_messages.h" |
| 15 #include "content/common/plugin_messages.h" | 16 #include "content/common/plugin_messages.h" |
| 16 #include "content/common/view_messages.h" | 17 #include "content/common/view_messages.h" |
| 17 #include "content/renderer/gpu/gpu_channel_host.h" | 18 #include "content/renderer/gpu/gpu_channel_host.h" |
| 18 #include "content/renderer/plugin_channel_host.h" | 19 #include "content/renderer/plugin_channel_host.h" |
| 19 #include "gpu/command_buffer/common/cmd_buffer_common.h" | 20 #include "gpu/command_buffer/common/cmd_buffer_common.h" |
| 20 #include "ui/gfx/size.h" | 21 #include "ui/gfx/size.h" |
| 21 | 22 |
| 22 using gpu::Buffer; | 23 using gpu::Buffer; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 } | 94 } |
| 94 | 95 |
| 95 bool CommandBufferProxy::Initialize(int32 size) { | 96 bool CommandBufferProxy::Initialize(int32 size) { |
| 96 DCHECK(!ring_buffer_.get()); | 97 DCHECK(!ring_buffer_.get()); |
| 97 | 98 |
| 98 ChildThread* child_thread = ChildThread::current(); | 99 ChildThread* child_thread = ChildThread::current(); |
| 99 if (!child_thread) | 100 if (!child_thread) |
| 100 return false; | 101 return false; |
| 101 | 102 |
| 102 base::SharedMemoryHandle handle; | 103 base::SharedMemoryHandle handle; |
| 103 if (!child_thread->Send(new ViewHostMsg_AllocateSharedMemoryBuffer( | 104 if (!child_thread->Send(new ChildProcessHostMsg_SyncAllocateSharedMemory( |
| 104 size, | 105 size, |
| 105 &handle))) { | 106 &handle))) { |
| 106 return false; | 107 return false; |
| 107 } | 108 } |
| 108 | 109 |
| 109 if (!base::SharedMemory::IsHandleValid(handle)) | 110 if (!base::SharedMemory::IsHandleValid(handle)) |
| 110 return false; | 111 return false; |
| 111 | 112 |
| 112 #if defined(OS_POSIX) | 113 #if defined(OS_POSIX) |
| 113 handle.auto_close = false; | 114 handle.auto_close = false; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 | 216 |
| 216 int32 CommandBufferProxy::CreateTransferBuffer(size_t size, int32 id_request) { | 217 int32 CommandBufferProxy::CreateTransferBuffer(size_t size, int32 id_request) { |
| 217 if (last_state_.error != gpu::error::kNoError) | 218 if (last_state_.error != gpu::error::kNoError) |
| 218 return -1; | 219 return -1; |
| 219 | 220 |
| 220 ChildThread* child_thread = ChildThread::current(); | 221 ChildThread* child_thread = ChildThread::current(); |
| 221 if (!child_thread) | 222 if (!child_thread) |
| 222 return -1; | 223 return -1; |
| 223 | 224 |
| 224 base::SharedMemoryHandle handle; | 225 base::SharedMemoryHandle handle; |
| 225 if (!child_thread->Send(new ViewHostMsg_AllocateSharedMemoryBuffer( | 226 if (!child_thread->Send(new ChildProcessHostMsg_SyncAllocateSharedMemory( |
| 226 size, | 227 size, |
| 227 &handle))) { | 228 &handle))) { |
| 228 return -1; | 229 return -1; |
| 229 } | 230 } |
| 230 | 231 |
| 231 if (!base::SharedMemory::IsHandleValid(handle)) | 232 if (!base::SharedMemory::IsHandleValid(handle)) |
| 232 return -1; | 233 return -1; |
| 233 | 234 |
| 234 // Handle is closed by the SharedMemory object below. This stops | 235 // Handle is closed by the SharedMemory object below. This stops |
| 235 // base::FileDescriptor from closing it as well. | 236 // base::FileDescriptor from closing it as well. |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 delete msg; | 443 delete msg; |
| 443 return false; | 444 return false; |
| 444 } | 445 } |
| 445 | 446 |
| 446 void CommandBufferProxy::OnUpdateState(const gpu::CommandBuffer::State& state) { | 447 void CommandBufferProxy::OnUpdateState(const gpu::CommandBuffer::State& state) { |
| 447 // Handle wraparound. It works as long as we don't have more than 2B state | 448 // Handle wraparound. It works as long as we don't have more than 2B state |
| 448 // updates in flight across which reordering occurs. | 449 // updates in flight across which reordering occurs. |
| 449 if (state.generation - last_state_.generation < 0x80000000U) | 450 if (state.generation - last_state_.generation < 0x80000000U) |
| 450 last_state_ = state; | 451 last_state_ = state; |
| 451 } | 452 } |
| OLD | NEW |