See bgo#321823.
EvDocument *document;
int start_page;
int end_page;
+ gboolean inverted_colors;
/* preload_cache_size is the number of pages prior to the current
* visible area that we cache. It's normally 1, but could be 2 in the
cairo_surface_destroy (job_info->surface);
}
job_info->surface = cairo_surface_reference (job_render->surface);
+ if (pixbuf_cache->inverted_colors) {
+ ev_document_misc_invert_surface (job_info->surface);
+ }
job_info->points_set = FALSE;
if (job_render->flags & EV_RENDER_INCLUDE_SELECTION) {
ev_pixbuf_cache_add_jobs_if_needed (pixbuf_cache, rotation, scale);
}
+void
+ev_pixbuf_cache_set_inverted_colors (EvPixbufCache *pixbuf_cache,
+ gboolean inverted_colors)
+{
+ gint i;
+
+ if (pixbuf_cache->inverted_colors == inverted_colors)
+ return;
+
+ pixbuf_cache->inverted_colors = inverted_colors;
+
+ for (i = 0; i < pixbuf_cache->preload_cache_size; i++) {
+ CacheJobInfo *job_info;
+
+ job_info = pixbuf_cache->prev_job + i;
+ if (job_info->surface)
+ ev_document_misc_invert_surface (job_info->surface);
+
+ job_info = pixbuf_cache->next_job + i;
+ if (job_info->surface)
+ ev_document_misc_invert_surface (job_info->surface);
+ }
+
+ for (i = 0; i < PAGE_CACHE_LEN (pixbuf_cache); i++) {
+ CacheJobInfo *job_info;
+
+ job_info = pixbuf_cache->job_list + i;
+ if (job_info->surface)
+ ev_document_misc_invert_surface (job_info->surface);
+ }
+}
+
cairo_surface_t *
ev_pixbuf_cache_get_surface (EvPixbufCache *pixbuf_cache,
gint page)
GdkRegion *region,
gint page,
gint rotation,
- gdouble scale);
+ gdouble scale);
+void ev_pixbuf_cache_set_inverted_colors (EvPixbufCache *pixbuf_cache,
+ gboolean inverted_colors);
/* Selection */
cairo_surface_t *ev_pixbuf_cache_get_selection_surface (EvPixbufCache *pixbuf_cache,
gint page,
static void
setup_caches (EvView *view)
{
+ gboolean inverted_colors;
+
view->height_to_page_cache = ev_view_get_height_to_page_cache (view);
view->pixbuf_cache = ev_pixbuf_cache_new (GTK_WIDGET (view), view->document);
+ inverted_colors = ev_document_model_get_inverted_colors (view->model);
+ ev_pixbuf_cache_set_inverted_colors (view->pixbuf_cache, inverted_colors);
g_signal_connect (view->pixbuf_cache, "job-finished", G_CALLBACK (job_finished_cb), view);
}
clear_selection (view);
}
+static void
+ev_view_inverted_colors_changed_cb (EvDocumentModel *model,
+ GParamSpec *pspec,
+ EvView *view)
+{
+ if (view->pixbuf_cache) {
+ gboolean inverted_colors;
+
+ inverted_colors = ev_document_model_get_inverted_colors (model);
+ ev_pixbuf_cache_set_inverted_colors (view->pixbuf_cache, inverted_colors);
+ gtk_widget_queue_resize (GTK_WIDGET (view));
+ }
+}
+
static void
ev_view_sizing_mode_changed_cb (EvDocumentModel *model,
GParamSpec *pspec,
g_signal_connect (view->model, "notify::rotation",
G_CALLBACK (ev_view_rotation_changed_cb),
view);
+ g_signal_connect (view->model, "notify::inverted-colors",
+ G_CALLBACK (ev_view_inverted_colors_changed_cb),
+ view);
g_signal_connect (view->model, "notify::sizing-mode",
G_CALLBACK (ev_view_sizing_mode_changed_cb),
view);