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

Side by Side Diff: content/common/gpu/gpu_command_buffer_stub.cc

Issue 8566059: Add CommandBuffer::SetGetBuffer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: etc Created 9 years, 1 month 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
OLDNEW
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 #if defined(ENABLE_GPU) 5 #if defined(ENABLE_GPU)
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/shared_memory.h" 10 #include "base/shared_memory.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 return false; 81 return false;
82 } 82 }
83 } 83 }
84 84
85 // Always use IPC_MESSAGE_HANDLER_DELAY_REPLY for synchronous message handlers 85 // Always use IPC_MESSAGE_HANDLER_DELAY_REPLY for synchronous message handlers
86 // here. This is so the reply can be delayed if the scheduler is unscheduled. 86 // here. This is so the reply can be delayed if the scheduler is unscheduled.
87 bool handled = true; 87 bool handled = true;
88 IPC_BEGIN_MESSAGE_MAP(GpuCommandBufferStub, message) 88 IPC_BEGIN_MESSAGE_MAP(GpuCommandBufferStub, message)
89 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_Initialize, 89 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_Initialize,
90 OnInitialize); 90 OnInitialize);
91 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_SetGetBuffer,
92 OnSetGetBuffer);
91 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_SetParent, 93 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_SetParent,
92 OnSetParent); 94 OnSetParent);
93 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetState, OnGetState); 95 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetState, OnGetState);
94 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetStateFast, 96 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetStateFast,
95 OnGetStateFast); 97 OnGetStateFast);
96 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncFlush, OnAsyncFlush); 98 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncFlush, OnAsyncFlush);
97 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Rescheduled, OnRescheduled); 99 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Rescheduled, OnRescheduled);
98 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_CreateTransferBuffer, 100 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_CreateTransferBuffer,
99 OnCreateTransferBuffer); 101 OnCreateTransferBuffer);
100 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_RegisterTransferBuffer, 102 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_RegisterTransferBuffer,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 surface_ = NULL; 142 surface_ = NULL;
141 } 143 }
142 144
143 void GpuCommandBufferStub::OnInitializeFailed(IPC::Message* reply_message) { 145 void GpuCommandBufferStub::OnInitializeFailed(IPC::Message* reply_message) {
144 Destroy(); 146 Destroy();
145 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, false); 147 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, false);
146 Send(reply_message); 148 Send(reply_message);
147 } 149 }
148 150
149 void GpuCommandBufferStub::OnInitialize( 151 void GpuCommandBufferStub::OnInitialize(
150 base::SharedMemoryHandle ring_buffer,
151 int32 size,
152 IPC::Message* reply_message) { 152 IPC::Message* reply_message) {
153 DCHECK(!command_buffer_.get()); 153 DCHECK(!command_buffer_.get());
154 154
155 command_buffer_.reset(new gpu::CommandBufferService); 155 command_buffer_.reset(new gpu::CommandBufferService);
156 156
157 #if defined(OS_WIN) 157 if (!command_buffer_->Initialize()) {
158 // Windows dups the shared memory handle it receives into the current process
159 // and closes it when this variable goes out of scope.
160 base::SharedMemory shared_memory(ring_buffer,
161 false,
162 channel_->renderer_process());
163 #else
164 // POSIX receives a dup of the shared memory handle and closes the dup when
165 // this variable goes out of scope.
166 base::SharedMemory shared_memory(ring_buffer, false);
167 #endif
168
169 if (!command_buffer_->Initialize(&shared_memory, size)) {
170 OnInitializeFailed(reply_message); 158 OnInitializeFailed(reply_message);
171 return; 159 return;
172 } 160 }
173 161
174 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group_.get())); 162 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group_.get()));
175 163
176 scheduler_.reset(new gpu::GpuScheduler(command_buffer_.get(), 164 scheduler_.reset(new gpu::GpuScheduler(command_buffer_.get(),
177 decoder_.get(), 165 decoder_.get(),
178 NULL)); 166 NULL));
179 167
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 decoder_->SetParent(parent_stub_for_initialization_->decoder_.get(), 260 decoder_->SetParent(parent_stub_for_initialization_->decoder_.get(),
273 parent_texture_for_initialization_); 261 parent_texture_for_initialization_);
274 parent_stub_for_initialization_.reset(); 262 parent_stub_for_initialization_.reset();
275 parent_texture_for_initialization_ = 0; 263 parent_texture_for_initialization_ = 0;
276 } 264 }
277 265
278 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, true); 266 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, true);
279 Send(reply_message); 267 Send(reply_message);
280 } 268 }
281 269
270 void GpuCommandBufferStub::OnSetGetBuffer(
271 int32 shm_id, IPC::Message* reply_message) {
272 scheduler_->SetGetBuffer(shm_id);
273 Send(reply_message);
274 }
275
282 void GpuCommandBufferStub::OnSetParent(int32 parent_route_id, 276 void GpuCommandBufferStub::OnSetParent(int32 parent_route_id,
283 uint32 parent_texture_id, 277 uint32 parent_texture_id,
284 IPC::Message* reply_message) { 278 IPC::Message* reply_message) {
285 279
286 GpuCommandBufferStub* parent_stub = NULL; 280 GpuCommandBufferStub* parent_stub = NULL;
287 if (parent_route_id != MSG_ROUTING_NONE) { 281 if (parent_route_id != MSG_ROUTING_NONE) {
288 parent_stub = channel_->LookupCommandBuffer(parent_route_id); 282 parent_stub = channel_->LookupCommandBuffer(parent_route_id);
289 } 283 }
290 284
291 bool result = true; 285 bool result = true;
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 void GpuCommandBufferStub::OnDestroyVideoDecoder(int decoder_route_id) { 506 void GpuCommandBufferStub::OnDestroyVideoDecoder(int decoder_route_id) {
513 channel_->RemoveRoute(decoder_route_id); 507 channel_->RemoveRoute(decoder_route_id);
514 video_decoders_.Remove(decoder_route_id); 508 video_decoders_.Remove(decoder_route_id);
515 } 509 }
516 510
517 void GpuCommandBufferStub::OnSetSurfaceVisible(bool visible) { 511 void GpuCommandBufferStub::OnSetSurfaceVisible(bool visible) {
518 surface_->SetVisible(visible); 512 surface_->SetVisible(visible);
519 } 513 }
520 514
521 #endif // defined(ENABLE_GPU) 515 #endif // defined(ENABLE_GPU)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698