summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhigang Gong <zhigang.gong@linux.intel.com>2012-04-26 18:28:17 +0800
committerZhigang Gong <zhigang.gong@linux.intel.com>2012-04-27 15:53:37 +0800
commit865516949d182d8fe5c99bd38e1850e342615592 (patch)
tree3eacbccddbb0b221d539001da189ec2b2515de47
parent26d5802ec12619ba05b150fc959f46bbc32f0534 (diff)
Fixed a1 bug.
It seems that mesa has bugs when uploading bitmap to texture. We switch to convert bitmap to a8 format and then upload the a8 texture. Also added a helper routine to dump 1bpp pixmap. Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
-rw-r--r--src/glamor_pixmap.c3
-rw-r--r--src/glamor_utils.h30
2 files changed, 29 insertions, 4 deletions
diff --git a/src/glamor_pixmap.c b/src/glamor_pixmap.c
index 6f66fb4..68a7b06 100644
--- a/src/glamor_pixmap.c
+++ b/src/glamor_pixmap.c
@@ -435,8 +435,7 @@ _glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, GLenum format, GLenum ty
if (bits == NULL)
goto ready_to_upload;
- if (glamor_priv->gl_flavor == GLAMOR_GL_ES2
- && revert > REVERT_NORMAL) {
+ if (revert > REVERT_NORMAL) {
/* XXX if we are restoring the pixmap, then we may not need to allocate
* new buffer */
void *converted_bits;
diff --git a/src/glamor_utils.h b/src/glamor_utils.h
index 25ad99d..c468490 100644
--- a/src/glamor_utils.h
+++ b/src/glamor_utils.h
@@ -241,6 +241,7 @@ gl_iformat_for_depth(int depth, GLenum * format)
{
switch (depth) {
#ifndef GLAMOR_GLES2
+ case 1:
case 8:
*format = GL_ALPHA;
break;
@@ -286,6 +287,9 @@ format_for_pixmap(PixmapPtr pixmap)
* Map picture's format to the correct gl texture format and type.
* no_alpha is used to indicate whehter we need to wire alpha to 1.
*
+ * Although opengl support A1/GL_BITMAP, we still don't use it
+ * here, it seems that mesa has bugs when uploading a A1 bitmap.
+ *
* Return 0 if find a matched texture type. Otherwise return -1.
**/
#ifndef GLAMOR_GLES2
@@ -304,8 +308,9 @@ glamor_get_tex_format_type_from_pictformat(PictFormatShort format,
*swap_rb = is_upload ? SWAP_NONE_UPLOADING : SWAP_NONE_DOWNLOADING;
switch (format) {
case PICT_a1:
- *tex_format = GL_COLOR_INDEX;
- *tex_type = GL_BITMAP;
+ *tex_format = GL_ALPHA;
+ *tex_type = GL_UNSIGNED_BYTE;
+ *revert = is_upload ? REVERT_UPLOADING_A1 : REVERT_DOWNLOADING_A1;
break;
case PICT_b8g8r8x8:
*no_alpha = 1;
@@ -730,6 +735,24 @@ inline static Bool glamor_tex_format_is_readable(GLenum format)
}
+static inline void _glamor_dump_pixmap_bits(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;
+
+ for (i = 0; i < h; i++)
+ {
+ ErrorF("line %3d: ", i);
+ for(j = 0; j < w; j++)
+ ErrorF("%2d ", (p[j/8] & (1 << (j%8)))>>(j%8));
+ p += stride;
+ ErrorF("\n");
+ }
+}
+
static inline void _glamor_dump_pixmap_byte(PixmapPtr pixmap, int x, int y, int w, int h)
{
int i,j;
@@ -803,6 +826,9 @@ static inline void glamor_dump_pixmap(PixmapPtr pixmap, int x, int y, int w, int
case 32:
_glamor_dump_pixmap_word(pixmap, x, y, w, h);
break;
+ case 1:
+ _glamor_dump_pixmap_bits(pixmap, x, y, w, h);
+ break;
default:
ErrorF("dump depth %d, not implemented.\n", pixmap->drawable.depth);
}