blob: af7bff17b8774394e4f9b22203d2d8df1559fd2e [file] [log] [blame]
Pekka Paalanen8c492b12012-09-11 17:02:04 +03001/*
2 * Copyright © 2012 Collabora, Ltd.
3 * Copyright © 2012 Rob Clark
4 *
5 * Permission to use, copy, modify, distribute, and sell this software and its
6 * documentation for any purpose is hereby granted without fee, provided that
7 * the above copyright notice appear in all copies and that both that copyright
8 * notice and this permission notice appear in supporting documentation, and
9 * that the name of the copyright holders not be used in advertising or
10 * publicity pertaining to distribution of the software without specific,
11 * written prior permission. The copyright holders make no representations
12 * about the suitability of this software for any purpose. It is provided "as
13 * is" without express or implied warranty.
14 *
15 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
17 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
19 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
20 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
21 * OF THIS SOFTWARE.
22 */
23
24/* cliptest: for debugging calculate_edges() function, which is copied
25 * from compositor.c.
26 * controls:
27 * clip box position: mouse left drag, keys: w a s d
28 * clip box size: mouse right drag, keys: i j k l
29 * surface orientation: mouse wheel, keys: n m
30 * surface transform disable key: r
31 */
32
Andrew Wedgbury9cd661e2014-04-07 12:40:35 +010033#include "config.h"
34
Pekka Paalanen8c492b12012-09-11 17:02:04 +030035#include <stdint.h>
36#include <stdio.h>
37#include <stdlib.h>
38#include <string.h>
39#include <fcntl.h>
40#include <libgen.h>
41#include <unistd.h>
42#include <math.h>
43#include <time.h>
44#include <pixman.h>
45#include <cairo.h>
46#include <float.h>
47#include <assert.h>
48
49#include <linux/input.h>
50#include <wayland-client.h>
51
Ondřej Majerech06e08922014-08-19 15:59:44 +020052#include "src/vertex-clipping.h"
Pekka Paalanen8c492b12012-09-11 17:02:04 +030053#include "window.h"
54
55typedef float GLfloat;
56
57struct geometry {
58 pixman_box32_t clip;
59
60 pixman_box32_t surf;
61 float s; /* sin phi */
62 float c; /* cos phi */
63 float phi;
64};
65
66struct weston_surface {
67 struct {
68 int enabled;
69 } transform;
70
71 struct geometry *geometry;
72};
73
74static void
75weston_surface_to_global_float(struct weston_surface *surface,
76 GLfloat sx, GLfloat sy, GLfloat *x, GLfloat *y)
77{
78 struct geometry *g = surface->geometry;
79
80 /* pure rotation around origin by sine and cosine */
81 *x = g->c * sx + g->s * sy;
82 *y = -g->s * sx + g->c * sy;
83}
84
Pekka Paalanen8c492b12012-09-11 17:02:04 +030085#define max(a, b) (((a) > (b)) ? (a) : (b))
86#define min(a, b) (((a) > (b)) ? (b) : (a))
87#define clip(x, a, b) min(max(x, a), b)
Pekka Paalanen8c492b12012-09-11 17:02:04 +030088
Pekka Paalanen0d64a0f2012-09-11 17:02:05 +030089/*
90 * Compute the boundary vertices of the intersection of the global coordinate
91 * aligned rectangle 'rect', and an arbitrary quadrilateral produced from
92 * 'surf_rect' when transformed from surface coordinates into global coordinates.
93 * The vertices are written to 'ex' and 'ey', and the return value is the
94 * number of vertices. Vertices are produced in clockwise winding order.
95 * Guarantees to produce either zero vertices, or 3-8 vertices with non-zero
96 * polygon area.
97 */
Pekka Paalanen8c492b12012-09-11 17:02:04 +030098static int
99calculate_edges(struct weston_surface *es, pixman_box32_t *rect,
100 pixman_box32_t *surf_rect, GLfloat *ex, GLfloat *ey)
101{
Pekka Paalanen0d64a0f2012-09-11 17:02:05 +0300102 struct clip_context ctx;
Ondřej Majerech06e08922014-08-19 15:59:44 +0200103 int i;
Pekka Paalanen8c492b12012-09-11 17:02:04 +0300104 GLfloat min_x, max_x, min_y, max_y;
Pekka Paalanen0d64a0f2012-09-11 17:02:05 +0300105 struct polygon8 surf = {
106 { surf_rect->x1, surf_rect->x2, surf_rect->x2, surf_rect->x1 },
107 { surf_rect->y1, surf_rect->y1, surf_rect->y2, surf_rect->y2 },
108 4
Pekka Paalanen8c492b12012-09-11 17:02:04 +0300109 };
Pekka Paalanen8c492b12012-09-11 17:02:04 +0300110
Pekka Paalanen0d64a0f2012-09-11 17:02:05 +0300111 ctx.clip.x1 = rect->x1;
112 ctx.clip.y1 = rect->y1;
113 ctx.clip.x2 = rect->x2;
114 ctx.clip.y2 = rect->y2;
Pekka Paalanen8c492b12012-09-11 17:02:04 +0300115
116 /* transform surface to screen space: */
Pekka Paalanen0d64a0f2012-09-11 17:02:05 +0300117 for (i = 0; i < surf.n; i++)
118 weston_surface_to_global_float(es, surf.x[i], surf.y[i],
119 &surf.x[i], &surf.y[i]);
Pekka Paalanen8c492b12012-09-11 17:02:04 +0300120
121 /* find bounding box: */
Pekka Paalanen0d64a0f2012-09-11 17:02:05 +0300122 min_x = max_x = surf.x[0];
123 min_y = max_y = surf.y[0];
Pekka Paalanen8c492b12012-09-11 17:02:04 +0300124
Pekka Paalanen0d64a0f2012-09-11 17:02:05 +0300125 for (i = 1; i < surf.n; i++) {
126 min_x = min(min_x, surf.x[i]);
127 max_x = max(max_x, surf.x[i]);
128 min_y = min(min_y, surf.y[i]);
129 max_y = max(max_y, surf.y[i]);
Pekka Paalanen8c492b12012-09-11 17:02:04 +0300130 }
131
132 /* First, simple bounding box check to discard early transformed
133 * surface rects that do not intersect with the clip region:
134 */
Pekka Paalanen0d64a0f2012-09-11 17:02:05 +0300135 if ((min_x >= ctx.clip.x2) || (max_x <= ctx.clip.x1) ||
136 (min_y >= ctx.clip.y2) || (max_y <= ctx.clip.y1))
Pekka Paalanen8c492b12012-09-11 17:02:04 +0300137 return 0;
138
139 /* Simple case, bounding box edges are parallel to surface edges,
140 * there will be only four edges. We just need to clip the surface
141 * vertices to the clip rect bounds:
142 */
143 if (!es->transform.enabled) {
Pekka Paalanen0d64a0f2012-09-11 17:02:05 +0300144 for (i = 0; i < surf.n; i++) {
145 ex[i] = clip(surf.x[i], ctx.clip.x1, ctx.clip.x2);
146 ey[i] = clip(surf.y[i], ctx.clip.y1, ctx.clip.y2);
Pekka Paalanen8c492b12012-09-11 17:02:04 +0300147 }
Pekka Paalanen0d64a0f2012-09-11 17:02:05 +0300148 return surf.n;
Pekka Paalanen8c492b12012-09-11 17:02:04 +0300149 }
150
Pekka Paalanen0d64a0f2012-09-11 17:02:05 +0300151 /* Transformed case: use a general polygon clipping algorithm to
152 * clip the surface rectangle with each side of 'rect'.
153 * The algorithm is Sutherland-Hodgman, as explained in
154 * http://www.codeguru.com/cpp/misc/misc/graphics/article.php/c8965/Polygon-Clipping.htm
155 * but without looking at any of that code.
Pekka Paalanen8c492b12012-09-11 17:02:04 +0300156 */
Ondřej Majerech06e08922014-08-19 15:59:44 +0200157 return clip_transformed(&ctx, &surf, ex, ey);
Pekka Paalanen8c492b12012-09-11 17:02:04 +0300158}
159
Pekka Paalanen0d64a0f2012-09-11 17:02:05 +0300160
Pekka Paalanen8c492b12012-09-11 17:02:04 +0300161/* ---------------------- copied ends -----------------------*/
162
163static void
164geometry_set_phi(struct geometry *g, float phi)
165{
166 g->phi = phi;
167 g->s = sin(phi);
168 g->c = cos(phi);
169}
170
171static void
172geometry_init(struct geometry *g)
173{
174 g->clip.x1 = -50;
175 g->clip.y1 = -50;
176 g->clip.x2 = -10;
177 g->clip.y2 = -10;
178
179 g->surf.x1 = -20;
180 g->surf.y1 = -20;
181 g->surf.x2 = 20;
182 g->surf.y2 = 20;
183
184 geometry_set_phi(g, 0.0);
185}
186
187struct ui_state {
188 uint32_t button;
189 int down;
190
191 int down_pos[2];
192 struct geometry geometry;
193};
194
195struct cliptest {
196 struct window *window;
197 struct widget *widget;
198 struct display *display;
199 int fullscreen;
200
201 struct ui_state ui;
202
203 struct geometry geometry;
204 struct weston_surface surface;
205};
206
207static void
208draw_polygon_closed(cairo_t *cr, GLfloat *x, GLfloat *y, int n)
209{
210 int i;
211
212 cairo_move_to(cr, x[0], y[0]);
213 for (i = 1; i < n; i++)
214 cairo_line_to(cr, x[i], y[i]);
215 cairo_line_to(cr, x[0], y[0]);
216}
217
218static void
219draw_polygon_labels(cairo_t *cr, GLfloat *x, GLfloat *y, int n)
220{
221 char str[16];
222 int i;
223
224 for (i = 0; i < n; i++) {
225 snprintf(str, 16, "%d", i);
226 cairo_move_to(cr, x[i], y[i]);
227 cairo_show_text(cr, str);
228 }
229}
230
231static void
232draw_coordinates(cairo_t *cr, double ox, double oy, GLfloat *x, GLfloat *y, int n)
233{
234 char str[64];
235 int i;
236 cairo_font_extents_t ext;
237
238 cairo_font_extents(cr, &ext);
239 for (i = 0; i < n; i++) {
240 snprintf(str, 64, "%d: %14.9f, %14.9f", i, x[i], y[i]);
241 cairo_move_to(cr, ox, oy + ext.height * (i + 1));
242 cairo_show_text(cr, str);
243 }
244}
245
246static void
247draw_box(cairo_t *cr, pixman_box32_t *box, struct weston_surface *surface)
248{
249 GLfloat x[4], y[4];
250
251 if (surface) {
252 weston_surface_to_global_float(surface, box->x1, box->y1, &x[0], &y[0]);
253 weston_surface_to_global_float(surface, box->x2, box->y1, &x[1], &y[1]);
254 weston_surface_to_global_float(surface, box->x2, box->y2, &x[2], &y[2]);
255 weston_surface_to_global_float(surface, box->x1, box->y2, &x[3], &y[3]);
256 } else {
257 x[0] = box->x1; y[0] = box->y1;
258 x[1] = box->x2; y[1] = box->y1;
259 x[2] = box->x2; y[2] = box->y2;
260 x[3] = box->x1; y[3] = box->y2;
261 }
262
263 draw_polygon_closed(cr, x, y, 4);
264}
265
266static void
267draw_geometry(cairo_t *cr, struct weston_surface *surface,
268 GLfloat *ex, GLfloat *ey, int n)
269{
270 struct geometry *g = surface->geometry;
271 GLfloat cx, cy;
272
273 draw_box(cr, &g->surf, surface);
274 cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.4);
275 cairo_fill(cr);
276 weston_surface_to_global_float(surface, g->surf.x1 - 4, g->surf.y1 - 4, &cx, &cy);
277 cairo_arc(cr, cx, cy, 1.5, 0.0, 2.0 * M_PI);
278 if (surface->transform.enabled == 0)
279 cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.8);
280 cairo_fill(cr);
281
282 draw_box(cr, &g->clip, NULL);
283 cairo_set_source_rgba(cr, 0.0, 0.0, 1.0, 0.4);
284 cairo_fill(cr);
285
Derek Foremana0fae462014-08-18 16:13:41 -0500286 if (n) {
287 draw_polygon_closed(cr, ex, ey, n);
288 cairo_set_source_rgb(cr, 0.0, 1.0, 0.0);
289 cairo_stroke(cr);
Pekka Paalanen8c492b12012-09-11 17:02:04 +0300290
Derek Foremana0fae462014-08-18 16:13:41 -0500291 cairo_set_source_rgba(cr, 0.0, 1.0, 0.0, 0.5);
292 draw_polygon_labels(cr, ex, ey, n);
293 }
Pekka Paalanen8c492b12012-09-11 17:02:04 +0300294}
295
296static void
297redraw_handler(struct widget *widget, void *data)
298{
299 struct cliptest *cliptest = data;
300 struct geometry *g = cliptest->surface.geometry;
301 struct rectangle allocation;
302 cairo_t *cr;
303 cairo_surface_t *surface;
304 GLfloat ex[8];
305 GLfloat ey[8];
306 int n;
307
308 n = calculate_edges(&cliptest->surface, &g->clip, &g->surf, ex, ey);
309
310 widget_get_allocation(cliptest->widget, &allocation);
311
312 surface = window_get_surface(cliptest->window);
313 cr = cairo_create(surface);
314 widget_get_allocation(cliptest->widget, &allocation);
315 cairo_rectangle(cr, allocation.x, allocation.y,
316 allocation.width, allocation.height);
317 cairo_clip(cr);
318
319 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
320 cairo_set_source_rgba(cr, 0, 0, 0, 1);
321 cairo_paint(cr);
322
323 cairo_translate(cr, allocation.x, allocation.y);
324 cairo_set_line_width(cr, 1.0);
325 cairo_move_to(cr, allocation.width / 2.0, 0.0);
326 cairo_line_to(cr, allocation.width / 2.0, allocation.height);
327 cairo_move_to(cr, 0.0, allocation.height / 2.0);
328 cairo_line_to(cr, allocation.width, allocation.height / 2.0);
329 cairo_set_source_rgba(cr, 0.5, 0.5, 0.5, 1.0);
330 cairo_stroke(cr);
331
332 cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
333 cairo_push_group(cr);
334 cairo_translate(cr, allocation.width / 2.0,
335 allocation.height / 2.0);
336 cairo_scale(cr, 4.0, 4.0);
337 cairo_set_line_width(cr, 0.5);
338 cairo_set_line_join(cr, CAIRO_LINE_JOIN_BEVEL);
339 cairo_select_font_face(cr, "Sans", CAIRO_FONT_SLANT_NORMAL,
340 CAIRO_FONT_WEIGHT_BOLD);
341 cairo_set_font_size(cr, 5.0);
342 draw_geometry(cr, &cliptest->surface, ex, ey, n);
343 cairo_pop_group_to_source(cr);
344 cairo_paint(cr);
345
346 cairo_set_source_rgba(cr, 0.0, 1.0, 0.0, 1.0);
347 cairo_select_font_face(cr, "monospace", CAIRO_FONT_SLANT_NORMAL,
348 CAIRO_FONT_WEIGHT_NORMAL);
349 cairo_set_font_size(cr, 12.0);
350 draw_coordinates(cr, 10.0, 10.0, ex, ey, n);
351
352 cairo_destroy(cr);
353
354 cairo_surface_destroy(surface);
355}
356
357static int
358motion_handler(struct widget *widget, struct input *input,
359 uint32_t time, float x, float y, void *data)
360{
361 struct cliptest *cliptest = data;
362 struct ui_state *ui = &cliptest->ui;
363 struct geometry *ref = &ui->geometry;
364 struct geometry *geom = &cliptest->geometry;
365 float dx, dy;
366
367 if (!ui->down)
368 return CURSOR_LEFT_PTR;
369
370 dx = (x - ui->down_pos[0]) * 0.25;
371 dy = (y - ui->down_pos[1]) * 0.25;
372
373 switch (ui->button) {
374 case BTN_LEFT:
375 geom->clip.x1 = ref->clip.x1 + dx;
376 geom->clip.y1 = ref->clip.y1 + dy;
377 /* fall through */
378 case BTN_RIGHT:
379 geom->clip.x2 = ref->clip.x2 + dx;
380 geom->clip.y2 = ref->clip.y2 + dy;
381 break;
382 default:
383 return CURSOR_LEFT_PTR;
384 }
385
386 widget_schedule_redraw(cliptest->widget);
387 return CURSOR_BLANK;
388}
389
390static void
391button_handler(struct widget *widget, struct input *input,
392 uint32_t time, uint32_t button,
393 enum wl_pointer_button_state state, void *data)
394{
395 struct cliptest *cliptest = data;
396 struct ui_state *ui = &cliptest->ui;
397
398 ui->button = button;
399
400 if (state == WL_POINTER_BUTTON_STATE_PRESSED) {
401 ui->down = 1;
402 input_get_position(input, &ui->down_pos[0], &ui->down_pos[1]);
403 } else {
404 ui->down = 0;
405 ui->geometry = cliptest->geometry;
406 }
407}
408
409static void
410axis_handler(struct widget *widget, struct input *input, uint32_t time,
411 uint32_t axis, wl_fixed_t value, void *data)
412{
413 struct cliptest *cliptest = data;
414 struct geometry *geom = &cliptest->geometry;
415
416 if (axis != WL_POINTER_AXIS_VERTICAL_SCROLL)
417 return;
418
419 geometry_set_phi(geom, geom->phi +
420 (M_PI / 12.0) * wl_fixed_to_double(value));
421 cliptest->surface.transform.enabled = 1;
422
423 widget_schedule_redraw(cliptest->widget);
424}
425
426static void
427key_handler(struct window *window, struct input *input, uint32_t time,
428 uint32_t key, uint32_t sym,
429 enum wl_keyboard_key_state state, void *data)
430{
431 struct cliptest *cliptest = data;
432 struct geometry *g = &cliptest->geometry;
433
434 if (state == WL_KEYBOARD_KEY_STATE_RELEASED)
435 return;
436
437 switch (sym) {
438 case XKB_KEY_Escape:
439 display_exit(cliptest->display);
440 return;
441 case XKB_KEY_w:
442 g->clip.y1 -= 1;
443 g->clip.y2 -= 1;
444 break;
445 case XKB_KEY_a:
446 g->clip.x1 -= 1;
447 g->clip.x2 -= 1;
448 break;
449 case XKB_KEY_s:
450 g->clip.y1 += 1;
451 g->clip.y2 += 1;
452 break;
453 case XKB_KEY_d:
454 g->clip.x1 += 1;
455 g->clip.x2 += 1;
456 break;
457 case XKB_KEY_i:
458 g->clip.y2 -= 1;
459 break;
460 case XKB_KEY_j:
461 g->clip.x2 -= 1;
462 break;
463 case XKB_KEY_k:
464 g->clip.y2 += 1;
465 break;
466 case XKB_KEY_l:
467 g->clip.x2 += 1;
468 break;
469 case XKB_KEY_n:
470 geometry_set_phi(g, g->phi + (M_PI / 24.0));
471 cliptest->surface.transform.enabled = 1;
472 break;
473 case XKB_KEY_m:
474 geometry_set_phi(g, g->phi - (M_PI / 24.0));
475 cliptest->surface.transform.enabled = 1;
476 break;
477 case XKB_KEY_r:
478 geometry_set_phi(g, 0.0);
479 cliptest->surface.transform.enabled = 0;
480 break;
481 default:
482 return;
483 }
484
485 widget_schedule_redraw(cliptest->widget);
486}
487
488static void
489keyboard_focus_handler(struct window *window,
490 struct input *device, void *data)
491{
492 struct cliptest *cliptest = data;
493
494 window_schedule_redraw(cliptest->window);
495}
496
497static void
498fullscreen_handler(struct window *window, void *data)
499{
500 struct cliptest *cliptest = data;
501
502 cliptest->fullscreen ^= 1;
503 window_set_fullscreen(window, cliptest->fullscreen);
504}
505
506static struct cliptest *
507cliptest_create(struct display *display)
508{
509 struct cliptest *cliptest;
510
Peter Huttererf3d62272013-08-08 11:57:05 +1000511 cliptest = xzalloc(sizeof *cliptest);
Pekka Paalanen8c492b12012-09-11 17:02:04 +0300512 cliptest->surface.geometry = &cliptest->geometry;
513 cliptest->surface.transform.enabled = 0;
514 geometry_init(&cliptest->geometry);
515 geometry_init(&cliptest->ui.geometry);
516
517 cliptest->window = window_create(display);
Jason Ekstrandee7fefc2013-10-13 19:08:38 -0500518 cliptest->widget = window_frame_create(cliptest->window, cliptest);
Pekka Paalanen8c492b12012-09-11 17:02:04 +0300519 window_set_title(cliptest->window, "cliptest");
520 cliptest->display = display;
521
522 window_set_user_data(cliptest->window, cliptest);
523 widget_set_redraw_handler(cliptest->widget, redraw_handler);
524 widget_set_button_handler(cliptest->widget, button_handler);
525 widget_set_motion_handler(cliptest->widget, motion_handler);
526 widget_set_axis_handler(cliptest->widget, axis_handler);
527
528 window_set_keyboard_focus_handler(cliptest->window,
529 keyboard_focus_handler);
530 window_set_key_handler(cliptest->window, key_handler);
531 window_set_fullscreen_handler(cliptest->window, fullscreen_handler);
532
533 /* set minimum size */
534 widget_schedule_resize(cliptest->widget, 200, 100);
535
536 /* set current size */
537 widget_schedule_resize(cliptest->widget, 500, 400);
538
539 return cliptest;
540}
541
542static struct timespec begin_time;
543
544static void
545reset_timer(void)
546{
547 clock_gettime(CLOCK_MONOTONIC, &begin_time);
548}
549
550static double
551read_timer(void)
552{
553 struct timespec t;
554
555 clock_gettime(CLOCK_MONOTONIC, &t);
556 return (double)(t.tv_sec - begin_time.tv_sec) +
557 1e-9 * (t.tv_nsec - begin_time.tv_nsec);
558}
559
560static int
561benchmark(void)
562{
563 struct weston_surface surface;
564 struct geometry geom;
565 GLfloat ex[8], ey[8];
566 int i;
567 double t;
568 const int N = 1000000;
569
570 geom.clip.x1 = -19;
571 geom.clip.y1 = -19;
572 geom.clip.x2 = 19;
573 geom.clip.y2 = 19;
574
575 geom.surf.x1 = -20;
576 geom.surf.y1 = -20;
577 geom.surf.x2 = 20;
578 geom.surf.y2 = 20;
579
580 geometry_set_phi(&geom, 0.0);
581
582 surface.transform.enabled = 1;
583 surface.geometry = &geom;
584
585 reset_timer();
586 for (i = 0; i < N; i++) {
587 geometry_set_phi(&geom, (float)i / 360.0f);
588 calculate_edges(&surface, &geom.clip, &geom.surf, ex, ey);
589 }
590 t = read_timer();
591
592 printf("%d calls took %g s, average %g us/call\n", N, t, t / N * 1e6);
593
594 return 0;
595}
596
vivek31732f72014-05-15 18:58:16 +0530597static void
598cliptest_destroy(struct cliptest *cliptest)
599{
600 widget_destroy(cliptest->widget);
601 window_destroy(cliptest->window);
602 free(cliptest);
603}
604
Pekka Paalanen8c492b12012-09-11 17:02:04 +0300605int
606main(int argc, char *argv[])
607{
608 struct display *d;
609 struct cliptest *cliptest;
610
Bill Spitzak36bcf472014-08-08 12:59:56 -0700611 if (argc > 1) {
612 if (argc == 2 && !strcmp(argv[1], "-b"))
613 return benchmark();
614 printf("Usage: %s [OPTIONS]\n -b run benchmark\n", argv[0]);
615 return 1;
616 }
Pekka Paalanen8c492b12012-09-11 17:02:04 +0300617
Kristian Høgsberg4172f662013-02-20 15:27:49 -0500618 d = display_create(&argc, argv);
Pekka Paalanen8c492b12012-09-11 17:02:04 +0300619 if (d == NULL) {
620 fprintf(stderr, "failed to create display: %m\n");
621 return -1;
622 }
623
624 cliptest = cliptest_create(d);
625 display_run(d);
626
vivek31732f72014-05-15 18:58:16 +0530627 cliptest_destroy(cliptest);
628 display_destroy(d);
Pekka Paalanen8c492b12012-09-11 17:02:04 +0300629
630 return 0;
631}