diff options
author | Dave Airlie <[email protected]> | 2011-09-14 11:08:57 +0100 |
---|---|---|
committer | Dave Airlie <[email protected]> | 2011-09-14 11:18:08 +0100 |
commit | 81a86aea4f0990a1b8795f9e00e7a6c4ba368281 (patch) | |
tree | 9798a61c65a74aba6790849544afcd6b32e15f51 /src/mesa/drivers | |
parent | 093dc9e548537e6c77e33064a584f849ad90dfa5 (diff) |
mesa/colormac: introduce inline helper for 4 unclamped float to ubyte.
This introduces an UNCLAMPED_FLOAT_TO_UBYTE x 4 inline function, as
suggested by Brian. It uses it in a few places I noticed from previous
color changes, and also some core mesa places. I haven't updated other places
yet.
Signed-off-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r-- | src/mesa/drivers/dri/intel/intel_blit.c | 5 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nouveau_util.h | 8 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r200/r200_state.c | 5 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_state.c | 5 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xm_dd.c | 15 |
5 files changed, 9 insertions, 29 deletions
diff --git a/src/mesa/drivers/dri/intel/intel_blit.c b/src/mesa/drivers/dri/intel/intel_blit.c index a45b6e40ecc..45cfb62014e 100644 --- a/src/mesa/drivers/dri/intel/intel_blit.c +++ b/src/mesa/drivers/dri/intel/intel_blit.c @@ -322,10 +322,7 @@ intelClearWithBlit(struct gl_context *ctx, GLbitfield mask) uint8_t clear[4]; GLfloat *color = ctx->Color.ClearColor.f; - UNCLAMPED_FLOAT_TO_UBYTE(clear[0], color[0]); - UNCLAMPED_FLOAT_TO_UBYTE(clear[1], color[1]); - UNCLAMPED_FLOAT_TO_UBYTE(clear[2], color[2]); - UNCLAMPED_FLOAT_TO_UBYTE(clear[3], color[3]); + _mesa_unclamped_float_rgba_to_ubyte(clear, color); switch (irb->Base.Format) { case MESA_FORMAT_ARGB8888: diff --git a/src/mesa/drivers/dri/nouveau/nouveau_util.h b/src/mesa/drivers/dri/nouveau/nouveau_util.h index 8cfe26dfb44..63566a63abc 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_util.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_util.h @@ -81,11 +81,9 @@ pack_rgba_f(gl_format f, float c[]) static inline unsigned pack_rgba_clamp_f(gl_format f, float c[]) { - return pack_rgba_i(f, (uint8_t []) { - UNCLAMPED_FLOAT_TO_UBYTE(c[RCOMP]), - UNCLAMPED_FLOAT_TO_UBYTE(c[GCOMP]), - UNCLAMPED_FLOAT_TO_UBYTE(c[BCOMP]), - UNCLAMPED_FLOAT_TO_UBYTE(c[ACOMP]) }); + GLubyte bytes[4]; + _mesa_unclamped_float_rgba_to_ubyte(bytes, c); + return pack_rgba_i(f, bytes); } static inline unsigned diff --git a/src/mesa/drivers/dri/r200/r200_state.c b/src/mesa/drivers/dri/r200/r200_state.c index ee13179c2be..b3755d8ddfe 100644 --- a/src/mesa/drivers/dri/r200/r200_state.c +++ b/src/mesa/drivers/dri/r200/r200_state.c @@ -1734,10 +1734,7 @@ static void r200ClearColor( struct gl_context *ctx, rrb = radeon_get_colorbuffer(&rmesa->radeon); if (!rrb) return; - UNCLAMPED_FLOAT_TO_UBYTE(color[0], c.f[0]); - UNCLAMPED_FLOAT_TO_UBYTE(color[1], c.f[1]); - UNCLAMPED_FLOAT_TO_UBYTE(color[2], c.f[2]); - UNCLAMPED_FLOAT_TO_UBYTE(color[3], c.f[3]); + _mesa_unclamped_float_rgba_to_ubyte(color, c.f); rmesa->radeon.state.color.clear = radeonPackColor( rrb->cpp, color[0], color[1], color[2], color[3] ); diff --git a/src/mesa/drivers/dri/radeon/radeon_state.c b/src/mesa/drivers/dri/radeon/radeon_state.c index 2e716c56221..979bb65f0be 100644 --- a/src/mesa/drivers/dri/radeon/radeon_state.c +++ b/src/mesa/drivers/dri/radeon/radeon_state.c @@ -1519,10 +1519,7 @@ static void radeonClearColor( struct gl_context *ctx, if (!rrb) return; - UNCLAMPED_FLOAT_TO_UBYTE(c[0], color.f[0]); - UNCLAMPED_FLOAT_TO_UBYTE(c[1], color.f[1]); - UNCLAMPED_FLOAT_TO_UBYTE(c[2], color.f[2]); - UNCLAMPED_FLOAT_TO_UBYTE(c[3], color.f[3]); + _mesa_unclamped_float_rgba_to_ubyte(c, color.f); rmesa->radeon.state.color.clear = radeonPackColor( rrb->cpp, c[0], c[1], c[2], c[3] ); } diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c index 52964ddd047..a59ffd3755a 100644 --- a/src/mesa/drivers/x11/xm_dd.c +++ b/src/mesa/drivers/x11/xm_dd.c @@ -111,10 +111,7 @@ clear_color( struct gl_context *ctx, const XMesaContext xmesa = XMESA_CONTEXT(ctx); XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer); - UNCLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[0], color.f[0]); - UNCLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[1], color.f[1]); - UNCLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[2], color.f[2]); - UNCLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[3], color.f[3]); + _mesa_unclamped_float_rgba_to_ubyte(xmesa->clearcolor, color.f); xmesa->clearpixel = xmesa_color_to_pixel( ctx, xmesa->clearcolor[0], xmesa->clearcolor[1], @@ -777,10 +774,7 @@ clear_color_HPCR_ximage( struct gl_context *ctx, int i; const XMesaContext xmesa = XMESA_CONTEXT(ctx); - UNCLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[0], color.f[0]); - UNCLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[1], color.f[1]); - UNCLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[2], color.f[2]); - UNCLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[3], color.f[3]); + _mesa_unclamped_float_rgba_to_ubyte(xmesa->clearcolor, color.f); if (color.f[0] == 0.0 && color.f[1] == 0.0 && color.f[2] == 0.0) { /* black is black */ @@ -812,10 +806,7 @@ clear_color_HPCR_pixmap( struct gl_context *ctx, int i; const XMesaContext xmesa = XMESA_CONTEXT(ctx); - UNCLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[0], color.f[0]); - UNCLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[1], color.f[1]); - UNCLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[2], color.f[2]); - UNCLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[3], color.f[3]); + _mesa_unclamped_float_rgba_to_ubyte(xmesa->clearcolor, color.f); if (color.f[0] == 0.0 && color.f[1] == 0.0 && color.f[2] == 0.0) { /* black is black */ |