summaryrefslogtreecommitdiff
path: root/src/screen/drm/buffer/root.zig
blob: e967d5147c7d6742132637804504cc5c9ae4be90 (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
const drm = @import("../root.zig");

pub const Buffer = struct {
	const Self = @This();
	pub const Raw = @import("raw.zig").Raw;

	current: Raw,
	crtc: Raw,

	pub fn init(card: *drm.Card, width: u32, height: u32, bpp: u32) !Self {
		return .{
			.current = try Raw.init(card, width, height, bpp),
			.crtc = try Raw.init(card, width, height, bpp),
		};
	}

	pub fn swap(self: *Self) void {
		const data = self.current.data;
		self.current.data = self.crtc.data;
		self.crtc.data = data;

		const id = self.current.id;
		self.current.id = self.crtc.id;
		self.crtc.id = id;
	}

	pub fn deinit(self: *Self) void {
		self.current.deinit();
		self.crtc.deinit();
	}
};