diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2000-10-19 18:08:05 +0000 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2000-10-19 18:08:05 +0000 |
commit | cc50ed60b374e126a85919f20a3c3a033e558aca (patch) | |
tree | e8b197696b9d64cbdff462a4a90acbab7acce860 /src | |
parent | 6aafd2491c17a92a2fea1de82a7f05307689adfe (diff) |
improved blending accuracy to fix Glean test failures
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/main/blend.c | 58 |
1 files changed, 39 insertions, 19 deletions
diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c index b9b2b4788b..c4e8e86bba 100644 --- a/src/mesa/main/blend.c +++ b/src/mesa/main/blend.c @@ -1,10 +1,10 @@ -/* $Id: blend.c,v 1.18 2000/09/07 15:45:27 brianp Exp $ */ +/* $Id: blend.c,v 1.19 2000/10/19 18:08:05 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.3 + * Version: 3.5 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -354,11 +354,31 @@ blend_transparency( GLcontext *ctx, GLuint n, const GLubyte mask[], /* 100% alpha, no-op */ } else { +#if 0 + /* This is pretty close, but Glean complains */ const GLint s = CHAN_MAX - t; - const GLint r = (rgba[i][RCOMP] * t + dest[i][RCOMP] * s) >> 8; - const GLint g = (rgba[i][GCOMP] * t + dest[i][GCOMP] * s) >> 8; - const GLint b = (rgba[i][BCOMP] * t + dest[i][BCOMP] * s) >> 8; - const GLint a = (rgba[i][ACOMP] * t + dest[i][ACOMP] * s) >> 8; + const GLint r = (rgba[i][RCOMP] * t + dest[i][RCOMP] * s + 1) >> 8; + const GLint g = (rgba[i][GCOMP] * t + dest[i][GCOMP] * s + 1) >> 8; + const GLint b = (rgba[i][BCOMP] * t + dest[i][BCOMP] * s + 1) >> 8; + const GLint a = (rgba[i][ACOMP] * t + dest[i][ACOMP] * s + 1) >> 8; +#elif 0 + /* This is slower but satisfies Glean */ + const GLint s = CHAN_MAX - t; + const GLint r = (rgba[i][RCOMP] * t + dest[i][RCOMP] * s) / 255; + const GLint g = (rgba[i][GCOMP] * t + dest[i][GCOMP] * s) / 255; + const GLint b = (rgba[i][BCOMP] * t + dest[i][BCOMP] * s) / 255; + const GLint a = (rgba[i][ACOMP] * t + dest[i][ACOMP] * s) / 255; +#else + /* This satisfies Glean and should be reasonably fast */ + /* Contributed by Nathan Hand */ +#define DIV255(X) (((X) << 8) + (X) + 256) >> 16 + const GLint s = CHAN_MAX - t; + const GLint r = DIV255(rgba[i][RCOMP] * t + dest[i][RCOMP] * s); + const GLint g = DIV255(rgba[i][GCOMP] * t + dest[i][GCOMP] * s); + const GLint b = DIV255(rgba[i][BCOMP] * t + dest[i][BCOMP] * s); + const GLint a = DIV255(rgba[i][ACOMP] * t + dest[i][ACOMP] * s); +#undef DIV255 +#endif ASSERT(r <= CHAN_MAX); ASSERT(g <= CHAN_MAX); ASSERT(b <= CHAN_MAX); @@ -770,22 +790,22 @@ blend_general( GLcontext *ctx, GLuint n, const GLubyte mask[], /* compute blended color */ if (ctx->Color.BlendEquation==GL_FUNC_ADD_EXT) { - r = Rs * sR + Rd * dR; - g = Gs * sG + Gd * dG; - b = Bs * sB + Bd * dB; - a = As * sA + Ad * dA; + r = Rs * sR + Rd * dR + 0.5F; + g = Gs * sG + Gd * dG + 0.5F; + b = Bs * sB + Bd * dB + 0.5F; + a = As * sA + Ad * dA + 0.5F; } else if (ctx->Color.BlendEquation==GL_FUNC_SUBTRACT_EXT) { - r = Rs * sR - Rd * dR; - g = Gs * sG - Gd * dG; - b = Bs * sB - Bd * dB; - a = As * sA - Ad * dA; + r = Rs * sR - Rd * dR + 0.5F; + g = Gs * sG - Gd * dG + 0.5F; + b = Bs * sB - Bd * dB + 0.5F; + a = As * sA - Ad * dA + 0.5F; } else if (ctx->Color.BlendEquation==GL_FUNC_REVERSE_SUBTRACT_EXT) { - r = Rd * dR - Rs * sR; - g = Gd * dG - Gs * sG; - b = Bd * dB - Bs * sB; - a = Ad * dA - As * sA; + r = Rd * dR - Rs * sR + 0.5F; + g = Gd * dG - Gs * sG + 0.5F; + b = Bd * dB - Bs * sB + 0.5F; + a = Ad * dA - As * sA + 0.5F; } else { /* should never get here */ |