From 9d890e28d12f05dcc9e301d5ba6c665009c8e5d8 Mon Sep 17 00:00:00 2001 From: auroux Date: Wed, 20 Oct 2010 22:22:36 +0000 Subject: [PATCH] option to force pdf background rendering via cairo (slower, nicer) --- ChangeLog | 1 + src/TODO | 19 +++++++++++++++++++ src/xo-file.c | 28 +++++++++++++++++++++++++--- src/xournal.h | 1 + 4 files changed, 46 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index a5b18ae..c4ce61e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,7 @@ This version: - Czech translation (David Kolibac), Dutch translation (Timo Kluck) - fix crash upon unplugging input devices - change close dialog box default to "save" (patch by Kit Barnes) + - option to force PDF background rendering via cairo (slower but nicer) Version 0.4.5 (Oct 2, 2009): - bugfixes for GTK+ 2.16/2.17 issues with xinput events diff --git a/src/TODO b/src/TODO index 704b7e6..57acb3a 100644 --- a/src/TODO +++ b/src/TODO @@ -29,6 +29,8 @@ BUGS: ** export to PDF should see cropbox size if smaller, and map the cropbox -- not the entire page -- to the page area! (2009-11-18 forum) +*** filter out very large coords when loading, not just infinity + WIN32: - test further - write an installer @@ -37,6 +39,15 @@ WIN32: - bug: printf() sometimes generates stroke coordinates 1.#J -1.#J (???) PATCHES TO INCORPORATE: + +* filter out very large coords when loading, not just infinity; also filter + out 1.#J's + +- patch: add Alt-Up/Dn accelerators for show/hide layer. See + show_hide_layer.patch + +***** my own patch noresize_background_v1.patch (also in xournal-working/) + ** patch: ortho/snap (revised Apr 13 2009) xournal_ortho_snap_patch_4 (by Josef Pavlicek) @@ -54,6 +65,7 @@ PATCHES TO INCORPORATE: ** insert images patch (Victor Saase) #2890925 ** as improved by Simon Guest April 14 2010 ** modified rev2 May 14, 2010: xournal-0.4.5-sjg-image-rev2.patch.gz +** rev6 by now... ** customize paper ruling (Gautam Iyer e-mail Nov 30 2009 / SF tracker) @@ -61,6 +73,10 @@ PATCHES TO INCORPORATE: cairo-png-rendering.diff.txt (refactor printing of page to cairo surface with the gtk-print code). +- patch by S. Guest + shortcut to increase/decrease text font size by 1 point (?) - acts just + as if one had clicked font sel box and resized (affects sel text + cur font) + - make default in ok_to_close() box "cancel" rather than "no". - make line spacing in text objects customizable: to a fixed scaling factor, @@ -108,6 +124,8 @@ PATCHES TO INCORPORATE: - horizontal mode instead of dual-view / multicolumn ? ** "new page before/after" on a PDF bg page should ask: same page, other page of PDF file, default paper +** should also have in Journal -> Paper style the option "Pdf page ..." + which then lets us change the page number. - new recognizer icon (andruk on patches tracker) - recognizer: if variable-width, associate average width - recognizer should snap to existing recognized geometric shapes @@ -131,6 +149,7 @@ PATCHES TO INCORPORATE: - proximity detection: eraser proximity switches mapping? proximity out removes cursor until next motionnotify? + - render page to bitmap: for export, preview, and copy-paste (render using libart, see how gnomecanvas does it?) NO: render using Cairo !!! then can switch to GtkPrint as well. diff --git a/src/xo-file.c b/src/xo-file.c index fd79711..e26bcd1 100644 --- a/src/xo-file.c +++ b/src/xo-file.c @@ -996,6 +996,8 @@ gboolean bgpdf_scheduler_callback(gpointer data) PopplerPage *pdfpage; gdouble height, width; int scaled_height, scaled_width; + GdkPixmap *pixmap; + cairo_t *cr; // if all requests have been cancelled, remove ourselves from main loop if (bgpdf.requests == NULL) { bgpdf.pid = 0; return FALSE; } @@ -1013,11 +1015,26 @@ gboolean bgpdf_scheduler_callback(gpointer data) poppler_page_get_size(pdfpage, &width, &height); scaled_width = (int) (req->dpi * width/72); scaled_height = (int) (req->dpi * height/72); - pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, - FALSE, 8, scaled_width, scaled_height); - poppler_page_render_to_pixbuf( + + if (ui.poppler_force_cairo) { // poppler -> cairo -> pixmap -> pixbuf + pixmap = gdk_pixmap_new(GTK_WIDGET(canvas)->window, scaled_width, scaled_height, -1); + cr = gdk_cairo_create(pixmap); + cairo_set_source_rgb(cr, 1., 1., 1.); + cairo_paint(cr); + cairo_scale(cr, scaled_width/width, scaled_height/height); + poppler_page_render(pdfpage, cr); + cairo_destroy(cr); + pixbuf = gdk_pixbuf_get_from_drawable(NULL, GDK_DRAWABLE(pixmap), + NULL, 0, 0, 0, 0, scaled_width, scaled_height); + g_object_unref(pixmap); + } + else { // directly poppler -> pixbuf: faster, but bitmap font bug + pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, + FALSE, 8, scaled_width, scaled_height); + poppler_page_render_to_pixbuf( pdfpage, 0, 0, scaled_width, scaled_height, req->dpi/72, 0, pixbuf); + } g_object_unref(pdfpage); set_cursor_busy(FALSE); } @@ -1355,6 +1372,7 @@ void init_config_default(void) ui.width_maximum_multiplier = 1.25; ui.button_switch_mapping = FALSE; ui.autoload_pdf_xoj = FALSE; + ui.poppler_force_cairo = FALSE; // the default UI vertical order ui.vertical_order[0][0] = 1; @@ -1523,6 +1541,9 @@ void save_config_to_file(void) update_keyval("general", "autosave_prefs", _(" auto-save preferences on exit (true/false)"), g_strdup(ui.auto_save_prefs?"true":"false")); + update_keyval("general", "poppler_force_cairo", + _(" force PDF rendering through cairo (slower but nicer) (true/false)"), + g_strdup(ui.poppler_force_cairo?"true":"false")); update_keyval("paper", "width", _(" the default page width, in points (1/72 in)"), @@ -1887,6 +1908,7 @@ void load_config_from_file(void) if (str!=NULL) { g_free(ui.shorten_menu_items); ui.shorten_menu_items = str; } parse_keyval_float("general", "highlighter_opacity", &ui.hiliter_opacity, 0., 1.); parse_keyval_boolean("general", "autosave_prefs", &ui.auto_save_prefs); + parse_keyval_boolean("general", "poppler_force_cairo", &ui.poppler_force_cairo); parse_keyval_float("paper", "width", &ui.default_page.width, 1., 5000.); parse_keyval_float("paper", "height", &ui.default_page.height, 1., 5000.); diff --git a/src/xournal.h b/src/xournal.h index 7c7d4c3..2ef72f3 100644 --- a/src/xournal.h +++ b/src/xournal.h @@ -295,6 +295,7 @@ typedef struct UIData { #if GTK_CHECK_VERSION(2,10,0) GtkPrintSettings *print_settings; #endif + gboolean poppler_force_cairo; // force poppler to use cairo } UIData; #define BRUSH_LINKED 0 -- 2.39.2