OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "gpu/command_buffer/service/fence_sync_manager.h" |
| 6 |
| 7 #include <stdint.h> |
| 8 |
| 9 #include "base/logging.h" |
| 10 |
| 11 namespace gpu { |
| 12 |
| 13 FenceSyncManager::FenceSyncManager() : fence_sync_release_(0) {} |
| 14 |
| 15 FenceSyncManager::~FenceSyncManager() { |
| 16 // Release all fences on destruction. |
| 17 ReleaseFenceSync(UINT32_MAX); |
| 18 } |
| 19 |
| 20 void FenceSyncManager::AddFenceSyncCallback(uint32_t max_order_number, |
| 21 uint32_t release, |
| 22 const base::Closure& callback) { |
| 23 fence_callback_queue_.push(FenceSyncCallback(release, callback)); |
| 24 } |
| 25 |
| 26 void FenceSyncManager::ReleaseFenceSync(uint32_t release) { |
| 27 DCHECK(release > fence_sync_release_); |
| 28 fence_sync_release_ = release; |
| 29 |
| 30 while (!fence_callback_queue_.empty() && |
| 31 fence_callback_queue_.top().release_count <= release) { |
| 32 fence_callback_queue_.top().callback_closure.Run(); |
| 33 fence_callback_queue_.pop(); |
| 34 } |
| 35 } |
| 36 |
| 37 FenceSyncManager::FenceSyncCallback::FenceSyncCallback( |
| 38 uint32_t release, |
| 39 const base::Closure& callback) |
| 40 : release_count(release), callback_closure(callback) {} |
| 41 |
| 42 FenceSyncManager::FenceSyncCallback::~FenceSyncCallback() {} |
| 43 |
| 44 } // namespace gpu |
OLD | NEW |