Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Side by Side Diff: cc/trees/swap_promise_manager.cc

Issue 2323423002: cc: Add SwapPromiseManager and SurfaceSequenceGenerator. (Closed)
Patch Set: rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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 "cc/trees/swap_promise_manager.h"
6
7 #include "cc/output/swap_promise.h"
8 #include "cc/trees/swap_promise_monitor.h"
9
10 namespace cc {
11
12 SwapPromiseManager::SwapPromiseManager() {}
13
14 SwapPromiseManager::~SwapPromiseManager() {
15 DCHECK(swap_promise_monitor_.empty());
16 BreakSwapPromises(SwapPromise::COMMIT_FAILS);
17 }
18
19 void SwapPromiseManager::QueueSwapPromise(
20 std::unique_ptr<SwapPromise> swap_promise) {
21 DCHECK(swap_promise);
22 swap_promise_list_.push_back(std::move(swap_promise));
23 }
24
25 void SwapPromiseManager::InsertSwapPromiseMonitor(SwapPromiseMonitor* monitor) {
26 swap_promise_monitor_.insert(monitor);
27 }
28
29 void SwapPromiseManager::RemoveSwapPromiseMonitor(SwapPromiseMonitor* monitor) {
30 swap_promise_monitor_.erase(monitor);
31 }
32
33 void SwapPromiseManager::NotifySwapPromiseMonitorsOfSetNeedsCommit() {
34 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin();
35 for (; it != swap_promise_monitor_.end(); it++)
vmpstr 2016/09/12 20:44:31 for (auto* swap_promise_monitor : swap_promise_mon
Khushal 2016/09/12 22:53:03 Done.
36 (*it)->OnSetNeedsCommitOnMain();
37 }
38
39 void SwapPromiseManager::WillCommit() {
40 for (const auto& swap_promise : swap_promise_list_)
41 swap_promise->OnCommit();
42 }
43
44 std::vector<std::unique_ptr<SwapPromise>>
45 SwapPromiseManager::TakeSwapPromises() {
46 std::vector<std::unique_ptr<SwapPromise>> result;
47 result.swap(swap_promise_list_);
48 return result;
49 }
50
51 void SwapPromiseManager::BreakSwapPromises(
52 SwapPromise::DidNotSwapReason reason) {
53 for (const auto& swap_promise : swap_promise_list_)
54 swap_promise->DidNotSwap(reason);
55 swap_promise_list_.clear();
56 }
57
58 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698