1 #pragma once 2 3 #include <kms++/kms++.h> 4 5 namespace kms 6 { 7 8 class CPUFramebuffer : public IFramebuffer { 9 public: 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 width()17 uint32_t width() const { return m_width; } height()18 uint32_t height() const { return m_height; } 19 format()20 PixelFormat format() const { return m_format; } num_planes()21 unsigned num_planes() const { return m_num_planes; } 22 stride(unsigned plane)23 uint32_t stride(unsigned plane) const { return m_planes[plane].stride; } size(unsigned plane)24 uint32_t size(unsigned plane) const { return m_planes[plane].size; } offset(unsigned plane)25 uint32_t offset(unsigned plane) const { return m_planes[plane].offset; } map(unsigned plane)26 uint8_t* map(unsigned plane) { return m_planes[plane].map; } 27 28 private: 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 } 45