summaryrefslogtreecommitdiff
path: root/src/screen/drm/buffer/root.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/screen/drm/buffer/root.zig')
-rw-r--r--src/screen/drm/buffer/root.zig18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/screen/drm/buffer/root.zig b/src/screen/drm/buffer/root.zig
index d40fd8d..f14ed66 100644
--- a/src/screen/drm/buffer/root.zig
+++ b/src/screen/drm/buffer/root.zig
@@ -1,4 +1,5 @@
const drm = @import("../root.zig");
+const graphics = @import("estd").graphics;
pub const Buffer = struct {
const Self = @This();
@@ -7,7 +8,7 @@ pub const Buffer = struct {
current: Raw,
crtc: Raw,
- pub fn init(card: *drm.Card, width: u32, height: u32) !Self {
+ 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),
@@ -15,10 +16,6 @@ pub const Buffer = struct {
}
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;
@@ -32,5 +29,16 @@ pub const Buffer = struct {
self.current.deinit();
self.crtc.deinit();
}
+
+ pub fn canvas(self: *Self) graphics.Canvas {
+ return .{
+ .width = self.current.width,
+ .height = self.current.height,
+ .buffer = @as(
+ [*]volatile graphics.Pixel,
+ @ptrCast(@alignCast(self.current.bytes))
+ )[0..self.current.bytes.len / 4],
+ };
+ }
};