[Glamor] [PATCH 19/34] glamor: Replace some goofy enum-likes with a real enum.

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


From: Eric Anholt <eric at anholt.net>

This unpacks the bitfield into an int size, but my experience has been
that packing bitfields doesn't matter for performance.

Ported 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_fbo.c  |  2 +-
 src/glamor_priv.h | 25 ++++++++++++++++---------
 2 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/src/glamor_fbo.c b/src/glamor_fbo.c
index 111d36c..f59c944 100644
--- a/src/glamor_fbo.c
+++ b/src/glamor_fbo.c
@@ -515,7 +515,7 @@ glamor_pixmap_attach_fbo(PixmapPtr pixmap, glamor_pixmap_fbo *fbo)
 	case GLAMOR_TEXTURE_LARGE:
 	case GLAMOR_TEXTURE_ONLY:
 	case GLAMOR_TEXTURE_DRM:
-		pixmap_priv->base.gl_fbo = 1;
+		pixmap_priv->base.gl_fbo = GLAMOR_FBO_NORMAL;
 		if (fbo->tex != 0)
 			pixmap_priv->base.gl_tex = 1;
 		else {
diff --git a/src/glamor_priv.h b/src/glamor_priv.h
index 35c6ce2..621709a 100644
--- a/src/glamor_priv.h
+++ b/src/glamor_priv.h
@@ -306,8 +306,21 @@ typedef enum glamor_access {
 	GLAMOR_ACCESS_WO,
 } glamor_access_t;
 
-#define GLAMOR_FBO_NORMAL     1
-#define GLAMOR_FBO_DOWNLOADED 2
+enum glamor_fbo_state {
+	/** There is no storage attached to the pixmap. */
+	GLAMOR_FBO_UNATTACHED,
+	/**
+	 * The pixmap has FBO storage attached, but devPrivate.ptr doesn't
+	 * point at anything.
+	 */
+	GLAMOR_FBO_NORMAL,
+	/**
+	 * The FBO is present and can be accessed as a linear memory
+	 * mapping through devPrivate.ptr.
+	 */
+	GLAMOR_FBO_DOWNLOADED,
+};
+
 /* glamor_pixmap_fbo:
  * @list:    to be used to link to the cache pool list.
  * @expire:  when push to cache pool list, set a expire count.
@@ -339,12 +352,6 @@ typedef struct glamor_pixmap_fbo {
 
 /*
  * glamor_pixmap_private - glamor pixmap's private structure.
- * @gl_fbo:
- * 	0 		  	- The pixmap doesn't has a fbo attached to it.
- * 	GLAMOR_FBO_NORMAL 	- The pixmap has a fbo and can be accessed normally.
- * 	GLAMOR_FBO_DOWNLOADED 	- The pixmap has a fbo and already downloaded to
- * 				  CPU, so it can only be treated as a in-memory pixmap
- * 				  if this bit is set.
  * @gl_tex:  The pixmap is in a gl texture originally.
  * @is_picture: The drawable is attached to a picture.
  * @pict_format: the corresponding picture's format.
@@ -418,7 +425,7 @@ typedef struct glamor_pixmap_clipped_regions{
 
 typedef struct glamor_pixmap_private_base {
 	glamor_pixmap_type_t type;
-	unsigned char gl_fbo:2;
+	enum glamor_fbo_state gl_fbo;
 	unsigned char is_picture:1;
 	unsigned char gl_tex:1;
 	glamor_pixmap_fbo *fbo;
-- 
1.8.3.1



More information about the Glamor mailing list