From 9fd81c0b38b2b843c24fb61bf8cb5b7873deaa72 Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Wed, 12 Feb 2025 12:48:11 +0100 Subject: graphics: add line --- src/screen/drm/buffer/raw.zig | 2 +- src/screen/drm/buffer/root.zig | 2 +- src/screen/drm/pixel.zig | 18 ------------------ src/screen/drm/request/frame-buffer.zig | 13 ++++++++++++- src/screen/drm/root.zig | 1 - 5 files changed, 14 insertions(+), 22 deletions(-) (limited to 'src/screen/drm') diff --git a/src/screen/drm/buffer/raw.zig b/src/screen/drm/buffer/raw.zig index c5a04f3..12784de 100644 --- a/src/screen/drm/buffer/raw.zig +++ b/src/screen/drm/buffer/raw.zig @@ -40,7 +40,7 @@ pub const Raw = struct { .id = 0, .width = fb.width, .height = fb.height, - .pixel_format = drm.Pixel.Format.xrgb8888, + .pixel_format = .xrgb8888, .flags = 0, .handles = [_] u32 { fb.handle, 0, 0, 0 }, .pitches = [_] u32 { fb.stride, 0, 0, 0 }, diff --git a/src/screen/drm/buffer/root.zig b/src/screen/drm/buffer/root.zig index f14ed66..30734f2 100644 --- a/src/screen/drm/buffer/root.zig +++ b/src/screen/drm/buffer/root.zig @@ -35,7 +35,7 @@ pub const Buffer = struct { .width = self.current.width, .height = self.current.height, .buffer = @as( - [*]volatile graphics.Pixel, + [*]volatile graphics.Color, @ptrCast(@alignCast(self.current.bytes)) )[0..self.current.bytes.len / 4], }; diff --git a/src/screen/drm/pixel.zig b/src/screen/drm/pixel.zig index 7c99e52..8b13789 100644 --- a/src/screen/drm/pixel.zig +++ b/src/screen/drm/pixel.zig @@ -1,19 +1 @@ -fn pixel_format_code(comptime a: u8, comptime b: u8, comptime c: u8, comptime d: u8) u32 { - return @as(u32, @intCast(a)) | - (@as(u32, @intCast(b)) << 8) | - (@as(u32, @intCast(c)) << 16) | - (@as(u32, @intCast(d)) << 24); -} - -pub const Pixel = packed struct(u32) { - blue: u8, - green: u8, - red: u8, - _padding: u8 = 0x0, - - pub const Format = enum(u32) { - xrgb8888 = pixel_format_code('X', 'R', '2', '4'), - }; -}; - diff --git a/src/screen/drm/request/frame-buffer.zig b/src/screen/drm/request/frame-buffer.zig index 8f93862..c9077e8 100644 --- a/src/screen/drm/request/frame-buffer.zig +++ b/src/screen/drm/request/frame-buffer.zig @@ -10,11 +10,22 @@ pub const CreateDumb = extern struct { size: u32, }; +fn pixel_format_code(comptime a: u8, comptime b: u8, comptime c: u8, comptime d: u8) u32 { + return @as(u32, @intCast(a)) | + (@as(u32, @intCast(b)) << 8) | + (@as(u32, @intCast(c)) << 16) | + (@as(u32, @intCast(d)) << 24); +} + +pub const PixelFormat = enum(u32) { + xrgb8888 = pixel_format_code('X', 'R', '2', '4'), +}; + pub const FrameBufferCmd2 = extern struct { id: u32, width: u32, height: u32, - pixel_format: drm.Pixel.Format, + pixel_format: PixelFormat, flags: u32, handles: [4]u32, pitches: [4]u32, diff --git a/src/screen/drm/root.zig b/src/screen/drm/root.zig index 5012743..2417463 100644 --- a/src/screen/drm/root.zig +++ b/src/screen/drm/root.zig @@ -6,4 +6,3 @@ pub const Event = @import("event.zig").Event; pub const Connector = @import("connector/root.zig").Connector; pub const Crtc = @import("crtc.zig").Crtc; pub const Buffer = @import("buffer/root.zig").Buffer; -pub const Pixel = @import("pixel.zig").Pixel; -- cgit v1.2.3-70-g09d2