From 811a6bd572f4c6b26e99b4e746f5d710947ee934 Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Sun, 2 Feb 2025 21:54:14 +0100 Subject: screen: drm change struct layout --- src/screen/drm/buffer/root.zig | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/screen/drm/buffer/root.zig (limited to 'src/screen/drm/buffer/root.zig') diff --git a/src/screen/drm/buffer/root.zig b/src/screen/drm/buffer/root.zig new file mode 100644 index 0000000..e967d51 --- /dev/null +++ b/src/screen/drm/buffer/root.zig @@ -0,0 +1,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(); + } +}; + -- cgit v1.2.3-70-g09d2