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

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

Issue 8758026: Revert "Revert 113250 - Add CommandBuffer::SetGetBuffer" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years 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 | « content/common/gpu/gpu_command_buffer_stub.h ('k') | content/common/gpu/gpu_messages.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) 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/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 return false; 80 return false;
81 } 81 }
82 } 82 }
83 83
84 // Always use IPC_MESSAGE_HANDLER_DELAY_REPLY for synchronous message handlers 84 // Always use IPC_MESSAGE_HANDLER_DELAY_REPLY for synchronous message handlers
85 // here. This is so the reply can be delayed if the scheduler is unscheduled. 85 // here. This is so the reply can be delayed if the scheduler is unscheduled.
86 bool handled = true; 86 bool handled = true;
87 IPC_BEGIN_MESSAGE_MAP(GpuCommandBufferStub, message) 87 IPC_BEGIN_MESSAGE_MAP(GpuCommandBufferStub, message)
88 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_Initialize, 88 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_Initialize,
89 OnInitialize); 89 OnInitialize);
90 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_SetGetBuffer,
91 OnSetGetBuffer);
90 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_SetParent, 92 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_SetParent,
91 OnSetParent); 93 OnSetParent);
92 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetState, OnGetState); 94 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetState, OnGetState);
93 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetStateFast, 95 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetStateFast,
94 OnGetStateFast); 96 OnGetStateFast);
95 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncFlush, OnAsyncFlush); 97 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncFlush, OnAsyncFlush);
96 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Rescheduled, OnRescheduled); 98 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Rescheduled, OnRescheduled);
97 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_CreateTransferBuffer, 99 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_CreateTransferBuffer,
98 OnCreateTransferBuffer); 100 OnCreateTransferBuffer);
99 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_RegisterTransferBuffer, 101 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_RegisterTransferBuffer,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 surface_ = NULL; 154 surface_ = NULL;
153 } 155 }
154 156
155 void GpuCommandBufferStub::OnInitializeFailed(IPC::Message* reply_message) { 157 void GpuCommandBufferStub::OnInitializeFailed(IPC::Message* reply_message) {
156 Destroy(); 158 Destroy();
157 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, false); 159 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, false);
158 Send(reply_message); 160 Send(reply_message);
159 } 161 }
160 162
161 void GpuCommandBufferStub::OnInitialize( 163 void GpuCommandBufferStub::OnInitialize(
162 base::SharedMemoryHandle ring_buffer,
163 int32 size,
164 IPC::Message* reply_message) { 164 IPC::Message* reply_message) {
165 DCHECK(!command_buffer_.get()); 165 DCHECK(!command_buffer_.get());
166 166
167 UNSHIPPED_TRACE_EVENT_INSTANT0("test_gpu", "TryCreateGLContext"); 167 UNSHIPPED_TRACE_EVENT_INSTANT0("test_gpu", "TryCreateGLContext");
168 168
169 command_buffer_.reset(new gpu::CommandBufferService); 169 command_buffer_.reset(new gpu::CommandBufferService);
170 170
171 #if defined(OS_WIN) 171 if (!command_buffer_->Initialize()) {
172 // Windows dups the shared memory handle it receives into the current process
173 // and closes it when this variable goes out of scope.
174 base::SharedMemory shared_memory(ring_buffer,
175 false,
176 channel_->renderer_process());
177 #else
178 // POSIX receives a dup of the shared memory handle and closes the dup when
179 // this variable goes out of scope.
180 base::SharedMemory shared_memory(ring_buffer, false);
181 #endif
182
183 if (!command_buffer_->Initialize(&shared_memory, size)) {
184 DLOG(ERROR) << "CommandBufferService failed to initialize.\n"; 172 DLOG(ERROR) << "CommandBufferService failed to initialize.\n";
185 OnInitializeFailed(reply_message); 173 OnInitializeFailed(reply_message);
186 return; 174 return;
187 } 175 }
188 176
189 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group_.get())); 177 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group_.get()));
190 178
191 scheduler_.reset(new gpu::GpuScheduler(command_buffer_.get(), 179 scheduler_.reset(new gpu::GpuScheduler(command_buffer_.get(),
192 decoder_.get(), 180 decoder_.get(),
193 NULL)); 181 NULL));
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 if (CommandLine::ForCurrentProcess()->HasSwitch( 243 if (CommandLine::ForCurrentProcess()->HasSwitch(
256 switches::kEnableGPUServiceLogging)) { 244 switches::kEnableGPUServiceLogging)) {
257 decoder_->set_debug(true); 245 decoder_->set_debug(true);
258 } 246 }
259 247
260 SetSwapInterval(); 248 SetSwapInterval();
261 249
262 command_buffer_->SetPutOffsetChangeCallback( 250 command_buffer_->SetPutOffsetChangeCallback(
263 base::Bind(&gpu::GpuScheduler::PutChanged, 251 base::Bind(&gpu::GpuScheduler::PutChanged,
264 base::Unretained(scheduler_.get()))); 252 base::Unretained(scheduler_.get())));
253 command_buffer_->SetGetBufferChangeCallback(
254 base::Bind(&gpu::GpuScheduler::SetGetBuffer,
255 base::Unretained(scheduler_.get())));
265 command_buffer_->SetParseErrorCallback( 256 command_buffer_->SetParseErrorCallback(
266 base::Bind(&GpuCommandBufferStub::OnParseError, base::Unretained(this))); 257 base::Bind(&GpuCommandBufferStub::OnParseError, base::Unretained(this)));
267 scheduler_->SetScheduledCallback( 258 scheduler_->SetScheduledCallback(
268 base::Bind(&GpuChannel::OnScheduled, base::Unretained(channel_))); 259 base::Bind(&GpuChannel::OnScheduled, base::Unretained(channel_)));
269 260
270 if (watchdog_) { 261 if (watchdog_) {
271 scheduler_->SetCommandProcessedCallback( 262 scheduler_->SetCommandProcessedCallback(
272 base::Bind(&GpuCommandBufferStub::OnCommandProcessed, 263 base::Bind(&GpuCommandBufferStub::OnCommandProcessed,
273 base::Unretained(this))); 264 base::Unretained(this)));
274 } 265 }
275 266
276 if (parent_stub_for_initialization_) { 267 if (parent_stub_for_initialization_) {
277 decoder_->SetParent(parent_stub_for_initialization_->decoder_.get(), 268 decoder_->SetParent(parent_stub_for_initialization_->decoder_.get(),
278 parent_texture_for_initialization_); 269 parent_texture_for_initialization_);
279 parent_stub_for_initialization_.reset(); 270 parent_stub_for_initialization_.reset();
280 parent_texture_for_initialization_ = 0; 271 parent_texture_for_initialization_ = 0;
281 } 272 }
282 273
283 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, true); 274 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, true);
284 Send(reply_message); 275 Send(reply_message);
285 276
286 UNSHIPPED_TRACE_EVENT_INSTANT1("test_gpu", "CreateGLContextSuccess", 277 UNSHIPPED_TRACE_EVENT_INSTANT1("test_gpu", "CreateGLContextSuccess",
287 "offscreen", surface_->IsOffscreen()); 278 "offscreen", surface_->IsOffscreen());
288 } 279 }
289 280
281 void GpuCommandBufferStub::OnSetGetBuffer(
282 int32 shm_id, IPC::Message* reply_message) {
283 command_buffer_->SetGetBuffer(shm_id);
284 Send(reply_message);
285 }
286
290 void GpuCommandBufferStub::OnSetParent(int32 parent_route_id, 287 void GpuCommandBufferStub::OnSetParent(int32 parent_route_id,
291 uint32 parent_texture_id, 288 uint32 parent_texture_id,
292 IPC::Message* reply_message) { 289 IPC::Message* reply_message) {
293 290
294 GpuCommandBufferStub* parent_stub = NULL; 291 GpuCommandBufferStub* parent_stub = NULL;
295 if (parent_route_id != MSG_ROUTING_NONE) { 292 if (parent_route_id != MSG_ROUTING_NONE) {
296 parent_stub = channel_->LookupCommandBuffer(parent_route_id); 293 parent_stub = channel_->LookupCommandBuffer(parent_route_id);
297 } 294 }
298 295
299 bool result = true; 296 bool result = true;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 void GpuCommandBufferStub::OnDestroyVideoDecoder(int decoder_route_id) { 462 void GpuCommandBufferStub::OnDestroyVideoDecoder(int decoder_route_id) {
466 channel_->RemoveRoute(decoder_route_id); 463 channel_->RemoveRoute(decoder_route_id);
467 video_decoders_.Remove(decoder_route_id); 464 video_decoders_.Remove(decoder_route_id);
468 } 465 }
469 466
470 void GpuCommandBufferStub::OnSetSurfaceVisible(bool visible) { 467 void GpuCommandBufferStub::OnSetSurfaceVisible(bool visible) {
471 surface_->SetVisible(visible); 468 surface_->SetVisible(visible);
472 } 469 }
473 470
474 #endif // defined(ENABLE_GPU) 471 #endif // defined(ENABLE_GPU)
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_command_buffer_stub.h ('k') | content/common/gpu/gpu_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698