From: Ville Syrjälä <ville.syrj...@linux.intel.com>

Several tests do one or more of the followin:
* 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 helpes: igt_create_pattern_fb(),
igt_create_color_pattern_fb(), igt_create_image_fb().

Signed-off-by: Ville Syrjälä <ville.syrj...@linux.intel.com>
---
 lib/igt_fb.c              | 124 ++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_fb.h              |  11 ++++
 tests/kms_atomic.c        |  30 ++++-------
 tests/kms_flip_tiling.c   |  25 +++-------
 tests/kms_panel_fitting.c |  42 ++++------------
 tests/kms_plane_scaling.c |  60 ++++++----------------
 tests/kms_pwrite_crc.c    |   9 +---
 tests/kms_setmode.c       |  11 ++--
 tests/pm_lpsp.c           |  11 +---
 tests/pm_rpm.c            |  10 ++--
 tests/testdisplay.c       |   8 ++-
 11 files changed, 188 insertions(+), 153 deletions(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 3ea9915c42c4..b3c7840a22ae 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -537,6 +537,130 @@ unsigned int igt_create_color_fb(int fd, int width, int 
height,
        return fb_id;
 }
 
+/**
+ * igt_create_pattern_fb:
+ * @fd: open i915 drm file descriptor
+ * @width: width of the framebuffer in pixel
+ * @height: height of the framebuffer in pixel
+ * @format: drm fourcc pixel format code
+ * @tiling: tiling layout of the framebuffer
+ * @fb: pointer to an #igt_fb structure
+ *
+ * This function allocates a gem buffer object suitable to back a framebuffer
+ * with the requested properties and then wraps it up in a drm framebuffer
+ * object. All metadata is stored in @fb.
+ *
+ * Compared to igt_create_fb() this function also fills the entire framebuffer
+ * with the test pattern.
+ *
+ * Returns:
+ * The kms id of the created framebuffer on success or a negative error code on
+ * failure.
+ */
+unsigned int igt_create_pattern_fb(int fd, int width, int height,
+                                  uint32_t format, uint64_t tiling,
+                                  struct igt_fb *fb /* out */)
+{
+       unsigned int fb_id;
+       cairo_t *cr;
+
+       fb_id = igt_create_fb(fd, width, height, format, tiling, fb);
+       igt_assert(fb_id);
+
+       cr = igt_get_cairo_ctx(fd, fb);
+       igt_paint_test_pattern(cr, width, height);
+       igt_assert(cairo_status(cr) == 0);
+       cairo_destroy(cr);
+
+       return fb_id;
+}
+
+/**
+ * igt_create_pattern_fb:
+ * @fd: open i915 drm file descriptor
+ * @width: width of the framebuffer in pixel
+ * @height: height of the framebuffer in pixel
+ * @format: drm fourcc pixel format code
+ * @tiling: tiling layout of the framebuffer
+ * @r: red value to use as fill color
+ * @g: gree value to use as fill color
+ * @b: blue value to use as fill color
+ * @fb: pointer to an #igt_fb structure
+ *
+ * This function allocates a gem buffer object suitable to back a framebuffer
+ * with the requested properties and then wraps it up in a drm framebuffer
+ * object. All metadata is stored in @fb.
+ *
+ * Compared to igt_create_fb() this function also fills the entire framebuffer
+ * with the test pattern.
+ *
+ * Returns:
+ * The kms id of the created framebuffer on success or a negative error code on
+ * failure.
+ */
+unsigned int igt_create_color_pattern_fb(int fd, int width, int height,
+                                        uint32_t format, uint64_t tiling,
+                                        double r, double g, double b,
+                                        struct igt_fb *fb /* out */)
+{
+       unsigned int fb_id;
+       cairo_t *cr;
+
+       fb_id = igt_create_fb(fd, width, height, format, tiling, fb);
+       igt_assert(fb_id);
+
+       cr = igt_get_cairo_ctx(fd, fb);
+       igt_paint_color(cr, 0, 0, width, height, r, g, b);
+       igt_paint_test_pattern(cr, width, height);
+       igt_assert(cairo_status(cr) == 0);
+       cairo_destroy(cr);
+
+       return fb_id;
+}
+
+/**
+ * igt_create_image_fb:
+ * @drm_fd: open i915 drm file descriptor
+ * @width: width of the framebuffer in pixel or 0
+ * @height: height of the framebuffer in pixel or 0
+ * @format: drm fourcc pixel format code
+ * @tiling: tiling layout of the framebuffer
+ * @filename: filename of the png image to draw
+ *
+ * Create a framebuffer with the specified image. If @width is zero the
+ * image width will be used. If @height is zero the image height will be used.
+ *
+ * Returns:
+ * The kms id of the created framebuffer on success or a negative error code on
+ * failure.
+ */
+unsigned int igt_create_image_fb(int fd, int width, int height,
+                                uint32_t format, uint64_t tiling,
+                                const char *filename,
+                                struct igt_fb *fb /* out */)
+{
+       cairo_surface_t *image;
+       uint32_t fb_id;
+       cairo_t *cr;
+
+       image = cairo_image_surface_create_from_png(filename);
+       igt_assert(cairo_surface_status(image) == CAIRO_STATUS_SUCCESS);
+       if (width == 0)
+               width = cairo_image_surface_get_width(image);
+       if (height == 0)
+               height = cairo_image_surface_get_height(image);
+       cairo_surface_destroy(image);
+
+       fb_id = igt_create_fb(fd, width, height, format, tiling, fb);
+
+       cr = igt_get_cairo_ctx(fd, fb);
+       igt_paint_image(cr, filename, 0, 0, width, height);
+       igt_assert(cairo_status(cr) == 0);
+       cairo_destroy(cr);
+
+       return fb_id;
+}
+
 struct box {
        int x, y, width, height;
 };
diff --git a/lib/igt_fb.h b/lib/igt_fb.h
index 37892b50d495..5cc8644d01d4 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -80,6 +80,17 @@ unsigned int igt_create_color_fb(int fd, int width, int 
height,
                                 uint32_t format, uint64_t tiling,
                                 double r, double g, double b,
                                 struct igt_fb *fb /* out */);
+unsigned int igt_create_pattern_fb(int fd, int width, int height,
+                                  uint32_t format, uint64_t tiling,
+                                  struct igt_fb *fb /* out */);
+unsigned int igt_create_color_pattern_fb(int fd, int width, int height,
+                                        uint32_t format, uint64_t tiling,
+                                        double r, double g, double b,
+                                        struct igt_fb *fb /* out */);
+unsigned int igt_create_image_fb(int drm_fd,  int width, int height,
+                                uint32_t format, uint64_t tiling,
+                                const char *filename,
+                                struct igt_fb *fb /* out */);
 unsigned int igt_create_stereo_fb(int drm_fd, drmModeModeInfo *mode,
                                  uint32_t format, uint64_t tiling);
 void igt_remove_fb(int fd, struct igt_fb *fb);
diff --git a/tests/kms_atomic.c b/tests/kms_atomic.c
index 7006e5eae411..501093cc3962 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);
diff --git a/tests/kms_flip_tiling.c b/tests/kms_flip_tiling.c
index 653a9706a700..4f7334de65fe 100644
--- a/tests/kms_flip_tiling.c
+++ b/tests/kms_flip_tiling.c
@@ -39,16 +39,6 @@ typedef struct {
        int gen;
 } data_t;
 
-static void
-fill_fb(struct igt_fb *fb, data_t *data, drmModeModeInfo *mode)
-{
-       cairo_t *cr;
-
-       cr = igt_get_cairo_ctx(data->drm_fd, fb);
-       igt_paint_test_pattern(cr, mode->hdisplay, mode->vdisplay);
-       cairo_destroy(cr);
-}
-
 static igt_pipe_crc_t *_pipe_crc;
 
 static igt_pipe_crc_t *pipe_crc_new(int pipe)
@@ -121,20 +111,17 @@ test_flip_tiling(data_t *data, igt_output_t *output, 
uint64_t tiling[2])
                        width *= 2;
        }
 
-       fb_id = igt_create_fb(data->drm_fd, width, mode->vdisplay,
-                             DRM_FORMAT_XRGB8888, tiling[0],
-                             &fb[0]);
+       fb_id = igt_create_pattern_fb(data->drm_fd, width, mode->vdisplay,
+                                     DRM_FORMAT_XRGB8888, tiling[0],
+                                     &fb[0]);
        igt_assert(fb_id);
 
        /* Second fb has different background so CRC does not match. */
-       fb_id = igt_create_color_fb(data->drm_fd, width, mode->vdisplay,
-                                   DRM_FORMAT_XRGB8888, tiling[1],
-                                   0.5, 0.5, 0.5, &fb[1]);
+       fb_id = igt_create_color_pattern_fb(data->drm_fd, width, mode->vdisplay,
+                                     DRM_FORMAT_XRGB8888, tiling[1],
+                                     0.5, 0.5, 0.5, &fb[1]);
        igt_assert(fb_id);
 
-       fill_fb(&fb[0], data, mode);
-       fill_fb(&fb[1], data, mode);
-
        /* Set the crtc and generate a reference CRC. */
        igt_plane_set_fb(primary, &fb[1]);
        igt_display_commit(&data->display);
diff --git a/tests/kms_panel_fitting.c b/tests/kms_panel_fitting.c
index f8726e277c9d..829d9cdd0631 100644
--- a/tests/kms_panel_fitting.c
+++ b/tests/kms_panel_fitting.c
@@ -53,26 +53,6 @@ typedef struct {
 
 #define FILE_NAME   "1080p-left.png"
 
-static void
-paint_color(data_t *d, struct igt_fb *fb, uint16_t w, uint16_t h)
-{
-       cairo_t *cr;
-
-       cr = igt_get_cairo_ctx(d->drm_fd, fb);
-       igt_paint_test_pattern(cr, w, h);
-       cairo_destroy(cr);
-}
-
-static void
-paint_image(data_t *d, struct igt_fb *fb, uint16_t w, uint16_t h)
-{
-       cairo_t *cr;
-
-       cr = igt_get_cairo_ctx(d->drm_fd, fb);
-       igt_paint_image(cr, FILE_NAME, 0, 0, w, h);
-       cairo_destroy(cr);
-}
-
 static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
                        igt_plane_t *plane, drmModeModeInfo *mode, enum 
igt_commit_style s)
 {
@@ -91,15 +71,13 @@ static void prepare_crtc(data_t *data, igt_output_t 
*output, enum pipe pipe,
        }
 
        /* allocate fb for plane 1 */
-       data->fb_id1 = igt_create_fb(data->drm_fd,
-                       mode->hdisplay, mode->vdisplay,
-                       DRM_FORMAT_XRGB8888,
-                       LOCAL_I915_FORMAT_MOD_X_TILED, /* tiled */
-                       &data->fb1);
+       data->fb_id1 = igt_create_pattern_fb(data->drm_fd,
+                                            mode->hdisplay, mode->vdisplay,
+                                            DRM_FORMAT_XRGB8888,
+                                            LOCAL_I915_FORMAT_MOD_X_TILED, /* 
tiled */
+                                            &data->fb1);
        igt_assert(data->fb_id1);
 
-       paint_color(data, &data->fb1, mode->hdisplay, mode->vdisplay);
-
        /*
         * We always set the primary plane to actually enable the pipe as
         * there's no way (that works) to light up a pipe with only a sprite
@@ -188,13 +166,11 @@ static void test_panel_fitting(data_t *d)
                d->image_h = cairo_image_surface_get_height(image);
                cairo_surface_destroy(image);
 
-               d->fb_id2 = igt_create_fb(d->drm_fd,
-                               d->image_w, d->image_h,
-                               DRM_FORMAT_XRGB8888,
-                               LOCAL_I915_FORMAT_MOD_X_TILED, /* tiled */
-                               &d->fb2);
+               d->fb_id2 = igt_create_image_fb(d->drm_fd, 0, 0,
+                                               DRM_FORMAT_XRGB8888,
+                                               LOCAL_I915_FORMAT_MOD_X_TILED, 
/* tiled */
+                                               FILE_NAME, &d->fb2);
                igt_assert(d->fb_id2);
-               paint_image(d, &d->fb2, d->fb2.width, d->fb2.height);
 
                /* Set up display to enable panel fitting */
                mode->hdisplay = 640;
diff --git a/tests/kms_plane_scaling.c b/tests/kms_plane_scaling.c
index 74bc6f8c148e..ad5404d90bfa 100644
--- a/tests/kms_plane_scaling.c
+++ b/tests/kms_plane_scaling.c
@@ -55,26 +55,6 @@ typedef struct {
 
 #define FILE_NAME   "1080p-left.png"
 
-static void
-paint_color(data_t *d, struct igt_fb *fb, uint16_t w, uint16_t h)
-{
-       cairo_t *cr;
-
-       cr = igt_get_cairo_ctx(d->drm_fd, fb);
-       igt_paint_test_pattern(cr, w, h);
-       cairo_destroy(cr);
-}
-
-static void
-paint_image(data_t *d, struct igt_fb *fb, uint16_t w, uint16_t h)
-{
-       cairo_t *cr;
-
-       cr = igt_get_cairo_ctx(d->drm_fd, fb);
-       igt_paint_image(cr, FILE_NAME, 0, 0, w, h);
-       cairo_destroy(cr);
-}
-
 static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
                        igt_plane_t *plane, drmModeModeInfo *mode, enum 
igt_commit_style s)
 {
@@ -93,15 +73,13 @@ static void prepare_crtc(data_t *data, igt_output_t 
*output, enum pipe pipe,
        }
 
        /* allocate fb for plane 1 */
-       data->fb_id1 = igt_create_fb(data->drm_fd,
-                       mode->hdisplay, mode->vdisplay,
-                       DRM_FORMAT_XRGB8888,
-                       LOCAL_I915_FORMAT_MOD_X_TILED, /* tiled */
-                       &data->fb1);
+       data->fb_id1 = igt_create_pattern_fb(data->drm_fd,
+                                            mode->hdisplay, mode->vdisplay,
+                                            DRM_FORMAT_XRGB8888,
+                                            LOCAL_I915_FORMAT_MOD_X_TILED, /* 
tiled */
+                                            &data->fb1);
        igt_assert(data->fb_id1);
 
-       paint_color(data, &data->fb1, mode->hdisplay, mode->vdisplay);
-
        /*
         * We always set the primary plane to actually enable the pipe as
         * there's no way (that works) to light up a pipe with only a sprite
@@ -201,7 +179,6 @@ static void test_plane_scaling(data_t *d)
 {
        igt_display_t *display = &d->display;
        igt_output_t *output;
-       cairo_surface_t *image;
        enum pipe pipe;
        int valid_tests = 0;
        int primary_plane_scaling = 0; /* For now */
@@ -218,27 +195,18 @@ static void test_plane_scaling(data_t *d)
                mode = igt_output_get_mode(output);
 
                /* allocate fb2 with image size */
-               image = cairo_image_surface_create_from_png(FILE_NAME);
-               igt_assert(cairo_surface_status(image) == CAIRO_STATUS_SUCCESS);
-               d->image_w = cairo_image_surface_get_width(image);
-               d->image_h = cairo_image_surface_get_height(image);
-               cairo_surface_destroy(image);
-
-               d->fb_id2 = igt_create_fb(d->drm_fd,
-                               d->image_w, d->image_h,
-                               DRM_FORMAT_XRGB8888,
-                               LOCAL_I915_FORMAT_MOD_X_TILED, /* tiled */
-                               &d->fb2);
+               d->fb_id2 = igt_create_image_fb(d->drm_fd, 0, 0,
+                                               DRM_FORMAT_XRGB8888,
+                                               LOCAL_I915_FORMAT_MOD_X_TILED, 
/* tiled */
+                                               FILE_NAME, &d->fb2);
                igt_assert(d->fb_id2);
-               paint_image(d, &d->fb2, d->fb2.width, d->fb2.height);
 
-               d->fb_id3 = igt_create_fb(d->drm_fd,
-                               mode->hdisplay, mode->vdisplay,
-                               DRM_FORMAT_XRGB8888,
-                               LOCAL_I915_FORMAT_MOD_X_TILED, /* tiled */
-                               &d->fb3);
+               d->fb_id3 = igt_create_pattern_fb(d->drm_fd,
+                                                 mode->hdisplay, 
mode->vdisplay,
+                                                 DRM_FORMAT_XRGB8888,
+                                                 
LOCAL_I915_FORMAT_MOD_X_TILED, /* tiled */
+                                                 &d->fb3);
                igt_assert(d->fb_id3);
-               paint_color(d, &d->fb3, mode->hdisplay, mode->vdisplay);
 
                /* Set up display with plane 1 */
                d->plane1 = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
diff --git a/tests/kms_pwrite_crc.c b/tests/kms_pwrite_crc.c
index 983418f845cd..86292bda32b3 100644
--- a/tests/kms_pwrite_crc.c
+++ b/tests/kms_pwrite_crc.c
@@ -50,7 +50,6 @@ static void test(data_t *data)
        igt_output_t *output = data->output;
        struct igt_fb *fb = &data->fb[1];
        drmModeModeInfo *mode;
-       cairo_t *cr;
        uint32_t caching;
        void *buf;
        igt_crc_t crc;
@@ -58,12 +57,8 @@ static void test(data_t *data)
        mode = igt_output_get_mode(output);
 
        /* create a non-white fb where we can pwrite later */
-       igt_create_fb(data->drm_fd, mode->hdisplay, mode->vdisplay,
-                     DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE, fb);
-
-       cr = igt_get_cairo_ctx(data->drm_fd, fb);
-       igt_paint_test_pattern(cr, fb->width, fb->height);
-       cairo_destroy(cr);
+       igt_create_pattern_fb(data->drm_fd, mode->hdisplay, mode->vdisplay,
+                             DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE, 
fb);
 
        /* flip to it to make it UC/WC and fully flushed */
        drmModeSetPlane(data->drm_fd,
diff --git a/tests/kms_setmode.c b/tests/kms_setmode.c
index d5ac8f931b55..531ce8391fa7 100644
--- a/tests/kms_setmode.c
+++ b/tests/kms_setmode.c
@@ -146,8 +146,6 @@ static int paint_fb(struct igt_fb *fb, const char 
*test_name,
 
        cr = igt_get_cairo_ctx(drm_fd, fb);
 
-       igt_paint_test_pattern(cr, fb->width, fb->height);
-
        cairo_move_to(cr, fb->width / 2, fb->height / 2);
        cairo_set_font_size(cr, 24);
        igt_cairo_printf_line(cr, align_hcenter, 40, "%s", test_name);
@@ -180,10 +178,11 @@ static void create_fb_for_crtc(struct crtc_config *crtc,
 
        bpp = 32;
        depth = 24;
-       fb_id = igt_create_fb(drm_fd, crtc->mode.hdisplay,
-                                 crtc->mode.vdisplay,
-                                 igt_bpp_depth_to_drm_format(bpp, depth),
-                                 LOCAL_DRM_FORMAT_MOD_NONE, fb_info);
+       fb_id = igt_create_pattern_fb(drm_fd, crtc->mode.hdisplay,
+                                     crtc->mode.vdisplay,
+                                     igt_bpp_depth_to_drm_format(bpp, depth),
+                                     LOCAL_DRM_FORMAT_MOD_NONE,
+                                     fb_info);
        igt_assert_lt(0, fb_id);
 }
 
diff --git a/tests/pm_lpsp.c b/tests/pm_lpsp.c
index 257ae1b8b1d9..a82420bf06de 100644
--- a/tests/pm_lpsp.c
+++ b/tests/pm_lpsp.c
@@ -78,16 +78,9 @@ static void screens_disabled_subtest(int drm_fd, 
drmModeResPtr drm_res)
 static uint32_t create_fb(int drm_fd, int width, int height)
 {
        struct igt_fb fb;
-       cairo_t *cr;
-       uint32_t buffer_id;
 
-       buffer_id = igt_create_fb(drm_fd, width, height, DRM_FORMAT_XRGB8888,
-                                 LOCAL_DRM_FORMAT_MOD_NONE, &fb);
-       cr = igt_get_cairo_ctx(drm_fd, &fb);
-       igt_paint_test_pattern(cr, width, height);
-       cairo_destroy(cr);
-
-       return buffer_id;
+       return igt_create_pattern_fb(drm_fd, width, height, DRM_FORMAT_XRGB8888,
+                                    LOCAL_DRM_FORMAT_MOD_NONE, &fb);
 }
 
 static void edp_subtest(int drm_fd, drmModeResPtr drm_res,
diff --git a/tests/pm_rpm.c b/tests/pm_rpm.c
index 55fdb31cb723..3a5e8bafd3c7 100644
--- a/tests/pm_rpm.c
+++ b/tests/pm_rpm.c
@@ -233,7 +233,6 @@ static bool init_modeset_params_for_type(struct 
mode_set_data *data,
        int i;
        uint32_t connector_id = 0;
        drmModeModeInfoPtr mode = NULL;
-       cairo_t *cr;
 
        for (i = 0; i < data->res->count_connectors; i++) {
                drmModeConnectorPtr c = data->connectors[i];
@@ -256,12 +255,9 @@ static bool init_modeset_params_for_type(struct 
mode_set_data *data,
        if (!connector_id)
                return false;
 
-       igt_create_fb(drm_fd, mode->hdisplay, mode->vdisplay,
-                     DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
-                     &params->fb);
-       cr = igt_get_cairo_ctx(drm_fd, &params->fb);
-       igt_paint_test_pattern(cr, mode->hdisplay, mode->vdisplay);
-       cairo_destroy(cr);
+       igt_create_pattern_fb(drm_fd, mode->hdisplay, mode->vdisplay,
+                             DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+                             &params->fb);
 
        params->crtc_id = data->res->crtcs[0];
        params->connector_id = connector_id;
diff --git a/tests/testdisplay.c b/tests/testdisplay.c
index 74e60b6f4bda..ff49e23a972d 100644
--- a/tests/testdisplay.c
+++ b/tests/testdisplay.c
@@ -259,8 +259,6 @@ static void paint_output_info(struct connector *c, struct 
igt_fb *fb)
        double max_width;
        int i;
 
-       igt_paint_test_pattern(cr, l_width, l_height);
-
        cairo_move_to(cr, l_width / 2, l_height / 2);
 
        /* Print connector and mode name */
@@ -353,9 +351,9 @@ set_mode(struct connector *c)
                width = c->mode.hdisplay;
                height = c->mode.vdisplay;
 
-               fb_id = igt_create_fb(drm_fd, width, height,
-                                     igt_bpp_depth_to_drm_format(bpp, depth),
-                                     tiling, &fb_info[current_fb]);
+               fb_id = igt_create_pattern_fb(drm_fd, width, height,
+                                             igt_bpp_depth_to_drm_format(bpp, 
depth),
+                                             tiling, &fb_info[current_fb]);
                paint_output_info(c, &fb_info[current_fb]);
                paint_color_key(&fb_info[current_fb]);
 
-- 
2.4.10

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to