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 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 // catches upwith the command buffer. | 601 // catches upwith the command buffer. |
602 // A malicious caller trying to create a collision by making next_signal_id | 602 // A malicious caller trying to create a collision by making next_signal_id |
603 // would have to make calls at an astounding rate (300B/s) and even if they | 603 // would have to make calls at an astounding rate (300B/s) and even if they |
604 // could do that, all they would do is to prevent some callbacks from getting | 604 // could do that, all they would do is to prevent some callbacks from getting |
605 // called, leading to stalled threads and/or memory leaks. | 605 // called, leading to stalled threads and/or memory leaks. |
606 uint32_t signal_id = next_signal_id_++; | 606 uint32_t signal_id = next_signal_id_++; |
607 Send(new GpuCommandBufferMsg_SignalQuery(route_id_, query, signal_id)); | 607 Send(new GpuCommandBufferMsg_SignalQuery(route_id_, query, signal_id)); |
608 signal_tasks_.insert(std::make_pair(signal_id, callback)); | 608 signal_tasks_.insert(std::make_pair(signal_id, callback)); |
609 } | 609 } |
610 | 610 |
611 bool CommandBufferProxyImpl::ProduceFrontBuffer(const gpu::Mailbox& mailbox) { | 611 void CommandBufferProxyImpl::TakeFrontBuffer(const gpu::Mailbox& mailbox) { |
612 CheckLock(); | 612 CheckLock(); |
613 if (last_state_.error != gpu::error::kNoError) | 613 if (last_state_.error != gpu::error::kNoError) |
614 return false; | 614 return; |
615 | 615 |
616 Send(new GpuCommandBufferMsg_ProduceFrontBuffer(route_id_, mailbox)); | 616 Send(new GpuCommandBufferMsg_TakeFrontBuffer(route_id_, mailbox)); |
617 return true; | 617 } |
| 618 |
| 619 void CommandBufferProxyImpl::ReturnFrontBuffer(const gpu::Mailbox& mailbox, |
| 620 const gpu::SyncToken& sync_token, |
| 621 bool is_lost) { |
| 622 CheckLock(); |
| 623 if (last_state_.error != gpu::error::kNoError) |
| 624 return; |
| 625 |
| 626 Send(new GpuCommandBufferMsg_WaitSyncToken(route_id_, sync_token)); |
| 627 Send(new GpuCommandBufferMsg_ReturnFrontBuffer(route_id_, mailbox, is_lost)); |
618 } | 628 } |
619 | 629 |
620 gpu::error::Error CommandBufferProxyImpl::GetLastError() { | 630 gpu::error::Error CommandBufferProxyImpl::GetLastError() { |
621 return last_state_.error; | 631 return last_state_.error; |
622 } | 632 } |
623 | 633 |
624 bool CommandBufferProxyImpl::Send(IPC::Message* msg) { | 634 bool CommandBufferProxyImpl::Send(IPC::Message* msg) { |
625 // Caller should not intentionally send a message if the context is lost. | 635 // Caller should not intentionally send a message if the context is lost. |
626 DCHECK(last_state_.error == gpu::error::kNoError); | 636 DCHECK(last_state_.error == gpu::error::kNoError); |
627 DCHECK(channel_); | 637 DCHECK(channel_); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 // the client for lost context a single time. | 779 // the client for lost context a single time. |
770 if (!channel_) | 780 if (!channel_) |
771 return; | 781 return; |
772 channel_->DestroyCommandBuffer(this); | 782 channel_->DestroyCommandBuffer(this); |
773 channel_ = nullptr; | 783 channel_ = nullptr; |
774 if (gpu_control_client_) | 784 if (gpu_control_client_) |
775 gpu_control_client_->OnGpuControlLostContext(); | 785 gpu_control_client_->OnGpuControlLostContext(); |
776 } | 786 } |
777 | 787 |
778 } // namespace gpu | 788 } // namespace gpu |
OLD | NEW |