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

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

Issue 8919014: Revert "Revert 113479 - Revert "Revert 113250 - Add CommandBuffer::SetGetBuffer"" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 surface_ = NULL; 158 surface_ = NULL;
157 } 159 }
158 160
159 void GpuCommandBufferStub::OnInitializeFailed(IPC::Message* reply_message) { 161 void GpuCommandBufferStub::OnInitializeFailed(IPC::Message* reply_message) {
160 Destroy(); 162 Destroy();
161 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, false); 163 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, false);
162 Send(reply_message); 164 Send(reply_message);
163 } 165 }
164 166
165 void GpuCommandBufferStub::OnInitialize( 167 void GpuCommandBufferStub::OnInitialize(
166 base::SharedMemoryHandle ring_buffer,
167 int32 size,
168 IPC::Message* reply_message) { 168 IPC::Message* reply_message) {
169 DCHECK(!command_buffer_.get()); 169 DCHECK(!command_buffer_.get());
170 170
171 UNSHIPPED_TRACE_EVENT_INSTANT0("test_gpu", "TryCreateGLContext"); 171 UNSHIPPED_TRACE_EVENT_INSTANT0("test_gpu", "TryCreateGLContext");
172 172
173 command_buffer_.reset(new gpu::CommandBufferService); 173 command_buffer_.reset(new gpu::CommandBufferService);
174 174
175 #if defined(OS_WIN) 175 if (!command_buffer_->Initialize()) {
176 // Windows dups the shared memory handle it receives into the current process
177 // and closes it when this variable goes out of scope.
178 base::SharedMemory shared_memory(ring_buffer,
179 false,
180 channel_->renderer_process());
181 #else
182 // POSIX receives a dup of the shared memory handle and closes the dup when
183 // this variable goes out of scope.
184 base::SharedMemory shared_memory(ring_buffer, false);
185 #endif
186
187 if (!command_buffer_->Initialize(&shared_memory, size)) {
188 DLOG(ERROR) << "CommandBufferService failed to initialize.\n"; 176 DLOG(ERROR) << "CommandBufferService failed to initialize.\n";
189 OnInitializeFailed(reply_message); 177 OnInitializeFailed(reply_message);
190 return; 178 return;
191 } 179 }
192 180
193 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group_.get())); 181 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group_.get()));
194 182
195 scheduler_.reset(new gpu::GpuScheduler(command_buffer_.get(), 183 scheduler_.reset(new gpu::GpuScheduler(command_buffer_.get(),
196 decoder_.get(), 184 decoder_.get(),
197 NULL)); 185 NULL));
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 if (CommandLine::ForCurrentProcess()->HasSwitch( 247 if (CommandLine::ForCurrentProcess()->HasSwitch(
260 switches::kEnableGPUServiceLogging)) { 248 switches::kEnableGPUServiceLogging)) {
261 decoder_->set_debug(true); 249 decoder_->set_debug(true);
262 } 250 }
263 251
264 SetSwapInterval(); 252 SetSwapInterval();
265 253
266 command_buffer_->SetPutOffsetChangeCallback( 254 command_buffer_->SetPutOffsetChangeCallback(
267 base::Bind(&gpu::GpuScheduler::PutChanged, 255 base::Bind(&gpu::GpuScheduler::PutChanged,
268 base::Unretained(scheduler_.get()))); 256 base::Unretained(scheduler_.get())));
257 command_buffer_->SetGetBufferChangeCallback(
258 base::Bind(&gpu::GpuScheduler::SetGetBuffer,
259 base::Unretained(scheduler_.get())));
269 command_buffer_->SetParseErrorCallback( 260 command_buffer_->SetParseErrorCallback(
270 base::Bind(&GpuCommandBufferStub::OnParseError, base::Unretained(this))); 261 base::Bind(&GpuCommandBufferStub::OnParseError, base::Unretained(this)));
271 scheduler_->SetScheduledCallback( 262 scheduler_->SetScheduledCallback(
272 base::Bind(&GpuChannel::OnScheduled, base::Unretained(channel_))); 263 base::Bind(&GpuChannel::OnScheduled, base::Unretained(channel_)));
273 264
274 if (watchdog_) { 265 if (watchdog_) {
275 scheduler_->SetCommandProcessedCallback( 266 scheduler_->SetCommandProcessedCallback(
276 base::Bind(&GpuCommandBufferStub::OnCommandProcessed, 267 base::Bind(&GpuCommandBufferStub::OnCommandProcessed,
277 base::Unretained(this))); 268 base::Unretained(this)));
278 } 269 }
279 270
280 if (parent_stub_for_initialization_) { 271 if (parent_stub_for_initialization_) {
281 decoder_->SetParent(parent_stub_for_initialization_->decoder_.get(), 272 decoder_->SetParent(parent_stub_for_initialization_->decoder_.get(),
282 parent_texture_for_initialization_); 273 parent_texture_for_initialization_);
283 parent_stub_for_initialization_.reset(); 274 parent_stub_for_initialization_.reset();
284 parent_texture_for_initialization_ = 0; 275 parent_texture_for_initialization_ = 0;
285 } 276 }
286 277
287 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, true); 278 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, true);
288 Send(reply_message); 279 Send(reply_message);
289 280
290 UNSHIPPED_TRACE_EVENT_INSTANT1("test_gpu", "CreateGLContextSuccess", 281 UNSHIPPED_TRACE_EVENT_INSTANT1("test_gpu", "CreateGLContextSuccess",
291 "offscreen", surface_->IsOffscreen()); 282 "offscreen", surface_->IsOffscreen());
292 } 283 }
293 284
285 void GpuCommandBufferStub::OnSetGetBuffer(
286 int32 shm_id, IPC::Message* reply_message) {
287 command_buffer_->SetGetBuffer(shm_id);
288 Send(reply_message);
289 }
290
294 void GpuCommandBufferStub::OnSetParent(int32 parent_route_id, 291 void GpuCommandBufferStub::OnSetParent(int32 parent_route_id,
295 uint32 parent_texture_id, 292 uint32 parent_texture_id,
296 IPC::Message* reply_message) { 293 IPC::Message* reply_message) {
297 294
298 GpuCommandBufferStub* parent_stub = NULL; 295 GpuCommandBufferStub* parent_stub = NULL;
299 if (parent_route_id != MSG_ROUTING_NONE) { 296 if (parent_route_id != MSG_ROUTING_NONE) {
300 parent_stub = channel_->LookupCommandBuffer(parent_route_id); 297 parent_stub = channel_->LookupCommandBuffer(parent_route_id);
301 } 298 }
302 299
303 bool result = true; 300 bool result = true;
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 void GpuCommandBufferStub::OnDestroyVideoDecoder(int decoder_route_id) { 468 void GpuCommandBufferStub::OnDestroyVideoDecoder(int decoder_route_id) {
472 channel_->RemoveRoute(decoder_route_id); 469 channel_->RemoveRoute(decoder_route_id);
473 video_decoders_.Remove(decoder_route_id); 470 video_decoders_.Remove(decoder_route_id);
474 } 471 }
475 472
476 void GpuCommandBufferStub::OnSetSurfaceVisible(bool visible) { 473 void GpuCommandBufferStub::OnSetSurfaceVisible(bool visible) {
477 surface_->SetVisible(visible); 474 surface_->SetVisible(visible);
478 } 475 }
479 476
480 #endif // defined(ENABLE_GPU) 477 #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