From 5b113d323dde18ef3bbae2f57d613be4ab7eb267 Mon Sep 17 00:00:00 2001 From: Ville Syrjälä Date: Thu, 17 Dec 2015 01:39:31 +0200 Subject: lib: Extract some common fb create+fill methods into helpers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Several tests do one or more of the following: * igt_create_fb() + igt_paint_test_pattern() * igt_create_color_fb() + igt_paint_test_pattern() * igt_create_fb() + igt_paint_image() Extract them into new helpers: igt_create_pattern_fb(), igt_create_color_pattern_fb(), igt_create_image_fb(). v2: Fix typos, and improve API docs (Thomas) Signed-off-by: Ville Syrjälä --- tests/kms_atomic.c | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) (limited to 'tests/kms_atomic.c') diff --git a/tests/kms_atomic.c b/tests/kms_atomic.c index 7006e5ea..501093cc 100644 --- a/tests/kms_atomic.c +++ b/tests/kms_atomic.c @@ -867,7 +867,6 @@ static void plane_overlay(struct kms_atomic_crtc_state *crtc, uint32_t format = plane_get_igt_format(&plane); drmModeAtomicReq *req = drmModeAtomicAlloc(); struct igt_fb fb; - cairo_t *cr; igt_require(req); igt_require(format != 0); @@ -881,12 +880,9 @@ static void plane_overlay(struct kms_atomic_crtc_state *crtc, plane.crtc_w = mode->hdisplay / 2; plane.crtc_h = mode->vdisplay / 2; plane.crtc_id = crtc->obj; - plane.fb_id = igt_create_fb(plane.state->desc->fd, - plane.crtc_w, plane.crtc_h, - format, I915_TILING_NONE, &fb); - - cr = igt_get_cairo_ctx(plane.state->desc->fd, &fb); - igt_paint_test_pattern(cr, plane.crtc_w, plane.crtc_h); + plane.fb_id = igt_create_pattern_fb(plane.state->desc->fd, + plane.crtc_w, plane.crtc_h, + format, I915_TILING_NONE, &fb); /* Enable the overlay plane using the atomic API, and double-check * state is what we think it should be. */ @@ -916,7 +912,6 @@ static void plane_primary(struct kms_atomic_crtc_state *crtc, uint32_t *connectors; int num_connectors; struct igt_fb fb; - cairo_t *cr; int i; connectors = calloc(crtc->state->num_connectors, sizeof(*connectors)); @@ -939,12 +934,9 @@ static void plane_primary(struct kms_atomic_crtc_state *crtc, plane.crtc_w = mode->hdisplay; plane.crtc_h = mode->vdisplay; plane.crtc_id = crtc->obj; - plane.fb_id = igt_create_fb(plane.state->desc->fd, - plane.crtc_w, plane.crtc_h, - format, I915_TILING_NONE, &fb); - - cr = igt_get_cairo_ctx(plane.state->desc->fd, &fb); - igt_paint_test_pattern(cr, plane.crtc_w, plane.crtc_h); + plane.fb_id = igt_create_pattern_fb(plane.state->desc->fd, + plane.crtc_w, plane.crtc_h, + format, I915_TILING_NONE, &fb); /* Flip the primary plane using the atomic API, and double-check * state is what we think it should be. */ @@ -1044,7 +1036,6 @@ static void plane_invalid_params(struct kms_atomic_crtc_state *crtc, uint32_t format = plane_get_igt_format(&plane); drmModeAtomicReq *req = drmModeAtomicAlloc(); struct igt_fb fb; - cairo_t *cr; /* Pass a series of invalid object IDs for the FB ID. */ plane.fb_id = plane.obj; @@ -1098,12 +1089,9 @@ static void plane_invalid_params(struct kms_atomic_crtc_state *crtc, plane.crtc_w = mode->hdisplay; plane.crtc_h = mode->vdisplay; plane.crtc_id = crtc->obj; - plane.fb_id = igt_create_fb(plane.state->desc->fd, - plane.crtc_w - 1, plane.crtc_h - 1, - format, I915_TILING_NONE, &fb); - - cr = igt_get_cairo_ctx(plane.state->desc->fd, &fb); - igt_paint_test_pattern(cr, plane.crtc_w - 1, plane.crtc_h - 1); + plane.fb_id = igt_create_pattern_fb(plane.state->desc->fd, + plane.crtc_w - 1, plane.crtc_h - 1, + format, I915_TILING_NONE, &fb); plane_commit_atomic_err(&plane, plane_old, req, ATOMIC_RELAX_NONE, ENOSPC); -- cgit v1.2.3