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 void CommandBufferProxyImpl::TakeFrontBuffer(const gpu::Mailbox& mailbox) { | 611 bool CommandBufferProxyImpl::ProduceFrontBuffer(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; | 614 return false; |
615 | 615 |
616 Send(new GpuCommandBufferMsg_TakeFrontBuffer(route_id_, mailbox)); | 616 Send(new GpuCommandBufferMsg_ProduceFrontBuffer(route_id_, mailbox)); |
617 } | 617 return true; |
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)); | |
628 } | 618 } |
629 | 619 |
630 gpu::error::Error CommandBufferProxyImpl::GetLastError() { | 620 gpu::error::Error CommandBufferProxyImpl::GetLastError() { |
631 return last_state_.error; | 621 return last_state_.error; |
632 } | 622 } |
633 | 623 |
634 bool CommandBufferProxyImpl::Send(IPC::Message* msg) { | 624 bool CommandBufferProxyImpl::Send(IPC::Message* msg) { |
635 // Caller should not intentionally send a message if the context is lost. | 625 // Caller should not intentionally send a message if the context is lost. |
636 DCHECK(last_state_.error == gpu::error::kNoError); | 626 DCHECK(last_state_.error == gpu::error::kNoError); |
637 DCHECK(channel_); | 627 DCHECK(channel_); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 // the client for lost context a single time. | 769 // the client for lost context a single time. |
780 if (!channel_) | 770 if (!channel_) |
781 return; | 771 return; |
782 channel_->DestroyCommandBuffer(this); | 772 channel_->DestroyCommandBuffer(this); |
783 channel_ = nullptr; | 773 channel_ = nullptr; |
784 if (gpu_control_client_) | 774 if (gpu_control_client_) |
785 gpu_control_client_->OnGpuControlLostContext(); | 775 gpu_control_client_->OnGpuControlLostContext(); |
786 } | 776 } |
787 | 777 |
788 } // namespace gpu | 778 } // namespace gpu |
OLD | NEW |