[evince/wip/gpoo/gtk4-rebase-port: 67/89] ev-view: simplify the draw_surface function




commit b81251c7ec59d1fafceccdb3c44ec16e39255e7c
Author: Qiu Wenbo <qiuwenbo kylinos com cn>
Date:   Mon Aug 23 16:48:47 2021 +0800

    ev-view: simplify the draw_surface function
    
    Signed-off-by: Qiu Wenbo <qiuwenbo kylinos com cn>

 libview/ev-view.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)
---
diff --git a/libview/ev-view.c b/libview/ev-view.c
index d873bb5af..892bddd2a 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -7268,16 +7268,12 @@ gdk_texture_new_for_surface(cairo_surface_t *surface)
 static void
 draw_surface (GtkSnapshot     *snapshot,
              GdkTexture      *texture,
-             gint             x,
-             gint             y,
-             gint             offset_x,
-             gint             offset_y,
-             gint             target_width,
-             gint             target_height)
+             const graphene_point_t *point,
+             const graphene_rect_t *area)
 {
        gtk_snapshot_save (snapshot);
-       gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT(x, y));
-       gtk_snapshot_append_texture (snapshot, texture, &GRAPHENE_RECT_INIT(-offset_x, -offset_y, 
target_width, target_height));
+       gtk_snapshot_translate (snapshot, point);
+       gtk_snapshot_append_texture (snapshot, texture, area);
        gtk_snapshot_restore (snapshot);
 }
 
@@ -7385,6 +7381,8 @@ draw_one_page (EvView       *view,
        if (gdk_rectangle_intersect (&real_page_area, expose_area, &overlap)) {
                gint             width, height;
                GdkTexture      *page_texture = NULL, *selection_texture = NULL;
+               graphene_point_t point;
+               graphene_rect_t area;
                gint offset_x, offset_y;
                cairo_region_t *region = NULL;
 
@@ -7403,10 +7401,13 @@ draw_one_page (EvView       *view,
                        ev_view_set_loading (view, FALSE);
 
                ev_view_get_page_size (view, page, &width, &height);
-               offset_x = overlap.x - real_page_area.x;
-               offset_y = overlap.y - real_page_area.y;
 
-               draw_surface (snapshot, page_texture, overlap.x, overlap.y, offset_x, offset_y, width, 
height);
+               area = GRAPHENE_RECT_INIT (real_page_area.x - overlap.x,
+                                          real_page_area.y - overlap.y,
+                                          width, height);
+               point = GRAPHENE_POINT_INIT (overlap.x, overlap.y);
+
+               draw_surface (snapshot, page_texture, &point, &area);
 
                /* Get the selection pixbuf iff we have something to draw */
                if (!find_selection_for_page (view, page))
@@ -7416,8 +7417,7 @@ draw_one_page (EvView       *view,
                                                                           page,
                                                                           view->scale);
                if (selection_texture) {
-                       draw_surface (snapshot, selection_texture, overlap.x, overlap.y, offset_x, offset_y,
-                                     width, height);
+                       draw_surface (snapshot, selection_texture, &point, &area);
                        return;
                }
 


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