Address review comments

This commit is contained in:
yunusey
2025-01-01 13:55:52 -05:00
parent 3b55452f57
commit cf52578067

View File

@ -828,7 +828,13 @@ pub fn updateFrame(
{ {
if (single_threaded_draw) self.draw_mutex.lock(); if (single_threaded_draw) self.draw_mutex.lock();
defer if (single_threaded_draw) self.draw_mutex.unlock(); defer if (single_threaded_draw) self.draw_mutex.unlock();
try self.prepBackgroundImage(); self.prepBackgroundImage() catch |err| switch (err) {
error.InvalidData => {
log.warn("invalid image data", .{});
self.current_background_image = null;
},
else => return err,
};
} }
// If we have any terminal dirty flags set then we need to rebuild // If we have any terminal dirty flags set then we need to rebuild
@ -2394,8 +2400,8 @@ pub fn drawFrame(self: *OpenGL, surface: *apprt.Surface) !void {
} }
// Check if we need to update our current background image // Check if we need to update our current background image
if (self.current_background_image != null) { if (self.current_background_image) |current_background_image| {
switch (self.current_background_image.?) { switch (current_background_image) {
.ready => {}, .ready => {},
.pending_gray, .pending_gray,
@ -2575,15 +2581,14 @@ fn drawBackgroundImage(
gl_state: *const GLState, gl_state: *const GLState,
) !void { ) !void {
// If we don't have a background image, just return // If we don't have a background image, just return
if (self.current_background_image == null) { const current_background_image = self.current_background_image orelse return;
return;
}
// Bind our background image program // Bind our background image program
const bind = try gl_state.bgimage_program.bind(); const bind = try gl_state.bgimage_program.bind();
defer bind.unbind(); defer bind.unbind();
// Get the texture // Get the texture
const texture = switch (self.current_background_image.?) { const texture = switch (current_background_image) {
.ready => |t| t, .ready => |t| t,
else => { else => {
return; return;