[Mesa-dev] [PATCH 3/3] meta: Fix incorrect rendering of the bitmap alpha component.

Francisco Jerez currojerez at riseup.net
Mon Nov 1 19:06:32 PDT 2010


---
 src/mesa/drivers/common/meta.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index f96e931..90eb5cb 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -2028,6 +2028,7 @@ _mesa_meta_Bitmap(struct gl_context *ctx,
    struct temp_texture *tex = get_bitmap_temp_texture(ctx);
    const GLenum texIntFormat = GL_ALPHA;
    const struct gl_pixelstore_attrib unpackSave = *unpack;
+   GLubyte alpha;
    struct vertex {
       GLfloat x, y, z, s, t, r, g, b, a;
    };
@@ -2138,15 +2139,18 @@ _mesa_meta_Bitmap(struct gl_context *ctx,
       return;
    }
 
-   bitmap8 = (GLubyte *) calloc(1, width * height);
+   bitmap8 = (GLubyte *) malloc(width * height);
    if (bitmap8) {
+      CLAMPED_FLOAT_TO_UBYTE(alpha, ctx->Current.RasterColor[ACOMP]);
+
+      memset(bitmap8, ~alpha, width * height);
       _mesa_expand_bitmap(width, height, &unpackSave, bitmap1,
-                          bitmap8, width, 0xff);
+                          bitmap8, width, alpha);
 
       _mesa_set_enable(ctx, tex->Target, GL_TRUE);
 
       _mesa_set_enable(ctx, GL_ALPHA_TEST, GL_TRUE);
-      _mesa_AlphaFunc(GL_GREATER, 0.0);
+      _mesa_AlphaFunc(GL_EQUAL, ctx->Current.RasterColor[ACOMP]);
 
       setup_drawpix_texture(ctx, tex, newTex, texIntFormat, width, height,
                             GL_ALPHA, GL_UNSIGNED_BYTE, bitmap8);
-- 
1.6.4.4



More information about the mesa-dev mailing list