| 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 "gpu/ipc/client/command_buffer_proxy_impl.h" | 5 #include "gpu/ipc/client/command_buffer_proxy_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 // catches upwith the command buffer. | 655 // catches upwith the command buffer. |
| 656 // A malicious caller trying to create a collision by making next_signal_id | 656 // A malicious caller trying to create a collision by making next_signal_id |
| 657 // would have to make calls at an astounding rate (300B/s) and even if they | 657 // would have to make calls at an astounding rate (300B/s) and even if they |
| 658 // could do that, all they would do is to prevent some callbacks from getting | 658 // could do that, all they would do is to prevent some callbacks from getting |
| 659 // called, leading to stalled threads and/or memory leaks. | 659 // called, leading to stalled threads and/or memory leaks. |
| 660 uint32_t signal_id = next_signal_id_++; | 660 uint32_t signal_id = next_signal_id_++; |
| 661 Send(new GpuCommandBufferMsg_SignalQuery(route_id_, query, signal_id)); | 661 Send(new GpuCommandBufferMsg_SignalQuery(route_id_, query, signal_id)); |
| 662 signal_tasks_.insert(std::make_pair(signal_id, callback)); | 662 signal_tasks_.insert(std::make_pair(signal_id, callback)); |
| 663 } | 663 } |
| 664 | 664 |
| 665 void CommandBufferProxyImpl::TakeFrontBuffer(const gpu::Mailbox& mailbox) { | 665 bool CommandBufferProxyImpl::ProduceFrontBuffer(const gpu::Mailbox& mailbox) { |
| 666 CheckLock(); | 666 CheckLock(); |
| 667 if (last_state_.error != gpu::error::kNoError) | 667 if (last_state_.error != gpu::error::kNoError) |
| 668 return; | 668 return false; |
| 669 | 669 |
| 670 Send(new GpuCommandBufferMsg_TakeFrontBuffer(route_id_, mailbox)); | 670 Send(new GpuCommandBufferMsg_ProduceFrontBuffer(route_id_, mailbox)); |
| 671 } | 671 return true; |
| 672 | |
| 673 void CommandBufferProxyImpl::ReturnFrontBuffer(const gpu::Mailbox& mailbox, | |
| 674 const gpu::SyncToken& sync_token, | |
| 675 bool is_lost) { | |
| 676 CheckLock(); | |
| 677 if (last_state_.error != gpu::error::kNoError) | |
| 678 return; | |
| 679 | |
| 680 Send(new GpuCommandBufferMsg_WaitSyncToken(route_id_, sync_token)); | |
| 681 Send(new GpuCommandBufferMsg_ReturnFrontBuffer(route_id_, mailbox, is_lost)); | |
| 682 } | 672 } |
| 683 | 673 |
| 684 gpu::error::Error CommandBufferProxyImpl::GetLastError() { | 674 gpu::error::Error CommandBufferProxyImpl::GetLastError() { |
| 685 return last_state_.error; | 675 return last_state_.error; |
| 686 } | 676 } |
| 687 | 677 |
| 688 bool CommandBufferProxyImpl::Send(IPC::Message* msg) { | 678 bool CommandBufferProxyImpl::Send(IPC::Message* msg) { |
| 689 // Caller should not intentionally send a message if the context is lost. | 679 // Caller should not intentionally send a message if the context is lost. |
| 690 DCHECK(last_state_.error == gpu::error::kNoError); | 680 DCHECK(last_state_.error == gpu::error::kNoError); |
| 691 DCHECK(channel_); | 681 DCHECK(channel_); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 return; | 842 return; |
| 853 channel_->FlushPendingStream(stream_id_); | 843 channel_->FlushPendingStream(stream_id_); |
| 854 channel_->Send(new GpuChannelMsg_DestroyCommandBuffer(route_id_)); | 844 channel_->Send(new GpuChannelMsg_DestroyCommandBuffer(route_id_)); |
| 855 channel_->RemoveRoute(route_id_); | 845 channel_->RemoveRoute(route_id_); |
| 856 channel_ = nullptr; | 846 channel_ = nullptr; |
| 857 if (gpu_control_client_) | 847 if (gpu_control_client_) |
| 858 gpu_control_client_->OnGpuControlLostContext(); | 848 gpu_control_client_->OnGpuControlLostContext(); |
| 859 } | 849 } |
| 860 | 850 |
| 861 } // namespace gpu | 851 } // namespace gpu |
| OLD | NEW |