summaryrefslogtreecommitdiff
path: root/src/image.zig
diff options
context:
space:
mode:
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;