| 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 void CommandBufferProxyImpl::TakeFrontBuffer(const gpu::Mailbox& mailbox) { | 620 bool CommandBufferProxyImpl::ProduceFrontBuffer(const gpu::Mailbox& mailbox) { |
| 621 CheckLock(); | 621 CheckLock(); |
| 622 if (last_state_.error != gpu::error::kNoError) | 622 if (last_state_.error != gpu::error::kNoError) |
| 623 return; | 623 return false; |
| 624 | 624 |
| 625 Send(new GpuCommandBufferMsg_TakeFrontBuffer(route_id_, mailbox)); | 625 Send(new GpuCommandBufferMsg_ProduceFrontBuffer(route_id_, mailbox)); |
| 626 } | 626 return true; |
| 627 | |
| 628 void CommandBufferProxyImpl::ReturnFrontBuffer(const gpu::Mailbox& mailbox, | |
| 629 const gpu::SyncToken& sync_token, | |
| 630 bool is_lost) { | |
| 631 CheckLock(); | |
| 632 if (last_state_.error != gpu::error::kNoError) | |
| 633 return; | |
| 634 | |
| 635 Send(new GpuCommandBufferMsg_ReturnFrontBuffer(route_id_, mailbox, sync_token, | |
| 636 is_lost)); | |
| 637 } | 627 } |
| 638 | 628 |
| 639 gpu::error::Error CommandBufferProxyImpl::GetLastError() { | 629 gpu::error::Error CommandBufferProxyImpl::GetLastError() { |
| 640 return last_state_.error; | 630 return last_state_.error; |
| 641 } | 631 } |
| 642 | 632 |
| 643 bool CommandBufferProxyImpl::Send(IPC::Message* msg) { | 633 bool CommandBufferProxyImpl::Send(IPC::Message* msg) { |
| 644 // Caller should not intentionally send a message if the context is lost. | 634 // Caller should not intentionally send a message if the context is lost. |
| 645 DCHECK(last_state_.error == gpu::error::kNoError); | 635 DCHECK(last_state_.error == gpu::error::kNoError); |
| 646 DCHECK(channel_); | 636 DCHECK(channel_); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 } | 719 } |
| 730 | 720 |
| 731 void CommandBufferProxyImpl::InvalidGpuReplyOnClientThread() { | 721 void CommandBufferProxyImpl::InvalidGpuReplyOnClientThread() { |
| 732 std::unique_ptr<base::AutoLock> lock; | 722 std::unique_ptr<base::AutoLock> lock; |
| 733 if (lock_) | 723 if (lock_) |
| 734 lock.reset(new base::AutoLock(*lock_)); | 724 lock.reset(new base::AutoLock(*lock_)); |
| 735 OnDestroyed(gpu::error::kInvalidGpuMessage, gpu::error::kLostContext); | 725 OnDestroyed(gpu::error::kInvalidGpuMessage, gpu::error::kLostContext); |
| 736 } | 726 } |
| 737 | 727 |
| 738 } // namespace gpu | 728 } // namespace gpu |
| OLD | NEW |