5 #include <X11/Xutil.h> /* for XDestroyImage */
6 #include <pixman.h> /* for pixman blt functions */
10 static const XPoint points[]= {
47 { 0, 0} /* and origin again for luck */
49 #define NUM_POINTS (sizeof(points)/sizeof(points[0]))
51 static void clear(struct test_display *dpy, struct test_target *tt)
53 XRenderColor render_color = {0};
54 XRenderFillRectangle(dpy->dpy, PictOpClear, tt->picture, &render_color,
55 0, 0, tt->width, tt->height);
58 static void draw_line(struct test_display *dpy, struct test_target *tt,
59 int alu, int width, int style, int cap,
60 const XPoint *p1, const XPoint *p2,
66 val.function = GXcopy;
67 val.foreground = WhitePixel(dpy->dpy, 0);
68 val.line_width = width;
69 val.line_style = style;
72 gc = XCreateGC(dpy->dpy, tt->draw,
79 XDrawLine(dpy->dpy, tt->draw, gc,
80 p1->x + dx, p1->y + dy,
81 p2->x + dx, p2->y + dy);
82 XFreeGC(dpy->dpy, gc);
85 static void line_tests(struct test *t, enum target target)
88 struct test_target real, ref;
89 int a, b, alu, lw, style, cap;
91 printf("Testing drawing of single line segments (%s): ",
92 test_target_name(target));
95 test_target_create_render(&t->real, target, &real);
96 test_target_create_render(&t->ref, target, &ref);
100 for (alu = 0; alu < 16; alu++) {
101 for (cap = CapNotLast; cap <= CapProjecting; cap++) {
102 for (lw = 0; lw <= 4; lw++) {
103 for (a = 0; a < NUM_POINTS; a++) {
104 for (b = 0; b < NUM_POINTS; b++) {
106 "p1=(%d, %d), p2=(%d, %d), width=%d, cap=%d, alu=%d",
107 points[a].x, points[a].y,
108 points[b].x, points[b].y,
111 clear(&t->real, &real);
112 clear(&t->ref, &ref);
114 draw_line(&t->real, &real, alu, lw, style, cap,
115 &points[a], &points[b], 64, 64);
116 draw_line(&t->ref, &ref, alu, lw, style, cap,
117 &points[a], &points[b], 64, 64);
120 real.draw, real.format,
121 ref.draw, ref.format,
122 0, 0, real.width, real.height,
130 test_target_destroy_render(&t->real, &real);
131 test_target_destroy_render(&t->ref, &ref);
136 int main(int argc, char **argv)
141 test_init(&test, argc, argv);
143 for (t = TARGET_FIRST; t <= TARGET_LAST; t++)
144 line_tests(&test, t);