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

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

Issue 1126963006: Move VISUAL_STATE promise to activation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: improve existing tests Created 5 years, 7 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
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 "cc/output/compositor_frame_metadata.h" 8 #include "cc/output/compositor_frame_metadata.h"
9 9
10 namespace cc { 10 namespace cc {
11 11
12 // When a change to the compositor's state/invalidation/whatever happens, a 12 // When a change to the compositor's state/invalidation/whatever happens, a
13 // Swap Promise can be inserted into LayerTreeHost/LayerTreeImpl, to track 13 // Swap Promise can be inserted into LayerTreeHost/LayerTreeImpl, to track
14 // whether the compositor's reply to the new state/invaliadtion/whatever is 14 // 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 15 // completed in the compositor, i.e. the compositor knows it has been sent
16 // to its output or not. 16 // to its output or not.
17 // 17 //
18 // If the commit results in a successful activation of the pending layer tree,
19 // SwapPromise::DidActivate() will be called.
20 //
18 // If the new compositor state is sent to the output, SwapPromise::DidSwap() 21 // 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 22 // will be called.
20 // output, SwapPromise::DidNotSwap() will be called.
21 // 23 //
22 // Client wishes to use SwapPromise should have a subclass that defines 24 // If the scheduler fails to activate the pending tree, or the compositor
23 // the behavior of DidSwap() and DidNotSwap(). Notice that the promise can 25 // fails to send its new state to the output, SwapPromise::DidNotSwap() will
24 // be broken at either main or impl thread, e.g. commit fails on main thread, 26 // be called. Note that it is possible to activate, and subsequently not swap.
25 // new frame data has no actual damage so LayerTreeHostImpl::SwapBuffers() 27 //
26 // bails out early on impl thread, so don't assume that DidSwap() and 28 // Promises complete afer either DidSwap() or DidNotSwap() is called, thus
27 // DidNotSwap() are called at a particular thread. It is better to let the 29 // there are three possible call sequences:
28 // subclass carry thread-safe member data and operate on that member data in 30 // DidNotSwap()
29 // DidSwap() and DidNotSwap(). 31 // DidActivate() ; DidSwap()
32 // DidActivate() ; DidNotSwap()
33 //
34 // Clients that wish to use SwapPromise should have a subclass that defines
35 // the behavior of DidActivate(), DidSwap() and DidNotSwap(). Notice that the
36 // promise can be broken at either main or impl thread, e.g. commit fails on
37 // main thread, new frame data has no actual damage so
38 // LayerTreeHostImpl::SwapBuffers() bails out early on impl thread, so don't
39 // assume that Did*() methods are called at a particular thread. It is better
40 // to let the subclass carry thread-safe member data and operate on that
41 // member data in Did*().
30 class CC_EXPORT SwapPromise { 42 class CC_EXPORT SwapPromise {
31 public: 43 public:
32 enum DidNotSwapReason { 44 enum DidNotSwapReason {
33 DID_NOT_SWAP_UNKNOWN,
34 SWAP_FAILS, 45 SWAP_FAILS,
35 COMMIT_FAILS, 46 COMMIT_FAILS,
36 COMMIT_NO_UPDATE, 47 COMMIT_NO_UPDATE,
48 ACTIVATION_FAILS,
37 }; 49 };
38 50
39 SwapPromise() {} 51 SwapPromise() {}
40 virtual ~SwapPromise() {} 52 virtual ~SwapPromise() {}
41 53
54 virtual void DidActivate() = 0;
42 virtual void DidSwap(CompositorFrameMetadata* metadata) = 0; 55 virtual void DidSwap(CompositorFrameMetadata* metadata) = 0;
43 virtual void DidNotSwap(DidNotSwapReason reason) = 0; 56 virtual void DidNotSwap(DidNotSwapReason reason) = 0;
44 57
45 // A non-zero trace id identifies a trace flow object that is embedded in the 58 // A non-zero trace id identifies a trace flow object that is embedded in the
46 // swap promise. This can be used for registering additional flow steps to 59 // swap promise. This can be used for registering additional flow steps to
47 // visualize the object's path through the system. 60 // visualize the object's path through the system.
48 virtual int64 TraceId() const = 0; 61 virtual int64 TraceId() const = 0;
49 }; 62 };
50 63
51 } // namespace cc 64 } // namespace cc
52 65
53 #endif // CC_OUTPUT_SWAP_PROMISE_H_ 66 #endif // CC_OUTPUT_SWAP_PROMISE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698