• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #pragma once
2 
3 #include <array>
4 #include <vector>
5 
6 #include "framebuffer.h"
7 #include "pixelformats.h"
8 
9 namespace kms
10 {
11 class ExtFramebuffer : public Framebuffer
12 {
13 public:
14 	ExtFramebuffer(Card& card, uint32_t width, uint32_t height, PixelFormat format,
15 		       std::vector<uint32_t> handles, std::vector<uint32_t> pitches, std::vector<uint32_t> offsets, std::vector<uint64_t> modifiers = {});
16 	~ExtFramebuffer() override;
17 
width()18 	uint32_t width() const override { return Framebuffer::width(); }
height()19 	uint32_t height() const override { return Framebuffer::height(); }
20 
format()21 	PixelFormat format() const override { return m_format; }
num_planes()22 	unsigned num_planes() const override { return m_num_planes; }
23 
handle(unsigned plane)24 	uint32_t handle(unsigned plane) const { return m_planes.at(plane).handle; }
stride(unsigned plane)25 	uint32_t stride(unsigned plane) const override { return m_planes.at(plane).stride; }
size(unsigned plane)26 	uint32_t size(unsigned plane) const override { return m_planes.at(plane).size; }
offset(unsigned plane)27 	uint32_t offset(unsigned plane) const override { return m_planes.at(plane).offset; }
28 
29 private:
30 	struct FramebufferPlane {
31 		uint32_t handle;
32 		uint32_t size;
33 		uint32_t stride;
34 		uint32_t offset;
35 		uint64_t modifier;
36 		uint8_t* map;
37 	};
38 
39 	unsigned m_num_planes;
40 	std::array<FramebufferPlane, 4> m_planes;
41 
42 	PixelFormat m_format;
43 };
44 
45 } // namespace kms
46