[evince/wip/gpoo/gtk4-rebase-port: 75/96] ev-view: remove inverted color and draw inverted color by GPU




commit 6432a195206f97890c1880cff445786a6451af17
Author: Qiu Wenbo <qiuwenbo kylinos com cn>
Date:   Mon Aug 23 17:07:45 2021 +0800

    ev-view: remove inverted color and draw inverted color by GPU
    
    Signed-off-by: Qiu Wenbo <qiuwenbo kylinos com cn>

 libview/ev-view.c | 50 +++++++++++++++++---------------------------------
 1 file changed, 17 insertions(+), 33 deletions(-)
---
diff --git a/libview/ev-view.c b/libview/ev-view.c
index 892bddd2a..5f8856bb9 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -5160,16 +5160,6 @@ link_preview_job_finished_cb (EvJobThumbnail *job,
                return;
        }
 
-#if 0
-#ifdef HAVE_HIDPI_SUPPORT
-        device_scale = gtk_widget_get_scale_factor (GTK_WIDGET (view));
-        cairo_surface_set_device_scale (job->thumbnail_surface, device_scale, device_scale);
-#endif
-
-       if (ev_document_model_get_inverted_colors (view->model))
-               ev_document_misc_invert_surface (job->thumbnail_surface);
-#endif
-
        link_preview_show_thumbnail (gdk_texture_new_for_pixbuf (job->thumbnail), view);
 
        g_object_unref (job);
@@ -7159,17 +7149,6 @@ ev_view_enter_notify_event (GtkEventControllerMotion     *self,
        ev_view_handle_cursor_over_xy (EV_VIEW (user_data), x, y);
 }
 
-#if 0
-static void
-ev_view_style_updated (GtkWidget *widget)
-{
-       if (EV_VIEW (widget)->pixbuf_cache)
-               ev_pixbuf_cache_style_changed (EV_VIEW (widget)->pixbuf_cache);
-
-       GTK_WIDGET_CLASS (ev_view_parent_class)->style_updated (widget);
-}
-#endif
-
 /*** Drawing ***/
 
 static void
@@ -7269,11 +7248,23 @@ static void
 draw_surface (GtkSnapshot     *snapshot,
              GdkTexture      *texture,
              const graphene_point_t *point,
-             const graphene_rect_t *area)
+             const graphene_rect_t *area,
+             gboolean inverted)
 {
        gtk_snapshot_save (snapshot);
        gtk_snapshot_translate (snapshot, point);
+
+       if (inverted) {
+               gtk_snapshot_push_blend (snapshot, GSK_BLEND_MODE_DIFFERENCE);
+               gtk_snapshot_append_color (snapshot, &(GdkRGBA) {1., 1., 1., 1.}, area);
+               gtk_snapshot_pop (snapshot);
+       }
+
        gtk_snapshot_append_texture (snapshot, texture, area);
+
+       if (inverted)
+               gtk_snapshot_pop (snapshot);
+
        gtk_snapshot_restore (snapshot);
 }
 
@@ -7385,6 +7376,7 @@ draw_one_page (EvView       *view,
                graphene_rect_t area;
                gint offset_x, offset_y;
                cairo_region_t *region = NULL;
+               gboolean inverted = ev_document_model_get_inverted_colors (view->model);
 
                page_texture = ev_pixbuf_cache_get_texture (view->pixbuf_cache, page);
 
@@ -7407,7 +7399,7 @@ draw_one_page (EvView       *view,
                                           width, height);
                point = GRAPHENE_POINT_INIT (overlap.x, overlap.y);
 
-               draw_surface (snapshot, page_texture, &point, &area);
+               draw_surface (snapshot, page_texture, &point, &area, inverted);
 
                /* Get the selection pixbuf iff we have something to draw */
                if (!find_selection_for_page (view, page))
@@ -7417,7 +7409,7 @@ draw_one_page (EvView       *view,
                                                                           page,
                                                                           view->scale);
                if (selection_texture) {
-                       draw_surface (snapshot, selection_texture, &point, &area);
+                       draw_surface (snapshot, selection_texture, &point, &area, inverted);
                        return;
                }
 
@@ -8471,8 +8463,6 @@ setup_caches (EvView *view)
                                 EV_PAGE_DATA_INCLUDE_TEXT_ATTRS |
                                 EV_PAGE_DATA_INCLUDE_TEXT_LOG_ATTRS);
 
-       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);
 }
 
@@ -8656,13 +8646,7 @@ 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_draw (GTK_WIDGET (view));
-       }
+       gtk_widget_queue_draw (GTK_WIDGET (view));
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]