public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH i-g-t 1/5] lib: Remove unused field from struct igt_fb
@ 2014-07-11 14:09 Damien Lespiau
  2014-07-11 14:09 ` [PATCH i-g-t 2/5] lib: Split the GTT mapping out of get_cairo_surface() Damien Lespiau
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Damien Lespiau @ 2014-07-11 14:09 UTC (permalink / raw)
  To: intel-gfx

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 lib/igt_fb.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lib/igt_fb.h b/lib/igt_fb.h
index 6d030e6..f5110d4 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -48,7 +48,6 @@ struct igt_fb {
 	uint32_t drm_format;
 	int width;
 	int height;
-	int depth;
 	unsigned stride;
 	unsigned tiling;
 	unsigned size;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH i-g-t 2/5] lib: Split the GTT mapping out of get_cairo_surface()
  2014-07-11 14:09 [PATCH i-g-t 1/5] lib: Remove unused field from struct igt_fb Damien Lespiau
@ 2014-07-11 14:09 ` Damien Lespiau
  2014-07-11 14:09 ` [PATCH i-g-t 3/5] lib: NULLify ->cairo_surface once unmapped Damien Lespiau
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Damien Lespiau @ 2014-07-11 14:09 UTC (permalink / raw)
  To: intel-gfx

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 <damien.lespiau@intel.com>
---
 lib/igt_fb.c | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index f43af93..39a1f62 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -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);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH i-g-t 3/5] lib: NULLify ->cairo_surface once unmapped
  2014-07-11 14:09 [PATCH i-g-t 1/5] lib: Remove unused field from struct igt_fb Damien Lespiau
  2014-07-11 14:09 ` [PATCH i-g-t 2/5] lib: Split the GTT mapping out of get_cairo_surface() Damien Lespiau
@ 2014-07-11 14:09 ` Damien Lespiau
  2014-07-11 14:09 ` [PATCH i-g-t 4/5] lib: Don't take a reference to the surface in get_cairo_surface() Damien Lespiau
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Damien Lespiau @ 2014-07-11 14:09 UTC (permalink / raw)
  To: intel-gfx

Just a matter of not leaving dangling pointers around.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 lib/igt_fb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 39a1f62..83f4343 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -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)
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH i-g-t 4/5] lib: Don't take a reference to the surface in get_cairo_surface()
  2014-07-11 14:09 [PATCH i-g-t 1/5] lib: Remove unused field from struct igt_fb Damien Lespiau
  2014-07-11 14:09 ` [PATCH i-g-t 2/5] lib: Split the GTT mapping out of get_cairo_surface() Damien Lespiau
  2014-07-11 14:09 ` [PATCH i-g-t 3/5] lib: NULLify ->cairo_surface once unmapped Damien Lespiau
@ 2014-07-11 14:09 ` Damien Lespiau
  2014-07-11 14:09 ` [PATCH i-g-t 5/5] testdisplay: Destroy the cairo context once the fb is painted Damien Lespiau
  2014-07-29 11:16 ` [PATCH i-g-t 1/5] lib: Remove unused field from struct igt_fb Damien Lespiau
  4 siblings, 0 replies; 6+ messages in thread
From: Damien Lespiau @ 2014-07-11 14:09 UTC (permalink / raw)
  To: intel-gfx

We 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 <damien.lespiau@intel.com>
---
 lib/igt_fb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 83f4343..d07af0d 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -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;
 }
 
 /**
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH i-g-t 5/5] testdisplay: Destroy the cairo context once the fb is painted
  2014-07-11 14:09 [PATCH i-g-t 1/5] lib: Remove unused field from struct igt_fb Damien Lespiau
                   ` (2 preceding siblings ...)
  2014-07-11 14:09 ` [PATCH i-g-t 4/5] lib: Don't take a reference to the surface in get_cairo_surface() Damien Lespiau
@ 2014-07-11 14:09 ` Damien Lespiau
  2014-07-29 11:16 ` [PATCH i-g-t 1/5] lib: Remove unused field from struct igt_fb Damien Lespiau
  4 siblings, 0 replies; 6+ messages in thread
From: Damien Lespiau @ 2014-07-11 14:09 UTC (permalink / raw)
  To: intel-gfx

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 tests/testdisplay.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/testdisplay.c b/tests/testdisplay.c
index 6d8fe3a..887105d 100644
--- a/tests/testdisplay.c
+++ b/tests/testdisplay.c
@@ -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)
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH i-g-t 1/5] lib: Remove unused field from struct igt_fb
  2014-07-11 14:09 [PATCH i-g-t 1/5] lib: Remove unused field from struct igt_fb Damien Lespiau
                   ` (3 preceding siblings ...)
  2014-07-11 14:09 ` [PATCH i-g-t 5/5] testdisplay: Destroy the cairo context once the fb is painted Damien Lespiau
@ 2014-07-29 11:16 ` Damien Lespiau
  4 siblings, 0 replies; 6+ messages in thread
From: Damien Lespiau @ 2014-07-29 11:16 UTC (permalink / raw)
  To: intel-gfx

Pushed those, before I forget.

-- 
Damien

On Fri, Jul 11, 2014 at 03:09:01PM +0100, Damien Lespiau wrote:
> Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
> ---
>  lib/igt_fb.h | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/lib/igt_fb.h b/lib/igt_fb.h
> index 6d030e6..f5110d4 100644
> --- a/lib/igt_fb.h
> +++ b/lib/igt_fb.h
> @@ -48,7 +48,6 @@ struct igt_fb {
>  	uint32_t drm_format;
>  	int width;
>  	int height;
> -	int depth;
>  	unsigned stride;
>  	unsigned tiling;
>  	unsigned size;
> -- 
> 1.8.3.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-07-29 11:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-11 14:09 [PATCH i-g-t 1/5] lib: Remove unused field from struct igt_fb Damien Lespiau
2014-07-11 14:09 ` [PATCH i-g-t 2/5] lib: Split the GTT mapping out of get_cairo_surface() Damien Lespiau
2014-07-11 14:09 ` [PATCH i-g-t 3/5] lib: NULLify ->cairo_surface once unmapped Damien Lespiau
2014-07-11 14:09 ` [PATCH i-g-t 4/5] lib: Don't take a reference to the surface in get_cairo_surface() Damien Lespiau
2014-07-11 14:09 ` [PATCH i-g-t 5/5] testdisplay: Destroy the cairo context once the fb is painted Damien Lespiau
2014-07-29 11:16 ` [PATCH i-g-t 1/5] lib: Remove unused field from struct igt_fb Damien Lespiau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox