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 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
610 // catches upwith the command buffer. | 610 // catches upwith the command buffer. |
611 // A malicious caller trying to create a collision by making next_signal_id | 611 // A malicious caller trying to create a collision by making next_signal_id |
612 // would have to make calls at an astounding rate (300B/s) and even if they | 612 // would have to make calls at an astounding rate (300B/s) and even if they |
613 // could do that, all they would do is to prevent some callbacks from getting | 613 // could do that, all they would do is to prevent some callbacks from getting |
614 // called, leading to stalled threads and/or memory leaks. | 614 // called, leading to stalled threads and/or memory leaks. |
615 uint32_t signal_id = next_signal_id_++; | 615 uint32_t signal_id = next_signal_id_++; |
616 Send(new GpuCommandBufferMsg_SignalQuery(route_id_, query, signal_id)); | 616 Send(new GpuCommandBufferMsg_SignalQuery(route_id_, query, signal_id)); |
617 signal_tasks_.insert(std::make_pair(signal_id, callback)); | 617 signal_tasks_.insert(std::make_pair(signal_id, callback)); |
618 } | 618 } |
619 | 619 |
620 bool CommandBufferProxyImpl::ProduceFrontBuffer(const gpu::Mailbox& mailbox) { | 620 bool CommandBufferProxyImpl::TakeFrontBuffer(const gpu::Mailbox& mailbox, |
621 CheckLock(); | 621 gpu::SyncToken* sync_token) { |
622 std::unique_ptr<base::AutoLock> lock; | |
623 if (lock_) | |
624 lock.reset(new base::AutoLock(*lock_)); | |
piman
2016/04/26 01:54:01
These should be CheckLock(). The client is respons
erikchen
2016/04/27 16:31:23
Done.
| |
622 if (last_state_.error != gpu::error::kNoError) | 625 if (last_state_.error != gpu::error::kNoError) |
623 return false; | 626 return false; |
624 | 627 |
625 Send(new GpuCommandBufferMsg_ProduceFrontBuffer(route_id_, mailbox)); | 628 Send(new GpuCommandBufferMsg_TakeFrontBuffer(route_id_, mailbox)); |
629 | |
630 uint64_t fence = GenerateFenceSyncRelease(); | |
piman
2016/04/26 01:54:01
This will not do the right thing for Pepper, where
erikchen
2016/04/27 16:31:23
Got it. I now generate the sync token on the peppe
| |
631 *sync_token = gpu::SyncToken(GetNamespaceID(), GetExtraCommandBufferData(), | |
632 GetCommandBufferID(), fence); | |
633 | |
634 // Force a synchronous IPC to validate sync token. | |
635 EnsureWorkVisible(); | |
636 sync_token->SetVerifyFlush(); | |
626 return true; | 637 return true; |
627 } | 638 } |
628 | 639 |
640 void CommandBufferProxyImpl::ReturnFrontBuffer(const gpu::Mailbox& mailbox, | |
641 const gpu::SyncToken& sync_token, | |
642 bool is_lost) { | |
643 std::unique_ptr<base::AutoLock> lock; | |
644 if (lock_) | |
645 lock.reset(new base::AutoLock(*lock_)); | |
646 if (last_state_.error != gpu::error::kNoError) | |
647 return; | |
648 | |
649 Send(new GpuCommandBufferMsg_ReturnFrontBuffer(route_id_, mailbox, sync_token, | |
650 is_lost)); | |
651 } | |
652 | |
629 gpu::error::Error CommandBufferProxyImpl::GetLastError() { | 653 gpu::error::Error CommandBufferProxyImpl::GetLastError() { |
630 return last_state_.error; | 654 return last_state_.error; |
631 } | 655 } |
632 | 656 |
633 bool CommandBufferProxyImpl::Send(IPC::Message* msg) { | 657 bool CommandBufferProxyImpl::Send(IPC::Message* msg) { |
634 // Caller should not intentionally send a message if the context is lost. | 658 // Caller should not intentionally send a message if the context is lost. |
635 DCHECK(last_state_.error == gpu::error::kNoError); | 659 DCHECK(last_state_.error == gpu::error::kNoError); |
636 DCHECK(channel_); | 660 DCHECK(channel_); |
637 | 661 |
638 if (!msg->is_sync()) { | 662 if (!msg->is_sync()) { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
719 } | 743 } |
720 | 744 |
721 void CommandBufferProxyImpl::InvalidGpuReplyOnClientThread() { | 745 void CommandBufferProxyImpl::InvalidGpuReplyOnClientThread() { |
722 std::unique_ptr<base::AutoLock> lock; | 746 std::unique_ptr<base::AutoLock> lock; |
723 if (lock_) | 747 if (lock_) |
724 lock.reset(new base::AutoLock(*lock_)); | 748 lock.reset(new base::AutoLock(*lock_)); |
725 OnDestroyed(gpu::error::kInvalidGpuMessage, gpu::error::kLostContext); | 749 OnDestroyed(gpu::error::kInvalidGpuMessage, gpu::error::kLostContext); |
726 } | 750 } |
727 | 751 |
728 } // namespace gpu | 752 } // namespace gpu |
OLD | NEW |