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

Side by Side Diff: content/renderer/gpu/command_buffer_proxy.cc

Issue 7762013: Added GPU process "echo" IPC message. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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 | « content/renderer/gpu/command_buffer_proxy.h ('k') | content/renderer/gpu/renderer_gl_context.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 #include "content/renderer/gpu/command_buffer_proxy.h" 5 #include "content/renderer/gpu/command_buffer_proxy.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/process_util.h" 9 #include "base/process_util.h"
10 #include "base/shared_memory.h" 10 #include "base/shared_memory.h"
11 #include "base/stl_util.h"
11 #include "base/task.h" 12 #include "base/task.h"
12 #include "content/common/gpu/gpu_messages.h" 13 #include "content/common/gpu/gpu_messages.h"
13 #include "content/common/plugin_messages.h" 14 #include "content/common/plugin_messages.h"
14 #include "content/common/view_messages.h" 15 #include "content/common/view_messages.h"
15 #include "content/renderer/gpu/gpu_channel_host.h" 16 #include "content/renderer/gpu/gpu_channel_host.h"
16 #include "content/renderer/plugin_channel_host.h" 17 #include "content/renderer/plugin_channel_host.h"
17 #include "content/renderer/render_thread.h" 18 #include "content/renderer/render_thread.h"
18 #include "gpu/command_buffer/common/cmd_buffer_common.h" 19 #include "gpu/command_buffer/common/cmd_buffer_common.h"
19 #include "ui/gfx/size.h" 20 #include "ui/gfx/size.h"
20 21
(...skipping 17 matching lines...) Expand all
38 delete it->second.shared_memory; 39 delete it->second.shared_memory;
39 it->second.shared_memory = NULL; 40 it->second.shared_memory = NULL;
40 } 41 }
41 } 42 }
42 43
43 bool CommandBufferProxy::OnMessageReceived(const IPC::Message& message) { 44 bool CommandBufferProxy::OnMessageReceived(const IPC::Message& message) {
44 bool handled = true; 45 bool handled = true;
45 IPC_BEGIN_MESSAGE_MAP(CommandBufferProxy, message) 46 IPC_BEGIN_MESSAGE_MAP(CommandBufferProxy, message)
46 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_UpdateState, OnUpdateState); 47 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_UpdateState, OnUpdateState);
47 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Destroyed, OnDestroyed); 48 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Destroyed, OnDestroyed);
48 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SwapBuffers, OnSwapBuffers);
49 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_NotifyRepaint, 49 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_NotifyRepaint,
50 OnNotifyRepaint); 50 OnNotifyRepaint);
51 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_EchoAck, OnEchoAck);
51 IPC_MESSAGE_UNHANDLED(handled = false) 52 IPC_MESSAGE_UNHANDLED(handled = false)
52 IPC_END_MESSAGE_MAP() 53 IPC_END_MESSAGE_MAP()
53 54
54 DCHECK(handled); 55 DCHECK(handled);
55 return handled; 56 return handled;
56 } 57 }
57 58
58 void CommandBufferProxy::OnChannelError() { 59 void CommandBufferProxy::OnChannelError() {
59 for (Decoders::iterator it = video_decoder_hosts_.begin(); 60 for (Decoders::iterator it = video_decoder_hosts_.begin();
60 it != video_decoder_hosts_.end(); ++it) { 61 it != video_decoder_hosts_.end(); ++it) {
(...skipping 11 matching lines...) Expand all
72 last_state_.error = gpu::error::kLostContext; 73 last_state_.error = gpu::error::kLostContext;
73 last_state_.context_lost_reason = reason; 74 last_state_.context_lost_reason = reason;
74 75
75 if (channel_error_callback_.get()) { 76 if (channel_error_callback_.get()) {
76 channel_error_callback_->Run(); 77 channel_error_callback_->Run();
77 // Avoid calling the error callback more than once. 78 // Avoid calling the error callback more than once.
78 channel_error_callback_.reset(); 79 channel_error_callback_.reset();
79 } 80 }
80 } 81 }
81 82
83 void CommandBufferProxy::OnEchoAck() {
84 DCHECK(!echo_tasks_.empty());
85 Task* task = echo_tasks_.front().release();
86 echo_tasks_.pop();
87 task->Run();
88 }
89
82 void CommandBufferProxy::SetChannelErrorCallback(Callback0::Type* callback) { 90 void CommandBufferProxy::SetChannelErrorCallback(Callback0::Type* callback) {
83 channel_error_callback_.reset(callback); 91 channel_error_callback_.reset(callback);
84 } 92 }
85 93
86 bool CommandBufferProxy::Initialize(int32 size) { 94 bool CommandBufferProxy::Initialize(int32 size) {
87 DCHECK(!ring_buffer_.get()); 95 DCHECK(!ring_buffer_.get());
88 96
89 RenderThread* render_thread = RenderThread::current(); 97 RenderThread* render_thread = RenderThread::current();
90 if (!render_thread) 98 if (!render_thread)
91 return false; 99 return false;
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 // Not implemented in proxy. 345 // Not implemented in proxy.
338 NOTREACHED(); 346 NOTREACHED();
339 } 347 }
340 348
341 void CommandBufferProxy::SetContextLostReason( 349 void CommandBufferProxy::SetContextLostReason(
342 gpu::error::ContextLostReason reason) { 350 gpu::error::ContextLostReason reason) {
343 // Not implemented in proxy. 351 // Not implemented in proxy.
344 NOTREACHED(); 352 NOTREACHED();
345 } 353 }
346 354
347 void CommandBufferProxy::OnSwapBuffers() { 355 bool CommandBufferProxy::Echo(Task* task) {
348 if (swap_buffers_callback_.get()) 356 if (last_state_.error != gpu::error::kNoError) {
349 swap_buffers_callback_->Run(); 357 delete task;
358 return false;
359 }
360
361 if (!Send(new GpuChannelMsg_Echo(GpuCommandBufferMsg_EchoAck(route_id_)))) {
362 delete task;
363 return false;
364 }
365
366 echo_tasks_.push(linked_ptr<Task>(task));
367
368 return true;
350 } 369 }
351 370
352 bool CommandBufferProxy::SetParent(CommandBufferProxy* parent_command_buffer, 371 bool CommandBufferProxy::SetParent(CommandBufferProxy* parent_command_buffer,
353 uint32 parent_texture_id) { 372 uint32 parent_texture_id) {
354 if (last_state_.error != gpu::error::kNoError) 373 if (last_state_.error != gpu::error::kNoError)
355 return false; 374 return false;
356 375
357 bool result; 376 bool result;
358 if (parent_command_buffer) { 377 if (parent_command_buffer) {
359 if (!Send(new GpuCommandBufferMsg_SetParent( 378 if (!Send(new GpuCommandBufferMsg_SetParent(
360 route_id_, 379 route_id_,
361 parent_command_buffer->route_id_, 380 parent_command_buffer->route_id_,
362 parent_texture_id, 381 parent_texture_id,
363 &result))) { 382 &result))) {
364 return false; 383 return false;
365 } 384 }
366 } else { 385 } else {
367 if (!Send(new GpuCommandBufferMsg_SetParent( 386 if (!Send(new GpuCommandBufferMsg_SetParent(
368 route_id_, 387 route_id_,
369 MSG_ROUTING_NONE, 388 MSG_ROUTING_NONE,
370 0, 389 0,
371 &result))) { 390 &result))) {
372 return false; 391 return false;
373 } 392 }
374 } 393 }
375 394
376 return result; 395 return result;
377 } 396 }
378 397
379 void CommandBufferProxy::SetSwapBuffersCallback(Callback0::Type* callback) {
380 swap_buffers_callback_.reset(callback);
381 }
382
383 void CommandBufferProxy::SetNotifyRepaintTask(Task* task) { 398 void CommandBufferProxy::SetNotifyRepaintTask(Task* task) {
384 notify_repaint_task_.reset(task); 399 notify_repaint_task_.reset(task);
385 } 400 }
386 401
387 scoped_refptr<GpuVideoDecodeAcceleratorHost> 402 scoped_refptr<GpuVideoDecodeAcceleratorHost>
388 CommandBufferProxy::CreateVideoDecoder( 403 CommandBufferProxy::CreateVideoDecoder(
389 const std::vector<int32>& configs, 404 const std::vector<int32>& configs,
390 media::VideoDecodeAccelerator::Client* client) { 405 media::VideoDecodeAccelerator::Client* client) {
391 int decoder_route_id; 406 int decoder_route_id;
392 if (!Send(new GpuCommandBufferMsg_CreateVideoDecoder(route_id_, configs, 407 if (!Send(new GpuCommandBufferMsg_CreateVideoDecoder(route_id_, configs,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 delete msg; 442 delete msg;
428 return false; 443 return false;
429 } 444 }
430 445
431 void CommandBufferProxy::OnUpdateState(const gpu::CommandBuffer::State& state) { 446 void CommandBufferProxy::OnUpdateState(const gpu::CommandBuffer::State& state) {
432 // Handle wraparound. It works as long as we don't have more than 2B state 447 // Handle wraparound. It works as long as we don't have more than 2B state
433 // updates in flight across which reordering occurs. 448 // updates in flight across which reordering occurs.
434 if (state.generation - last_state_.generation < 0x80000000U) 449 if (state.generation - last_state_.generation < 0x80000000U)
435 last_state_ = state; 450 last_state_ = state;
436 } 451 }
OLDNEW
« no previous file with comments | « content/renderer/gpu/command_buffer_proxy.h ('k') | content/renderer/gpu/renderer_gl_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698