lib: Remove unused field from struct igt_fb
PATCH 1/5 lib: Remove unused field from struct igt_fb
Signed-off-by Damien Lespiau <[email protected]>
--- lib/igt_fb.h | 1 - 1 file changed, 1 deletion(-)
lib/igt_fb.h +0 -1
@@ -48,7 +48,6 @@ struct igt_fb {uint32_t drm_format;int width;int height; -int depth;unsigned stride;unsigned tiling;unsigned size;
Signature · 1 line
1.8.3.1
PATCH 2/5 lib: Split the GTT mapping out of get_cairo_surface()
This is preparation work for when we need a different way to get a linear buffer we can use with cairo.
Signed-off-by Damien Lespiau <[email protected]>
--- lib/igt_fb.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-)
lib/igt_fb.c +15 -11
@@ -518,24 +518,28 @@ static cairo_format_t drm_format_to_cairo(uint32_t drm_format)igt_fail (101 ); } -static void __destroy_cairo_surface (void *arg) +static void destroy_cairo_surface__gtt (void *arg) {struct igt_fb *fb = arg;munmap (cairo_image_surface_get_data (fb->cairo_surface), fb->size); } +static void create_cairo_surface__gtt (int fd,struct igt_fb *fb) +{ + fb->cairo_surface = +cairo_image_surface_create_for_data (gem_mmap (fd, fb->gem_handle, fb->size,PROT_READ |PROT_WRITE ), +drm_format_to_cairo (fb->drm_format), + fb->width, fb->height, fb->stride); + +cairo_surface_set_user_data (fb->cairo_surface, + (cairo_user_data_key_t *)create_cairo_surface__gtt, + fb, destroy_cairo_surface__gtt); +} +static cairo_surface_t *get_cairo_surface (int fd,struct igt_fb *fb) { -if (fb->cairo_surface ==NULL ) { - fb->cairo_surface = -cairo_image_surface_create_for_data (gem_mmap (fd, fb->gem_handle, fb->size,PROT_READ |PROT_WRITE ), -drm_format_to_cairo (fb->drm_format), - fb->width, fb->height, fb->stride); - -cairo_surface_set_user_data (fb->cairo_surface, - (cairo_user_data_key_t *)get_cairo_surface, - fb, __destroy_cairo_surface); - } +if (fb->cairo_surface ==NULL ) +create_cairo_surface__gtt (fd, fb);gem_set_domain (fd, fb->gem_handle,I915_GEM_DOMAIN_CPU ,I915_GEM_DOMAIN_CPU );
Signature · 1 line
1.8.3.1
PATCH 3/5 lib: NULLify ->cairo_surface once unmapped
In reply to Damien LespiauJust a matter of not leaving dangling pointers around.
Signed-off-by Damien Lespiau <[email protected]>
--- lib/igt_fb.c | 2 ++ 1 file changed, 2 insertions(+)
lib/igt_fb.c +2 -0
@@ -521,7 +521,9 @@ static cairo_format_t drm_format_to_cairo(uint32_t drm_format)static void destroy_cairo_surface__gtt (void *arg) {struct igt_fb *fb = arg; +munmap (cairo_image_surface_get_data (fb->cairo_surface), fb->size); + fb->cairo_surface =NULL ; }static void create_cairo_surface__gtt (int fd,struct igt_fb *fb)
Signature · 1 line
1.8.3.1
PATCH 4/5 lib: Don't take a reference to the surface in get_cairo_surface()
In reply to Damien LespiauWe don't need to keep a reference to the surface, the cairo context will keep a reference to it until we destroy it.
Signed-off-by Damien Lespiau <[email protected]>
--- lib/igt_fb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/igt_fb.c +1 -1
@@ -547,7 +547,7 @@ static cairo_surface_t *get_cairo_surface(int fd, struct igt_fb *fb) I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU);igt_assert (cairo_surface_status (fb->cairo_surface) ==CAIRO_STATUS_SUCCESS ); -return cairo_surface_reference (fb->cairo_surface); +return fb->cairo_surface; }/**
Signature · 1 line
1.8.3.1
PATCH 5/5 testdisplay: Destroy the cairo context once the fb is painted
In reply to Damien LespiauSigned-off-by Damien Lespiau <[email protected]>
--- tests/testdisplay.c | 2 ++ 1 file changed, 2 insertions(+)
tests/testdisplay.c +2 -0
@@ -314,6 +314,8 @@ static void paint_output_info(struct connector *c, struct igt_fb *fb)paint_image (cr,IGT_DATADIR "/pass.png" );igt_assert (!cairo_status (cr)); + +cairo_destroy (cr); }static void sighandler (int signo)
Signature · 1 line
1.8.3.1
Pushed those, before I forget.
Signature · 1 line
Damien
Quoted 24 lines · Damien Lespiau
Signed-off-by Damien Lespiau <[email protected]>--- lib/igt_fb.h | 1 - 1 file changed, 1 deletion(-)lib/igt_fb.h +0
-1@@ -48,7 +48,6 @@ struct igt_fb {uint32_t drm_format;int width;int height; -int depth;unsigned stride;unsigned tiling;unsigned size;Signature · 6 lines
1.8.3.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx