summaryrefslogtreecommitdiff
path: root/kms++/inc/kms++/framebuffer.h
blob: bcfd1f05c7654f945e72759ee079292b9459a6eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#pragma once

#include "drmobject.h"
#include "pixelformats.h"

namespace kms
{
enum class CpuAccess
{
	Read,
	Write,
	ReadWrite,
};

class IFramebuffer {
public:
	virtual ~IFramebuffer() { }

	virtual uint32_t width() const = 0;
	virtual uint32_t height() const = 0;

	virtual PixelFormat format() const { throw std::runtime_error("not implemented"); }
	virtual unsigned num_planes() const { throw std::runtime_error("not implemented"); }

	virtual uint32_t stride(unsigned plane) const { throw std::runtime_error("not implemented"); }
	virtual uint32_t size(unsigned plane) const { throw std::runtime_error("not implemented"); }
	virtual uint32_t offset(unsigned plane) const { throw std::runtime_error("not implemented"); }
	virtual uint8_t* map(unsigned plane) { throw std::runtime_error("not implemented"); }
	virtual int prime_fd(unsigned plane) { throw std::runtime_error("not implemented"); }

	virtual void begin_cpu_access(CpuAccess access) { }
	virtual void end_cpu_access() { }
};

class Framebuffer : public DrmObject, public IFramebuffer
{
public:
	Framebuffer(Card& card, uint32_t id);
	~Framebuffer() override;

	uint32_t width() const override { return m_width; }
	uint32_t height() const override { return m_height; }

	void flush();
protected:
	Framebuffer(Card& card, uint32_t width, uint32_t height);

private:
	uint32_t m_width;
	uint32_t m_height;
};

}