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 24 matching lines...) Expand all Loading... |
35 CommandBufferProxyImpl::~CommandBufferProxyImpl() { | 35 CommandBufferProxyImpl::~CommandBufferProxyImpl() { |
36 FOR_EACH_OBSERVER(DeletionObserver, | 36 FOR_EACH_OBSERVER(DeletionObserver, |
37 deletion_observers_, | 37 deletion_observers_, |
38 OnWillDeleteImpl()); | 38 OnWillDeleteImpl()); |
39 } | 39 } |
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_EchoAck, OnEchoAck); | |
46 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_ConsoleMsg, OnConsoleMessage); | 45 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_ConsoleMsg, OnConsoleMessage); |
47 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SetMemoryAllocation, | 46 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SetMemoryAllocation, |
48 OnSetMemoryAllocation); | 47 OnSetMemoryAllocation); |
49 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalSyncPointAck, | 48 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_SignalSyncPointAck, |
50 OnSignalSyncPointAck); | 49 OnSignalSyncPointAck); |
51 IPC_MESSAGE_UNHANDLED(handled = false) | 50 IPC_MESSAGE_UNHANDLED(handled = false) |
52 IPC_END_MESSAGE_MAP() | 51 IPC_END_MESSAGE_MAP() |
53 | 52 |
54 DCHECK(handled); | 53 DCHECK(handled); |
55 return handled; | 54 return handled; |
(...skipping 12 matching lines...) Expand all Loading... |
68 last_state_.error = gpu::error::kLostContext; | 67 last_state_.error = gpu::error::kLostContext; |
69 last_state_.context_lost_reason = reason; | 68 last_state_.context_lost_reason = reason; |
70 | 69 |
71 if (!channel_error_callback_.is_null()) { | 70 if (!channel_error_callback_.is_null()) { |
72 channel_error_callback_.Run(); | 71 channel_error_callback_.Run(); |
73 // Avoid calling the error callback more than once. | 72 // Avoid calling the error callback more than once. |
74 channel_error_callback_.Reset(); | 73 channel_error_callback_.Reset(); |
75 } | 74 } |
76 } | 75 } |
77 | 76 |
78 void CommandBufferProxyImpl::OnEchoAck() { | |
79 DCHECK(!echo_tasks_.empty()); | |
80 base::Closure callback = echo_tasks_.front(); | |
81 echo_tasks_.pop(); | |
82 callback.Run(); | |
83 } | |
84 | |
85 void CommandBufferProxyImpl::OnConsoleMessage( | 77 void CommandBufferProxyImpl::OnConsoleMessage( |
86 const GPUCommandBufferConsoleMessage& message) { | 78 const GPUCommandBufferConsoleMessage& message) { |
87 if (!console_message_callback_.is_null()) { | 79 if (!console_message_callback_.is_null()) { |
88 console_message_callback_.Run(message.message, message.id); | 80 console_message_callback_.Run(message.message, message.id); |
89 } | 81 } |
90 } | 82 } |
91 | 83 |
92 void CommandBufferProxyImpl::SetMemoryAllocationChangedCallback( | 84 void CommandBufferProxyImpl::SetMemoryAllocationChangedCallback( |
93 const MemoryAllocationChangedCallback& callback) { | 85 const MemoryAllocationChangedCallback& callback) { |
94 if (last_state_.error != gpu::error::kNoError) | 86 if (last_state_.error != gpu::error::kNoError) |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 | 339 |
348 // Remove the gpu memory buffer from the client side cache. | 340 // Remove the gpu memory buffer from the client side cache. |
349 DCHECK(gpu_memory_buffers_.find(id) != gpu_memory_buffers_.end()); | 341 DCHECK(gpu_memory_buffers_.find(id) != gpu_memory_buffers_.end()); |
350 gpu_memory_buffers_.take(id); | 342 gpu_memory_buffers_.take(id); |
351 } | 343 } |
352 | 344 |
353 int CommandBufferProxyImpl::GetRouteID() const { | 345 int CommandBufferProxyImpl::GetRouteID() const { |
354 return route_id_; | 346 return route_id_; |
355 } | 347 } |
356 | 348 |
357 void CommandBufferProxyImpl::Echo(const base::Closure& callback) { | |
358 if (last_state_.error != gpu::error::kNoError) { | |
359 return; | |
360 } | |
361 | |
362 if (!Send(new GpuCommandBufferMsg_Echo( | |
363 route_id_, GpuCommandBufferMsg_EchoAck(route_id_)))) { | |
364 return; | |
365 } | |
366 | |
367 echo_tasks_.push(callback); | |
368 } | |
369 | |
370 uint32 CommandBufferProxyImpl::CreateStreamTexture(uint32 texture_id) { | 349 uint32 CommandBufferProxyImpl::CreateStreamTexture(uint32 texture_id) { |
371 if (last_state_.error != gpu::error::kNoError) | 350 if (last_state_.error != gpu::error::kNoError) |
372 return 0; | 351 return 0; |
373 | 352 |
374 int32 stream_id = channel_->GenerateRouteID(); | 353 int32 stream_id = channel_->GenerateRouteID(); |
375 bool succeeded = false; | 354 bool succeeded = false; |
376 Send(new GpuCommandBufferMsg_CreateStreamTexture( | 355 Send(new GpuCommandBufferMsg_CreateStreamTexture( |
377 route_id_, texture_id, stream_id, &succeeded)); | 356 route_id_, texture_id, stream_id, &succeeded)); |
378 if (!succeeded) { | 357 if (!succeeded) { |
379 DLOG(ERROR) << "GpuCommandBufferMsg_CreateStreamTexture returned failure"; | 358 DLOG(ERROR) << "GpuCommandBufferMsg_CreateStreamTexture returned failure"; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 if (last_state_.error == gpu::error::kNoError) | 498 if (last_state_.error == gpu::error::kNoError) |
520 shared_state()->Read(&last_state_); | 499 shared_state()->Read(&last_state_); |
521 } | 500 } |
522 | 501 |
523 gpu::CommandBufferSharedState* CommandBufferProxyImpl::shared_state() const { | 502 gpu::CommandBufferSharedState* CommandBufferProxyImpl::shared_state() const { |
524 return reinterpret_cast<gpu::CommandBufferSharedState*>( | 503 return reinterpret_cast<gpu::CommandBufferSharedState*>( |
525 shared_state_shm_->memory()); | 504 shared_state_shm_->memory()); |
526 } | 505 } |
527 | 506 |
528 } // namespace content | 507 } // namespace content |
OLD | NEW |