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 case cc::SwapPromise::COMMIT_FAILS: | |
17 return ui::INPUT_EVENT_LATENCY_TERMINATED_COMMIT_FAILED_COMPONENT; | |
18 case cc::SwapPromise::SWAP_PROMISE_LIST_OVERFLOW: | |
19 return ui::LATENCY_INFO_LIST_TERMINATED_OVERFLOW_COMPONENT; | |
20 } | |
21 NOTREACHED() << "Unhandled DidNotSwapReason."; | |
22 return ui::INPUT_EVENT_LATENCY_TERMINATED_SWAP_FAILED_COMPONENT; | |
23 } | |
24 } // namespace | |
25 | |
26 namespace cc { | |
27 | |
28 LatencyInfoSwapPromise::LatencyInfoSwapPromise(const ui::LatencyInfo& latency) | |
29 : latency_(latency) { | |
30 } | |
31 | |
32 LatencyInfoSwapPromise::~LatencyInfoSwapPromise() { | |
33 } | |
34 | |
35 void LatencyInfoSwapPromise::DidSwap(CompositorFrameMetadata* metadata) { | |
36 DCHECK(!latency_.terminated); | |
37 // TODO(miletus): Append the |latency_| into metadata's LatencyInfo list | |
38 // once we remove LatencyInfo merge in GPU side. | |
39 metadata->latency_info.MergeWith(latency_); | |
40 } | |
41 | |
42 void LatencyInfoSwapPromise::DidNotSwap(DidNotSwapReason reason) { | |
43 latency_.AddLatencyNumber(DidNotSwapReasonToLatencyComponentType(reason), | |
44 0, 0); | |
45 // TODO(miletus): Turn this back on once per-event LatencyInfo tracking | |
46 // is enabled in GPU side. | |
47 // DCHECK(latency_.terminated); | |
48 } | |
49 | |
50 } // namespace cc | |
OLD | NEW |