diff options
Diffstat (limited to 'trace-graph.c')
-rw-r--r-- | trace-graph.c | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/trace-graph.c b/trace-graph.c index 10e1d65..f63c202 100644 --- a/trace-graph.c +++ b/trace-graph.c | |||
@@ -1638,16 +1638,36 @@ static gint draw_plot_line(struct graph_info *ginfo, int i, | |||
1638 | return x; | 1638 | return x; |
1639 | } | 1639 | } |
1640 | 1640 | ||
1641 | static void draw_plot_label(struct graph_info *ginfo, char *label, | ||
1642 | gint x, gint y, gint max_width) | ||
1643 | { | ||
1644 | PangoLayout *layout; | ||
1645 | gint text_width, text_height; | ||
1646 | static PangoFontDescription *font = NULL; | ||
1647 | |||
1648 | if (!font) { | ||
1649 | font = pango_font_description_from_string("Sans 6"); | ||
1650 | } | ||
1651 | |||
1652 | layout = gtk_widget_create_pango_layout(ginfo->draw, label); | ||
1653 | pango_layout_set_font_description(layout, font); | ||
1654 | pango_layout_get_pixel_size(layout, &text_width, &text_height); | ||
1655 | |||
1656 | if (text_width <= max_width) { | ||
1657 | gdk_draw_layout(ginfo->curr_pixmap, | ||
1658 | ginfo->draw->style->black_gc, | ||
1659 | x, y, layout); | ||
1660 | } | ||
1661 | g_object_unref(layout); | ||
1662 | } | ||
1663 | |||
1641 | static void draw_plot_box(struct graph_info *ginfo, int i, | 1664 | static void draw_plot_box(struct graph_info *ginfo, int i, |
1642 | unsigned long long start, | 1665 | unsigned long long start, |
1643 | unsigned long long end, | 1666 | unsigned long long end, |
1644 | gboolean fill, gboolean thin, | 1667 | gboolean fill, gboolean thin, |
1645 | char *label, GdkGC *gc) | 1668 | char *label, GdkGC *gc) |
1646 | { | 1669 | { |
1647 | gint x1; | 1670 | gint x1, x2, y, size; |
1648 | gint x2; | ||
1649 | gint y; | ||
1650 | gint size; | ||
1651 | 1671 | ||
1652 | x1 = convert_time_to_x(ginfo, start); | 1672 | x1 = convert_time_to_x(ginfo, start); |
1653 | x2 = convert_time_to_x(ginfo, end); | 1673 | x2 = convert_time_to_x(ginfo, end); |
@@ -1659,10 +1679,12 @@ static void draw_plot_box(struct graph_info *ginfo, int i, | |||
1659 | fill, | 1679 | fill, |
1660 | x1, y, | 1680 | x1, y, |
1661 | x2 - x1, size); | 1681 | x2 - x1, size); |
1682 | if (label) | ||
1683 | draw_plot_label(ginfo, label, x1 + 1, y + 1, x2 - x1 - 2); | ||
1662 | } | 1684 | } |
1663 | 1685 | ||
1664 | static void draw_plot_release(struct graph_info *ginfo, int i, | 1686 | static void draw_plot_release(struct graph_info *ginfo, int i, |
1665 | unsigned long long time, char *label, GdkGC *gc) | 1687 | unsigned long long time, GdkGC *gc) |
1666 | { | 1688 | { |
1667 | 1689 | ||
1668 | int tbase = PLOT_TOP(i) + PLOT_TRI_SIZE; | 1690 | int tbase = PLOT_TOP(i) + PLOT_TRI_SIZE; |
@@ -1681,7 +1703,7 @@ static void draw_plot_release(struct graph_info *ginfo, int i, | |||
1681 | } | 1703 | } |
1682 | 1704 | ||
1683 | static void draw_plot_deadline(struct graph_info *ginfo, int i, | 1705 | static void draw_plot_deadline(struct graph_info *ginfo, int i, |
1684 | unsigned long long time, char *label, GdkGC *gc) | 1706 | unsigned long long time, GdkGC *gc) |
1685 | { | 1707 | { |
1686 | int tbase = PLOT_BOX_BOTTOM(i); | 1708 | int tbase = PLOT_BOX_BOTTOM(i); |
1687 | int x = convert_time_to_x(ginfo, time); | 1709 | int x = convert_time_to_x(ginfo, time); |
@@ -1699,8 +1721,7 @@ static void draw_plot_deadline(struct graph_info *ginfo, int i, | |||
1699 | } | 1721 | } |
1700 | 1722 | ||
1701 | static void draw_plot_completion(struct graph_info *ginfo, int i, | 1723 | static void draw_plot_completion(struct graph_info *ginfo, int i, |
1702 | unsigned long long time, char *label, | 1724 | unsigned long long time, GdkGC *gc) |
1703 | GdkGC *gc) | ||
1704 | { | 1725 | { |
1705 | int tbase = PLOT_BOX_BOTTOM(i) + PLOT_BTRI_SIZE; | 1726 | int tbase = PLOT_BOX_BOTTOM(i) + PLOT_BTRI_SIZE; |
1706 | int x = convert_time_to_x(ginfo, time); | 1727 | int x = convert_time_to_x(ginfo, time); |
@@ -1748,7 +1769,7 @@ static void draw_plot(struct graph_info *ginfo, struct graph_plot *plot, | |||
1748 | } | 1769 | } |
1749 | 1770 | ||
1750 | draw_plot_box(ginfo, plot->pos, info.bstart, info.bend, | 1771 | draw_plot_box(ginfo, plot->pos, info.bstart, info.bend, |
1751 | info.bfill, info.bthin, info.blabel, plot->gc); | 1772 | info.bfill, info.bthin, info.blabel, plot->gc); |
1752 | } | 1773 | } |
1753 | 1774 | ||
1754 | if (info.release) { | 1775 | if (info.release) { |
@@ -1756,8 +1777,7 @@ static void draw_plot(struct graph_info *ginfo, struct graph_plot *plot, | |||
1756 | plot->last_color = 0; | 1777 | plot->last_color = 0; |
1757 | set_color(ginfo->draw, plot->gc, plot->last_color); | 1778 | set_color(ginfo->draw, plot->gc, plot->last_color); |
1758 | } | 1779 | } |
1759 | draw_plot_release(ginfo, plot->pos, | 1780 | draw_plot_release(ginfo, plot->pos, info.rtime, plot->gc); |
1760 | info.rtime, info.rlabel, plot->gc); | ||
1761 | } | 1781 | } |
1762 | 1782 | ||
1763 | if (info.deadline) { | 1783 | if (info.deadline) { |
@@ -1765,8 +1785,7 @@ static void draw_plot(struct graph_info *ginfo, struct graph_plot *plot, | |||
1765 | plot->last_color = 0; | 1785 | plot->last_color = 0; |
1766 | set_color(ginfo->draw, plot->gc, plot->last_color); | 1786 | set_color(ginfo->draw, plot->gc, plot->last_color); |
1767 | } | 1787 | } |
1768 | draw_plot_deadline(ginfo, plot->pos, | 1788 | draw_plot_deadline(ginfo, plot->pos, info.dtime, plot->gc); |
1769 | info.dtime, info.dlabel, plot->gc); | ||
1770 | } | 1789 | } |
1771 | 1790 | ||
1772 | if (info.completion) { | 1791 | if (info.completion) { |
@@ -1774,8 +1793,7 @@ static void draw_plot(struct graph_info *ginfo, struct graph_plot *plot, | |||
1774 | plot->last_color = 0; | 1793 | plot->last_color = 0; |
1775 | set_color(ginfo->draw, plot->gc, plot->last_color); | 1794 | set_color(ginfo->draw, plot->gc, plot->last_color); |
1776 | } | 1795 | } |
1777 | draw_plot_completion(ginfo, plot->pos, | 1796 | draw_plot_completion(ginfo, plot->pos, info.ctime, plot->gc); |
1778 | info.ctime, info.dlabel, plot->gc); | ||
1779 | } | 1797 | } |
1780 | 1798 | ||
1781 | 1799 | ||