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

Side by Side Diff: cc/debug/performance_draw_timing_counter.cc

Issue 397443002: [not for review] Add Draw entries to window Performance Timeline Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git pull of third_party/WebKit Created 6 years, 5 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
(Empty)
1 // Copyright 2014 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/debug/performance_draw_timing_counter.h"
6
7 #include <algorithm>
8 #include <limits>
9
10 #include "base/metrics/histogram.h"
11 #include "cc/trees/proxy.h"
12
13 namespace cc {
14
15 // static
16 scoped_ptr<PerformanceDrawTimingCounter>
17 PerformanceDrawTimingCounter::Create() {
18 return make_scoped_ptr(new PerformanceDrawTimingCounter);
19 }
20
21 PerformanceDrawTimingCounter::PerformanceDrawTimingCounter() {
22 }
23
24 void PerformanceDrawTimingCounter::SaveTimeStamp(int frame_id, int64_t rect_id,
25 base::TimeTicks timestamp) {
26 struct DrawEvent drawEvent(frame_id, rect_id, timestamp);
27 ring_buffer_.SaveToBuffer(drawEvent);
28 }
29
30 void PerformanceDrawTimingCounter::SaveTimeStamps(base::TimeTicks timestamp,
31 const std::vector<std::pair<int, int64_t> > &frame_ids) {
32 for (std::vector<std::pair<int, int64_t> >::const_iterator it =
33 frame_ids.begin(); it != frame_ids.end(); ++it) {
34 struct DrawEvent drawEvent(it->first, it->second, timestamp);
enne (OOO) 2014/07/22 20:44:24 style nit: draw_event, no struct bikeshed: Maybe
Mike B 2014/07/25 23:09:40 Done.
35 ring_buffer_.SaveToBuffer(drawEvent);
36 }
37 }
38
39 scoped_ptr<DrawTimingSet> PerformanceDrawTimingCounter::getDrawTimingCounts() {
40 typedef base::hash_map
41 <int64_t, std::vector<std::pair<int, base::TimeTicks> > > DrawsByRectId;
42 DrawsByRectId id_map;
43 for (RingBufferType::Iterator it = begin(); it; ++it) {
44 id_map[it->rect_id_].push_back(std::make_pair(it->frame_id_,
45 it->timestamp_));
46 }
47 scoped_ptr<DrawTimingSet> draws_info(new DrawTimingSet);
48 for (DrawsByRectId::iterator id = id_map.begin(); id != id_map.end(); ++id) {
49 LayerTreeHostCommon::DrawTimingInfo draw;
50 draw.rect_id = id->first;
51 draw.timestamps = id->second;
52 std::sort(draw.timestamps.begin(), draw.timestamps.end());
53 draws_info->draws.push_back(draw);
54 }
55 return draws_info.Pass();
56 }
57
58 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698