1 #pragma once 2 3 #include <kms++/kms++.h> 4 5 namespace kms 6 { 7 class ExtCPUFramebuffer : public IFramebuffer 8 { 9 public: 10 ExtCPUFramebuffer(uint32_t width, uint32_t height, PixelFormat format, 11 uint8_t* buffer, uint32_t size, uint32_t pitch, uint32_t offset); 12 ExtCPUFramebuffer(uint32_t width, uint32_t height, PixelFormat format, 13 uint8_t* buffers[4], uint32_t sizes[4], uint32_t pitches[4], uint32_t offsets[4]); 14 virtual ~ExtCPUFramebuffer(); 15 width()16 uint32_t width() const { return m_width; } height()17 uint32_t height() const { return m_height; } 18 format()19 PixelFormat format() const { return m_format; } num_planes()20 unsigned num_planes() const { return m_num_planes; } 21 stride(unsigned plane)22 uint32_t stride(unsigned plane) const { return m_planes[plane].stride; } size(unsigned plane)23 uint32_t size(unsigned plane) const { return m_planes[plane].size; } offset(unsigned plane)24 uint32_t offset(unsigned plane) const { return m_planes[plane].offset; } map(unsigned plane)25 uint8_t* map(unsigned plane) { return m_planes[plane].map; } 26 27 private: 28 struct FramebufferPlane { 29 uint32_t size; 30 uint32_t stride; 31 uint32_t offset; 32 uint8_t* map; 33 }; 34 35 uint32_t m_width; 36 uint32_t m_height; 37 PixelFormat m_format; 38 39 unsigned m_num_planes; 40 struct FramebufferPlane m_planes[4]; 41 }; 42 } // namespace kms 43