From 00efc5c16ed191f07f9a8a5d00acc41ddb064b46 Mon Sep 17 00:00:00 2001 From: Jonathan Blandford Date: Sat, 06 Aug 2005 05:13:20 +0000 Subject: Clean up selection to be much smoother! Sat Aug 6 01:12:44 2005 Jonathan Blandford * NOTES: * backend/ev-selection.c: (ev_selection_render_selection): * backend/ev-selection.h: * pdf/ev-poppler.cc: * shell/ev-jobs.c: (ev_job_render_dispose), (ev_job_render_new), (ev_job_render_run): * shell/ev-jobs.h: * shell/ev-pixbuf-cache.c: (dispose_cache_job_info), (ev_pixbuf_cache_new), (job_finished_cb), (add_job_if_needed), (convert_gdk_color_to_uint), (ev_pixbuf_cache_get_text_mapping), (ev_pixbuf_cache_style_changed), (ev_pixbuf_cache_get_selection_pixbuf), (ev_pixbuf_cache_set_selection_list), (ev_pixbuf_cache_get_selection_list): * shell/ev-pixbuf-cache.h: * shell/ev-utils.c: (ev_print_region_contents): * shell/ev-utils.h: * shell/ev-view.c: (ev_view_queue_draw_page), (selection_update_idle_cb), (ev_view_motion_notify_event), (ev_view_style_set), (draw_one_page), (ev_view_class_init), (setup_caches), (ev_view_find_next), (merge_selection_region), (selection_free): * shell/ev-window.c: (ev_window_update_fullscreen_popup): Clean up selection to be much smoother! --- (limited to 'pdf') diff --git a/pdf/ev-poppler.cc b/pdf/ev-poppler.cc index 2c5b526..b4a6799 100644 --- a/pdf/ev-poppler.cc +++ b/pdf/ev-poppler.cc @@ -103,6 +103,20 @@ G_DEFINE_TYPE_WITH_CODE (PdfDocument, pdf_document, G_TYPE_OBJECT, pdf_selection_iface_init); }); + +static void +set_rc_data (PdfDocument *pdf_document, + EvRenderContext *rc) +{ + if (rc->data == NULL) { + rc->data = poppler_document_get_page (pdf_document->document, + rc->page); + rc->destroy = g_object_unref; + } else { + g_assert (rc->page == poppler_page_get_index (POPPLER_PAGE (rc->data))); + } +} + static void pdf_document_search_free (PdfDocumentSearch *search) { @@ -330,17 +344,16 @@ pdf_document_render_pixbuf (EvDocument *document, EvRenderContext *rc) { PdfDocument *pdf_document; - PopplerPage *poppler_page; GdkPixbuf *pixbuf; double width_points, height_points; gint width, height; pdf_document = PDF_DOCUMENT (document); - poppler_page = poppler_document_get_page (pdf_document->document, - rc->page); - set_page_orientation (pdf_document, poppler_page, rc->rotation); - poppler_page_get_size (poppler_page, &width_points, &height_points); + set_rc_data (pdf_document, rc); + set_page_orientation (pdf_document, POPPLER_PAGE (rc->data), rc->rotation); + + poppler_page_get_size (POPPLER_PAGE (rc->data), &width_points, &height_points); width = (int) ((width_points * rc->scale) + 0.5); height = (int) ((height_points * rc->scale) + 0.5); @@ -348,13 +361,12 @@ pdf_document_render_pixbuf (EvDocument *document, FALSE, 8, width, height); - poppler_page_render_to_pixbuf (poppler_page, + poppler_page_render_to_pixbuf (POPPLER_PAGE (rc->data), 0, 0, width, height, rc->scale, pixbuf); - g_object_unref (poppler_page); return pixbuf; } @@ -1169,19 +1181,20 @@ pdf_selection_render_selection (EvSelection *selection, EvRenderContext *rc, GdkPixbuf **pixbuf, EvRectangle *points, - EvRectangle *old_points) + EvRectangle *old_points, + guint text, + guint base) { PdfDocument *pdf_document; - PopplerPage *poppler_page; double width_points, height_points; gint width, height; pdf_document = PDF_DOCUMENT (selection); - poppler_page = poppler_document_get_page (pdf_document->document, - rc->page); - set_page_orientation (pdf_document, poppler_page, rc->rotation); + set_rc_data (pdf_document, rc); - poppler_page_get_size (poppler_page, &width_points, &height_points); + set_page_orientation (pdf_document, POPPLER_PAGE (rc->data), rc->rotation); + + poppler_page_get_size (POPPLER_PAGE (rc->data), &width_points, &height_points); width = (int) ((width_points * rc->scale) + 0.5); height = (int) ((height_points * rc->scale) + 0.5); @@ -1191,16 +1204,12 @@ pdf_selection_render_selection (EvSelection *selection, width, height); } - /* FIXME: Hardcoded clearlooks selection color. We should - * track theme color changes and focus out event and update - * selection color accordingly. */ - poppler_page_render_selection (poppler_page, + poppler_page_render_selection (POPPLER_PAGE (rc->data), rc->scale, *pixbuf, (PopplerRectangle *)points, (PopplerRectangle *)old_points, - 0x00ffffff, 0x007c99ad); - g_object_unref (poppler_page); - + text, + base); } @@ -1210,16 +1219,14 @@ pdf_selection_get_selection_region (EvSelection *selection, EvRectangle *points) { PdfDocument *pdf_document; - PopplerPage *poppler_page; GdkRegion *retval; pdf_document = PDF_DOCUMENT (selection); - poppler_page = poppler_document_get_page (pdf_document->document, - rc->page); - set_page_orientation (pdf_document, poppler_page, rc->rotation); - retval = poppler_page_get_selection_region (poppler_page, rc->scale, (PopplerRectangle *) points); - g_object_unref (poppler_page); + set_rc_data (pdf_document, rc); + set_page_orientation (pdf_document, POPPLER_PAGE (rc->data), rc->rotation); + + retval = poppler_page_get_selection_region ((PopplerPage *)rc->data, rc->scale, (PopplerRectangle *) points); return retval; } -- cgit v0.9.1