diff mbox

[v2,libdrm,2/3] modetest: Make RGB565 pwetty too

Message ID 1366298819-27290-2-git-send-email-ville.syrjala@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ville Syrjala April 18, 2013, 3:26 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Render the crosshairs for 565 and x888/a888 formats.

v2: Use the drm format to determine cairo format

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 tests/modetest/buffers.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

Comments

Laurent Pinchart April 18, 2013, 3:30 p.m. UTC | #1
On Thursday 18 April 2013 18:26:58 ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Render the crosshairs for 565 and x888/a888 formats.
> 
> v2: Use the drm format to determine cairo format
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  tests/modetest/buffers.c | 26 +++++++++++++++++++++++---
>  1 file changed, 23 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/modetest/buffers.c b/tests/modetest/buffers.c
> index 2f3adf8..abacea5 100644
> --- a/tests/modetest/buffers.c
> +++ b/tests/modetest/buffers.c
> @@ -656,15 +656,32 @@ fill_smpte(const struct format_info *info, void
> *planes[3], unsigned int width, #define BLUE  0
> 
>  static void
> -make_pwetty(void *data, int width, int height, int stride)
> +make_pwetty(void *data, int width, int height, int stride, uint32_t format)
> {
>  #ifdef HAVE_CAIRO
>  	cairo_surface_t *surface;
>  	cairo_t *cr;
>  	int x, y;
> +	cairo_format_t cairo_format;
> +
> +	/* we can ignore the order of R,G,B channels */
> +	switch (format) {
> +	case DRM_FORMAT_XRGB8888:
> +	case DRM_FORMAT_ARGB8888:
> +	case DRM_FORMAT_XBGR8888:
> +	case DRM_FORMAT_ABGR8888:
> +		cairo_format = CAIRO_FORMAT_ARGB32;
> +		break;
> +	case DRM_FORMAT_RGB565:
> +	case DRM_FORMAT_BGR565:
> +		cairo_format = CAIRO_FORMAT_RGB16_565;
> +		break;
> +	default:
> +		return;
> +	}
> 
>  	surface = cairo_image_surface_create_for_data(data,
> -						      CAIRO_FORMAT_ARGB32,
> +						      cairo_format,
>  						      width, height,
>  						      stride);
>  	cr = cairo_create(surface);
> @@ -774,6 +791,7 @@ fill_tiles_rgb16(const struct format_info *info,
> unsigned char *mem, unsigned int width, unsigned int height, unsigned int
> stride)
>  {
>  	const struct rgb_info *rgb = &info->rgb;
> +	unsigned char *mem_base = mem;
>  	unsigned int x, y;
> 
>  	for (y = 0; y < height; ++y) {
> @@ -790,6 +808,8 @@ fill_tiles_rgb16(const struct format_info *info,
> unsigned char *mem, }
>  		mem += stride;
>  	}
> +
> +	make_pwetty(mem_base, width, height, stride, info->format);
>  }
> 
>  static void
> @@ -837,7 +857,7 @@ fill_tiles_rgb32(const struct format_info *info,
> unsigned char *mem, mem += stride;
>  	}
> 
> -	make_pwetty(mem_base, width, height, stride);
> +	make_pwetty(mem_base, width, height, stride, info->format);
>  }
> 
>  static void
diff mbox

Patch

diff --git a/tests/modetest/buffers.c b/tests/modetest/buffers.c
index 2f3adf8..abacea5 100644
--- a/tests/modetest/buffers.c
+++ b/tests/modetest/buffers.c
@@ -656,15 +656,32 @@  fill_smpte(const struct format_info *info, void *planes[3], unsigned int width,
 #define BLUE  0
 
 static void
-make_pwetty(void *data, int width, int height, int stride)
+make_pwetty(void *data, int width, int height, int stride, uint32_t format)
 {
 #ifdef HAVE_CAIRO
 	cairo_surface_t *surface;
 	cairo_t *cr;
 	int x, y;
+	cairo_format_t cairo_format;
+
+	/* we can ignore the order of R,G,B channels */
+	switch (format) {
+	case DRM_FORMAT_XRGB8888:
+	case DRM_FORMAT_ARGB8888:
+	case DRM_FORMAT_XBGR8888:
+	case DRM_FORMAT_ABGR8888:
+		cairo_format = CAIRO_FORMAT_ARGB32;
+		break;
+	case DRM_FORMAT_RGB565:
+	case DRM_FORMAT_BGR565:
+		cairo_format = CAIRO_FORMAT_RGB16_565;
+		break;
+	default:
+		return;
+	}
 
 	surface = cairo_image_surface_create_for_data(data,
-						      CAIRO_FORMAT_ARGB32,
+						      cairo_format,
 						      width, height,
 						      stride);
 	cr = cairo_create(surface);
@@ -774,6 +791,7 @@  fill_tiles_rgb16(const struct format_info *info, unsigned char *mem,
 		 unsigned int width, unsigned int height, unsigned int stride)
 {
 	const struct rgb_info *rgb = &info->rgb;
+	unsigned char *mem_base = mem;
 	unsigned int x, y;
 
 	for (y = 0; y < height; ++y) {
@@ -790,6 +808,8 @@  fill_tiles_rgb16(const struct format_info *info, unsigned char *mem,
 		}
 		mem += stride;
 	}
+
+	make_pwetty(mem_base, width, height, stride, info->format);
 }
 
 static void
@@ -837,7 +857,7 @@  fill_tiles_rgb32(const struct format_info *info, unsigned char *mem,
 		mem += stride;
 	}
 
-	make_pwetty(mem_base, width, height, stride);
+	make_pwetty(mem_base, width, height, stride, info->format);
 }
 
 static void