diff options
| author | Tomi Valkeinen <tomi.valkeinen@iki.fi> | 2015-10-03 23:33:27 +0300 | 
|---|---|---|
| committer | Tomi Valkeinen <tomi.valkeinen@iki.fi> | 2015-10-04 10:21:56 +0300 | 
| commit | e4e0e144f6cdb9ec5f1d3e1b1ba044a013f90c14 (patch) | |
| tree | 5943b403e3ecd1f432921e03c19584e2b3f5ba76 | |
| parent | 8a991ee6b675d18739557e004ce993fa090ef0b5 (diff) | |
DumbFB: clean up format_info code
| -rw-r--r-- | libkms++/dumbframebuffer.cpp | 25 | 
1 files changed, 7 insertions, 18 deletions
| diff --git a/libkms++/dumbframebuffer.cpp b/libkms++/dumbframebuffer.cpp index e493b9f..4e3b56b 100644 --- a/libkms++/dumbframebuffer.cpp +++ b/libkms++/dumbframebuffer.cpp @@ -47,38 +47,27 @@ struct FormatPlaneInfo  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; | 
