lib: refactor kmstest_create_fb

Factor out parts that will be used by an upcoming patch adding
kmstest_create_fb2.

Also call the fb paint functions directly, there is not much
point in passing a function pointer for that.

Signed-off-by: Imre Deak <imre.deak@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@gmail.com>
This commit is contained in:
Imre Deak
2013-05-24 17:26:54 +03:00
parent bfb0cdd668
commit f68d964c57
4 changed files with 153 additions and 95 deletions
+10 -5
View File
@@ -258,15 +258,18 @@ static void paint_image(cairo_t *cr, const char *file)
cairo_surface_destroy(image);
}
static void
paint_output_info(cairo_t *cr, int l_width, int l_height, void *priv)
static void paint_output_info(struct connector *c, struct kmstest_fb *fb)
{
struct connector *c = priv;
cairo_t *cr = kmstest_get_cairo_ctx(drm_fd, fb);
int l_width = fb->width;
int l_height = fb->height;
double str_width;
double x, y, top_y;
double max_width;
int i;
kmstest_paint_test_pattern(cr, l_width, l_height);
cairo_select_font_face(cr, "Helvetica",
CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_NORMAL);
@@ -308,6 +311,8 @@ paint_output_info(cairo_t *cr, int l_width, int l_height, void *priv)
if (qr_code)
paint_image(cr, "./pass.png");
assert(!cairo_status(cr));
}
static void sighandler(int signo)
@@ -362,8 +367,8 @@ set_mode(struct connector *c)
height = c->mode.vdisplay;
fb_id = kmstest_create_fb(drm_fd, width, height, bpp, depth,
enable_tiling, &fb_info,
paint_output_info, c);
enable_tiling, &fb_info);
paint_output_info(c, &fb_info);
fb_ptr = gem_mmap(drm_fd, fb_info.gem_handle,
fb_info.size, PROT_READ | PROT_WRITE);