|
@@ -229,7 +229,7 @@ begin_draw() {
|
|
|
* indicated location.
|
|
* indicated location.
|
|
|
*/
|
|
*/
|
|
|
void GtkStatsFlameGraph::
|
|
void GtkStatsFlameGraph::
|
|
|
-draw_bar(int depth, int from_x, int to_x, int collector_index) {
|
|
|
|
|
|
|
+draw_bar(int depth, int from_x, int to_x, int collector_index, int parent_index) {
|
|
|
double bottom = get_ysize() - depth * _pixel_scale * 5;
|
|
double bottom = get_ysize() - depth * _pixel_scale * 5;
|
|
|
double top = bottom - _pixel_scale * 5;
|
|
double top = bottom - _pixel_scale * 5;
|
|
|
|
|
|
|
@@ -257,18 +257,32 @@ draw_bar(int depth, int from_x, int to_x, int collector_index) {
|
|
|
int right = std::min(to_x, get_xsize()) - _pixel_scale / 2;
|
|
int right = std::min(to_x, get_xsize()) - _pixel_scale / 2;
|
|
|
|
|
|
|
|
const PStatClientData *client_data = GtkStatsGraph::_monitor->get_client_data();
|
|
const PStatClientData *client_data = GtkStatsGraph::_monitor->get_client_data();
|
|
|
- const std::string &name = client_data->get_collector_name(collector_index);
|
|
|
|
|
|
|
+ const PStatCollectorDef &def = client_data->get_collector_def(collector_index);
|
|
|
|
|
|
|
|
// Choose a suitable foreground color.
|
|
// Choose a suitable foreground color.
|
|
|
LRGBColor fg = get_collector_text_color(collector_index, is_highlighted);
|
|
LRGBColor fg = get_collector_text_color(collector_index, is_highlighted);
|
|
|
cairo_set_source_rgb(_cr, fg[0], fg[1], fg[2]);
|
|
cairo_set_source_rgb(_cr, fg[0], fg[1], fg[2]);
|
|
|
|
|
|
|
|
- PangoLayout *layout = gtk_widget_create_pango_layout(_graph_window, name.c_str());
|
|
|
|
|
|
|
+ PangoLayout *layout = gtk_widget_create_pango_layout(_graph_window, def._name.c_str());
|
|
|
pango_layout_set_attributes(layout, _pango_attrs);
|
|
pango_layout_set_attributes(layout, _pango_attrs);
|
|
|
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
|
|
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
|
|
|
pango_layout_set_width(layout, (right - left) * PANGO_SCALE);
|
|
pango_layout_set_width(layout, (right - left) * PANGO_SCALE);
|
|
|
pango_layout_set_height(layout, -1);
|
|
pango_layout_set_height(layout, -1);
|
|
|
|
|
|
|
|
|
|
+ if (!pango_layout_is_ellipsized(layout)) {
|
|
|
|
|
+ // We have room for more. Show the collector's actual parent, if it's
|
|
|
|
|
+ // different than the block it's shown above.
|
|
|
|
|
+ if (def._parent_index > 0 && def._parent_index != parent_index) {
|
|
|
|
|
+ const PStatCollectorDef &parent_def = client_data->get_collector_def(def._parent_index);
|
|
|
|
|
+ std::string long_name = parent_def._name + ":" + def._name;
|
|
|
|
|
+ pango_layout_set_text(layout, long_name.c_str(), long_name.size());
|
|
|
|
|
+ if (pango_layout_is_ellipsized(layout)) {
|
|
|
|
|
+ // Nope, it's too long, go back.
|
|
|
|
|
+ pango_layout_set_text(layout, def._name.c_str(), def._name.size());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
int width, height;
|
|
int width, height;
|
|
|
pango_layout_get_pixel_size(layout, &width, &height);
|
|
pango_layout_get_pixel_size(layout, &width, &height);
|
|
|
|
|
|