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

Side by Side Diff: chrome/plugin/command_buffer_stub.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, 9 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 | « chrome/plugin/command_buffer_stub.h ('k') | chrome/renderer/command_buffer_proxy.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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "chrome/plugin/command_buffer_stub.h"
6
5 #include "base/callback.h" 7 #include "base/callback.h"
6 #include "base/scoped_open_process.h" 8 #include "base/scoped_open_process.h"
7 #include "base/shared_memory.h" 9 #include "base/shared_memory.h"
8 #include "chrome/common/gpu_messages.h" 10 #include "chrome/common/gpu_messages.h"
9 #include "chrome/common/plugin_messages.h" 11 #include "chrome/common/plugin_messages.h"
10 #include "chrome/plugin/command_buffer_stub.h"
11 #include "chrome/plugin/plugin_channel.h" 12 #include "chrome/plugin/plugin_channel.h"
12 13
13 using gpu::Buffer; 14 using gpu::Buffer;
14 15
15 CommandBufferStub::CommandBufferStub(PluginChannel* channel, 16 CommandBufferStub::CommandBufferStub(PluginChannel* channel,
16 int plugin_host_route_id, 17 int plugin_host_route_id,
17 gfx::PluginWindowHandle window) 18 gfx::PluginWindowHandle window)
18 : channel_(channel), 19 : channel_(channel),
19 plugin_host_route_id_(plugin_host_route_id), 20 plugin_host_route_id_(plugin_host_route_id),
20 window_(window) { 21 window_(window) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 return false; 61 return false;
61 } 62 }
62 63
63 return channel_->Send(message); 64 return channel_->Send(message);
64 } 65 }
65 66
66 void CommandBufferStub::NotifyRepaint() { 67 void CommandBufferStub::NotifyRepaint() {
67 Send(new GpuCommandBufferMsg_NotifyRepaint(route_id_)); 68 Send(new GpuCommandBufferMsg_NotifyRepaint(route_id_));
68 } 69 }
69 70
70 void CommandBufferStub::OnInitialize(int32 size, 71 void CommandBufferStub::OnInitialize(base::SharedMemoryHandle ring_buffer,
71 base::SharedMemoryHandle* ring_buffer) { 72 int32 size,
72 DCHECK(!command_buffer_.get()); 73 bool* result) {
73 74 // TODO(apatrick): Pepper3D v1 is not used anymore. This function is never
74 *ring_buffer = base::SharedMemory::NULLHandle(); 75 // called. Delete the GPU plugin.
75 76 NOTREACHED();
76 // Assume service is responsible for duplicating the handle from the calling 77 *result = false;
77 // process.
78 base::ScopedOpenProcess peer_process;
79 if (!peer_process.Open(channel_->peer_pid()))
80 return;
81
82 command_buffer_.reset(new gpu::CommandBufferService);
83
84 // Initialize the CommandBufferService.
85 if (!command_buffer_->Initialize(size)) {
86 Destroy();
87 return;
88 }
89
90 // Get the ring buffer.
91 Buffer buffer = command_buffer_->GetRingBuffer();
92 if (!buffer.shared_memory) {
93 Destroy();
94 return;
95 }
96
97 // Initialize the GPUProcessor.
98 processor_.reset(new gpu::GPUProcessor(command_buffer_.get(), NULL));
99 if (!processor_->Initialize(window_, gfx::Size(), NULL, std::vector<int32>(),
100 NULL, 0)) {
101 Destroy();
102 return;
103 }
104
105 // Perform platform specific initialization.
106 if (!InitializePlatformSpecific()) {
107 Destroy();
108 return;
109 }
110
111 // Share the ring buffer to the client process.
112 if (!buffer.shared_memory->ShareToProcess(peer_process.handle(),
113 ring_buffer)) {
114 Destroy();
115 return;
116 }
117
118 // Setup callbacks for events.
119 command_buffer_->SetPutOffsetChangeCallback(
120 NewCallback(processor_.get(),
121 &gpu::GPUProcessor::ProcessCommands));
122 #if defined(OS_MACOSX)
123 processor_->SetSwapBuffersCallback(
124 NewCallback(this,
125 &CommandBufferStub::SwapBuffersCallback));
126 processor_->SetTransportDIBAllocAndFree(
127 NewCallback(this, &CommandBufferStub::AllocTransportDIB),
128 NewCallback(this, &CommandBufferStub::FreeTransportDIB));
129 #endif
130 } 78 }
131 79
132 void CommandBufferStub::OnGetState(gpu::CommandBuffer::State* state) { 80 void CommandBufferStub::OnGetState(gpu::CommandBuffer::State* state) {
133 *state = command_buffer_->GetState(); 81 *state = command_buffer_->GetState();
134 } 82 }
135 83
136 void CommandBufferStub::OnAsyncGetState() { 84 void CommandBufferStub::OnAsyncGetState() {
137 gpu::CommandBuffer::State state = command_buffer_->GetState(); 85 gpu::CommandBuffer::State state = command_buffer_->GetState();
138 Send(new GpuCommandBufferMsg_UpdateState(route_id_, state)); 86 Send(new GpuCommandBufferMsg_UpdateState(route_id_, state));
139 } 87 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 Send(new PluginHostMsg_AllocTransportDIB(plugin_host_route_id_, 186 Send(new PluginHostMsg_AllocTransportDIB(plugin_host_route_id_,
239 size, 187 size,
240 dib_handle)); 188 dib_handle));
241 } 189 }
242 190
243 void CommandBufferStub::FreeTransportDIB(TransportDIB::Id dib_id) { 191 void CommandBufferStub::FreeTransportDIB(TransportDIB::Id dib_id) {
244 Send(new PluginHostMsg_FreeTransportDIB(plugin_host_route_id_, 192 Send(new PluginHostMsg_FreeTransportDIB(plugin_host_route_id_,
245 dib_id)); 193 dib_id));
246 } 194 }
247 #endif 195 #endif
OLDNEW
« no previous file with comments | « chrome/plugin/command_buffer_stub.h ('k') | chrome/renderer/command_buffer_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698