On Thu, Nov 23, 2017 at 01:59:28PM -0500, Ilia Mirkin wrote: > We need to shift the values up, otherwise we'd end up with a negative > shift. This works for up-to 16-bit components, which is fine for now. Shouldn't we actually replicate the high bits in the low bits? > > Signed-off-by: Ilia Mirkin <imirkin@xxxxxxxxxxxx> > --- > tests/util/pattern.c | 14 ++++++++++---- > 1 file changed, 10 insertions(+), 4 deletions(-) > > diff --git a/tests/util/pattern.c b/tests/util/pattern.c > index 41fb541b..2f9bb384 100644 > --- a/tests/util/pattern.c > +++ b/tests/util/pattern.c > @@ -64,11 +64,17 @@ struct color_yuv { > .u = MAKE_YUV_601_U(r, g, b), \ > .v = MAKE_YUV_601_V(r, g, b) } > > +static inline uint32_t shiftcolor(const struct util_color_component *comp, > + uint32_t value) > +{ > + return ((value << 8) >> (16 - comp->length)) << comp->offset; > +} > + > #define MAKE_RGBA(rgb, r, g, b, a) \ > - ((((r) >> (8 - (rgb)->red.length)) << (rgb)->red.offset) | \ > - (((g) >> (8 - (rgb)->green.length)) << (rgb)->green.offset) | \ > - (((b) >> (8 - (rgb)->blue.length)) << (rgb)->blue.offset) | \ > - (((a) >> (8 - (rgb)->alpha.length)) << (rgb)->alpha.offset)) > + (shiftcolor(&(rgb)->red, (r)) | \ > + shiftcolor(&(rgb)->green, (g)) | \ > + shiftcolor(&(rgb)->blue, (b)) | \ > + shiftcolor(&(rgb)->alpha, (a))) > > #define MAKE_RGB24(rgb, r, g, b) \ > { .value = MAKE_RGBA(rgb, r, g, b, 0) } > -- > 2.13.6 > > _______________________________________________ > dri-devel mailing list > dri-devel@xxxxxxxxxxxxxxxxxxxxx > https://lists.freedesktop.org/mailman/listinfo/dri-devel -- Ville Syrjälä Intel OTC _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel