-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathwesgr.h
243 lines (191 loc) · 5.17 KB
/
wesgr.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
/*
* Copyright © 2014 Pekka Paalanen <[email protected]>
*
* Permission to use, copy, modify, distribute, and sell this software and
* its documentation for any purpose is hereby granted without fee, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of the copyright holders not be used in
* advertising or publicity pertaining to distribution of the software
* without specific, written prior permission. The copyright holders make
* no representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef WESGR_H
#define WESGR_H
#include <stdint.h>
#include <time.h>
#define ARRAY_LENGTH(a) (sizeof(a) / sizeof((a)[0]))
struct json_object;
struct info_weston_output;
struct info_weston_surface;
struct update {
struct timespec damage;
struct timespec flush;
struct timespec vblank;
struct update *next;
};
struct update_graph {
struct update_graph *next;
struct update *updates;
const char *style;
char *label;
double y;
struct update *need_vblank;
};
struct activity {
struct timespec begin;
struct timespec end;
struct activity *next;
};
struct activity_set {
struct activity *act;
};
struct vblank {
struct timespec ts;
struct vblank *next;
};
struct vblank_set {
struct vblank *vbl;
};
struct transition {
struct timespec ts;
struct transition *next;
};
struct transition_set {
struct transition *trans;
const char *style;
};
struct line_block {
struct timespec begin;
struct timespec end;
const char *style;
char *desc;
struct line_block *next;
};
struct line_graph {
struct line_block *block;
const char *style;
const char *label;
double y;
};
struct output_graph {
struct info_weston_output *info;
struct output_graph *next;
struct line_graph delay_line;
struct line_graph submit_line;
struct line_graph gpu_line;
struct line_graph renderer_gpu_line;
struct transition_set begins;
struct transition_set posts;
struct vblank_set vblanks;
struct activity_set not_looping;
struct update_graph *updates;
double y1, y2;
double title_y;
struct timespec last_req;
struct timespec last_finished;
struct timespec last_begin;
struct timespec last_posted;
struct timespec last_exit_loop;
struct timespec last_renderer_gpu_begin;
};
struct graph_data {
struct output_graph *output;
struct timespec begin;
struct timespec end;
double time_axis_y;
double legend_y;
};
struct surface_graph_list {
struct surface_graph_list *next;
struct output_graph *output_gr;
struct update_graph *update_gr;
};
enum object_type {
TYPE_WESTON_OUTPUT,
TYPE_WESTON_SURFACE,
};
struct info_weston_output {
const char *name;
struct output_graph *output_gr;
};
struct info_weston_surface {
char *description;
struct update *open_update;
struct surface_graph_list *glist;
struct surface_graph_list *last;
};
struct object_info {
unsigned id;
enum object_type type;
struct json_object *jobj;
union {
struct info_weston_output wo;
struct info_weston_surface ws;
} info;
};
struct lookup_table {
unsigned id_base;
void **array;
unsigned alloc;
};
struct parse_context {
struct lookup_table idmap;
struct graph_data *gdata;
};
typedef int (*tp_handler_t)(struct parse_context *ctx,
const struct timespec *ts,
struct json_object *jobj);
struct tp_handler_item {
const char *tp_name;
tp_handler_t func;
};
extern const struct tp_handler_item tp_handler_list[];
int
graph_data_init(struct graph_data *gdata);
void
graph_data_release(struct graph_data *gdata);
int
graph_data_end(struct graph_data *gdata);
void
graph_data_time(struct graph_data *gdata, const struct timespec *ts);
int
graph_data_to_svg(struct graph_data *gdata, int from_ms, int to_ms,
const char *filename);
int
parse_context_init(struct parse_context *ctx, struct graph_data *gdata);
void
parse_context_release(struct parse_context *ctx);
int
parse_context_process_object(struct parse_context *ctx,
struct json_object *jobj);
struct object_info *
get_object_info_from_timepoint(struct parse_context *ctx,
struct json_object *jobj, const char *member);
struct timespec
get_timespec_from_timepoint(struct parse_context *ctx,
struct json_object *jobj, const char *member);
static inline void
timespec_invalidate(struct timespec *ts)
{
ts->tv_nsec = -1;
}
static inline int
timespec_is_valid(const struct timespec *ts)
{
return ts->tv_nsec >= 0;
}
void
generic_error(const char *file, int line, const char *func);
#define ERROR ({ generic_error(__FILE__, __LINE__, __func__); -1; })
#define ERROR_NULL ({ generic_error(__FILE__, __LINE__, __func__); NULL; })
#endif /* WESGR_H */