diff options
author | Carlos Garcia Campos <[email protected]> | 2013-06-27 14:54:50 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2017-09-06 18:25:34 +0200 |
commit | 0ee1072cd93969ce37071942bfe3241ad3e63910 (patch) | |
tree | 34b6efbd81358eab9c3a8d60a8f0db6073c48c6c /libview | |
parent | 88d064b76c75c2d33b744c9d18e094dcb47d7c97 (diff) | |
download | atril-0ee1072cd93969ce37071942bfe3241ad3e63910.tar.bz2 atril-0ee1072cd93969ce37071942bfe3241ad3e63910.tar.xz |
libview: Use a larger damage area to redraw selections
Depending on the zoom level the area actually drawn by cairo can be a
bit larger than the selected region due to rounding errors or pixel
alignment. We use the selected region to build the damage area to
invalidate when drawing selections which in many cases is not large
enough. This causes that sometimes when removing a selections some small
rectangles keep drawn because they are not redrawn. To avoid this we
grow the damage area computed from selected regions.
origin commit:
https://git.gnome.org/browse/evince/commit/?h=gnome-3-10&id=a497fb4
Diffstat (limited to 'libview')
-rw-r--r-- | libview/ev-view.c | 52 |
1 files changed, 25 insertions, 27 deletions
diff --git a/libview/ev-view.c b/libview/ev-view.c index e8f85957..0728bc41 100644 --- a/libview/ev-view.c +++ b/libview/ev-view.c @@ -7603,27 +7603,6 @@ merge_selection_region (EvView *view, * have changed */ region = cairo_region_copy (old_sel->covered_region); cairo_region_union (region, new_sel->covered_region); - - if (cairo_region_is_empty (region)) { - cairo_region_destroy (region); - region = NULL; - } else { - gint num_rectangles = cairo_region_num_rectangles (region); - GdkRectangle r; - - /* We need to make the damage region a little bigger - * because the edges of the old selection might change - */ - cairo_region_get_rectangle (region, 0, &r); - r.x -= 5; - r.width = 5; - cairo_region_union_rectangle (region, &r); - - cairo_region_get_rectangle (region, num_rectangles - 1, &r); - r.x += r.width; - r.width = 5; - cairo_region_union_rectangle (region, &r); - } } } else if (old_sel->covered_region) { region = cairo_region_copy (old_sel->covered_region); @@ -7644,15 +7623,34 @@ merge_selection_region (EvView *view, /* Redraw the damaged region! */ if (region) { - GdkRectangle page_area; - GtkBorder border; + GdkRectangle page_area; + GtkBorder border; + cairo_region_t *damage_region; + gint i, n_rects; ev_view_get_page_extents (view, cur_page, &page_area, &border); - cairo_region_translate (region, - page_area.x + border.left - view->scroll_x, - page_area.y + border.top - view->scroll_y); - gdk_window_invalidate_region (gtk_widget_get_window (GTK_WIDGET (view)), region, TRUE); + + damage_region = cairo_region_create (); + /* Translate the region and grow it 2 pixels because for some zoom levels + * the area actually drawn by cairo is larger than the selected region, due + * to rounding errors or pixel alignment. + */ + n_rects = cairo_region_num_rectangles (region); + for (i = 0; i < n_rects; i++) { + cairo_rectangle_int_t rect; + + cairo_region_get_rectangle (region, i, &rect); + rect.x += page_area.x + border.left - view->scroll_x - 2; + rect.y += page_area.y + border.top - view->scroll_y - 2; + rect.width += 4; + rect.height += 4; + cairo_region_union_rectangle (damage_region, &rect); + } cairo_region_destroy (region); + + gdk_window_invalidate_region (gtk_widget_get_window (GTK_WIDGET (view)), + damage_region, TRUE); + cairo_region_destroy (damage_region); } } |