From 8a991ee6b675d18739557e004ce993fa090ef0b5 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Sat, 3 Oct 2015 23:29:18 +0300 Subject: use PixelFormat all around --- libkmstest/colorbar.cpp | 12 ++++++------ libkmstest/conv.cpp | 14 +++++++------- libkmstest/testpat.cpp | 10 ++++++---- 3 files changed, 19 insertions(+), 17 deletions(-) (limited to 'libkmstest') diff --git a/libkmstest/colorbar.cpp b/libkmstest/colorbar.cpp index bc9cdca..31a4510 100644 --- a/libkmstest/colorbar.cpp +++ b/libkmstest/colorbar.cpp @@ -102,23 +102,23 @@ static void drm_draw_color_bar_semiplanar_yuv(DumbFramebuffer& buf, int old_xpos void draw_color_bar(DumbFramebuffer& buf, int old_xpos, int xpos, int width) { switch (buf.format()) { - case DRM_FORMAT_NV12: - case DRM_FORMAT_NV21: + case PixelFormat::NV12: + case PixelFormat::NV21: // XXX not right but gets something on the screen drm_draw_color_bar_semiplanar_yuv(buf, old_xpos, xpos, width); break; - case DRM_FORMAT_YUYV: - case DRM_FORMAT_UYVY: + case PixelFormat::YUYV: + case PixelFormat::UYVY: // XXX not right but gets something on the screen drm_draw_color_bar_rgb565(buf, old_xpos, xpos, width); break; - case DRM_FORMAT_RGB565: + case PixelFormat::RGB565: drm_draw_color_bar_rgb565(buf, old_xpos, xpos, width); break; - case DRM_FORMAT_XRGB8888: + case PixelFormat::XRGB8888: drm_draw_color_bar_rgb888(buf, old_xpos, xpos, width); break; diff --git a/libkmstest/conv.cpp b/libkmstest/conv.cpp index f2f19ac..45f4a75 100644 --- a/libkmstest/conv.cpp +++ b/libkmstest/conv.cpp @@ -34,13 +34,13 @@ static void fb_rgb_to_packed_yuv(DumbFramebuffer& dst_fb, const DumbFramebuffer& YUV yuv2 = read_rgb_as_yuv(src_fb, x + 1, y); switch (dst_fb.format()) { - case DRM_FORMAT_UYVY: + case PixelFormat::UYVY: dst[x * 2 + 0] = (yuv1.u + yuv2.u) / 2; dst[x * 2 + 1] = yuv1.y; dst[x * 2 + 2] = (yuv1.v + yuv2.v) / 2; dst[x * 2 + 3] = yuv2.y; break; - case DRM_FORMAT_YUYV: + case PixelFormat::YUYV: dst[x * 2 + 0] = yuv1.y; dst[x * 2 + 1] = (yuv1.u + yuv2.u) / 2; dst[x * 2 + 2] = yuv2.y; @@ -116,17 +116,17 @@ static void fb_rgb_to_rgb565(DumbFramebuffer& dst_fb, const DumbFramebuffer& src void color_convert(DumbFramebuffer& dst, const DumbFramebuffer &src) { switch (dst.format()) { - case DRM_FORMAT_NV12: - case DRM_FORMAT_NV21: + case PixelFormat::NV12: + case PixelFormat::NV21: fb_rgb_to_semiplanar_yuv(dst, src); break; - case DRM_FORMAT_YUYV: - case DRM_FORMAT_UYVY: + case PixelFormat::YUYV: + case PixelFormat::UYVY: fb_rgb_to_packed_yuv(dst, src); break; - case DRM_FORMAT_RGB565: + case PixelFormat::RGB565: fb_rgb_to_rgb565(dst, src); break; diff --git a/libkmstest/testpat.cpp b/libkmstest/testpat.cpp index 1516369..c8188d8 100644 --- a/libkmstest/testpat.cpp +++ b/libkmstest/testpat.cpp @@ -21,19 +21,19 @@ static void draw_pixel(DumbFramebuffer& buf, unsigned x, unsigned y, RGB color) static RGB c1; switch (buf.format()) { - case DRM_FORMAT_XRGB8888: + case PixelFormat::XRGB8888: { uint32_t *p = (uint32_t*)(buf.map(0) + buf.stride(0) * y + x * 4); *p = color.raw; break; } - case DRM_FORMAT_RGB565: + case PixelFormat::RGB565: { uint16_t *p = (uint16_t*)(buf.map(0) + buf.stride(0) * y + x * 2); *p = color.rgb565(); break; } - case DRM_FORMAT_UYVY: + case PixelFormat::UYVY: { if ((x & 1) == 0) { c1 = color; @@ -51,7 +51,7 @@ static void draw_pixel(DumbFramebuffer& buf, unsigned x, unsigned y, RGB color) p[3] = yuv2.y; break; } - case DRM_FORMAT_YUYV: + case PixelFormat::YUYV: { if ((x & 1) == 0) { c1 = color; @@ -69,6 +69,8 @@ static void draw_pixel(DumbFramebuffer& buf, unsigned x, unsigned y, RGB color) p[3] = (yuv1.v + yuv2.v) / 2; break; } + default: + throw std::invalid_argument("unknown pixelformat"); } } -- cgit v1.2.3