[Glamor] [PATCH 2/2] glamor_render: Convert 1bpp to 8bpp before uploading.

zhigang.gong at linux.intel.com zhigang.gong at linux.intel.com
Mon Mar 26 23:14:05 PDT 2012


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

Then we can avoid the extremely fallback path.

Signed-off-by: Zhigang Gong <zhigang.gong at linux.intel.com>
---
 src/glamor_render.c |   71 +++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 57 insertions(+), 14 deletions(-)

diff --git a/src/glamor_render.c b/src/glamor_render.c
index 042fabe..ee087e2 100644
--- a/src/glamor_render.c
+++ b/src/glamor_render.c
@@ -872,6 +872,11 @@ combine_pict_format(PictFormatShort * des, const PictFormatShort src,
 	}
 	return FALSE;
 }
+static PicturePtr glamor_convert_picture(ScreenPtr screen,
+					 PicturePtr source,
+					 int x_source,
+					 int y_source, int width, int height,
+					 PictFormatShort new_format);
 
 static Bool
 glamor_composite_with_shader(CARD8 op,
@@ -907,6 +912,8 @@ glamor_composite_with_shader(CARD8 op,
 	dest_pixmap_priv = glamor_get_pixmap_private(dest_pixmap);
 	int vert_stride = 4;
 	int nrect_max;
+	PicturePtr saved_mask = NULL;
+	PicturePtr saved_source = NULL;
 	Bool ret = FALSE;
 
 	if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dest_pixmap_priv)) {
@@ -1032,6 +1039,33 @@ glamor_composite_with_shader(CARD8 op,
 		}
 	}
 #ifdef GLAMOR_PIXMAP_DYNAMIC_UPLOAD
+
+	if (source_status == GLAMOR_UPLOAD_PENDING) {
+		if (source->pDrawable->depth == 1) {
+			saved_source = source;
+			source = glamor_convert_picture(screen, source, 0, 0,
+							saved_source->pDrawable->width,
+							saved_source->pDrawable->height,
+							PICT_a8);
+
+			source_pixmap = glamor_get_drawable_pixmap(source->pDrawable);
+			source_pixmap_priv = glamor_get_pixmap_private(source_pixmap);
+		}
+	}
+
+	if (mask_status == GLAMOR_UPLOAD_PENDING) {
+		if (mask->pDrawable->depth == 1) {
+			saved_mask = mask;
+			mask = glamor_convert_picture(screen, mask, 0, 0,
+							saved_mask->pDrawable->width,
+							saved_mask->pDrawable->height,
+							PICT_a8);
+
+			mask_pixmap = glamor_get_drawable_pixmap(mask->pDrawable);
+			mask_pixmap_priv = glamor_get_pixmap_private(mask_pixmap);
+		}
+	}
+
 	if (source_status == GLAMOR_UPLOAD_PENDING
 	    && mask_status == GLAMOR_UPLOAD_PENDING
 	    && source_pixmap == mask_pixmap) {
@@ -1272,6 +1306,11 @@ fail:
 	if (saved_source_format)
 		source->format = saved_source_format;
 done:
+	if (saved_source)
+		FreePicture(source, 0);
+	if (saved_mask)
+		FreePicture(mask, 0);
+
 	return ret;
 }
 
@@ -2730,19 +2769,23 @@ GRADIENT_FAIL:
 #undef LINEAR_DEFAULT_STOPS
 
 static PicturePtr
-glamor_convert_gradient_picture(ScreenPtr screen,
-                                PicturePtr source,
-                                int x_source,
-                                int y_source, int width, int height)
+glamor_convert_picture(ScreenPtr screen,
+                       PicturePtr source,
+                       int x_source,
+                       int y_source, int width, int height,
+		       PictFormatShort new_format)
 {
 	PixmapPtr pixmap;
 	PicturePtr dst = NULL;
 	int error;
 	PictFormatShort format;
-	if (!source->pDrawable)
-		format = PICT_a8r8g8b8;
-	else
-		format = source->format;
+	if (new_format == 0) {
+		if (!source->pDrawable)
+			format = PICT_a8r8g8b8;
+		else
+			format = source->format;
+	} else
+		format = new_format;
 
 	if (!source->pDrawable) {
 		if (source->pSourcePict->type == SourcePictTypeLinear) {
@@ -2857,9 +2900,9 @@ _glamor_composite(CARD8 op,
 		   (glamor_priv, source_pixmap->drawable.width,
 		    source_pixmap->drawable.height))))) {
 		temp_src =
-		    glamor_convert_gradient_picture(screen, source,
-						    x_source, y_source,
-						    width, height);
+		    glamor_convert_picture(screen, source,
+					   x_source, y_source,
+					   width, height, 0);
 		if (!temp_src) {
 			temp_src = source;
 			goto fail;
@@ -2884,9 +2927,9 @@ _glamor_composite(CARD8 op,
 		/* XXX if mask->pDrawable is the same as source->pDrawable, we have an opportunity
 		 * to do reduce one convertion. */
 		temp_mask =
-		    glamor_convert_gradient_picture(screen, mask,
-						    x_mask, y_mask,
-						    width, height);
+		    glamor_convert_picture(screen, mask,
+					   x_mask, y_mask,
+					   width, height, 0);
 		if (!temp_mask) {
 			temp_mask = mask;
 			goto fail;
-- 
1.7.4.4



More information about the Glamor mailing list