Eliminate xcb_change_gc_single everywhere with C99

This commit is contained in:
Michael Stapelberg
2011-10-23 18:06:25 +01:00
parent 9eda7fb6fb
commit 6dc6ba11fc
5 changed files with 12 additions and 29 deletions

View File

@ -108,23 +108,15 @@ xcb_window_t create_window(xcb_connection_t *conn, Rect dims, uint16_t window_cl
return result;
}
/*
* Changes a single value in the graphic context (so one doesnt have to define an array of values)
*
*/
void xcb_change_gc_single(xcb_connection_t *conn, xcb_gcontext_t gc, uint32_t mask, uint32_t value) {
xcb_change_gc(conn, gc, mask, &value);
}
/*
* Draws a line from x,y to to_x,to_y using the given color
*
*/
void xcb_draw_line(xcb_connection_t *conn, xcb_drawable_t drawable, xcb_gcontext_t gc,
uint32_t colorpixel, uint32_t x, uint32_t y, uint32_t to_x, uint32_t to_y) {
xcb_change_gc_single(conn, gc, XCB_GC_FOREGROUND, colorpixel);
xcb_point_t points[] = {{x, y}, {to_x, to_y}};
xcb_poly_line(conn, XCB_COORD_MODE_ORIGIN, drawable, gc, 2, points);
xcb_change_gc(conn, gc, XCB_GC_FOREGROUND, (uint32_t[]){ colorpixel });
xcb_poly_line(conn, XCB_COORD_MODE_ORIGIN, drawable, gc, 2,
(xcb_point_t[]) { {x, y}, {to_x, to_y} });
}
/*
@ -133,7 +125,7 @@ void xcb_draw_line(xcb_connection_t *conn, xcb_drawable_t drawable, xcb_gcontext
*/
void xcb_draw_rect(xcb_connection_t *conn, xcb_drawable_t drawable, xcb_gcontext_t gc,
uint32_t colorpixel, uint32_t x, uint32_t y, uint32_t width, uint32_t height) {
xcb_change_gc_single(conn, gc, XCB_GC_FOREGROUND, colorpixel);
xcb_change_gc(conn, gc, XCB_GC_FOREGROUND, (uint32_t[]){ colorpixel });
xcb_rectangle_t rect = {x, y, width, height};
xcb_poly_fill_rectangle(conn, drawable, gc, 1, &rect);
}