1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2006 Parisa heidari (inspired from CFV by Mathieu Desnoyers)
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation;
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 #ifndef _HISTODRAWING_H
21 #define _HISTODRAWING_H
26 //#include <lttv/tracecontext.h>
27 #include <lttv/traceset.h>
28 #include <lttvwindow/lttvwindow.h>
30 #include "histodrawitem.h"
33 #define SAFETY 50 // safety pixels at right and bottom of pixmap buffer
35 typedef enum _draw_color
{
38 COL_RUN_USER_MODE
,/* green */
39 COL_RUN_SYSCALL
, /* pale blue */
40 COL_RUN_TRAP
, /* yellow */
41 COL_RUN_IRQ
, /* red */
42 COL_WAIT
, /* dark red */
43 COL_WAIT_CPU
, /* dark yellow */
44 COL_ZOMBIE
, /* dark purple */
45 COL_WAIT_FORK
, /* dark green */
46 COL_EXIT
, /* "less dark" magenta */
47 COL_MODE_UNKNOWN
, /* white */
48 COL_UNNAMED
, /* white */
49 NUM_COLORS
} draw_color
;
51 extern GdkColor histo_drawing_colors
[NUM_COLORS
];
53 /* This part of the viewer does :
54 * Draw horizontal lines, getting graphic context as arg.
55 * Copy region of the screen into another.
56 * Modify the boundaries to reflect a scale change. (resize)
57 * Refresh the physical screen with the pixmap
58 * A helper function is provided here to convert from time to process
59 * identifier to pixels and the contrary (will be useful for mouse selection).
60 * Insert an empty square in the drawing, moving the bottom part.
62 * Note: The last point is exactly why it would not be so easy to add the
63 * vertical line functionnality as in the original version of LTT. In order
64 * to do so, we should keep all processes in the list for the duration of
65 * all the trace instead of dynamically adding and removing them when we
66 * scroll. Another possibility is to redraw all the visible area when a new
67 * process is added to the list. The second solution seems more appropriate
71 * The pixmap used has the width of the physical window, but the height
72 * of the shown processes.
75 #ifndef TYPE_histoDrawing_t_DEFINED
76 #define TYPE_histoDrawing_t_DEFINED
77 typedef struct _histoDrawing_t histoDrawing_t
;
78 #endif //TYPE_DRAWING_T_DEFINED
80 #ifndef TYPE_HistoControlFlowData_DEFINED
81 #define TYPE_HistoControlFlowData_DEFINED
82 typedef struct _HistoControlFlowData HistoControlFlowData
;
83 #endif //TYPE_HistoControlFlowData_DEFINED
85 struct _histoDrawing_t
{
87 GtkWidget
*drawing_area
;
91 GtkWidget *scrollbar;*///at
this time
,not necessary
for histogram
93 GtkWidget
*ruler_hbox
;
97 GtkWidget
*vruler_drawing_hbox
;
98 GtkWidget
*vertical_ruler
;
101 HistoControlFlowData
*histo_control_flow_data
;
103 PangoLayout
*pango_layout
;
105 gint height
, width
, depth
;
106 /* height and width of allocated buffer pixmap */
107 gint alloc_height
, alloc_width
;
109 /* X coordinate of damaged region */
110 gint damage_begin
, damage_end
; /* damaged region to be exposed,
115 GdkGC
*ruler_gc_butt
;
116 GdkGC
*ruler_gc_round
;
118 /* Position of the horizontal selector, -1 for none */
122 histoDrawing_t
*histo_drawing_construct(HistoControlFlowData
*histo_control_flow_data
);
123 void histo_drawing_destroy(histoDrawing_t
*drawing
);
126 void histo_drawing_data_request(histoDrawing_t
*drawing
,
131 GtkWidget
*histo_drawing_get_widget(histoDrawing_t
*drawing
);
132 GtkWidget
*histo_drawing_get_drawing_area(histoDrawing_t
*drawing
);
134 void histo_drawing_draw_line(histoDrawing_t
*drawing
,
140 //void drawing_copy(histoDrawing_t *drawing,
141 // guint xsrc, guint ysrc,
142 // guint xdest, guint ydest,
143 // guint width, guint height);
145 /* Clear the drawing : make it 1xwidth. */
146 void histo_drawing_clear(histoDrawing_t
*drawing
,guint clear_from
,guint clear_to
);
148 void histo_drawing_update_ruler(histoDrawing_t
*drawing
, TimeWindow
*time_window
);
150 void histo_drawing_update_vertical_ruler(histoDrawing_t
*drawing
);//, TimeWindow *time_window);
152 void histo_drawing_request_expose(EventsRequest
*events_request
,
153 LttvTraceset
*traceset
,
156 void histo_drawing_data_request_begin(EventsRequest
*events_request
,
157 LttvTraceset
*traceset
);
158 void histo_drawing_chunk_begin(EventsRequest
*events_request
, LttvTraceset
*traceset
);
161 /* histo_convert_pixels_to_time
163 * Convert from window pixel and time interval to an absolute time.
165 static inline void histo_convert_pixels_to_time(
168 TimeWindow time_window
,
173 time_d
= time_window
.time_width_double
;
174 time_d
= time_d
/ (double)width
* (double)x
;
175 *time
= ltt_time_from_double(time_d
);
176 *time
= ltt_time_add(time_window
.start_time
, *time
);
180 static inline void histo_convert_time_to_pixels(
181 TimeWindow time_window
,
188 g_assert(ltt_time_compare(window_time_begin
, time
) <= 0 &&
189 ltt_time_compare(window_time_end
, time
) >= 0);
192 time
= ltt_time_sub(time
, time_window
.start_time
);
194 time_d
= ltt_time_to_double(time
);
196 if(time_window
.time_width_double
== 0.0) {
197 g_assert(time_d
== 0.0);
200 *x
= (guint
)(time_d
/ time_window
.time_width_double
* (double)width
);