diff options
Diffstat (limited to 'src/screen/drm/buffer/root.zig')
| -rw-r--r-- | src/screen/drm/buffer/root.zig | 32 |
1 files changed, 32 insertions, 0 deletions
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(); + } +}; + |