blob: d2073bcaf248dc32c56eb02b2bc3df5068f570bf [file] [log] [blame]
Tomi Valkeinen83d27aa2016-03-15 11:46:09 +02001#pragma once
2
3#include "kms++.h"
4
5namespace kms
6{
7
8class CPUFramebuffer : public IMappedFramebuffer {
9public:
10 CPUFramebuffer(uint32_t width, uint32_t height, PixelFormat format);
11
12 virtual ~CPUFramebuffer();
13
14 CPUFramebuffer(const CPUFramebuffer& other) = delete;
15 CPUFramebuffer& operator=(const CPUFramebuffer& other) = delete;
16
17 uint32_t width() const { return m_width; }
18 uint32_t height() const { return m_height; }
19
20 PixelFormat format() const { return m_format; }
21 unsigned num_planes() const { return m_num_planes; }
22
23 uint32_t stride(unsigned plane) const { return m_planes[plane].stride; }
24 uint32_t size(unsigned plane) const { return m_planes[plane].size; }
25 uint32_t offset(unsigned plane) const { return m_planes[plane].offset; }
26 uint8_t* map(unsigned plane) { return m_planes[plane].map; }
27
28private:
29 struct FramebufferPlane {
30 uint32_t size;
31 uint32_t stride;
32 uint32_t offset;
33 uint8_t *map;
34 };
35
36 uint32_t m_width;
37 uint32_t m_height;
38 PixelFormat m_format;
39
40 unsigned m_num_planes;
41 struct FramebufferPlane m_planes[4];
42};
43
44}