summaryrefslogtreecommitdiff
path: root/src/screen/drm/buffer/root.zig
blob: d40fd8dd1239594c865685f8e703f4ca9f70bb30 (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
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) !Self {
		return .{
			.current = try Raw.init(card, width, height),
			.crtc = try Raw.init(card, width, height),
		};
	}

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

		const bytes = self.current.bytes;
		self.current.bytes = self.crtc.bytes;
		self.crtc.bytes = bytes;

		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();
	}
};