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

Unified Diff: chrome/renderer/command_buffer_proxy.cc

Issue 6588029: Moved creation of GPU command buffer shared memory into the browser process.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/command_buffer_proxy.h ('k') | gpu/command_buffer/client/gles2_implementation_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/command_buffer_proxy.cc
===================================================================
--- chrome/renderer/command_buffer_proxy.cc (revision 76263)
+++ chrome/renderer/command_buffer_proxy.cc (working copy)
@@ -68,22 +68,62 @@
bool CommandBufferProxy::Initialize(int32 size) {
DCHECK(!ring_buffer_.get());
- // Initialize the service. Assuming we are sandboxed, the GPU
- // process is responsible for duplicating the handle. This might not be true
- // for NaCl.
+ RenderThread* render_thread = RenderThread::current();
+ if (!render_thread)
+ return false;
+
base::SharedMemoryHandle handle;
- if (Send(new GpuCommandBufferMsg_Initialize(route_id_, size, &handle)) &&
- base::SharedMemory::IsHandleValid(handle)) {
- ring_buffer_.reset(new base::SharedMemory(handle, false));
- if (ring_buffer_->Map(size)) {
- num_entries_ = size / sizeof(gpu::CommandBufferEntry);
- return true;
- }
+ if (!render_thread->Send(new ViewHostMsg_AllocateSharedMemoryBuffer(
+ 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))) {
+ LOG(ERROR) << "Could not send GpuCommandBufferMsg_Initialize.";
+ return false;
+ }
+
+ if (!result) {
+ LOG(ERROR) << "Failed to initialize command buffer service.";
+ 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;
}
- return false;
+ num_entries_ = size / sizeof(gpu::CommandBufferEntry);
+ return true;
}
Buffer CommandBufferProxy::GetRingBuffer() {
« no previous file with comments | « chrome/renderer/command_buffer_proxy.h ('k') | gpu/command_buffer/client/gles2_implementation_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698