summaryrefslogtreecommitdiff
path: root/libkms++
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@iki.fi>2015-10-03 23:29:18 +0300
committerTomi Valkeinen <tomi.valkeinen@iki.fi>2015-10-04 10:21:56 +0300
commit8a991ee6b675d18739557e004ce993fa090ef0b5 (patch)
tree3ec4413fc64a6cc9bcaa3c6bd1467c18a166fad3 /libkms++
parent2c0f9b2d85b71b916ef5c53d0b8c814167ae8525 (diff)
use PixelFormat all around
Diffstat (limited to 'libkms++')
-rw-r--r--libkms++/dumbframebuffer.cpp30
-rw-r--r--libkms++/dumbframebuffer.h6
2 files changed, 17 insertions, 19 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;
};
}