summaryrefslogtreecommitdiff
path: root/kms++util/src/testpat.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kms++util/src/testpat.cpp')
-rw-r--r--kms++util/src/testpat.cpp68
1 files changed, 33 insertions, 35 deletions
diff --git a/kms++util/src/testpat.cpp b/kms++util/src/testpat.cpp
index ab197dc..f9a3c8a 100644
--- a/kms++util/src/testpat.cpp
+++ b/kms++util/src/testpat.cpp
@@ -105,17 +105,10 @@ static void draw_test_pattern_part(IFramebuffer& fb, unsigned start_y, unsigned
unsigned x, y;
unsigned w = fb.width();
- switch (fb.format()) {
- case PixelFormat::XRGB8888:
- case PixelFormat::XBGR8888:
- case PixelFormat::ARGB8888:
- case PixelFormat::ABGR8888:
- case PixelFormat::RGB888:
- case PixelFormat::BGR888:
- case PixelFormat::RGB565:
- case PixelFormat::BGR565:
- case PixelFormat::ARGB4444:
- case PixelFormat::ARGB1555:
+ const PixelFormatInfo& format_info = get_pixel_format_info(fb.format());
+
+ switch (format_info.type) {
+ case PixelColorType::RGB:
for (y = start_y; y < end_y; y++) {
for (x = 0; x < w; x++) {
RGB pixel = get_test_pattern_pixel(fb, x, y);
@@ -124,35 +117,40 @@ static void draw_test_pattern_part(IFramebuffer& fb, unsigned start_y, unsigned
}
break;
- case PixelFormat::UYVY:
- case PixelFormat::YUYV:
- case PixelFormat::YVYU:
- case PixelFormat::VYUY:
- for (y = start_y; y < end_y; y++) {
- for (x = 0; x < w; x += 2) {
- RGB pixel1 = get_test_pattern_pixel(fb, x, y);
- RGB pixel2 = get_test_pattern_pixel(fb, x + 1, y);
- draw_yuv422_macropixel(fb, x, y, pixel1.yuv(yuvt), pixel2.yuv(yuvt));
+ case PixelColorType::YUV:
+ switch (format_info.num_planes) {
+ case 1:
+ for (y = start_y; y < end_y; y++) {
+ for (x = 0; x < w; x += 2) {
+ RGB pixel1 = get_test_pattern_pixel(fb, x, y);
+ RGB pixel2 = get_test_pattern_pixel(fb, x + 1, y);
+ draw_yuv422_macropixel(fb, x, y, pixel1.yuv(yuvt), pixel2.yuv(yuvt));
+ }
}
- }
- break;
-
- case PixelFormat::NV12:
- case PixelFormat::NV21:
- for (y = start_y; y < end_y; y += 2) {
- for (x = 0; x < w; x += 2) {
- RGB pixel00 = get_test_pattern_pixel(fb, x, y);
- RGB pixel10 = get_test_pattern_pixel(fb, x + 1, y);
- RGB pixel01 = get_test_pattern_pixel(fb, x, y + 1);
- RGB pixel11 = get_test_pattern_pixel(fb, x + 1, y + 1);
- draw_yuv420_macropixel(fb, x, y,
- pixel00.yuv(yuvt), pixel10.yuv(yuvt),
- pixel01.yuv(yuvt), pixel11.yuv(yuvt));
+ break;
+
+ case 2:
+ for (y = start_y; y < end_y; y += 2) {
+ for (x = 0; x < w; x += 2) {
+ RGB pixel00 = get_test_pattern_pixel(fb, x, y);
+ RGB pixel10 = get_test_pattern_pixel(fb, x + 1, y);
+ RGB pixel01 = get_test_pattern_pixel(fb, x, y + 1);
+ RGB pixel11 = get_test_pattern_pixel(fb, x + 1, y + 1);
+ draw_yuv420_macropixel(fb, x, y,
+ pixel00.yuv(yuvt), pixel10.yuv(yuvt),
+ pixel01.yuv(yuvt), pixel11.yuv(yuvt));
+ }
}
+ break;
+
+ default:
+ throw invalid_argument("unsupported number of pixel format planes");
}
+
break;
+
default:
- throw std::invalid_argument("unknown pixelformat");
+ throw invalid_argument("unsupported pixel format");
}
}