summaryrefslogtreecommitdiff
path: root/glamor/glamor_utils.h
diff options
context:
space:
mode:
authorZhigang Gong <zhigang.gong@linux.intel.com>2012-02-03 11:46:01 +0800
committerEric Anholt <eric@anholt.net>2013-12-18 11:23:48 -0800
commitbf24c2c06870dc38b21795f4f6fc51b053134181 (patch)
tree0fa273b4bd807aa6e1976986f6a05723be6df5d4 /glamor/glamor_utils.h
parent91891b3711b1fe1402bb7742c20e976fab63c6fe (diff)
glamor_dump_pixmap: Add helper routine to dump pixmap.
For debug purpose only to dump the pixmap's content. As this function will call glamor_prepare_access/glamor_finish_access internally. Please use it carefully. Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Diffstat (limited to 'glamor/glamor_utils.h')
-rw-r--r--glamor/glamor_utils.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/glamor/glamor_utils.h b/glamor/glamor_utils.h
index a60b146c1..74ce6cd0f 100644
--- a/glamor/glamor_utils.h
+++ b/glamor/glamor_utils.h
@@ -610,4 +610,57 @@ inline static Bool glamor_tex_format_is_readable(GLenum format)
}
+static inline void _glamor_dump_pixmap_byte(PixmapPtr pixmap, int x, int y, int w, int h)
+{
+ int i,j;
+ unsigned char * p = pixmap->devPrivate.ptr;
+ int stride = pixmap->devKind;
+
+ p = p + y * stride + x;
+ ErrorF("devKind %d, x %d y %d w %d h %d width %d height %d\n", stride, x, y, w, h, pixmap->drawable.width, pixmap->drawable.height);
+
+ 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;
+ unsigned int * p = pixmap->devPrivate.ptr;
+ int stride = pixmap->devKind / 4;
+
+ 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(PixmapPtr pixmap, int x, int y, int w, int 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 24:
+ case 32:
+ _glamor_dump_pixmap_word(pixmap, x, y, w, h);
+ break;
+ default:
+ assert(0);
+ }
+ glamor_finish_access(&pixmap->drawable, GLAMOR_ACCESS_RO);
+}
#endif