summaryrefslogtreecommitdiff
path: root/libkms++
diff options
context:
space:
mode:
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;
};
}