diff options
-rw-r--r-- | libkms++/dumbframebuffer.cpp | 30 | ||||
-rw-r--r-- | libkms++/dumbframebuffer.h | 6 | ||||
-rw-r--r-- | libkmstest/colorbar.cpp | 12 | ||||
-rw-r--r-- | libkmstest/conv.cpp | 14 | ||||
-rw-r--r-- | libkmstest/testpat.cpp | 10 | ||||
-rw-r--r-- | tests/db.cpp | 4 | ||||
-rw-r--r-- | tests/testpat.cpp | 4 |
7 files changed, 40 insertions, 40 deletions
diff --git a/libkms++/dumbframebuffer.cpp b/libkms++/dumbframebuffer.cpp index abea762..e493b9f 100644 --- a/libkms++/dumbframebuffer.cpp +++ b/libkms++/dumbframebuffer.cpp @@ -23,9 +23,9 @@ DumbFramebuffer::DumbFramebuffer(Card &card, uint32_t width, uint32_t height, co } DumbFramebuffer::DumbFramebuffer(Card& card, uint32_t width, uint32_t height, PixelFormat format) - :Framebuffer(card, width, height) + :Framebuffer(card, width, height), m_format(format) { - Create(width, height, (uint32_t)format); + Create(); } DumbFramebuffer::~DumbFramebuffer() @@ -47,24 +47,24 @@ struct FormatPlaneInfo struct FormatInfo { - uint32_t format; + PixelFormat format; uint8_t num_planes; struct FormatPlaneInfo planes[4]; }; static const FormatInfo format_info_array[] = { /* YUV packed */ - { DRM_FORMAT_UYVY, 1, { { 32, 2, 1 } }, }, - { DRM_FORMAT_YUYV, 1, { { 32, 2, 1 } }, }, + { PixelFormat::UYVY, 1, { { 32, 2, 1 } }, }, + { PixelFormat::YUYV, 1, { { 32, 2, 1 } }, }, /* YUV semi-planar */ - { DRM_FORMAT_NV12, 2, { { 8, 1, 1, }, { 16, 2, 2 } }, }, + { PixelFormat::NV12, 2, { { 8, 1, 1, }, { 16, 2, 2 } }, }, /* RGB16 */ - { DRM_FORMAT_RGB565, 1, { { 16, 1, 1 } }, }, + { PixelFormat::RGB565, 1, { { 16, 1, 1 } }, }, /* RGB32 */ - { DRM_FORMAT_XRGB8888, 1, { { 32, 1, 1 } }, }, + { PixelFormat::XRGB8888, 1, { { 32, 1, 1 } }, }, }; -static const FormatInfo& find_format(uint32_t format) +static const FormatInfo& find_format(PixelFormat format) { for (uint i = 0; i < ARRAY_SIZE(format_info_array); ++i) { if (format == format_info_array[i].format) @@ -74,13 +74,11 @@ static const FormatInfo& find_format(uint32_t format) throw std::invalid_argument("foo"); } -void DumbFramebuffer::Create(uint32_t width, uint32_t height, uint32_t format) +void DumbFramebuffer::Create() { int r; - m_format = format; - - const FormatInfo& format_info = find_format(format); + const FormatInfo& format_info = find_format(m_format); m_num_planes = format_info.num_planes; @@ -90,8 +88,8 @@ void DumbFramebuffer::Create(uint32_t width, uint32_t height, uint32_t format) /* create dumb buffer */ struct drm_mode_create_dumb creq = drm_mode_create_dumb(); - creq.width = width / pi.xsub; - creq.height = height / pi.ysub; + creq.width = width() / pi.xsub; + creq.height = height() / pi.ysub; creq.bpp = pi.bitspp; r = drmIoctl(card().fd(), DRM_IOCTL_MODE_CREATE_DUMB, &creq); if (r) @@ -128,7 +126,7 @@ void DumbFramebuffer::Create(uint32_t width, uint32_t height, uint32_t format) uint32_t pitches[4] = { m_planes[0].stride, m_planes[1].stride }; uint32_t offsets[4] = { 0 }; uint32_t id; - r = drmModeAddFB2(card().fd(), width, height, format, + r = drmModeAddFB2(card().fd(), width(), height(), (uint32_t)format(), bo_handles, pitches, offsets, &id, 0); if (r) throw std::invalid_argument("foo"); diff --git a/libkms++/dumbframebuffer.h b/libkms++/dumbframebuffer.h index 25a3c2e..c3c0adb 100644 --- a/libkms++/dumbframebuffer.h +++ b/libkms++/dumbframebuffer.h @@ -14,7 +14,7 @@ public: void print_short() const; - uint32_t format() const { return m_format; } + PixelFormat format() const { return m_format; } uint8_t* map(unsigned plane) const { return m_planes[plane].map; } uint32_t stride(unsigned plane) const { return m_planes[plane].stride; } @@ -30,12 +30,12 @@ private: uint8_t *map; }; - void Create(uint32_t width, uint32_t height, uint32_t format); + void Create(); void Destroy(); unsigned m_num_planes; struct FramebufferPlane m_planes[4]; - uint32_t m_format; + PixelFormat m_format; }; } 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"); } } diff --git a/tests/db.cpp b/tests/db.cpp index 84fb767..c72d121 100644 --- a/tests/db.cpp +++ b/tests/db.cpp @@ -106,8 +106,8 @@ int main() auto mode = conn->get_default_mode(); - auto fb1 = new DumbFramebuffer(card, mode.hdisplay, mode.vdisplay, "XR24"); - auto fb2 = new DumbFramebuffer(card, mode.hdisplay, mode.vdisplay, "XR24"); + auto fb1 = new DumbFramebuffer(card, mode.hdisplay, mode.vdisplay, PixelFormat::XRGB8888); + auto fb2 = new DumbFramebuffer(card, mode.hdisplay, mode.vdisplay, PixelFormat::XRGB8888); printf("conn %u, crtc %u, fb1 %u, fb2 %u\n", conn->id(), crtc->id(), fb1->id(), fb2->id()); diff --git a/tests/testpat.cpp b/tests/testpat.cpp index 02f195a..52e9713 100644 --- a/tests/testpat.cpp +++ b/tests/testpat.cpp @@ -30,7 +30,7 @@ int main() auto mode = conn->get_default_mode(); - auto fb = new DumbFramebuffer(card, mode.hdisplay, mode.vdisplay, "XR24"); + auto fb = new DumbFramebuffer(card, mode.hdisplay, mode.vdisplay, PixelFormat::XRGB8888); draw_test_pattern(*fb); fbs.push_back(fb); @@ -54,7 +54,7 @@ int main() } if (plane) { - auto planefb = new DumbFramebuffer(card, 400, 400, "YUYV"); + auto planefb = new DumbFramebuffer(card, 400, 400, PixelFormat::YUYV); draw_test_pattern(*planefb); fbs.push_back(planefb); |