Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 43 additions & 2 deletions src/views/darkroom.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ static inline gboolean _full_request(dt_develop_t *dev)
return
dev->full.pipe->status == DT_DEV_PIXELPIPE_DIRTY
|| dev->full.pipe->status == DT_DEV_PIXELPIPE_INVALID
|| dev->full.pipe->changed != DT_DEV_PIPE_UNCHANGED
|| dev->full.pipe->input_timestamp < dev->preview_pipe->input_timestamp;
}

Expand Down Expand Up @@ -589,7 +590,8 @@ void expose(dt_view_t *self,

const gboolean expose_full =
port->pipe->backbuf // do we have an image?
&& port->pipe->output_imgid == dev->image_storage.id; // same image?
&& port->pipe->output_imgid == dev->image_storage.id // same image?
&& !port->pipe->loading; // not loading a new one?

if(expose_full)
{
Expand All @@ -603,9 +605,25 @@ void expose(dt_view_t *self,
}
if(!dt_conf_get_bool("darkroom/ui/loading_screen"))
{
// cache the rendered bitmap for use while loading the next image
// Cache the rendered content for display while loading the next image.
#ifdef _WIN32
// On the Win32 GDK backend, holding a cairo_surface_reference() to
// cairo_get_target(cri) prevents GTK from properly invalidating the
// widget surface, causing gtk_widget_queue_draw() to silently fail
// (issue #20831). Copy to a standalone image surface instead.
cairo_surface_t *target = cairo_get_target(cri);
if(width > 0 && height > 0)
{
darktable.gui->surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
cairo_t *cr2 = cairo_create(darktable.gui->surface);
cairo_set_source_surface(cr2, target, 0, 0);
cairo_paint(cr2);
cairo_destroy(cr2);
}
#else
darktable.gui->surface = cairo_get_target(cri);
cairo_surface_reference(darktable.gui->surface);
#endif
}
}
else if(dev->preview_pipe->output_imgid != dev->image_storage.id)
Expand Down Expand Up @@ -735,6 +753,12 @@ void expose(dt_view_t *self,
cairo_paint(cri);
cairo_restore(cri);
}
else
{
// No cached surface (first entry from lighttable) — paint background
dt_gui_gtk_set_source_rgb(cri, DT_GUI_COLOR_DARKROOM_BG);
cairo_paint(cri);
}
dt_toast_log("%s", load_txt);
}
g_free(load_txt);
Expand Down Expand Up @@ -3594,6 +3618,23 @@ void leave(dt_view_t *self)
if(darktable.lib->proxy.colorpicker.picker_proxy)
dt_iop_color_picker_reset(darktable.lib->proxy.colorpicker.picker_proxy->module, FALSE);

// Clear cached surface so the loading screen shows on next darkroom entry
if(darktable.gui->surface)
{
cairo_surface_destroy(darktable.gui->surface);
darktable.gui->surface = NULL;
}

// Invalidate pipe output so expose_full is FALSE on next entry.
// Without this, re-opening the same image skips the loading screen
// because the stale backbuf + matching output_imgid makes expose_full TRUE.
dt_pthread_mutex_lock(&darktable.develop->full.pipe->backbuf_mutex);
g_free(darktable.develop->full.pipe->backbuf);
darktable.develop->full.pipe->backbuf = NULL;
darktable.develop->full.pipe->output_imgid = NO_IMGID;
dt_pthread_mutex_unlock(&darktable.develop->full.pipe->backbuf_mutex);
darktable.develop->preview_pipe->output_imgid = NO_IMGID;

DT_CONTROL_SIGNAL_DISCONNECT_ALL(self, "darkroom");

// store groups for next time:
Expand Down
Loading