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

Unified Diff: chrome/gpu/gpu_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, 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/gpu/gpu_command_buffer_stub.h ('k') | chrome/plugin/command_buffer_stub.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/gpu/gpu_command_buffer_stub.cc
===================================================================
--- chrome/gpu/gpu_command_buffer_stub.cc (revision 76263)
+++ chrome/gpu/gpu_command_buffer_stub.cc (working copy)
@@ -192,11 +192,12 @@
}
void GpuCommandBufferStub::OnInitialize(
+ base::SharedMemoryHandle ring_buffer,
int32 size,
- base::SharedMemoryHandle* ring_buffer) {
+ bool* result) {
DCHECK(!command_buffer_.get());
- *ring_buffer = base::SharedMemory::NULLHandle();
+ *result = false;
command_buffer_.reset(new gpu::CommandBufferService);
@@ -215,50 +216,57 @@
gfx::PluginWindowHandle output_window_handle = handle_;
#endif // defined(OS_WIN)
+#if defined(OS_WIN)
+ // Windows dups the shared memory handle it receives into the current process
+ // and closes it when this variable goes out of scope.
+ base::SharedMemory shared_memory(ring_buffer,
+ false,
+ channel_->renderer_process());
+#else
+ // POSIX receives a dup of the shared memory handle and closes the dup when
+ // this variable goes out of scope.
+ base::SharedMemory shared_memory(ring_buffer, false);
+#endif
+
// Initialize the CommandBufferService and GPUProcessor.
- if (command_buffer_->Initialize(size)) {
- Buffer buffer = command_buffer_->GetRingBuffer();
- if (buffer.shared_memory) {
- gpu::GPUProcessor* parent_processor =
- parent_ ? parent_->processor_.get() : NULL;
- processor_.reset(new gpu::GPUProcessor(command_buffer_.get(), NULL));
- if (processor_->Initialize(
- output_window_handle,
- initial_size_,
- allowed_extensions_.c_str(),
- requested_attribs_,
- parent_processor,
- parent_texture_id_)) {
- command_buffer_->SetPutOffsetChangeCallback(
- NewCallback(processor_.get(),
- &gpu::GPUProcessor::ProcessCommands));
- processor_->SetSwapBuffersCallback(
- NewCallback(this, &GpuCommandBufferStub::OnSwapBuffers));
+ if (command_buffer_->Initialize(&shared_memory, size)) {
+ gpu::GPUProcessor* parent_processor =
+ parent_ ? parent_->processor_.get() : NULL;
+ processor_.reset(new gpu::GPUProcessor(command_buffer_.get(), NULL));
+ if (processor_->Initialize(
+ output_window_handle,
+ initial_size_,
+ allowed_extensions_.c_str(),
+ requested_attribs_,
+ parent_processor,
+ parent_texture_id_)) {
+ command_buffer_->SetPutOffsetChangeCallback(
+ NewCallback(processor_.get(),
+ &gpu::GPUProcessor::ProcessCommands));
+ processor_->SetSwapBuffersCallback(
+ NewCallback(this, &GpuCommandBufferStub::OnSwapBuffers));
- // Assume service is responsible for duplicating the handle from the
- // calling process.
- buffer.shared_memory->ShareToProcess(channel_->renderer_process(),
- ring_buffer);
#if defined(OS_MACOSX)
- if (handle_) {
- // This context conceptually puts its output directly on the
- // screen, rendered by the accelerated plugin layer in
- // RenderWidgetHostViewMac. Set up a pathway to notify the
- // browser process when its contents change.
- processor_->SetSwapBuffersCallback(
- NewCallback(this,
- &GpuCommandBufferStub::SwapBuffersCallback));
- }
+ if (handle_) {
+ // This context conceptually puts its output directly on the
+ // screen, rendered by the accelerated plugin layer in
+ // RenderWidgetHostViewMac. Set up a pathway to notify the
+ // browser process when its contents change.
+ processor_->SetSwapBuffersCallback(
+ NewCallback(this,
+ &GpuCommandBufferStub::SwapBuffersCallback));
+ }
#endif // defined(OS_MACOSX)
- // Set up a pathway for resizing the output window or framebuffer at the
- // right time relative to other GL commands.
- processor_->SetResizeCallback(
- NewCallback(this, &GpuCommandBufferStub::ResizeCallback));
- } else {
- processor_.reset();
- command_buffer_.reset();
- }
+ // Set up a pathway for resizing the output window or framebuffer at the
+ // right time relative to other GL commands.
+ processor_->SetResizeCallback(
+ NewCallback(this, &GpuCommandBufferStub::ResizeCallback));
+
+ *result = true;
+ } else {
+ processor_.reset();
+ command_buffer_.reset();
}
}
}
« no previous file with comments | « chrome/gpu/gpu_command_buffer_stub.h ('k') | chrome/plugin/command_buffer_stub.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698