• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <map>
2 
3 #include <kms++util/cpuframebuffer.h>
4 
5 using namespace std;
6 
7 namespace kms {
8 
CPUFramebuffer(uint32_t width,uint32_t height,PixelFormat format)9 CPUFramebuffer::CPUFramebuffer(uint32_t width, uint32_t height, PixelFormat format)
10 	: m_width(width), m_height(height), m_format(format)
11 {
12 	const PixelFormatInfo& format_info = get_pixel_format_info(m_format);
13 
14 	m_num_planes = format_info.num_planes;
15 
16 	for (unsigned i = 0; i < format_info.num_planes; ++i) {
17 		const PixelFormatPlaneInfo& pi = format_info.planes[i];
18 		FramebufferPlane& plane = m_planes[i];
19 
20 		plane.stride = width * pi.bitspp / 8;
21 		plane.size = plane.stride * height/ pi.ysub;
22 		plane.offset = 0;
23 		plane.map = new uint8_t[plane.size];
24 	}
25 }
26 
~CPUFramebuffer()27 CPUFramebuffer::~CPUFramebuffer()
28 {
29 	for (unsigned i = 0; i < m_num_planes; ++i) {
30 		FramebufferPlane& plane = m_planes[i];
31 
32 		delete plane.map;
33 	}
34 }
35 
36 }
37