summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/common/meta.c
diff options
context:
space:
mode:
authorFrancisco Jerez <[email protected]>2010-11-02 02:49:48 +0100
committerBrian Paul <[email protected]>2010-11-04 13:58:54 -0600
commit7831994868d039da726cc0c1a86b1f94137ad412 (patch)
treee00205a5e23749dc34ddb646b7b13c259c7be439 /src/mesa/drivers/common/meta.c
parentd8463623893b189dae5ab7288395ffb54849c572 (diff)
meta: Fix incorrect rendering of the bitmap alpha component.
Signed-off-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/drivers/common/meta.c')
-rw-r--r--src/mesa/drivers/common/meta.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index b7a092e64f6..6433c89d813 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -1997,6 +1997,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 fg, bg;
struct vertex {
GLfloat x, y, z, s, t, r, g, b, a;
};
@@ -2098,21 +2099,26 @@ _mesa_meta_Bitmap(struct gl_context *ctx,
_mesa_BufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts);
}
+ /* choose different foreground/background alpha values */
+ CLAMPED_FLOAT_TO_UBYTE(fg, ctx->Current.RasterColor[ACOMP]);
+ bg = (fg > 127 ? 0 : 255);
+
bitmap1 = _mesa_map_pbo_source(ctx, &unpackSave, bitmap1);
if (!bitmap1) {
_mesa_meta_end(ctx);
return;
}
- bitmap8 = (GLubyte *) calloc(1, width * height);
+ bitmap8 = (GLubyte *) malloc(width * height);
if (bitmap8) {
+ memset(bitmap8, bg, width * height);
_mesa_expand_bitmap(width, height, &unpackSave, bitmap1,
- bitmap8, width, 0xff);
+ bitmap8, width, fg);
_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_NOTEQUAL, UBYTE_TO_FLOAT(bg));
setup_drawpix_texture(ctx, tex, newTex, texIntFormat, width, height,
GL_ALPHA, GL_UNSIGNED_BYTE, bitmap8);