1 #pragma once 2 3 #include <kms++/kms++.h> 4 5 namespace kms 6 { 7 8 class ExtCPUFramebuffer : public IFramebuffer 9 { 10 public: 11 ExtCPUFramebuffer(uint32_t width, uint32_t height, PixelFormat format, 12 uint8_t* buffer, uint32_t size, uint32_t pitch, uint32_t offset); 13 ExtCPUFramebuffer(uint32_t width, uint32_t height, PixelFormat format, 14 uint8_t* buffers[4], uint32_t sizes[4], uint32_t pitches[4], uint32_t offsets[4]); 15 virtual ~ExtCPUFramebuffer(); 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