[Intel-gfx] [PATCH igt 19/28] lib: Introduce a new helper kmstest_create_color_fb()

Damien Lespiau damien.lespiau at intel.com
Fri Feb 7 15:49:03 CET 2014


We need to create fbs of a single color in a few places. Time to
abstract that out to a helper function.

Signed-off-by: Damien Lespiau <damien.lespiau at intel.com>
---
 lib/igt_kms.c | 19 +++++++++++++++++++
 lib/igt_kms.h |  4 ++++
 2 files changed, 23 insertions(+)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 23a7318..74e52b6 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -358,6 +358,25 @@ unsigned int kmstest_create_fb2(int fd, int width, int height, uint32_t format,
 	return fb_id;
 }
 
+unsigned int kmstest_create_color_fb(int fd, int width, int height,
+				     uint32_t format, bool tiled,
+				     double r, double g, double b,
+				     struct kmstest_fb *fb /* out */)
+{
+	unsigned int fb_id;
+	cairo_t *cr;
+
+	fb_id = kmstest_create_fb2(fd, width, height, format, tiled, fb);
+	igt_assert(fb_id);
+
+	cr = kmstest_get_cairo_ctx(fd, fb);
+	kmstest_paint_color(cr, 0, 0, width, height, r, g, b);
+	igt_assert(cairo_status(cr) == 0);
+	cairo_destroy(cr);
+
+	return fb_id;
+}
+
 static cairo_format_t drm_format_to_cairo(uint32_t drm_format)
 {
 	struct format_desc_struct *f;
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index a37f6b9..8110dad 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -79,6 +79,10 @@ unsigned int kmstest_create_fb(int fd, int width, int height, int bpp,
 			       struct kmstest_fb *fb_info);
 unsigned int kmstest_create_fb2(int fd, int width, int height, uint32_t format,
 			        bool tiled, struct kmstest_fb *fb);
+unsigned int kmstest_create_color_fb(int fd, int width, int height,
+				     uint32_t format, bool tiled,
+				     double r, double g, double b,
+				     struct kmstest_fb *fb /* out */);
 void kmstest_remove_fb(int fd, struct kmstest_fb *fb_info);
 cairo_t *kmstest_get_cairo_ctx(int fd, struct kmstest_fb *fb);
 cairo_surface_t *kmstest_get_cairo_surface(int fd, struct kmstest_fb *fb);
-- 
1.8.3.1




More information about the Intel-gfx mailing list