[PATCH libdrm 1/3] tests: util: pattern: Use 64bit RGB samples

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use of 32bit RGB samples, where each component is 8bit, cannot
support formats with components greater than 8bit (ex, XRGB2101010).
Introduce MAKE_RGBA_64() which creates pixels from a 64bit sample.
Each component in a 64bit sample is 16bit long, thus a pixel with 10bit
components can be generated correctly.

MAKE_RGBA() can use MAKE_RGBA_64() by scaling each 8bit component
to 16bit, for compatilbity.

Signed-off-by: Hyun Kwon <hyun.kwon@xxxxxxxxxx>
---
 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 9fa0a41..aa067c9 100644
--- a/tests/util/pattern.c
+++ b/tests/util/pattern.c
@@ -60,11 +60,17 @@ struct color_yuv {
 	  .u = MAKE_YUV_601_U(r, g, b), \
 	  .v = MAKE_YUV_601_V(r, g, b) }
 
+#define COLOR_MASK(value, color) \
+	((value & ((1 << (color).length) - 1)) << (color).offset)
+
+#define MAKE_RGBA_64(rgb, r, g, b, a) \
+	(COLOR_MASK(((r) >> (16 - (rgb)->red.length)), (rgb)->red) | \
+	 COLOR_MASK(((g) >> (16 - (rgb)->green.length)), (rgb)->green) | \
+	 COLOR_MASK(((b) >> (16 - (rgb)->blue.length)), (rgb)->blue) | \
+	 COLOR_MASK(((a) >> (16 - (rgb)->alpha.length)), (rgb)->alpha))
+
 #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))
+	MAKE_RGBA_64(rgb, (r) * 0x101, (g) * 0x101, (b) * 0x101, (a) * 0x101)
 
 #define MAKE_RGB24(rgb, r, g, b) \
 	{ .value = MAKE_RGBA(rgb, r, g, b, 0) }
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux