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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 | 215 |
215 int32 CommandBufferProxy::CreateTransferBuffer(size_t size, int32 id_request) { | 216 int32 CommandBufferProxy::CreateTransferBuffer(size_t size, int32 id_request) { |
216 if (last_state_.error != gpu::error::kNoError) | 217 if (last_state_.error != gpu::error::kNoError) |
217 return -1; | 218 return -1; |
218 | 219 |
219 ChildThread* child_thread = ChildThread::current(); | 220 ChildThread* child_thread = ChildThread::current(); |
220 if (!child_thread) | 221 if (!child_thread) |
221 return -1; | 222 return -1; |
222 | 223 |
223 base::SharedMemoryHandle handle; | 224 base::SharedMemoryHandle handle; |
224 if (!child_thread->Send(new ViewHostMsg_AllocateSharedMemoryBuffer( | 225 if (!child_thread->Send(new ChildProcessHostMsg_SyncAllocateSharedMemory( |
225 size, | 226 size, |
226 &handle))) { | 227 &handle))) { |
227 return -1; | 228 return -1; |
228 } | 229 } |
229 | 230 |
230 if (!base::SharedMemory::IsHandleValid(handle)) | 231 if (!base::SharedMemory::IsHandleValid(handle)) |
231 return -1; | 232 return -1; |
232 | 233 |
233 // Handle is closed by the SharedMemory object below. This stops | 234 // Handle is closed by the SharedMemory object below. This stops |
234 // base::FileDescriptor from closing it as well. | 235 // base::FileDescriptor from closing it as well. |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 delete msg; | 442 delete msg; |
442 return false; | 443 return false; |
443 } | 444 } |
444 | 445 |
445 void CommandBufferProxy::OnUpdateState(const gpu::CommandBuffer::State& state) { | 446 void CommandBufferProxy::OnUpdateState(const gpu::CommandBuffer::State& state) { |
446 // Handle wraparound. It works as long as we don't have more than 2B state | 447 // Handle wraparound. It works as long as we don't have more than 2B state |
447 // updates in flight across which reordering occurs. | 448 // updates in flight across which reordering occurs. |
448 if (state.generation - last_state_.generation < 0x80000000U) | 449 if (state.generation - last_state_.generation < 0x80000000U) |
449 last_state_ = state; | 450 last_state_ = state; |
450 } | 451 } |
OLD | NEW |