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 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 // catches upwith the command buffer. | 605 // catches upwith the command buffer. |
606 // A malicious caller trying to create a collision by making next_signal_id | 606 // A malicious caller trying to create a collision by making next_signal_id |
607 // would have to make calls at an astounding rate (300B/s) and even if they | 607 // would have to make calls at an astounding rate (300B/s) and even if they |
608 // could do that, all they would do is to prevent some callbacks from getting | 608 // could do that, all they would do is to prevent some callbacks from getting |
609 // called, leading to stalled threads and/or memory leaks. | 609 // called, leading to stalled threads and/or memory leaks. |
610 uint32_t signal_id = next_signal_id_++; | 610 uint32_t signal_id = next_signal_id_++; |
611 Send(new GpuCommandBufferMsg_SignalQuery(route_id_, query, signal_id)); | 611 Send(new GpuCommandBufferMsg_SignalQuery(route_id_, query, signal_id)); |
612 signal_tasks_.insert(std::make_pair(signal_id, callback)); | 612 signal_tasks_.insert(std::make_pair(signal_id, callback)); |
613 } | 613 } |
614 | 614 |
615 bool CommandBufferProxyImpl::ProduceFrontBuffer(const gpu::Mailbox& mailbox) { | 615 void CommandBufferProxyImpl::TakeFrontBuffer(const gpu::Mailbox& mailbox) { |
616 CheckLock(); | 616 CheckLock(); |
617 if (last_state_.error != gpu::error::kNoError) | 617 if (last_state_.error != gpu::error::kNoError) |
618 return false; | 618 return; |
619 | 619 |
620 Send(new GpuCommandBufferMsg_ProduceFrontBuffer(route_id_, mailbox)); | 620 Send(new GpuCommandBufferMsg_TakeFrontBuffer(route_id_, mailbox)); |
621 return true; | 621 } |
| 622 |
| 623 void CommandBufferProxyImpl::ReturnFrontBuffer(const gpu::Mailbox& mailbox, |
| 624 const gpu::SyncToken& sync_token, |
| 625 bool is_lost) { |
| 626 CheckLock(); |
| 627 if (last_state_.error != gpu::error::kNoError) |
| 628 return; |
| 629 |
| 630 Send(new GpuCommandBufferMsg_WaitSyncToken(route_id_, sync_token)); |
| 631 Send(new GpuCommandBufferMsg_ReturnFrontBuffer(route_id_, mailbox, is_lost)); |
622 } | 632 } |
623 | 633 |
624 gpu::error::Error CommandBufferProxyImpl::GetLastError() { | 634 gpu::error::Error CommandBufferProxyImpl::GetLastError() { |
625 return last_state_.error; | 635 return last_state_.error; |
626 } | 636 } |
627 | 637 |
628 bool CommandBufferProxyImpl::Send(IPC::Message* msg) { | 638 bool CommandBufferProxyImpl::Send(IPC::Message* msg) { |
629 // Caller should not intentionally send a message if the context is lost. | 639 // Caller should not intentionally send a message if the context is lost. |
630 DCHECK(last_state_.error == gpu::error::kNoError); | 640 DCHECK(last_state_.error == gpu::error::kNoError); |
631 DCHECK(channel_); | 641 DCHECK(channel_); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 // the client for lost context a single time. | 800 // the client for lost context a single time. |
791 if (!channel_) | 801 if (!channel_) |
792 return; | 802 return; |
793 channel_->DestroyCommandBuffer(this); | 803 channel_->DestroyCommandBuffer(this); |
794 channel_ = nullptr; | 804 channel_ = nullptr; |
795 if (gpu_control_client_) | 805 if (gpu_control_client_) |
796 gpu_control_client_->OnGpuControlLostContext(); | 806 gpu_control_client_->OnGpuControlLostContext(); |
797 } | 807 } |
798 | 808 |
799 } // namespace gpu | 809 } // namespace gpu |
OLD | NEW |