OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "cc/base/latency_info_swap_promise.h" | |
6 | |
7 #include "base/logging.h" | |
8 | |
9 namespace { | |
10 ui::LatencyComponentType DidNotSwapReasonToLatencyComponentType( | |
11 cc::SwapPromise::DidNotSwapReason reason) { | |
12 switch (reason) { | |
13 case cc::SwapPromise::DID_NOT_SWAP_UNKNOWN: | |
14 case cc::SwapPromise::SWAP_FAILS: | |
15 return ui::INPUT_EVENT_LATENCY_TERMINATED_SWAP_FAILED_COMPONENT; | |
16 break; | |
danakj
2013/11/27 20:26:10
nit: break is kinda pointless after a return state
Yufeng Shen (Slow to review)
2013/11/27 21:19:34
Done.
| |
17 case cc::SwapPromise::COMMIT_FAILS: | |
18 return ui::INPUT_EVENT_LATENCY_TERMINATED_COMMIT_FAILED_COMPONENT; | |
19 break; | |
20 case cc::SwapPromise::SWAP_PROMISE_LIST_OVERFLOW: | |
21 return ui::LATENCY_INFO_LIST_TERMINATED_OVERFLOW_COMPONENT; | |
22 break; | |
23 default: | |
24 DLOG(WARNING) << "Unhandled DidNotSwapReason.\n"; | |
danakj
2013/11/27 20:26:10
Should this be a NOTREACHED()?
danakj
2013/11/27 20:26:10
Generally you don't need \n at the end of LOG line
Yufeng Shen (Slow to review)
2013/11/27 21:19:34
Done.
Yufeng Shen (Slow to review)
2013/11/27 21:19:34
Done.
| |
25 break; | |
26 } | |
27 return ui::INPUT_EVENT_LATENCY_TERMINATED_SWAP_FAILED_COMPONENT; | |
28 } | |
29 } // namespace | |
30 | |
31 namespace cc { | |
32 | |
33 LatencyInfoSwapPromise::LatencyInfoSwapPromise(const ui::LatencyInfo& latency) | |
34 : latency_(latency) { | |
35 } | |
36 | |
37 LatencyInfoSwapPromise::~LatencyInfoSwapPromise() { | |
38 } | |
39 | |
40 void LatencyInfoSwapPromise::DidSwap(CompositorFrameMetadata* metadata) { | |
41 DCHECK(!latency_.terminated); | |
42 // TODO(mileus): Append the |latency_| into metadata's LatencyInfo list | |
43 // once we remove LatencyInfo merge in GPU side. | |
44 metadata->latency_info.MergeWith(latency_); | |
45 } | |
46 | |
47 void LatencyInfoSwapPromise::DidNotSwap(DidNotSwapReason reason) { | |
48 latency_.AddLatencyNumber(DidNotSwapReasonToLatencyComponentType(reason), | |
49 0, 0); | |
50 DCHECK(latency_.terminated); | |
51 } | |
52 | |
53 } // namespace cc | |
OLD | NEW |