[Glamor] [PATCH 05/34] glamor: Pass pixmaps around to unifdef glamor_iformat_for_depth().

Alex Deucher alexdeucher at gmail.com
Fri Feb 28 10:02:00 PST 2014


From: Eric Anholt <eric at anholt.net>

Pulled from Eric's xserver glamor tree.

Signed-off-by: Eric Anholt <eric at anholt.net>
Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
---
 src/glamor.c         |  4 ++--
 src/glamor_picture.c |  3 +--
 src/glamor_pixmap.c  |  4 ++--
 src/glamor_utils.h   | 29 ++++++++++++++---------------
 4 files changed, 19 insertions(+), 21 deletions(-)

diff --git a/src/glamor.c b/src/glamor.c
index 24cbbf4..52e2f21 100644
--- a/src/glamor.c
+++ b/src/glamor.c
@@ -96,7 +96,7 @@ glamor_set_pixmap_texture(PixmapPtr pixmap, unsigned int tex)
 		glamor_destroy_fbo(fbo);
 	}
 
-	gl_iformat_for_depth(pixmap->drawable.depth, &format);
+	format = gl_iformat_for_pixmap(pixmap);
 	fbo = glamor_create_fbo_from_tex(glamor_priv, pixmap->drawable.width,
 					 pixmap->drawable.height,
 					 format, tex, 0);
@@ -165,7 +165,7 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
 	pixmap_priv->base.pixmap = pixmap;
 	pixmap_priv->base.glamor_priv = glamor_priv;
 
-	gl_iformat_for_depth(depth, &format);
+	format = gl_iformat_for_pixmap(pixmap);
 
 	pitch = (((w * pixmap->drawable.bitsPerPixel + 7) / 8) + 3) & ~3;
 	screen->ModifyPixmapHeader(pixmap, w, h, 0, 0, pitch, NULL);
diff --git a/src/glamor_picture.c b/src/glamor_picture.c
index 7d5ffbb..c55425d 100644
--- a/src/glamor_picture.c
+++ b/src/glamor_picture.c
@@ -92,8 +92,7 @@ glamor_create_picture(PicturePtr picture)
 			 * we have to mark this pixmap as a separated texture, and don't
 			 * fallback to DDX layer. */
 			if (pixmap_priv->type == GLAMOR_TEXTURE_DRM
-			    && !glamor_pict_format_is_compatible(picture->format,
-								 pixmap->drawable.depth))
+			    && !glamor_pict_format_is_compatible(picture->format, pixmap))
 				glamor_set_pixmap_type(pixmap, GLAMOR_SEPARATE_TEXTURE);
 		}
 	}
diff --git a/src/glamor_pixmap.c b/src/glamor_pixmap.c
index d0004a9..9756163 100644
--- a/src/glamor_pixmap.c
+++ b/src/glamor_pixmap.c
@@ -400,7 +400,7 @@ __glamor_upload_pixmap_to_texture(PixmapPtr pixmap, unsigned int *tex,
 	if (*tex == 0) {
 		dispatch->glGenTextures(1, tex);
 		if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP)
-			gl_iformat_for_depth(pixmap->drawable.depth, &iformat);
+			iformat = gl_iformat_for_pixmap(pixmap);
 		else
 			iformat = format;
 		non_sub = 1;
@@ -625,7 +625,7 @@ glamor_pixmap_upload_prepare(PixmapPtr pixmap, GLenum format, int no_alpha, int
 		return 0;
 
 	if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP)
-		gl_iformat_for_depth(pixmap->drawable.depth, &iformat);
+		iformat = gl_iformat_for_pixmap(pixmap);
 	else
 		iformat = format;
 
diff --git a/src/glamor_utils.h b/src/glamor_utils.h
index 334015d..2fb3744 100644
--- a/src/glamor_utils.h
+++ b/src/glamor_utils.h
@@ -900,20 +900,18 @@ depth_for_type(GLenum type)
 	}
 }
 
-static inline void
-gl_iformat_for_depth(int depth, GLenum * format)
+static inline GLenum
+gl_iformat_for_pixmap(PixmapPtr pixmap)
 {
-	switch (depth) {
-#ifndef GLAMOR_GLES2
-	case 1:
-	case 8:
-		*format = GL_ALPHA;
-		break;
-#endif
-	default:
-		*format = GL_RGBA;
-		break;
-       }
+	glamor_screen_private *glamor_priv =
+	    glamor_get_screen_private(pixmap->drawable.pScreen);
+
+	if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP &&
+	    (pixmap->drawable.depth == 1 || pixmap->drawable.depth == 8)) {
+	    return GL_ALPHA;
+	} else {
+	    return GL_RGBA;
+	}
 }
 
 static inline CARD32
@@ -1348,11 +1346,12 @@ glamor_get_rgba_from_pixel(CARD32 pixel,
 	return TRUE;
 }
 
-inline static Bool glamor_pict_format_is_compatible(PictFormatShort pict_format, int depth)
+inline static Bool
+glamor_pict_format_is_compatible(PictFormatShort pict_format, PixmapPtr pixmap)
 {
 	GLenum iformat;
 
-	gl_iformat_for_depth(depth, &iformat);
+	iformat = gl_iformat_for_pixmap(pixmap);
 	switch (iformat) {
 		case GL_RGBA:
 			return (pict_format == PICT_a8r8g8b8 || pict_format == PICT_x8r8g8b8);
-- 
1.8.3.1



More information about the Glamor mailing list