[evince/wip/highlight: 58/59] libview: Use DocumentsAnnotations to render annotations animation
- From: Giselle Reis <gisellemnr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince/wip/highlight: 58/59] libview: Use DocumentsAnnotations to render annotations animation
- Date: Sun, 2 Nov 2014 10:59:55 +0000 (UTC)
commit f7f6c745303349122a6543b5964ffe1941a5a5ef
Author: José Aliste <jaliste src gnome org>
Date: Tue Sep 9 19:12:21 2014 -0300
libview: Use DocumentsAnnotations to render annotations animation
When creating an annotation that needs drag mode, we need to render
the annotation being created fast so we can have a smooth animation.
We take advantange of new API in poppler that allows for this.
libview/ev-view.c | 44 ++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 42 insertions(+), 2 deletions(-)
---
diff --git a/libview/ev-view.c b/libview/ev-view.c
index f638351..b6a4688 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -110,6 +110,8 @@ typedef struct {
#define ANNOTATION_ICON_SIZE 24
+static void
+draw_annot (EvView *view, cairo_t *cr, gint x, gint y, double x_scale, double y_scale);
/*** Scrolling ***/
static void view_update_range_and_current_page (EvView *view);
static void ensure_rectangle_is_visible (EvView *view,
@@ -5249,8 +5251,7 @@ ev_view_motion_notify_event (GtkWidget *widget,
view->annot_info.annot, &rect, mask);
ev_document_doc_mutex_unlock ();
- /* FIXME: reload only annotation area */
- ev_view_reload_page (view, view->current_page, NULL);
+ gtk_widget_queue_draw (GTK_WIDGET (view));
} else {
/* Schedule timeout to scroll during selection and additionally
* scroll once to allow arbitrary speed. */
@@ -5371,8 +5372,10 @@ ev_view_button_release_event (GtkWidget *widget,
if (view->annot_info.mode == MODE_DRAW && view->pressed_button == 1) {
view->annot_info.mode = MODE_NORMAL;
+ view->annot_info.annot = NULL;
ev_view_handle_cursor_over_xy (view, event->x, event->y);
view->pressed_button = -1;
+ ev_view_reload_page (view, view->current_page, NULL);
return FALSE;
}
@@ -6398,6 +6401,23 @@ draw_one_page (EvView *view,
draw_surface (cr, page_surface, overlap.x, overlap.y, offset_x, offset_y, width, height);
+ if (view->annot_info.annot && ev_annotation_get_page_index (view->annot_info.annot) == page)
{
+ double scale_x, scale_y;
+ double device_scale_x = 1, device_scale_y = 1;
+
+ scale_x = (gdouble)width / cairo_image_surface_get_width (page_surface);
+ scale_y = (gdouble)height / cairo_image_surface_get_height (page_surface);
+
+#ifdef HAVE_HIDPI_SUPPORT
+ cairo_surface_get_device_scale (page_surface, &device_scale_x, &device_scale_y);
+#endif
+
+ scale_x *= device_scale_x;
+ scale_y *= device_scale_y;
+ draw_annot (view, cr, real_page_area.x, real_page_area.y,
+ scale_x, scale_y);
+ }
+
/* Get the selection pixbuf iff we have something to draw */
if (!find_selection_for_page (view, page))
return;
@@ -7346,6 +7366,26 @@ ev_view_change_page (EvView *view,
}
static void
+draw_annot (EvView *view, cairo_t *cr, gint x, gint y, gdouble scale_x, gdouble scale_y)
+{
+ EvAnnotation *annot = view->annot_info.annot;
+ EvDocumentAnnotations *doc_annots = EV_DOCUMENT_ANNOTATIONS (view->document);
+
+ cairo_save (cr);
+ cairo_translate (cr, x, y);
+ cairo_scale (cr, scale_x * view->scale, scale_y * view->scale);
+
+ if (!EV_IS_ANNOTATION_TEXT_MARKUP (view->annot_info.annot))
+ return;
+
+ ev_document_doc_mutex_lock();
+ ev_document_annotations_render_annotation (doc_annots, annot, cr);
+ ev_document_doc_mutex_unlock();
+ cairo_restore (cr);
+}
+
+
+static void
job_finished_cb (EvPixbufCache *pixbuf_cache,
cairo_region_t *region,
EvView *view)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]