[igt-dev] [PATCH i-g-t 2/2] lib/igt_fb: Extract use_convert()

Ville Syrjala ville.syrjala at linux.intel.com
Wed Sep 18 13:51:56 UTC 2019


From: Ville Syrjälä <ville.syrjala at linux.intel.com>

Extract the "should we use a convert surface?" logic into a small
helper in the vein of use_blitter() and use_rendercopy().

Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
 lib/igt_fb.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 612c25d5baed..41c646d655d6 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -3192,6 +3192,16 @@ void igt_fb_unmap_buffer(struct igt_fb *fb, void *buffer)
 	return unmap_bo(fb, buffer);
 }
 
+static bool use_convert(const struct igt_fb *fb)
+{
+	const struct format_desc_struct *f = lookup_drm_format(fb->drm_format);
+
+	return igt_format_is_yuv(fb->drm_format) ||
+		igt_format_is_fp16(fb->drm_format) ||
+		(f->cairo_id == CAIRO_FORMAT_INVALID &&
+		 f->pixman_id != PIXMAN_invalid);
+}
+
 /**
  * igt_get_cairo_surface:
  * @fd: open drm file descriptor
@@ -3208,10 +3218,7 @@ cairo_surface_t *igt_get_cairo_surface(int fd, struct igt_fb *fb)
 	const struct format_desc_struct *f = lookup_drm_format(fb->drm_format);
 
 	if (fb->cairo_surface == NULL) {
-		if (igt_format_is_yuv(fb->drm_format) ||
-		    igt_format_is_fp16(fb->drm_format) ||
-		    ((f->cairo_id == CAIRO_FORMAT_INVALID) &&
-		     (f->pixman_id != PIXMAN_invalid)))
+		if (use_convert(fb))
 			create_cairo_surface__convert(fd, fb);
 		else if (use_blitter(fb) || use_rendercopy(fb) || igt_vc4_is_tiled(fb->modifier))
 			create_cairo_surface__gpu(fd, fb);
-- 
2.21.0



More information about the igt-dev mailing list