1 // Copyright 2015 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.
5 #ifndef CC_DEBUG_FRAME_TIMING_TRACKER_H_
6 #define CC_DEBUG_FRAME_TIMING_TRACKER_H_
11 #include "base/basictypes.h"
12 #include "base/containers/hash_tables.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/time/time.h"
15 #include "cc/base/cc_export.h"
19 // This class maintains a history of timestamps and rect IDs to communicate
20 // frame events back to Blink
21 // TODO(mpb): Start using this. crbug.com/442554
22 class CC_EXPORT FrameTimingTracker
{
24 struct CC_EXPORT CompositeTimingEvent
{
25 CompositeTimingEvent(int, base::TimeTicks
);
26 ~CompositeTimingEvent();
29 base::TimeTicks timestamp
;
32 using CompositeTimingSet
=
33 base::hash_map
<int, std::vector
<CompositeTimingEvent
>>;
35 static scoped_ptr
<FrameTimingTracker
> Create();
37 ~FrameTimingTracker();
39 // This routine takes all of the individual CompositeEvents stored in the
40 // tracker and collects them by "rect_id", as in the example below.
41 // [ {f_id1,r_id1,t1}, {f_id2,r_id1,t2}, {f_id3,r_id2,t3} ]
43 // [ {r_id1,<{f_id1,t1},{f_id2,t2}>}, {r_id2,<{f_id3,t3}>} ]
44 scoped_ptr
<CompositeTimingSet
> GroupCountsByRectId();
46 // This routine takes a timestamp and an array of frame_id,rect_id pairs
47 // and generates CompositeTimingEvents (frame_id, timestamp) and adds them to
48 // internal hash_map keyed on rect_id
49 using FrameAndRectIds
= std::pair
<int, int64_t>;
50 void SaveTimeStamps(base::TimeTicks timestamp
,
51 const std::vector
<FrameAndRectIds
>& frame_ids
);
56 scoped_ptr
<CompositeTimingSet
> composite_events_
;
58 DISALLOW_COPY_AND_ASSIGN(FrameTimingTracker
);
63 #endif // CC_DEBUG_FRAME_TIMING_TRACKER_H_