27 PStatPianoRoll::BarBuilder::
35 void PStatPianoRoll::BarBuilder::
45 void PStatPianoRoll::BarBuilder::
46 add_data_point(
double time,
bool is_start) {
49 if (_color_bars.empty() || _color_bars.back()._end >= 0.0) {
53 _color_bars.push_back(bar);
58 if (_color_bars.empty()) {
63 _color_bars.push_back(bar);
66 _color_bars.back()._end = time;
75 void PStatPianoRoll::BarBuilder::
77 if (!_color_bars.empty() && _color_bars.back()._end < 0.0) {
78 _color_bars.back()._end = time;
86 PStatPianoRoll(
PStatMonitor *monitor,
int thread_index,
int xsize,
int ysize) :
88 _thread_index(thread_index)
90 _time_width = 1.0 / pstats_target_frame_rate;
94 _guide_bar_units = GBU_ms | GBU_hz | GBU_show_units;
120 if (frame_number != _current_frame) {
121 compute_page(thread_data->
get_frame(frame_number));
122 _current_frame = frame_number;
136 void PStatPianoRoll::
137 changed_size(
int xsize,
int ysize) {
138 if (xsize != _xsize || ysize != _ysize) {
151 void PStatPianoRoll::
153 if (!_labels.empty()) {
155 for (
int i = 0; i < (int)_labels.size(); i++) {
156 int collector_index = _labels[i];
157 const ColorBars &bars = _page_data[collector_index]._color_bars;
160 ColorBars::const_iterator bi;
161 for (bi = bars.begin(); bi != bars.end(); ++bi) {
162 const ColorBar &bar = (*bi);
174 void PStatPianoRoll::
175 normal_guide_bars() {
177 update_guide_bars(
get_xsize() / 100, _time_width);
184 void PStatPianoRoll::
193 void PStatPianoRoll::
201 void PStatPianoRoll::
202 draw_bar(
int,
int,
int) {
209 void PStatPianoRoll::
217 void PStatPianoRoll::
225 void PStatPianoRoll::
232 class SortCollectorLabels1 {
235 _client_data(client_data) {
237 bool operator () (
int a,
int b)
const {
239 _client_data->get_collector_def(a)._sort >
240 _client_data->get_collector_def(b)._sort;
248 void PStatPianoRoll::
255 _page_data.swap(previous);
258 for (
int i = 0; i < num_events; i++) {
260 double time = frame_data.
get_time(i);
261 bool is_start = frame_data.
is_start(i);
262 _page_data[collector_index].add_data_point(time, is_start);
266 bool changed_bars = (_page_data.size() != previous.size());
269 PageData::const_iterator ai, bi;
270 ai = _page_data.begin();
271 bi = previous.begin();
272 while (ai != _page_data.end() && !changed_bars) {
273 changed_bars = ((*ai).first == (*bi).first);
285 PageData::const_iterator pi;
286 for (pi = _page_data.begin(); pi != _page_data.end(); ++pi) {
287 int collector_index = (*pi).first;
289 _labels.push_back(collector_index);
293 SortCollectorLabels1 sort_labels(client_data);
294 sort(_labels.begin(), _labels.end(), sort_labels);
296 _labels_changed =
true;
300 double time = frame_data.
get_end();
301 PageData::iterator pi;
302 for (pi = _page_data.begin(); pi != _page_data.end(); ++pi) {
303 (*pi).second.finish(time);