diff options
author | Roland Scheidegger <[email protected]> | 2014-04-23 20:00:03 +0200 |
---|---|---|
committer | Roland Scheidegger <[email protected]> | 2014-04-25 19:29:30 +0200 |
commit | fa4082320acaf0a1a22ae56144eef94b2997818d (patch) | |
tree | 3b18c83012d42ce24c248e23e4ee3cf239c6153c /src/gallium/auxiliary | |
parent | 2f65f61beac3a45fdf27bf25d7b13cd1fa2bbb8c (diff) |
gallium/util: use ui[4] instead of ui in union util_color
util_color often merely represents a collection of bytes, however it is
inconvenient if those bytes can only be accessed as floats/doubles for int
formats exceeding 32bits.
(Note that since rgba8 formats use one uint, not 4 bytes, hence the byte and
short member were left as is.)
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r-- | src/gallium/auxiliary/util/u_pack_color.h | 38 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_surface.c | 2 |
2 files changed, 20 insertions, 20 deletions
diff --git a/src/gallium/auxiliary/util/u_pack_color.h b/src/gallium/auxiliary/util/u_pack_color.h index 166c68b5758..e0c9018f8ef 100644 --- a/src/gallium/auxiliary/util/u_pack_color.h +++ b/src/gallium/auxiliary/util/u_pack_color.h @@ -51,7 +51,7 @@ union util_color { ubyte ub; ushort us; - uint ui; + uint ui[4]; ushort h[4]; /* half float */ float f[4]; double d[4]; @@ -67,32 +67,32 @@ util_pack_color_ub(ubyte r, ubyte g, ubyte b, ubyte a, switch (format) { case PIPE_FORMAT_ABGR8888_UNORM: { - uc->ui = (r << 24) | (g << 16) | (b << 8) | a; + uc->ui[0] = (r << 24) | (g << 16) | (b << 8) | a; } return; case PIPE_FORMAT_XBGR8888_UNORM: { - uc->ui = (r << 24) | (g << 16) | (b << 8) | 0xff; + uc->ui[0] = (r << 24) | (g << 16) | (b << 8) | 0xff; } return; case PIPE_FORMAT_BGRA8888_UNORM: { - uc->ui = (a << 24) | (r << 16) | (g << 8) | b; + uc->ui[0] = (a << 24) | (r << 16) | (g << 8) | b; } return; case PIPE_FORMAT_BGRX8888_UNORM: { - uc->ui = (0xff << 24) | (r << 16) | (g << 8) | b; + uc->ui[0] = (0xff << 24) | (r << 16) | (g << 8) | b; } return; case PIPE_FORMAT_ARGB8888_UNORM: { - uc->ui = (b << 24) | (g << 16) | (r << 8) | a; + uc->ui[0] = (b << 24) | (g << 16) | (r << 8) | a; } return; case PIPE_FORMAT_XRGB8888_UNORM: { - uc->ui = (b << 24) | (g << 16) | (r << 8) | 0xff; + uc->ui[0] = (b << 24) | (g << 16) | (r << 8) | 0xff; } return; case PIPE_FORMAT_B5G6R5_UNORM: @@ -168,7 +168,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc, switch (format) { case PIPE_FORMAT_ABGR8888_UNORM: { - uint p = uc->ui; + uint p = uc->ui[0]; *r = (ubyte) ((p >> 24) & 0xff); *g = (ubyte) ((p >> 16) & 0xff); *b = (ubyte) ((p >> 8) & 0xff); @@ -177,7 +177,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc, return; case PIPE_FORMAT_XBGR8888_UNORM: { - uint p = uc->ui; + uint p = uc->ui[0]; *r = (ubyte) ((p >> 24) & 0xff); *g = (ubyte) ((p >> 16) & 0xff); *b = (ubyte) ((p >> 8) & 0xff); @@ -186,7 +186,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc, return; case PIPE_FORMAT_BGRA8888_UNORM: { - uint p = uc->ui; + uint p = uc->ui[0]; *r = (ubyte) ((p >> 16) & 0xff); *g = (ubyte) ((p >> 8) & 0xff); *b = (ubyte) ((p >> 0) & 0xff); @@ -195,7 +195,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc, return; case PIPE_FORMAT_BGRX8888_UNORM: { - uint p = uc->ui; + uint p = uc->ui[0]; *r = (ubyte) ((p >> 16) & 0xff); *g = (ubyte) ((p >> 8) & 0xff); *b = (ubyte) ((p >> 0) & 0xff); @@ -204,7 +204,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc, return; case PIPE_FORMAT_ARGB8888_UNORM: { - uint p = uc->ui; + uint p = uc->ui[0]; *r = (ubyte) ((p >> 8) & 0xff); *g = (ubyte) ((p >> 16) & 0xff); *b = (ubyte) ((p >> 24) & 0xff); @@ -213,7 +213,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc, return; case PIPE_FORMAT_XRGB8888_UNORM: { - uint p = uc->ui; + uint p = uc->ui[0]; *r = (ubyte) ((p >> 8) & 0xff); *g = (ubyte) ((p >> 16) & 0xff); *b = (ubyte) ((p >> 24) & 0xff); @@ -352,32 +352,32 @@ util_pack_color(const float rgba[4], enum pipe_format format, union util_color * switch (format) { case PIPE_FORMAT_ABGR8888_UNORM: { - uc->ui = (r << 24) | (g << 16) | (b << 8) | a; + uc->ui[0] = (r << 24) | (g << 16) | (b << 8) | a; } return; case PIPE_FORMAT_XBGR8888_UNORM: { - uc->ui = (r << 24) | (g << 16) | (b << 8) | 0xff; + uc->ui[0] = (r << 24) | (g << 16) | (b << 8) | 0xff; } return; case PIPE_FORMAT_BGRA8888_UNORM: { - uc->ui = (a << 24) | (r << 16) | (g << 8) | b; + uc->ui[0] = (a << 24) | (r << 16) | (g << 8) | b; } return; case PIPE_FORMAT_BGRX8888_UNORM: { - uc->ui = (0xff << 24) | (r << 16) | (g << 8) | b; + uc->ui[0] = (0xff << 24) | (r << 16) | (g << 8) | b; } return; case PIPE_FORMAT_ARGB8888_UNORM: { - uc->ui = (b << 24) | (g << 16) | (r << 8) | a; + uc->ui[0] = (b << 24) | (g << 16) | (r << 8) | a; } return; case PIPE_FORMAT_XRGB8888_UNORM: { - uc->ui = (b << 24) | (g << 16) | (r << 8) | 0xff; + uc->ui[0] = (b << 24) | (g << 16) | (r << 8) | 0xff; } return; case PIPE_FORMAT_B5G6R5_UNORM: diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c index 07997d2adc7..654b5bbc552 100644 --- a/src/gallium/auxiliary/util/u_surface.c +++ b/src/gallium/auxiliary/util/u_surface.c @@ -196,7 +196,7 @@ util_fill_rect(ubyte * dst, for (i = 0; i < height; i++) { uint32_t *row = (uint32_t *)dst; for (j = 0; j < width; j++) - *row++ = uc->ui; + *row++ = uc->ui[0]; dst += dst_stride; } break; |