Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(399)

Side by Side Diff: content/renderer/gpu/command_buffer_proxy.cc

Issue 9270025: Remove renderer dependencies from the GPU client classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add overrides Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | content/renderer/gpu/gpu_channel_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/callback.h" 7 #include "base/callback.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/process_util.h" 10 #include "base/process_util.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 DLOG(INFO) << "CONSOLE_MESSAGE: " 94 DLOG(INFO) << "CONSOLE_MESSAGE: "
95 << message.id << " : " << message.message; 95 << message.id << " : " << message.message;
96 } 96 }
97 97
98 void CommandBufferProxy::SetChannelErrorCallback( 98 void CommandBufferProxy::SetChannelErrorCallback(
99 const base::Closure& callback) { 99 const base::Closure& callback) {
100 channel_error_callback_ = callback; 100 channel_error_callback_ = callback;
101 } 101 }
102 102
103 bool CommandBufferProxy::Initialize() { 103 bool CommandBufferProxy::Initialize() {
104 ChildThread* child_thread = ChildThread::current(); 104 if (!channel_->factory()->IsMainThread())
105 if (!child_thread)
106 return false; 105 return false;
107 106
108 bool result; 107 bool result;
109 if (!Send(new GpuCommandBufferMsg_Initialize(route_id_, &result))) { 108 if (!Send(new GpuCommandBufferMsg_Initialize(route_id_, &result))) {
110 LOG(ERROR) << "Could not send GpuCommandBufferMsg_Initialize."; 109 LOG(ERROR) << "Could not send GpuCommandBufferMsg_Initialize.";
111 return false; 110 return false;
112 } 111 }
113 112
114 if (!result) { 113 if (!result) {
115 LOG(ERROR) << "Failed to initialize command buffer service."; 114 LOG(ERROR) << "Failed to initialize command buffer service.";
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 171
173 void CommandBufferProxy::SetGetOffset(int32 get_offset) { 172 void CommandBufferProxy::SetGetOffset(int32 get_offset) {
174 // Not implemented in proxy. 173 // Not implemented in proxy.
175 NOTREACHED(); 174 NOTREACHED();
176 } 175 }
177 176
178 int32 CommandBufferProxy::CreateTransferBuffer(size_t size, int32 id_request) { 177 int32 CommandBufferProxy::CreateTransferBuffer(size_t size, int32 id_request) {
179 if (last_state_.error != gpu::error::kNoError) 178 if (last_state_.error != gpu::error::kNoError)
180 return -1; 179 return -1;
181 180
182 ChildThread* child_thread = ChildThread::current();
183 if (!child_thread)
184 return -1;
185
186 base::SharedMemoryHandle handle;
187 if (!child_thread->Send(new ChildProcessHostMsg_SyncAllocateSharedMemory(
188 size,
189 &handle))) {
190 return -1;
191 }
192
193 if (!base::SharedMemory::IsHandleValid(handle))
194 return -1;
195
196 // Handle is closed by the SharedMemory object below. This stops
197 // base::FileDescriptor from closing it as well.
198 #if defined(OS_POSIX)
199 handle.auto_close = false;
200 #endif
201
202 // Take ownership of shared memory. This will close the handle if Send below 181 // Take ownership of shared memory. This will close the handle if Send below
203 // fails. Otherwise, callee takes ownership before this variable 182 // fails. Otherwise, callee takes ownership before this variable
204 // goes out of scope by duping the handle. 183 // goes out of scope by duping the handle.
205 base::SharedMemory shared_memory(handle, false); 184 scoped_ptr<base::SharedMemory> shm(
185 channel_->factory()->AllocateSharedMemory(size));
186 if (!shm.get())
187 return -1;
188
189 base::SharedMemoryHandle handle = shm->handle();
190 #if defined(OS_POSIX)
191 DCHECK(!handle.auto_close);
192 #endif
206 193
207 int32 id; 194 int32 id;
208 if (!Send(new GpuCommandBufferMsg_RegisterTransferBuffer(route_id_, 195 if (!Send(new GpuCommandBufferMsg_RegisterTransferBuffer(route_id_,
209 handle, 196 handle,
210 size, 197 size,
211 id_request, 198 id_request,
212 &id))) { 199 &id))) {
213 return -1; 200 return -1;
214 } 201 }
215 202
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 delete msg; 404 delete msg;
418 return false; 405 return false;
419 } 406 }
420 407
421 void CommandBufferProxy::OnUpdateState(const gpu::CommandBuffer::State& state) { 408 void CommandBufferProxy::OnUpdateState(const gpu::CommandBuffer::State& state) {
422 // Handle wraparound. It works as long as we don't have more than 2B state 409 // Handle wraparound. It works as long as we don't have more than 2B state
423 // updates in flight across which reordering occurs. 410 // updates in flight across which reordering occurs.
424 if (state.generation - last_state_.generation < 0x80000000U) 411 if (state.generation - last_state_.generation < 0x80000000U)
425 last_state_ = state; 412 last_state_ = state;
426 } 413 }
OLDNEW
« no previous file with comments | « no previous file | content/renderer/gpu/gpu_channel_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698