[Glamor] [PATCH 4/9] Consolidate the choose of internal texture format to one function.

zhigang.gong at linux.intel.com zhigang.gong at linux.intel.com
Sun Jan 8 21:36:06 PST 2012


From: Zhigang Gong <zhigang.gong at linux.intel.com>

Signed-off-by: Zhigang Gong <zhigang.gong at linux.intel.com>
---
 src/glamor.c        |   15 +--------------
 src/glamor_pixmap.c |   19 +++----------------
 src/glamor_utils.h  |   20 ++++++++++++++++++++
 3 files changed, 24 insertions(+), 30 deletions(-)

diff --git a/src/glamor.c b/src/glamor.c
index bbcf942..3634e70 100644
--- a/src/glamor.c
+++ b/src/glamor.c
@@ -169,20 +169,7 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
 	if (w == 0 || h == 0 || type == GLAMOR_MEMORY)
 		return pixmap;
 
-	switch (depth) {
-#if 0
-	case 8:
-		format = GL_ALPHA;
-		break;
-#endif
-	case 24:
-		format = GL_RGB;
-		break;
-	default:
-		format = GL_RGBA;
-		break;
-	}
-
+	gl_iformat_for_depth(depth, &format);
 	/* Create the texture used to store the pixmap's data. */
 	dispatch->glGenTextures(1, &tex);
 	dispatch->glBindTexture(GL_TEXTURE_2D, tex);
diff --git a/src/glamor_pixmap.c b/src/glamor_pixmap.c
index 884dd83..f43a90b 100644
--- a/src/glamor_pixmap.c
+++ b/src/glamor_pixmap.c
@@ -221,23 +221,10 @@ __glamor_upload_pixmap_to_texture(PixmapPtr pixmap, GLenum format,
 	void *texels;
 	GLenum iformat;
 
-	switch (pixmap->drawable.depth) {
-#if 0
-	case 8:
-		iformat = GL_ALPHA;
-		break;
-#endif
-	case 24:
-		iformat = GL_RGB;
-		break;
-	default:
-		iformat = GL_RGBA;
-		break;
-	}
-
-	if (glamor_priv->gl_flavor == GLAMOR_GL_ES2) {
+	if (glamor_priv->gl_flavor == GLAMOR_GL_ES2)
 		iformat = format;
-	}
+	else
+		gl_iformat_for_depth(pixmap->drawable.depth, &iformat);
 
 	stride = pixmap->devKind;
 	row_length = (stride * 8) / pixmap->drawable.bitsPerPixel;
diff --git a/src/glamor_utils.h b/src/glamor_utils.h
index dfb7711..49c7e1d 100644
--- a/src/glamor_utils.h
+++ b/src/glamor_utils.h
@@ -224,6 +224,26 @@ format_for_depth(int depth)
 	}
 }
 
+static inline void
+gl_iformat_for_depth(int depth, GLenum * format)
+{
+	switch (depth) {
+#if 0
+	case 8:
+		*format = GL_ALPHA;
+		break;
+#endif
+	case 24:
+		*format = GL_RGB;
+		break;
+	default:
+		*format = GL_RGBA;
+		break;
+       }
+}
+
+
+
 static inline CARD32
 format_for_pixmap(PixmapPtr pixmap)
 {
-- 
1.7.4.4



More information about the Glamor mailing list