OLD | NEW |
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/promise.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 new compositor state is sent to the output, SwapPromise::DidSwap() | 18 // 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 | 19 // will be called, and if the compositor fails to send its new state to the |
20 // output, SwapPromise::DidNotSwap() will be called. | 20 // output, SwapPromise::DidNotSwap() will be called. |
21 // | 21 // |
22 // Client wishes to use SwapPromise should have a subclass that defines | 22 // Client wishes to use SwapPromise should have a subclass that defines |
23 // the behavior of DidSwap() and DidNotSwap(). Notice that the promise can | 23 // 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, | 24 // 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() | 25 // new frame data has no actual damage so LayerTreeHostImpl::SwapBuffers() |
26 // bails out early on impl thread, so don't assume that DidSwap() and | 26 // 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 | 27 // 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 | 28 // subclass carry thread-safe member data and operate on that member data in |
29 // DidSwap() and DidNotSwap(). | 29 // DidSwap() and DidNotSwap(). |
30 class CC_EXPORT SwapPromise { | 30 class CC_EXPORT SwapPromise : public Promise { |
31 public: | 31 public: |
32 enum DidNotSwapReason { | |
33 DID_NOT_SWAP_UNKNOWN, | |
34 SWAP_FAILS, | |
35 COMMIT_FAILS, | |
36 COMMIT_NO_UPDATE, | |
37 }; | |
38 | |
39 SwapPromise() {} | 32 SwapPromise() {} |
40 virtual ~SwapPromise() {} | 33 ~SwapPromise() override; |
41 | 34 |
42 virtual void DidSwap(CompositorFrameMetadata* metadata) = 0; | 35 virtual void DidSwap(CompositorFrameMetadata* metadata) = 0; |
43 virtual void DidNotSwap(DidNotSwapReason reason) = 0; | 36 virtual void DidNotSwap(DidNotSwap::Reason reason) = 0; |
44 | 37 |
45 // A non-zero trace id identifies a trace flow object that is embedded in the | 38 bool OnDidSwap(CompositorFrameMetadata* metadata) final; |
46 // swap promise. This can be used for registering additional flow steps to | 39 bool OnDidNotSwap(DidNotSwap::Reason reason) final; |
47 // visualize the object's path through the system. | |
48 virtual int64 TraceId() const = 0; | |
49 }; | 40 }; |
50 | 41 |
51 } // namespace cc | 42 } // namespace cc |
52 | 43 |
53 #endif // CC_OUTPUT_SWAP_PROMISE_H_ | 44 #endif // CC_OUTPUT_SWAP_PROMISE_H_ |
OLD | NEW |