Skip to content

Commit 87db861

Browse files
feat: parity with display-uefi example
1 parent c5907b2 commit 87db861

File tree

2 files changed

+279
-9
lines changed

2 files changed

+279
-9
lines changed

build.zig.zon

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
.hash = "1220d2ec9243d536336636288e99d77388d6c80a3dbf6cea02a35e7f6feaf37235cf",
99
},
1010
.@"phantom.display.uefi" = .{
11-
.url = "https://github.com/PhantomUIx/display-uefi/archive/85551ee93471d862e1e9954631eec10b95013e07.tar.gz",
12-
.hash = "12200ecf708dfaf4345cc3cd29b6ea98b7678e8d6ba6125bd564249f2110341988b4",
11+
.url = "https://github.com/PhantomUIx/display-uefi/archive/b8cca2bc89c1ca18286dcff532c078f03796ed15.tar.gz",
12+
.hash = "1220ee53b7c05fab7f5f6a54a5ae3b41b4d2065d3e42d19dfa99e392e4f3c5e0b936",
1313
},
1414
.phantom = .{
15-
.url = "https://github.com/PhantomUIx/core/archive/2646d5559bc49ed09f08562b0a72737b9d9eb412.tar.gz",
16-
.hash = "12205969c3bc047bea9d42ddd7c0486da4a519430b1dc2e02f190debb1afdefae465",
15+
.url = "https://github.com/PhantomUIx/core/archive/2db7b2a76366cfb99ebe339562ee283e75c6048b.tar.gz",
16+
.hash = "12200a1841006e5a45b0757e7edc1a9e291972ca4711afad16fefb2af5a8bd00c210",
1717
},
1818
.vizops = .{
19-
.url = "https://github.com/MidstallSoftware/vizops/archive/7a1b49fea05d75cabc920c247eba0274e91bf967.tar.gz",
20-
.hash = "12208e6d1334b77b2ac9351867da74dbce8f8470ea0367ffa1531fcf42e22b631371",
19+
.url = "https://github.com/MidstallSoftware/vizops/archive/e29a12c162d01a2e53727cab3940a3c029ab2968.tar.gz",
20+
.hash = "1220455bbe6f95bea0fe18cf3451ec162d60d93cb54a8a19dfdb4060951da8025116",
2121
},
2222
},
2323
}

src/compositor.zig

Lines changed: 273 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,251 @@ const sceneBackendType: phantom.scene.BackendType = @enumFromInt(@intFromEnum(op
1111
const sceneBackend = phantom.scene.Backend(sceneBackendType);
1212

1313
pub fn main() void {
14+
const colors: []const [17]vizops.color.Any = &.{
15+
.{
16+
.{
17+
.uint8 = .{
18+
.sRGB = .{
19+
.value = .{ 0xf7, 0x76, 0x8e, 0xff },
20+
},
21+
},
22+
},
23+
.{
24+
.uint8 = .{
25+
.sRGB = .{
26+
.value = .{ 0xff, 0x9e, 0x64, 0xff },
27+
},
28+
},
29+
},
30+
.{
31+
.uint8 = .{
32+
.sRGB = .{
33+
.value = .{ 0xe0, 0xaf, 0x68, 0xff },
34+
},
35+
},
36+
},
37+
.{
38+
.uint8 = .{
39+
.sRGB = .{
40+
.value = .{ 0x9e, 0xce, 0x6a, 0xff },
41+
},
42+
},
43+
},
44+
.{
45+
.uint8 = .{
46+
.sRGB = .{
47+
.value = .{ 0x73, 0xda, 0xca, 0xff },
48+
},
49+
},
50+
},
51+
.{
52+
.uint8 = .{
53+
.sRGB = .{
54+
.value = .{ 0xb4, 0xf9, 0xf8, 0xff },
55+
},
56+
},
57+
},
58+
.{
59+
.uint8 = .{
60+
.sRGB = .{
61+
.value = .{ 0x2a, 0xc3, 0xde, 0xff },
62+
},
63+
},
64+
},
65+
.{
66+
.uint8 = .{
67+
.sRGB = .{
68+
.value = .{ 0x7d, 0xcf, 0xff, 0xff },
69+
},
70+
},
71+
},
72+
.{
73+
.uint8 = .{
74+
.sRGB = .{
75+
.value = .{ 0x7a, 0xa2, 0xf7, 0xff },
76+
},
77+
},
78+
},
79+
.{
80+
.uint8 = .{
81+
.sRGB = .{
82+
.value = .{ 0xbb, 0x9a, 0xf7, 0xff },
83+
},
84+
},
85+
},
86+
.{
87+
.uint8 = .{
88+
.sRGB = .{
89+
.value = .{ 0xc0, 0xca, 0xf5, 0xff },
90+
},
91+
},
92+
},
93+
.{
94+
.uint8 = .{
95+
.sRGB = .{
96+
.value = .{ 0xa9, 0xb1, 0xd6, 0xff },
97+
},
98+
},
99+
},
100+
.{
101+
.uint8 = .{
102+
.sRGB = .{
103+
.value = .{ 0x9a, 0xa5, 0xce, 0xff },
104+
},
105+
},
106+
},
107+
.{
108+
.uint8 = .{
109+
.sRGB = .{
110+
.value = .{ 0xcf, 0xc9, 0xc2, 0xff },
111+
},
112+
},
113+
},
114+
.{
115+
.uint8 = .{
116+
.sRGB = .{
117+
.value = .{ 0x56, 0x5f, 0x89, 0xff },
118+
},
119+
},
120+
},
121+
.{
122+
.uint8 = .{
123+
.sRGB = .{
124+
.value = .{ 0x41, 0x48, 0x68, 0xff },
125+
},
126+
},
127+
},
128+
.{
129+
.uint8 = .{
130+
.sRGB = .{
131+
.value = .{ 0x1a, 0x1b, 0x26, 0xff },
132+
},
133+
},
134+
},
135+
},
136+
.{
137+
.{
138+
.uint8 = .{
139+
.sRGB = .{
140+
.value = .{ 0xf7, 0x76, 0x8e, 0xff },
141+
},
142+
},
143+
},
144+
.{
145+
.uint8 = .{
146+
.sRGB = .{
147+
.value = .{ 0xff, 0x9e, 0x64, 0xff },
148+
},
149+
},
150+
},
151+
.{
152+
.uint8 = .{
153+
.sRGB = .{
154+
.value = .{ 0xe0, 0xaf, 0x68, 0xff },
155+
},
156+
},
157+
},
158+
.{
159+
.uint8 = .{
160+
.sRGB = .{
161+
.value = .{ 0x9e, 0xce, 0x6a, 0xff },
162+
},
163+
},
164+
},
165+
.{
166+
.uint8 = .{
167+
.sRGB = .{
168+
.value = .{ 0x73, 0xda, 0xca, 0xff },
169+
},
170+
},
171+
},
172+
.{
173+
.uint8 = .{
174+
.sRGB = .{
175+
.value = .{ 0xb4, 0xf9, 0xf8, 0xff },
176+
},
177+
},
178+
},
179+
.{
180+
.uint8 = .{
181+
.sRGB = .{
182+
.value = .{ 0x2a, 0xc3, 0xde, 0xff },
183+
},
184+
},
185+
},
186+
.{
187+
.uint8 = .{
188+
.sRGB = .{
189+
.value = .{ 0x7d, 0xcf, 0xff, 0xff },
190+
},
191+
},
192+
},
193+
.{
194+
.uint8 = .{
195+
.sRGB = .{
196+
.value = .{ 0x7a, 0xa2, 0xf7, 0xff },
197+
},
198+
},
199+
},
200+
.{
201+
.uint8 = .{
202+
.sRGB = .{
203+
.value = .{ 0xbb, 0x9a, 0xf7, 0xff },
204+
},
205+
},
206+
},
207+
.{
208+
.uint8 = .{
209+
.sRGB = .{
210+
.value = .{ 0xc0, 0xca, 0xf5, 0xff },
211+
},
212+
},
213+
},
214+
.{
215+
.uint8 = .{
216+
.sRGB = .{
217+
.value = .{ 0xa9, 0xb1, 0xd6, 0xff },
218+
},
219+
},
220+
},
221+
.{
222+
.uint8 = .{
223+
.sRGB = .{
224+
.value = .{ 0x9a, 0xa5, 0xce, 0xff },
225+
},
226+
},
227+
},
228+
.{
229+
.uint8 = .{
230+
.sRGB = .{
231+
.value = .{ 0xcf, 0xc9, 0xc2, 0xff },
232+
},
233+
},
234+
},
235+
.{
236+
.uint8 = .{
237+
.sRGB = .{
238+
.value = .{ 0x56, 0x5f, 0x89, 0xff },
239+
},
240+
},
241+
},
242+
.{
243+
.uint8 = .{
244+
.sRGB = .{
245+
.value = .{ 0x41, 0x48, 0x68, 0xff },
246+
},
247+
},
248+
},
249+
.{
250+
.uint8 = .{
251+
.sRGB = .{
252+
.value = .{ 0x24, 0x28, 0x3b, 0xff },
253+
},
254+
},
255+
},
256+
},
257+
};
258+
14259
const alloc = if (builtin.link_libc) std.heap.c_allocator else if (builtin.os.tag == .uefi) std.os.uefi.pool_allocator else std.heap.page_allocator;
15260

16261
var display = displayBackend.Display.init(alloc, .compositor);
@@ -26,7 +271,7 @@ pub fn main() void {
26271
.scale = vizops.vector.Float32Vector2.init(1.0),
27272
.name = "display-0",
28273
.manufacturer = "PhantomUI",
29-
.format = try vizops.color.fourcc.Value.decode(vizops.color.fourcc.formats.argb16161616),
274+
.colorFormat = vizops.color.fourcc.Value.decode(vizops.color.fourcc.formats.argb16161616) catch |e| @panic(@errorName(e)),
30275
}) catch |e| @panic(@errorName(e));
31276
}
32277

@@ -47,6 +292,31 @@ pub fn main() void {
47292
}
48293

49294
const scene = surface.createScene(@enumFromInt(@intFromEnum(sceneBackendType))) catch |e| @panic(@errorName(e));
50-
_ = scene;
51-
// TODO: render something to the scene
295+
296+
var children: [17]*phantom.scene.Node = undefined;
297+
298+
for (&children, colors[0]) |*child, color| {
299+
child.* = scene.createNode(.NodeRect, .{
300+
.color = color,
301+
.size = vizops.vector.Float32Vector2.init([_]f32{ 100.0 / 17.0, 100.0 }),
302+
}) catch |e| @panic(@errorName(e));
303+
}
304+
305+
const flex = scene.createNode(.NodeFlex, .{
306+
.direction = phantom.painting.Axis.horizontal,
307+
.children = &children,
308+
}) catch |e| @panic(@errorName(e));
309+
defer flex.deinit();
310+
311+
var i: usize = 0;
312+
while (i < 5) : (i += 1) {
313+
_ = scene.frame(flex) catch |e| @panic(@errorName(e));
314+
315+
const currPalette = scene.seq % colors.len;
316+
for (children, colors[currPalette]) |child, color| {
317+
child.setProperties(.{ .color = color }) catch |e| @panic(@errorName(e));
318+
}
319+
320+
flex.setProperties(.{ .children = &children }) catch |e| @panic(@errorName(e));
321+
}
52322
}

0 commit comments

Comments
 (0)