1 #pragma once
3 #include "drmobject.h"
5 namespace kms
6 {
8 class Framebuffer : public DrmObject
9 {
10 public:
11 Framebuffer(Card& card, uint32_t width, uint32_t height, const char* fourcc);
12 virtual ~Framebuffer();
14 void print_short() const;
16 uint32_t width() const { return m_width; }
17 uint32_t height() const { return m_height; }
18 uint32_t format() const { return m_format; }
20 uint8_t* map(unsigned plane) const { return m_planes[plane].map; }
21 uint32_t stride(unsigned plane) const { return m_planes[plane].stride; }
22 uint32_t size(unsigned plane) const { return m_planes[plane].size; }
24 void clear();
26 private:
27 struct FramebufferPlane {
28 uint32_t handle;
29 uint32_t size;
30 uint32_t stride;
31 uint8_t *map;
32 };
34 void Create(uint32_t width, uint32_t height, uint32_t format);
35 void Destroy();
37 unsigned m_num_planes;
38 struct FramebufferPlane m_planes[4];
40 uint32_t m_width;
41 uint32_t m_height;
42 uint32_t m_format;
43 };
44 }