summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8a991ee)
raw | patch | inline | side by side (parent: 8a991ee)
author | Tomi Valkeinen <tomi.valkeinen@iki.fi> | |
Sat, 3 Oct 2015 20:33:27 +0000 (23:33 +0300) | ||
committer | Tomi Valkeinen <tomi.valkeinen@iki.fi> | |
Sun, 4 Oct 2015 07:21:56 +0000 (10:21 +0300) |
libkms++/dumbframebuffer.cpp | patch | blob | history |
index e493b9fc4ba61855805d8fb1d0169d0e7c2b902d..4e3b56bef804c52d87e89fb8b8c824c4c7f7c6e5 100644 (file)
struct FormatInfo
{
- PixelFormat format;
uint8_t num_planes;
struct FormatPlaneInfo planes[4];
};
-static const FormatInfo format_info_array[] = {
+static const map<PixelFormat, FormatInfo> format_info_array = {
/* YUV packed */
- { PixelFormat::UYVY, 1, { { 32, 2, 1 } }, },
- { PixelFormat::YUYV, 1, { { 32, 2, 1 } }, },
+ { PixelFormat::UYVY, { 1, { { 32, 2, 1 } }, } },
+ { PixelFormat::YUYV, { 1, { { 32, 2, 1 } }, } },
/* YUV semi-planar */
- { PixelFormat::NV12, 2, { { 8, 1, 1, }, { 16, 2, 2 } }, },
+ { PixelFormat::NV12, { 2, { { 8, 1, 1, }, { 16, 2, 2 } }, } },
/* RGB16 */
- { PixelFormat::RGB565, 1, { { 16, 1, 1 } }, },
+ { PixelFormat::RGB565, { 1, { { 16, 1, 1 } }, } },
/* RGB32 */
- { PixelFormat::XRGB8888, 1, { { 32, 1, 1 } }, },
+ { PixelFormat::XRGB8888, { 1, { { 32, 1, 1 } }, } },
};
-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)
- return format_info_array[i];
- }
-
- throw std::invalid_argument("foo");
-}
-
void DumbFramebuffer::Create()
{
int r;
- const FormatInfo& format_info = find_format(m_format);
+ const FormatInfo& format_info = format_info_array.at(m_format);
m_num_planes = format_info.num_planes;