[igt-dev] [PATCH i-g-t 2/2] tests/kms: Add missing igt_put_cairo_ctx()

Bhanuprakash Modem bhanuprakash.modem at intel.com
Mon Mar 13 04:56:01 UTC 2023


Remeber to call igt_put_cairo_ctx() after rendering to make
sure the results actually end up in the framebuffer (in case
the rendering happens to a temporary buffer and there needs
to be a copy back at the end).

Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem at intel.com>
---
 tests/kms_async_flips.c | 4 ++++
 tests/kms_lease.c       | 2 +-
 tests/kms_writeback.c   | 1 +
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/tests/kms_async_flips.c b/tests/kms_async_flips.c
index 55be0bd87..34808f401 100644
--- a/tests/kms_async_flips.c
+++ b/tests/kms_async_flips.c
@@ -494,9 +494,11 @@ static void test_crc(data_t *data)
 
 	cr = igt_get_cairo_ctx(data->drm_fd, &data->bufs[frame]);
 	igt_paint_color(cr, 0, 0, data->bufs[frame].width, data->bufs[frame].height, 1.0, 0.0, 0.0);
+	igt_put_cairo_ctx(cr);
 
 	cr = igt_get_cairo_ctx(data->drm_fd, &data->bufs[!frame]);
 	igt_paint_color(cr, 0, 0, data->bufs[!frame].width, data->bufs[!frame].height, 1.0, 0.0, 0.0);
+	igt_put_cairo_ctx(cr);
 
 	ret = drmModeSetCrtc(data->drm_fd, data->crtc_id, data->bufs[frame].fb_id, 0, 0,
 			     &data->output->config.connector->connector_id, 1,
@@ -518,6 +520,7 @@ static void test_crc(data_t *data)
 		/* fill the next fb with the expected color */
 		cr = igt_get_cairo_ctx(data->drm_fd, &data->bufs[frame]);
 		igt_paint_color(cr, 0, 0, 1, data->bufs[frame].height, 1.0, 0.0, 0.0);
+		igt_put_cairo_ctx(cr);
 
 		data->flip_pending = true;
 		ret = drmModePageFlip(data->drm_fd, data->crtc_id, data->bufs[frame].fb_id,
@@ -530,6 +533,7 @@ static void test_crc(data_t *data)
 		frame = !frame;
 		cr = igt_get_cairo_ctx(data->drm_fd, &data->bufs[frame]);
 		igt_paint_color_rand(cr, 0, 0, 1, data->bufs[frame].height);
+		igt_put_cairo_ctx(cr);
 	}
 
 	igt_pipe_crc_stop(data->pipe_crc);
diff --git a/tests/kms_lease.c b/tests/kms_lease.c
index 7eab77078..b9b669420 100644
--- a/tests/kms_lease.c
+++ b/tests/kms_lease.c
@@ -207,7 +207,7 @@ static int paint_fb(int drm_fd, struct igt_fb *fb, const char *test_name,
 	igt_cairo_printf_line(cr, align_hcenter, 10, "%s", connector_str);
 	igt_cairo_printf_line(cr, align_hcenter, 10, "%s", pipe_str);
 
-	cairo_destroy(cr);
+	igt_put_cairo_ctx(cr);
 
 	return 0;
 }
diff --git a/tests/kms_writeback.c b/tests/kms_writeback.c
index 9d1345857..c4808b02c 100644
--- a/tests/kms_writeback.c
+++ b/tests/kms_writeback.c
@@ -414,6 +414,7 @@ static void commit_and_dump_fb(igt_display_t *display, igt_output_t *output, igt
 	snprintf(filepath_out, PATH_MAX, "%s/%s.png", path_name, file_name);
 	status = cairo_surface_write_to_png(fb_surface_out, filepath_out);
 	igt_assert_eq(status, CAIRO_STATUS_SUCCESS);
+	cairo_surface_destroy(fb_surface_out);
 
 	igt_remove_fb(display->drm_fd, &output_fb);
 }
-- 
2.39.1



More information about the igt-dev mailing list