OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/common/gpu/client/command_buffer_proxy.h" | 5 #include "content/common/gpu/client/command_buffer_proxy.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 } | 91 } |
92 | 92 |
93 void CommandBufferProxy::OnConsoleMessage( | 93 void CommandBufferProxy::OnConsoleMessage( |
94 const GPUCommandBufferConsoleMessage& message) { | 94 const GPUCommandBufferConsoleMessage& message) { |
95 if (!console_message_callback_.is_null()) { | 95 if (!console_message_callback_.is_null()) { |
96 console_message_callback_.Run(message.message, message.id); | 96 console_message_callback_.Run(message.message, message.id); |
97 } | 97 } |
98 } | 98 } |
99 | 99 |
100 void CommandBufferProxy::SetMemoryAllocationChangedCallback( | 100 void CommandBufferProxy::SetMemoryAllocationChangedCallback( |
101 const base::Callback<void(const GpuMemoryAllocation&)>& callback) { | 101 const base::Callback<void(const GpuMemoryAllocationForRenderer&)>& |
102 callback) { | |
102 memory_allocation_changed_callback_ = callback; | 103 memory_allocation_changed_callback_ = callback; |
103 } | 104 } |
104 | 105 |
105 void CommandBufferProxy::OnSetMemoryAllocation( | 106 void CommandBufferProxy::OnSetMemoryAllocation( |
106 const GpuMemoryAllocation& allocation) { | 107 const GpuMemoryAllocationForRenderer& allocation) { |
107 if (!memory_allocation_changed_callback_.is_null()) | 108 if (!memory_allocation_changed_callback_.is_null()) |
108 memory_allocation_changed_callback_.Run(allocation); | 109 memory_allocation_changed_callback_.Run(allocation); |
110 | |
111 if (allocation.suggest_have_backbuffer) | |
mmocny
2012/03/15 19:11:43
Send right away for now, but should be done via Gr
| |
112 Send(new GpuCommandBufferMsg_CreateBackbuffer(route_id_)); | |
113 else | |
114 Send(new GpuCommandBufferMsg_DestroyBackbuffer(route_id_)); | |
109 } | 115 } |
110 | 116 |
111 void CommandBufferProxy::SetChannelErrorCallback( | 117 void CommandBufferProxy::SetChannelErrorCallback( |
112 const base::Closure& callback) { | 118 const base::Closure& callback) { |
113 channel_error_callback_ = callback; | 119 channel_error_callback_ = callback; |
114 } | 120 } |
115 | 121 |
116 bool CommandBufferProxy::Initialize() { | 122 bool CommandBufferProxy::Initialize() { |
117 bool result; | 123 bool result; |
118 if (!Send(new GpuCommandBufferMsg_Initialize(route_id_, &result))) { | 124 if (!Send(new GpuCommandBufferMsg_Initialize(route_id_, &result))) { |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
356 | 362 |
357 echo_tasks_.push(callback); | 363 echo_tasks_.push(callback); |
358 | 364 |
359 return true; | 365 return true; |
360 } | 366 } |
361 | 367 |
362 bool CommandBufferProxy::SetSurfaceVisible(bool visible) { | 368 bool CommandBufferProxy::SetSurfaceVisible(bool visible) { |
363 if (last_state_.error != gpu::error::kNoError) | 369 if (last_state_.error != gpu::error::kNoError) |
364 return false; | 370 return false; |
365 | 371 |
366 return Send(new GpuCommandBufferMsg_SetSurfaceVisible(route_id_, visible)); | 372 bool ret = Send(new GpuCommandBufferMsg_SetSurfaceVisible( |
373 route_id_, visible)); | |
374 if (visible) | |
375 Send(new GpuCommandBufferMsg_CreateBackbuffer(route_id_)); | |
376 else | |
377 Send(new GpuCommandBufferMsg_DestroyBackbuffer(route_id_)); | |
378 return ret; | |
367 } | 379 } |
368 | 380 |
369 bool CommandBufferProxy::SetParent(CommandBufferProxy* parent_command_buffer, | 381 bool CommandBufferProxy::SetParent(CommandBufferProxy* parent_command_buffer, |
370 uint32 parent_texture_id) { | 382 uint32 parent_texture_id) { |
371 if (last_state_.error != gpu::error::kNoError) | 383 if (last_state_.error != gpu::error::kNoError) |
372 return false; | 384 return false; |
373 | 385 |
374 bool result; | 386 bool result; |
375 if (parent_command_buffer) { | 387 if (parent_command_buffer) { |
376 if (!Send(new GpuCommandBufferMsg_SetParent( | 388 if (!Send(new GpuCommandBufferMsg_SetParent( |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
454 | 466 |
455 void CommandBufferProxy::SetOnConsoleMessageCallback( | 467 void CommandBufferProxy::SetOnConsoleMessageCallback( |
456 const GpuConsoleMessageCallback& callback) { | 468 const GpuConsoleMessageCallback& callback) { |
457 console_message_callback_ = callback; | 469 console_message_callback_ = callback; |
458 } | 470 } |
459 | 471 |
460 void CommandBufferProxy::TryUpdateState() { | 472 void CommandBufferProxy::TryUpdateState() { |
461 if (last_state_.error == gpu::error::kNoError) | 473 if (last_state_.error == gpu::error::kNoError) |
462 shared_state_->Read(&last_state_); | 474 shared_state_->Read(&last_state_); |
463 } | 475 } |
OLD | NEW |