summaryrefslogtreecommitdiff
path: root/src/image.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-05 11:40:11 -0300
committerGabriel Schneider <[email protected]>2026-11-05 12:41:36 -0300
commit3f1533813b6692a736251e4d467a7f108229ddee (patch)
tree37a32c5ebbf9d3af08923856fd6fa516f3b33a39 /src/image.zig
parentcfd2b993feda1b3f7474225bb32db8cac8edc5ae (diff)
downloadpardes-3f1533813b6692a736251e4d467a7f108229ddee.tar.gz
pardes-3f1533813b6692a736251e4d467a7f108229ddee.zip
targets: the DOM web shell goes (src/web.zig and src/web/, its harnesses web_harness, web_snapshot, web_driver_test and web-snapshots/, tools/web_fixture.py, -Dplatform=web, -Ddump, and the web, web-harness, web-snap, web-e2e and web-driver-test steps), and with it what only a freestanding build needed: `hosted` and every guard on it (every build has a host now), memory's stack-fallback arenas and reduced_target sizes, the emscripten main, the tree-sitter libc shim and the stb stub, lsp's has_client, the web arms of the platform switches (-Dplatform is tui, gui or macos); the macOS files pass zig ast-check; docs/web.md is a paragraph on what it was
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/image.zig')
-rw-r--r--src/image.zig17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/image.zig b/src/image.zig
index 09522612..aeb0423a 100644
--- a/src/image.zig
+++ b/src/image.zig
@@ -726,10 +726,8 @@ var started = false;
extern fn stbi_info_from_memory(buffer: [*]const u8, len: c_int, x: *c_int, y: *c_int, comp: *c_int) c_int;
-/// stb_image's header reader; a freestanding build has no stb_image (its
-/// decoder is the shim in src/web/zstbi.zig), so no header reads as one.
+/// stb_image's header reader.
fn stbiInfo(bytes: []const u8, w: *c_int, h: *c_int, c: *c_int) bool {
- if (comptime !pardes.hosted) return false;
return stbi_info_from_memory(bytes.ptr, @intCast(bytes.len), w, h, c) == 1;
}
@@ -907,9 +905,6 @@ const GridKey = struct {
ascii: bool = true,
};
-/// A host's thread; a freestanding build has none to have.
-const Decoder = if (pardes.hosted) std.Thread else void;
-
pub const State = struct {
/// What the replay digest leaves out (src/walk.zig): the picture as
/// decoded from its bytes, off the loop as the render first wants it,
@@ -928,12 +923,12 @@ pub const State = struct {
grid: GlyphArt.Grid = .{ .cells = &.{}, .cols = 0, .rows = 0 },
grid_key: GridKey = .{},
/// The decode under way off the loop (ensureDecoded), and its answer.
- decoder: ?Decoder = null,
+ decoder: ?std.Thread = null,
decoded: std.atomic.Value(bool) = .init(false),
answer: ?Decoded = null,
pub fn deinit(state: *State, gpa: std.mem.Allocator) void {
- if (comptime pardes.hosted) if (state.decoder) |t| t.join();
+ if (state.decoder) |t| t.join();
if (state.answer) |a| gpa.free(a.rgba);
gpa.free(state.path);
if (state.rgba.len > 0) gpa.free(state.rgba);
@@ -995,11 +990,11 @@ pub fn tagPrefix(arena: std.mem.Allocator, state: *const State, glyphs: bool) ![
/// docs' screenshot: all of it once on the frame before).
/// ponytail: a thread a picture; a pool if many open at once.
fn ensureDecoded(p: *pardes.Pardes, state: *State) void {
- if (comptime pardes.hosted) if (state.decoder) |t| {
+ if (state.decoder) |t| {
if (!state.decoded.load(.acquire)) return;
t.join();
state.decoder = null;
- };
+ }
if (state.answer) |decoded| {
state.answer = null;
state.rgba = decoded.rgba;
@@ -1015,7 +1010,7 @@ fn ensureDecoded(p: *pardes.Pardes, state: *State) void {
st.decoded.store(true, .release);
}
};
- if (comptime pardes.hosted and !builtin.is_test) {
+ if (comptime !builtin.is_test) {
if (std.Thread.spawn(.{}, Work.run, .{ p.image_gpa, state })) |t| {
state.decoder = t;
return;