mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-26 14:43:50 -04:00
pstats: Timeline: show longer collector name if there's room
Similar to what we're doing on the flame graph now Also, tweak tooltip message for collectors that overlap frame boundary if it's partially on a dropped frame, so that it isn't misleading
This commit is contained in:
parent
cb0d52b1b5
commit
d6055cc927
@ -228,14 +228,25 @@ draw_bar(int row, int from_x, int to_x, int collector_index,
|
||||
double text_top = top + (bottom - top - text_height) / 2.0;
|
||||
|
||||
if (text_width >= text_right - text_left) {
|
||||
size_t c = collector_name.rfind(':');
|
||||
if (text_right - text_left < scale * 6) {
|
||||
// It's a really tiny space. Draw a single letter.
|
||||
const char *ch = collector_name.data() + (c != std::string::npos ? c + 1 : 0);
|
||||
pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER);
|
||||
pango_layout_set_text(layout, collector_name.c_str(), 1);
|
||||
pango_layout_set_text(layout, ch, 1);
|
||||
} else {
|
||||
// It's going to be tricky to fit it, let pango figure it out.
|
||||
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
|
||||
// Maybe just use everything after the last colon.
|
||||
if (c != std::string::npos) {
|
||||
pango_layout_set_text(layout, collector_name.data() + c + 1,
|
||||
collector_name.size() - c - 1);
|
||||
pango_layout_get_pixel_size(layout, &text_width, &text_height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (text_width >= text_right - text_left) {
|
||||
// It's going to be tricky to fit it, let pango figure it out.
|
||||
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
|
||||
pango_layout_set_width(layout, (text_right - text_left) * PANGO_SCALE);
|
||||
cairo_move_to(_cr, text_left, text_top);
|
||||
}
|
||||
|
@ -381,7 +381,11 @@ get_bar_tooltip(int row, int x) const {
|
||||
if (client_data != nullptr && client_data->has_collector(bar._collector_index)) {
|
||||
std::ostringstream text;
|
||||
text << client_data->get_collector_fullname(bar._collector_index);
|
||||
text << " (" << format_number(bar._end - bar._start, GBU_show_units | GBU_ms) << ")";
|
||||
text << " (";
|
||||
if (bar._open_begin || bar._open_end) {
|
||||
text << "at least ";
|
||||
}
|
||||
text << format_number(bar._end - bar._start, GBU_show_units | GBU_ms) << ")";
|
||||
return text.str();
|
||||
}
|
||||
}
|
||||
@ -669,9 +673,17 @@ draw_row(int thread_index, int row_index, double start_time, double end_time) {
|
||||
|
||||
if (to_x >= 0 && to_x > from_x && from_x < get_xsize()) {
|
||||
if (bar._collector_index != 0) {
|
||||
draw_bar(thread_row._row_offset + row_index, from_x, to_x,
|
||||
bar._collector_index,
|
||||
client_data->get_collector_name(bar._collector_index));
|
||||
const PStatCollectorDef &def = client_data->get_collector_def(bar._collector_index);
|
||||
if (to_x - from_x >= 32 && def._parent_index > 0) {
|
||||
// Try including the parent name.
|
||||
const PStatCollectorDef &parent_def = client_data->get_collector_def(def._parent_index);
|
||||
std::string long_name = parent_def._name + ":" + def._name;
|
||||
draw_bar(thread_row._row_offset + row_index, from_x, to_x,
|
||||
bar._collector_index, long_name);
|
||||
} else {
|
||||
draw_bar(thread_row._row_offset + row_index, from_x, to_x,
|
||||
bar._collector_index, def._name);
|
||||
}
|
||||
} else {
|
||||
draw_bar(thread_row._row_offset + row_index, from_x, to_x,
|
||||
bar._collector_index,
|
||||
|
Loading…
x
Reference in New Issue
Block a user