[Glamor] [PATCH v3 2/5] glamor_utils: Added debug function to dump depth 15/16 pixmap.

Zhigang Gong zhigang.gong at linux.intel.com
Thu Apr 5 08:08:26 PDT 2012


Signed-off-by: Zhigang Gong <zhigang.gong at linux.intel.com>
---
 src/glamor_utils.h |   28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/src/glamor_utils.h b/src/glamor_utils.h
index 75ebc7e..29b7b12 100644
--- a/src/glamor_utils.h
+++ b/src/glamor_utils.h
@@ -658,6 +658,24 @@ static inline void _glamor_dump_pixmap_byte(PixmapPtr pixmap, int x, int y, int
 	}
 }
 
+static inline void _glamor_dump_pixmap_sword(PixmapPtr pixmap, int x, int y, int w, int h)
+{
+	int i,j;
+	unsigned short * p = pixmap->devPrivate.ptr;
+	int stride = pixmap->devKind / 2;
+
+	p = p + y * stride + x;
+
+	for (i = 0; i < h; i++)
+	{
+		ErrorF("line %3d: ", i);
+		for(j = 0; j < w; j++)
+			ErrorF("%2x ", p[j]);
+		p += stride;
+		ErrorF("\n");
+	}
+}
+
 static inline void _glamor_dump_pixmap_word(PixmapPtr pixmap, int x, int y, int w, int h)
 {
 	int i,j;
@@ -678,17 +696,25 @@ static inline void _glamor_dump_pixmap_word(PixmapPtr pixmap, int x, int y, int
 
 static inline void glamor_dump_pixmap(PixmapPtr pixmap, int x, int y, int w, int h)
 {
+	w = ((x + w) > pixmap->drawable.width) ? (pixmap->drawable.width - x) : w;
+	h = ((y + h) > pixmap->drawable.height) ? (pixmap->drawable.height - y) : h;
+
 	glamor_prepare_access(&pixmap->drawable, GLAMOR_ACCESS_RO);
 	switch (pixmap->drawable.depth) {
 	case 8:
 		_glamor_dump_pixmap_byte(pixmap, x, y, w, h);
 		break;
+	case 15:
+	case 16:
+		_glamor_dump_pixmap_sword(pixmap, x, y, w, h);
+		break;
+
 	case 24:
 	case 32:
 		_glamor_dump_pixmap_word(pixmap, x, y, w, h);
 		break;
 	default:
-		assert(0);
+		ErrorF("dump depth %d, not implemented.\n", pixmap->drawable.depth);
 	}
 	glamor_finish_access(&pixmap->drawable, GLAMOR_ACCESS_RO);
 }
-- 
1.7.4.4



More information about the Glamor mailing list