Compare commits

..

No commits in common. "69d45fea44dcf289a997c2df1d813ba355af743d" and "4e11970a7eb852010fe609ef155d580ae415e54c" have entirely different histories.

2 changed files with 22 additions and 17 deletions

View File

@ -85,7 +85,7 @@ struct _FivBrowser {
Thumbnailer *thumbnailers; ///< Parallelized thumbnailers Thumbnailer *thumbnailers; ///< Parallelized thumbnailers
size_t thumbnailers_len; ///< Thumbnailers array size size_t thumbnailers_len; ///< Thumbnailers array size
GQueue thumbnailers_queue; ///< Queued up Entry pointers GList *thumbnailers_queue; ///< Queued up Entry pointers
GdkCursor *pointer; ///< Cached pointer cursor GdkCursor *pointer; ///< Cached pointer cursor
cairo_pattern_t *glow; ///< CAIRO_FORMAT_A8 mask for corners cairo_pattern_t *glow; ///< CAIRO_FORMAT_A8 mask for corners
@ -597,7 +597,10 @@ thumbnailer_reprocess_entry(FivBrowser *self, GBytes *output, Entry *entry)
if ((flags & FIV_IO_SERIALIZE_LOW_QUALITY)) { if ((flags & FIV_IO_SERIALIZE_LOW_QUALITY)) {
cairo_surface_set_user_data(entry->thumbnail, &fiv_thumbnail_key_lq, cairo_surface_set_user_data(entry->thumbnail, &fiv_thumbnail_key_lq,
(void *) (intptr_t) 1, NULL); (void *) (intptr_t) 1, NULL);
g_queue_push_tail(&self->thumbnailers_queue, entry);
// TODO(p): Improve complexity; this will iterate the whole linked list.
self->thumbnailers_queue =
g_list_append(self->thumbnailers_queue, entry);
} }
// This choice of mtime favours unnecessary thumbnail reloading // This choice of mtime favours unnecessary thumbnail reloading
@ -660,9 +663,14 @@ thumbnailer_next(Thumbnailer *t)
{ {
// TODO(p): Try to keep the minions alive (stdout will be a problem). // TODO(p): Try to keep the minions alive (stdout will be a problem).
FivBrowser *self = t->self; FivBrowser *self = t->self;
if (!(t->target = g_queue_pop_head(&self->thumbnailers_queue))) GList *link = self->thumbnailers_queue;
if (!link)
return FALSE; return FALSE;
t->target = link->data;
self->thumbnailers_queue =
g_list_delete_link(self->thumbnailers_queue, self->thumbnailers_queue);
// Case analysis: // Case analysis:
// - We haven't found any thumbnail for the entry at all // - We haven't found any thumbnail for the entry at all
// (and it has a symbolic icon as a result): // (and it has a symbolic icon as a result):
@ -698,7 +706,8 @@ thumbnailer_next(Thumbnailer *t)
static void static void
thumbnailers_abort(FivBrowser *self) thumbnailers_abort(FivBrowser *self)
{ {
g_queue_clear(&self->thumbnailers_queue); g_list_free(self->thumbnailers_queue);
self->thumbnailers_queue = NULL;
for (size_t i = 0; i < self->thumbnailers_len; i++) { for (size_t i = 0; i < self->thumbnailers_len; i++) {
Thumbnailer *t = self->thumbnailers + i; Thumbnailer *t = self->thumbnailers + i;
@ -720,20 +729,17 @@ thumbnailers_start(FivBrowser *self)
if (!self->model) if (!self->model)
return; return;
GQueue lq = G_QUEUE_INIT; GList *missing = NULL, *lq = NULL;
for (guint i = 0; i < self->entries->len; i++) { for (guint i = self->entries->len; i--; ) {
Entry *entry = &g_array_index(self->entries, Entry, i); Entry *entry = &g_array_index(self->entries, Entry, i);
if (entry->icon) if (entry->icon)
g_queue_push_tail(&self->thumbnailers_queue, entry); missing = g_list_prepend(missing, entry);
else if (cairo_surface_get_user_data( else if (cairo_surface_get_user_data(
entry->thumbnail, &fiv_thumbnail_key_lq)) entry->thumbnail, &fiv_thumbnail_key_lq))
g_queue_push_tail(&lq, entry); lq = g_list_prepend(lq, entry);
}
while (!g_queue_is_empty(&lq)) {
g_queue_push_tail_link(
&self->thumbnailers_queue, g_queue_pop_head_link(&lq));
} }
self->thumbnailers_queue = g_list_concat(missing, lq);
for (size_t i = 0; i < self->thumbnailers_len; i++) { for (size_t i = 0; i < self->thumbnailers_len; i++) {
if (!thumbnailer_next(self->thumbnailers + i)) if (!thumbnailer_next(self->thumbnailers + i))
break; break;
@ -1700,7 +1706,6 @@ fiv_browser_init(FivBrowser *self)
g_malloc0_n(self->thumbnailers_len, sizeof *self->thumbnailers); g_malloc0_n(self->thumbnailers_len, sizeof *self->thumbnailers);
for (size_t i = 0; i < self->thumbnailers_len; i++) for (size_t i = 0; i < self->thumbnailers_len; i++)
self->thumbnailers[i].self = self; self->thumbnailers[i].self = self;
g_queue_init(&self->thumbnailers_queue);
set_item_size(self, FIV_THUMBNAIL_SIZE_NORMAL); set_item_size(self, FIV_THUMBNAIL_SIZE_NORMAL);
self->glow_padded = cairo_pattern_create_rgba(0, 0, 0, 0); self->glow_padded = cairo_pattern_create_rgba(0, 0, 0, 0);

View File

@ -657,8 +657,8 @@ fiv_thumbnail_lookup(const char *uri, gint64 mtime_msec, FivThumbnailSize size)
use = FIV_THUMBNAIL_SIZE_MAX - i; use = FIV_THUMBNAIL_SIZE_MAX - i;
const char *name = fiv_thumbnail_sizes[use].thumbnail_spec_name; const char *name = fiv_thumbnail_sizes[use].thumbnail_spec_name;
gchar *wide = g_strconcat(thumbnails_dir, G_DIR_SEPARATOR_S "wide-", gchar *wide =
name, G_DIR_SEPARATOR_S, sum, ".webp", NULL); g_strdup_printf("%s/wide-%s/%s.webp", thumbnails_dir, name, sum);
result = read_wide_thumbnail(wide, uri, mtime_msec / 1000, &error); result = read_wide_thumbnail(wide, uri, mtime_msec / 1000, &error);
if (error) { if (error) {
g_debug("%s: %s", wide, error->message); g_debug("%s: %s", wide, error->message);
@ -673,8 +673,8 @@ fiv_thumbnail_lookup(const char *uri, gint64 mtime_msec, FivThumbnailSize size)
break; break;
} }
gchar *path = g_strconcat(thumbnails_dir, G_DIR_SEPARATOR_S, gchar *path =
name, G_DIR_SEPARATOR_S, sum, ".png", NULL); g_strdup_printf("%s/%s/%s.png", thumbnails_dir, name, sum);
result = read_png_thumbnail(path, uri, mtime_msec / 1000, &error); result = read_png_thumbnail(path, uri, mtime_msec / 1000, &error);
if (error) { if (error) {
g_debug("%s: %s", path, error->message); g_debug("%s: %s", path, error->message);