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

Side by Side Diff: cc/base/swap_promise.h

Issue 81533002: Use LatencyInfoSwapPromise to track LatencyInfo through compositor (Closed) Base URL: http://git.chromium.org/chromium/src.git@swap_promise_2
Patch Set: reupload Created 7 years 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef CC_BASE_SWAP_PROMISE_H_ 5 #ifndef CC_BASE_SWAP_PROMISE_H_
6 #define CC_BASE_SWAP_PROMISE_H_ 6 #define CC_BASE_SWAP_PROMISE_H_
7 7
8 #include "cc/output/compositor_frame_metadata.h"
9
8 namespace cc { 10 namespace cc {
9 11
10 const unsigned int kMaxQueuedSwapPromiseNumber = 100; 12 const unsigned int kMaxQueuedSwapPromiseNumber = 100;
11 13
12 // When a change to the compositor's state/invalidation/whatever happens, a 14 // When a change to the compositor's state/invalidation/whatever happens, a
13 // Swap Promise can be inserted into LayerTreeHost/LayerTreeImpl, to track 15 // Swap Promise can be inserted into LayerTreeHost/LayerTreeImpl, to track
14 // whether the compositor's reply to the new state/invaliadtion/whatever is 16 // whether the compositor's reply to the new state/invaliadtion/whatever is
15 // completed in the compositor, i.e. the compositor knows it has been sent 17 // completed in the compositor, i.e. the compositor knows it has been sent
16 // to its output or not. 18 // to its output or not.
17 // 19 //
18 // If the new compositor state is sent to the output, SwapPromise::DidSwap() 20 // If the new compositor state is sent to the output, SwapPromise::DidSwap()
19 // will be called, and if the compositor fails to send its new state to the 21 // will be called, and if the compositor fails to send its new state to the
20 // output, SwapPromise::DidNotSwap() will be called. 22 // output, SwapPromise::DidNotSwap() will be called.
21 // 23 //
22 // Client wishes to use SwapPromise should have a subclass that defines 24 // Client wishes to use SwapPromise should have a subclass that defines
23 // the behavior of DidSwap() and DidNotSwap(). Notice that the promise can 25 // the behavior of DidSwap() and DidNotSwap(). Notice that the promise can
24 // be broken at either main or impl thread, e.g. commit fails on main thread, 26 // be broken at either main or impl thread, e.g. commit fails on main thread,
25 // new frame data has no actual damage so LayerTreeHostImpl::SwapBuffers() 27 // new frame data has no actual damage so LayerTreeHostImpl::SwapBuffers()
26 // bails out early on impl thread, so don't assume that DidSwap() and 28 // bails out early on impl thread, so don't assume that DidSwap() and
27 // DidNotSwap() are called at a particular thread. It is better to let the 29 // DidNotSwap() are called at a particular thread. It is better to let the
28 // subclass carry thread-safe member data and operate on that member data in 30 // subclass carry thread-safe member data and operate on that member data in
29 // DidSwap() and DidNotSwap(). 31 // DidSwap() and DidNotSwap().
30 class SwapPromise { 32 class SwapPromise {
31 public: 33 public:
32 SwapPromise() {} 34 enum SwapPromiseType {
danakj 2013/11/27 20:11:42 This is no longer needed
Yufeng Shen (Slow to review) 2013/11/27 20:18:52 Done.
33 virtual ~SwapPromise() {} 35 SWAP_PROMISE_UNKNOWN,
36 SWAP_PROMISE_LATENCY_INFO,
37 };
34 38
35 enum DidNotSwapReason { 39 enum DidNotSwapReason {
36 DID_NOT_SWAP_UNKNOWN, 40 DID_NOT_SWAP_UNKNOWN,
37 SWAP_FAILS, 41 SWAP_FAILS,
38 COMMIT_FAILS, 42 COMMIT_FAILS,
39 SWAP_PROMISE_LIST_OVERFLOW, 43 SWAP_PROMISE_LIST_OVERFLOW,
40 }; 44 };
41 45
42 virtual void DidSwap() = 0; 46 explicit SwapPromise(SwapPromiseType type) : type_(type) {}
47 virtual ~SwapPromise() {}
48
49 SwapPromiseType type() {
50 return type_;
51 }
52
53 virtual void DidSwap(CompositorFrameMetadata* metadata) = 0;
43 virtual void DidNotSwap(DidNotSwapReason reason) = 0; 54 virtual void DidNotSwap(DidNotSwapReason reason) = 0;
55
56 protected:
57 SwapPromiseType type_;
danakj 2013/11/27 20:11:42 The type should be able to go away now.
Yufeng Shen (Slow to review) 2013/11/27 20:18:52 Done.
44 }; 58 };
45 59
46 } // namespace cc 60 } // namespace cc
47 61
48 #endif // CC_BASE_SWAP_PROMISE_H_ 62 #endif // CC_BASE_SWAP_PROMISE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698