mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2026-08-21 13:23:02 +00:00
kmstest: Fix up lifetimes of cairo objects
cairo_t is the short lived drawing context, whereas cairo_surface_t is the heavyweight object that persists and is also tied to underlying GEM objects. So make the kmstest API reflect the different weights and fix the lifetime and underlying object reference leaks. Based on the fix by Paulo Zanoni. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
@@ -87,6 +87,7 @@ connector_set_mode(data_t *data, connector_t *connector, drmModeModeInfo *mode)
|
||||
kmstest_paint_color(cr, 0, 0, mode->hdisplay, mode->vdisplay,
|
||||
0.0, 0.0, 0.0);
|
||||
igt_assert(cairo_status(cr) == 0);
|
||||
cairo_destroy(cr);
|
||||
|
||||
#if 0
|
||||
fprintf(stdout, "Using pipe %c, %dx%d\n", pipe_name(config->pipe),
|
||||
|
||||
@@ -105,6 +105,7 @@ static uint32_t create_fb(data_t *data,
|
||||
cr = kmstest_get_cairo_ctx(data->drm_fd, fb);
|
||||
kmstest_paint_color(cr, 0, 0, w, h, r, g, b);
|
||||
igt_assert(cairo_status(cr) == 0);
|
||||
cairo_destroy(cr);
|
||||
|
||||
return fb_id;
|
||||
}
|
||||
|
||||
@@ -1003,6 +1003,7 @@ static void paint_flip_mode(struct kmstest_fb *fb, bool odd_frame)
|
||||
cairo_fill(cr);
|
||||
|
||||
igt_assert(!cairo_status(cr));
|
||||
cairo_destroy(cr);
|
||||
}
|
||||
|
||||
static int
|
||||
|
||||
@@ -100,6 +100,7 @@ connector_set_mode(data_t *data, connector_t *connector, drmModeModeInfo *mode)
|
||||
kmstest_paint_color(cr, 0, 0, mode->hdisplay, mode->vdisplay,
|
||||
0.0, 1.0, 0.0);
|
||||
igt_assert(cairo_status(cr) == 0);
|
||||
cairo_destroy(cr);
|
||||
|
||||
#if 0
|
||||
fprintf(stdout, "Using pipe %c, %dx%d\n", pipe_name(config->pipe),
|
||||
|
||||
+2
-2
@@ -55,8 +55,6 @@ static int paint_fb(struct kmstest_fb *fb, const char *test_name,
|
||||
cairo_t *cr;
|
||||
|
||||
cr = kmstest_get_cairo_ctx(drm_fd, fb);
|
||||
if (!cr)
|
||||
return -1;
|
||||
|
||||
kmstest_paint_color_gradient(cr, 0, 0, fb->width, fb->height, 1, 1, 1);
|
||||
kmstest_paint_test_pattern(cr, fb->width, fb->height);
|
||||
@@ -69,6 +67,8 @@ static int paint_fb(struct kmstest_fb *fb, const char *test_name,
|
||||
kmstest_cairo_printf_line(cr, align_hcenter, 10, "%s", mode_format_str);
|
||||
kmstest_cairo_printf_line(cr, align_hcenter, 10, "%s", cconf_str);
|
||||
|
||||
cairo_destroy(cr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -151,8 +151,6 @@ static int paint_fb(struct kmstest_fb *fb, const char *test_name,
|
||||
int i;
|
||||
|
||||
cr = kmstest_get_cairo_ctx(drm_fd, fb);
|
||||
if (!cr)
|
||||
return -1;
|
||||
|
||||
kmstest_paint_test_pattern(cr, fb->width, fb->height);
|
||||
|
||||
@@ -176,6 +174,8 @@ static int paint_fb(struct kmstest_fb *fb, const char *test_name,
|
||||
crtc_str[i]);
|
||||
}
|
||||
|
||||
cairo_destroy(cr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -97,6 +97,8 @@ static uint32_t create_fb(int drm_fd, int width, int height)
|
||||
&fb);
|
||||
cr = kmstest_get_cairo_ctx(drm_fd, &fb);
|
||||
kmstest_paint_test_pattern(cr, width, height);
|
||||
cairo_destroy(cr);
|
||||
|
||||
return buffer_id;
|
||||
}
|
||||
|
||||
|
||||
@@ -280,6 +280,8 @@ static struct scanout_fb *create_fb(struct mode_set_data *data, int width,
|
||||
|
||||
cr = kmstest_get_cairo_ctx(drm_fd, &fb);
|
||||
kmstest_paint_test_pattern(cr, width, height);
|
||||
cairo_destroy(cr);
|
||||
|
||||
return fb_info;
|
||||
}
|
||||
|
||||
|
||||
@@ -507,6 +507,8 @@ static uint32_t create_stereo_fb(drmModeModeInfo *mode, struct kmstest_fb *fb)
|
||||
layout.right.x, layout.right.y,
|
||||
layout.right.width, layout.right.height);
|
||||
|
||||
cairo_destroy(cr);
|
||||
|
||||
{
|
||||
char buffer[64];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user