From a5c28bcb2ead34e921617711ebf94ffcb5d72878 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Mon, 23 May 2016 09:54:08 +0300 Subject: File/dir renames --- libkms++util/cpuframebuffer.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 libkms++util/cpuframebuffer.cpp (limited to 'libkms++util/cpuframebuffer.cpp') diff --git a/libkms++util/cpuframebuffer.cpp b/libkms++util/cpuframebuffer.cpp new file mode 100644 index 0000000..1f14ddc --- /dev/null +++ b/libkms++util/cpuframebuffer.cpp @@ -0,0 +1,36 @@ +#include + +#include "cpuframebuffer.h" + +using namespace std; + +namespace kms { + +CPUFramebuffer::CPUFramebuffer(uint32_t width, uint32_t height, PixelFormat format) + : m_width(width), m_height(height), m_format(format) +{ + const PixelFormatInfo& format_info = get_pixel_format_info(m_format); + + m_num_planes = format_info.num_planes; + + for (unsigned i = 0; i < format_info.num_planes; ++i) { + const PixelFormatPlaneInfo& pi = format_info.planes[i]; + FramebufferPlane& plane = m_planes[i]; + + plane.stride = width * pi.bitspp / 8; + plane.size = plane.stride * height/ pi.ysub; + plane.offset = 0; + plane.map = new uint8_t[plane.size]; + } +} + +CPUFramebuffer::~CPUFramebuffer() +{ + for (unsigned i = 0; i < m_num_planes; ++i) { + FramebufferPlane& plane = m_planes[i]; + + delete plane.map; + } +} + +} -- cgit v1.2.3