Chromium Code Reviews| 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_impl.h" | 5 #include "content/common/gpu/client/command_buffer_proxy_impl.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/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 | 40 |
| 41 bool CommandBufferProxyImpl::OnMessageReceived(const IPC::Message& message) { | 41 bool CommandBufferProxyImpl::OnMessageReceived(const IPC::Message& message) { |
| 42 bool handled = true; | 42 bool handled = true; |
| 43 IPC_BEGIN_MESSAGE_MAP(CommandBufferProxyImpl, message) | 43 IPC_BEGIN_MESSAGE_MAP(CommandBufferProxyImpl, message) |
| 44 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Destroyed, OnDestroyed); | 44 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Destroyed, OnDestroyed); |
| 45 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_ConsoleMsg, OnConsoleMessage); | 45 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_ConsoleMsg, OnConsoleMessage); |
| 46 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SetMemoryAllocation, | 46 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SetMemoryAllocation, |
| 47 OnSetMemoryAllocation); | 47 OnSetMemoryAllocation); |
| 48 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalSyncPointAck, | 48 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalSyncPointAck, |
| 49 OnSignalSyncPointAck); | 49 OnSignalSyncPointAck); |
| 50 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SwapBuffersCompleted, | |
| 51 OnSwapBuffersCompleted); | |
| 50 IPC_MESSAGE_UNHANDLED(handled = false) | 52 IPC_MESSAGE_UNHANDLED(handled = false) |
| 51 IPC_END_MESSAGE_MAP() | 53 IPC_END_MESSAGE_MAP() |
| 52 | 54 |
| 53 DCHECK(handled); | 55 DCHECK(handled); |
| 54 return handled; | 56 return handled; |
| 55 } | 57 } |
| 56 | 58 |
| 57 void CommandBufferProxyImpl::OnChannelError() { | 59 void CommandBufferProxyImpl::OnChannelError() { |
| 58 OnDestroyed(gpu::error::kUnknown); | 60 OnDestroyed(gpu::error::kUnknown); |
| 59 } | 61 } |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 latency_info_)); | 187 latency_info_)); |
| 186 latency_info_.clear(); | 188 latency_info_.clear(); |
| 187 } | 189 } |
| 188 | 190 |
| 189 void CommandBufferProxyImpl::SetLatencyInfo( | 191 void CommandBufferProxyImpl::SetLatencyInfo( |
| 190 const std::vector<ui::LatencyInfo>& latency_info) { | 192 const std::vector<ui::LatencyInfo>& latency_info) { |
| 191 for (size_t i = 0; i < latency_info.size(); i++) | 193 for (size_t i = 0; i < latency_info.size(); i++) |
| 192 latency_info_.push_back(latency_info[i]); | 194 latency_info_.push_back(latency_info[i]); |
| 193 } | 195 } |
| 194 | 196 |
| 197 void CommandBufferProxyImpl::SetSwapBuffersCompletionCallback( | |
| 198 const SwapBuffersCompletionCallback& callback) { | |
| 199 swap_buffers_completion_callback_ = callback; | |
| 200 } | |
| 201 | |
| 195 void CommandBufferProxyImpl::WaitForTokenInRange(int32 start, int32 end) { | 202 void CommandBufferProxyImpl::WaitForTokenInRange(int32 start, int32 end) { |
| 196 TRACE_EVENT2("gpu", | 203 TRACE_EVENT2("gpu", |
| 197 "CommandBufferProxyImpl::WaitForToken", | 204 "CommandBufferProxyImpl::WaitForToken", |
| 198 "start", | 205 "start", |
| 199 start, | 206 start, |
| 200 "end", | 207 "end", |
| 201 end); | 208 end); |
| 202 TryUpdateState(); | 209 TryUpdateState(); |
| 203 if (!InRange(start, end, last_state_.token) && | 210 if (!InRange(start, end, last_state_.token) && |
| 204 last_state_.error == gpu::error::kNoError) { | 211 last_state_.error == gpu::error::kNoError) { |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 497 void CommandBufferProxyImpl::TryUpdateState() { | 504 void CommandBufferProxyImpl::TryUpdateState() { |
| 498 if (last_state_.error == gpu::error::kNoError) | 505 if (last_state_.error == gpu::error::kNoError) |
| 499 shared_state()->Read(&last_state_); | 506 shared_state()->Read(&last_state_); |
| 500 } | 507 } |
| 501 | 508 |
| 502 gpu::CommandBufferSharedState* CommandBufferProxyImpl::shared_state() const { | 509 gpu::CommandBufferSharedState* CommandBufferProxyImpl::shared_state() const { |
| 503 return reinterpret_cast<gpu::CommandBufferSharedState*>( | 510 return reinterpret_cast<gpu::CommandBufferSharedState*>( |
| 504 shared_state_shm_->memory()); | 511 shared_state_shm_->memory()); |
| 505 } | 512 } |
| 506 | 513 |
| 514 void CommandBufferProxyImpl::OnSwapBuffersCompleted( | |
| 515 const std::vector<ui::LatencyInfo>& latency_info) { | |
| 516 if (!swap_buffers_completion_callback_.is_null()) { | |
| 517 if (!ui::LatencyInfo::Verify( | |
| 518 latency_info, "CommandBufferProxyImpl::OnSwapBuffersCompleted")) { | |
| 519 swap_buffers_completion_callback_.Run(std::vector<ui::LatencyInfo>()); | |
|
piman
2014/10/07 20:20:51
return? We don't want to run the callback twice, d
no sievers
2014/10/07 20:22:23
Doh! Done.
| |
| 520 } | |
| 521 swap_buffers_completion_callback_.Run(latency_info); | |
| 522 } | |
| 523 } | |
| 524 | |
| 507 } // namespace content | 525 } // namespace content |
| OLD | NEW |