1 #pragma once 2 3 #include "drmobject.h" 4 #include "pixelformats.h" 5 6 namespace kms 7 { 8 enum class CpuAccess { 9 Read, 10 Write, 11 ReadWrite, 12 }; 13 14 class IFramebuffer 15 { 16 public: ~IFramebuffer()17 virtual ~IFramebuffer() {} 18 19 virtual uint32_t width() const = 0; 20 virtual uint32_t height() const = 0; 21 format()22 virtual PixelFormat format() const { throw std::runtime_error("not implemented"); } num_planes()23 virtual unsigned num_planes() const { throw std::runtime_error("not implemented"); } 24 stride(unsigned plane)25 virtual uint32_t stride(unsigned plane) const { throw std::runtime_error("not implemented"); } size(unsigned plane)26 virtual uint32_t size(unsigned plane) const { throw std::runtime_error("not implemented"); } offset(unsigned plane)27 virtual uint32_t offset(unsigned plane) const { throw std::runtime_error("not implemented"); } map(unsigned plane)28 virtual uint8_t* map(unsigned plane) { throw std::runtime_error("not implemented"); } prime_fd(unsigned plane)29 virtual int prime_fd(unsigned plane) { throw std::runtime_error("not implemented"); } 30 begin_cpu_access(CpuAccess access)31 virtual void begin_cpu_access(CpuAccess access) {} end_cpu_access()32 virtual void end_cpu_access() {} 33 }; 34 35 class Framebuffer : public DrmObject, public IFramebuffer 36 { 37 public: 38 Framebuffer(Card& card, uint32_t id); 39 ~Framebuffer() override; 40 width()41 uint32_t width() const override { return m_width; } height()42 uint32_t height() const override { return m_height; } 43 44 void flush(); 45 46 protected: 47 Framebuffer(Card& card, uint32_t width, uint32_t height); 48 49 private: 50 uint32_t m_width; 51 uint32_t m_height; 52 }; 53 54 } // namespace kms 55