diff options
Diffstat (limited to 'kms++util/src/cpuframebuffer.cpp')
| -rw-r--r-- | kms++util/src/cpuframebuffer.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/kms++util/src/cpuframebuffer.cpp b/kms++util/src/cpuframebuffer.cpp new file mode 100644 index 0000000..64ad531 --- /dev/null +++ b/kms++util/src/cpuframebuffer.cpp @@ -0,0 +1,35 @@ +#include <map> + +#include <kms++util/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) { + FramebufferPlane& plane = m_planes[i]; + + plane.stride = format_info.stride(width, i); + plane.size = format_info.planesize(plane.stride, height, i); + plane.offset = 0; + plane.map = new uint8_t[plane.size]; + } +} + +CPUFramebuffer::~CPUFramebuffer() +{ + for (unsigned i = 0; i < m_num_planes; ++i) { + const FramebufferPlane& plane = m_planes[i]; + + delete[] plane.map; + } +} + +} // namespace kms |
