summaryrefslogtreecommitdiff
path: root/kms++util/src/extcpuframebuffer.cpp
blob: feb3addd091f7d883e2e3be1fff6fd25fdf6d920 (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

#include <kms++util/kms++util.h>

using namespace std;

namespace kms
{

ExtCPUFramebuffer::ExtCPUFramebuffer(uint32_t width, uint32_t height, PixelFormat format,
				     uint8_t* buffer, uint32_t size, uint32_t pitch, uint32_t offset)
	: m_width(width), m_height(height), m_format(format)
{
	const PixelFormatInfo& format_info = get_pixel_format_info(m_format);

	m_num_planes = format_info.num_planes;

	ASSERT(m_num_planes == 1);

	FramebufferPlane& plane = m_planes[0];

	plane.stride = pitch;
	plane.size = size;
	plane.offset = offset;
	plane.map = buffer;
}

ExtCPUFramebuffer::ExtCPUFramebuffer(uint32_t width, uint32_t height, PixelFormat format,
				     uint8_t* buffers[4], uint32_t sizes[4], uint32_t pitches[4], uint32_t offsets[4])
	: m_width(width), m_height(height), m_format(format)
{
	const PixelFormatInfo& format_info = get_pixel_format_info(m_format);

	m_num_planes = format_info.num_planes;

	for (unsigned i = 0; i < format_info.num_planes; ++i) {
		FramebufferPlane& plane = m_planes[i];

		plane.stride = pitches[i];
		plane.size = sizes[i];
		plane.offset = offsets[i];
		plane.map = buffers[i];
	}
}

ExtCPUFramebuffer::~ExtCPUFramebuffer()
{
}

}