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

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

Issue 2580493002: Splitting DidSwap in cc::SwapPromise into WillSwap and DidSwap (Closed)
Patch Set: remove blank line Created 4 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_OUTPUT_SWAP_PROMISE_H_ 5 #ifndef CC_OUTPUT_SWAP_PROMISE_H_
6 #define CC_OUTPUT_SWAP_PROMISE_H_ 6 #define CC_OUTPUT_SWAP_PROMISE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "cc/output/compositor_frame_metadata.h" 10 #include "cc/output/compositor_frame_metadata.h"
11 11
12 namespace cc { 12 namespace cc {
13 13
14 // 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
15 // Swap Promise can be inserted into LayerTreeHost/LayerTreeImpl, to track 15 // Swap Promise can be inserted into LayerTreeHost/LayerTreeImpl, to track
16 // 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
17 // 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
18 // to its output or not. 18 // to its output or not.
19 // 19 //
20 // If the commit results in a successful activation of the pending layer tree, 20 // If the commit results in a successful activation of the pending layer tree,
21 // SwapPromise::DidActivate() will be called. 21 // SwapPromise::DidActivate() will be called.
22 // 22 //
23 // If the new compositor state is sent to the output, SwapPromise::DidSwap() 23 // If the new compositor state is goint to be sent to the output,
24 // will be called. 24 // SwapPromise::WillSwap() will be called before the swap and
25 // SwapPromise::DidSwap() will be called once the swap is over.
25 // 26 //
26 // If the scheduler fails to activate the pending tree, or the compositor 27 // If the scheduler fails to activate the pending tree, or the compositor
27 // fails to send its new state to the output, SwapPromise::DidNotSwap() will 28 // fails to send its new state to the output, SwapPromise::DidNotSwap() will
28 // be called. Note that it is possible to activate, and subsequently not swap. 29 // be called. Note that it is possible to activate, and subsequently not swap.
29 // 30 //
30 // Promises complete afer either DidSwap() or DidNotSwap() is called, thus 31 // Promises complete afer either DidSwap() or DidNotSwap() is called, thus
31 // there are three possible call sequences: 32 // there are three possible call sequences:
32 // DidNotSwap() 33 // DidNotSwap()
33 // DidActivate() ; DidSwap() 34 // DidActivate() ; WillSwap(); DidSwap()
34 // DidActivate() ; DidNotSwap() 35 // DidActivate() ; DidNotSwap()
35 // 36 //
36 // Clients that wish to use SwapPromise should have a subclass that defines 37 // Clients that wish to use SwapPromise should have a subclass that defines
37 // the behavior of DidActivate(), DidSwap() and DidNotSwap(). Notice that the 38 // the behavior of DidActivate(), WillSwap(), DidSwap() and DidNotSwap(). Notice
38 // promise can be broken at either main or impl thread, e.g. commit fails on 39 // that the promise can be broken at either main or impl thread, e.g. commit
39 // main thread, new frame data has no actual damage so 40 // fails on main thread, new frame data has no actual damage so
40 // LayerTreeHostImpl::SwapBuffers() bails out early on impl thread, so don't 41 // LayerTreeHostImpl::SwapBuffers() bails out early on impl thread, so don't
41 // assume that Did*() methods are called at a particular thread. It is better 42 // assume that Did*() methods are called at a particular thread. It is better
42 // to let the subclass carry thread-safe member data and operate on that 43 // to let the subclass carry thread-safe member data and operate on that
43 // member data in Did*(). 44 // member data in Did*().
44 class CC_EXPORT SwapPromise { 45 class CC_EXPORT SwapPromise {
45 public: 46 public:
46 enum DidNotSwapReason { 47 enum DidNotSwapReason {
47 SWAP_FAILS, 48 SWAP_FAILS,
48 COMMIT_FAILS, 49 COMMIT_FAILS,
49 COMMIT_NO_UPDATE, 50 COMMIT_NO_UPDATE,
50 ACTIVATION_FAILS, 51 ACTIVATION_FAILS,
51 }; 52 };
52 53
53 enum class DidNotSwapAction { 54 enum class DidNotSwapAction {
54 BREAK_PROMISE, 55 BREAK_PROMISE,
55 KEEP_ACTIVE, 56 KEEP_ACTIVE,
56 }; 57 };
57 58
58 SwapPromise() {} 59 SwapPromise() {}
59 virtual ~SwapPromise() {} 60 virtual ~SwapPromise() {}
60 61
61 virtual void DidActivate() = 0; 62 virtual void DidActivate() = 0;
62 virtual void DidSwap(CompositorFrameMetadata* metadata) = 0; 63 virtual void WillSwap(CompositorFrameMetadata* metadata) = 0;
64 virtual void DidSwap() = 0;
63 // Return |KEEP_ACTIVE| if this promise should remain active (should not be 65 // Return |KEEP_ACTIVE| if this promise should remain active (should not be
64 // broken by the owner). 66 // broken by the owner).
65 virtual DidNotSwapAction DidNotSwap(DidNotSwapReason reason) = 0; 67 virtual DidNotSwapAction DidNotSwap(DidNotSwapReason reason) = 0;
66 // This is called when the main thread starts a (blocking) commit 68 // This is called when the main thread starts a (blocking) commit
67 virtual void OnCommit() {} 69 virtual void OnCommit() {}
68 70
69 // A non-zero trace id identifies a trace flow object that is embedded in the 71 // A non-zero trace id identifies a trace flow object that is embedded in the
70 // swap promise. This can be used for registering additional flow steps to 72 // swap promise. This can be used for registering additional flow steps to
71 // visualize the object's path through the system. 73 // visualize the object's path through the system.
72 virtual int64_t TraceId() const = 0; 74 virtual int64_t TraceId() const = 0;
73 }; 75 };
74 76
75 } // namespace cc 77 } // namespace cc
76 78
77 #endif // CC_OUTPUT_SWAP_PROMISE_H_ 79 #endif // CC_OUTPUT_SWAP_PROMISE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698