From: theAdib Date: Fri, 1 May 2009 22:25:05 +0000 (+0000) Subject: BUG 322116, PDF export does not use the highest quality for rasterized filter X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=a657cb9a6e1aca06d04f49bd9844e89c91e34f76;p=inkscape.git BUG 322116, PDF export does not use the highest quality for rasterized filter --- diff --git a/src/display/nr-arena.cpp b/src/display/nr-arena.cpp index ce13072b9..74e0f409c 100644 --- a/src/display/nr-arena.cpp +++ b/src/display/nr-arena.cpp @@ -14,7 +14,10 @@ #include "nr-arena-item.h" #include "nr-arena.h" +#include "nr-filter-gaussian.h" +#include "nr-filter-types.h" #include +#include "preferences.h" static void nr_arena_class_init (NRArenaClass *klass); static void nr_arena_init (NRArena *arena); @@ -52,7 +55,10 @@ static void nr_arena_init (NRArena *arena) { arena->delta = 0; // to be set by desktop from prefs + arena->renderoffscreen = false; // use render values from preferences otherwise render exact arena->rendermode = Inkscape::RENDERMODE_NORMAL; // default is normal render + arena->blurquality = BLUR_QUALITY_NORMAL; + arena->filterquality = Inkscape::Filters::FILTER_QUALITY_NORMAL; arena->outlinecolor = 0xff; // black; to be set by desktop from bg color arena->canvasarena = NULL; } @@ -72,6 +78,16 @@ nr_arena_request_update (NRArena *arena, NRArenaItem *item) nr_return_if_fail (NR_IS_ARENA (arena)); nr_return_if_fail (item != NULL); nr_return_if_fail (NR_IS_ARENA_ITEM (item)); + // setup render parameter + if (arena->renderoffscreen == false) { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + arena->blurquality = prefs->getInt("/options/blurquality/value", 0); + arena->filterquality = prefs->getInt("/options/filterquality/value", 0); + } else { + arena->blurquality = BLUR_QUALITY_BEST; + arena->filterquality = Inkscape::Filters::FILTER_QUALITY_BEST; + arena->rendermode = Inkscape::RENDERMODE_NORMAL; + } if (aobject->callbacks) { for (unsigned int i = 0; i < aobject->callbacks->length; i++) { @@ -93,6 +109,16 @@ nr_arena_request_render_rect (NRArena *arena, NRRectL *area) nr_return_if_fail (NR_IS_ARENA (arena)); nr_return_if_fail (area != NULL); + // setup render parameter + if (arena->renderoffscreen == false) { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + arena->blurquality = prefs->getInt("/options/blurquality/value", 0); + arena->filterquality = prefs->getInt("/options/filterquality/value", 0); + } else { + arena->blurquality = BLUR_QUALITY_BEST; + arena->filterquality = Inkscape::Filters::FILTER_QUALITY_BEST; + arena->rendermode = Inkscape::RENDERMODE_NORMAL; + } if (aobject->callbacks && area && !nr_rect_l_test_empty_ptr(area)) { for (unsigned int i = 0; i < aobject->callbacks->length; i++) { NRObjectListener *listener = aobject->callbacks->listeners + i; @@ -139,6 +165,21 @@ nr_arena_render_paintserver_fill (NRPixBlock *pb, NRRectL *area, SPPainter *pain nr_pixblock_release (&cb_opa); } +/** + set arena to offscreen mode + rendering will be exact + @param arena NRArena object +*/ +void +nr_arena_set_renderoffscreen (NRArena *arena) +{ + nr_return_if_fail (arena != NULL); + nr_return_if_fail (NR_IS_ARENA (arena)); + + // the real assignment to the quality indicators is in the update function + arena->renderoffscreen = true; + +} /* Local Variables: diff --git a/src/display/nr-arena.h b/src/display/nr-arena.h index 1a042b355..1c091b7c7 100644 --- a/src/display/nr-arena.h +++ b/src/display/nr-arena.h @@ -46,7 +46,11 @@ struct NRArena : public NRActiveObject { } double delta; + bool renderoffscreen; // if true then rendering must be exact Inkscape::RenderMode rendermode; + int blurquality; // will be updated during update from preferences + int filterquality; // will be updated during update from preferences + guint32 outlinecolor; SPCanvasArena *canvasarena; // may be NULL is this arena is not the screen but used for export etc. }; @@ -56,6 +60,7 @@ struct NRArenaClass : public NRActiveObjectClass { void nr_arena_request_update (NRArena *arena, NRArenaItem *item); void nr_arena_request_render_rect (NRArena *arena, NRRectL *area); +void nr_arena_set_renderoffscreen (NRArena *arena); void nr_arena_render_paintserver_fill (NRPixBlock *pb, NRRectL *area, SPPainter *painter, float opacity, NRPixBlock *mask); diff --git a/src/display/nr-filter-gaussian.cpp b/src/display/nr-filter-gaussian.cpp index 5d071be8c..90220d296 100644 --- a/src/display/nr-filter-gaussian.cpp +++ b/src/display/nr-filter-gaussian.cpp @@ -597,7 +597,7 @@ int FilterGaussian::render(FilterSlot &slot, FilterUnits const &units) #endif // HAVE_OPENMP // Subsampling constants - int const quality = prefs->getInt("/options/blurquality/value"); + int const quality = slot.get_blurquality(); int const x_step_l2 = _effect_subsample_step_log2(deviation_x_org, quality); int const y_step_l2 = _effect_subsample_step_log2(deviation_y_org, quality); int const x_step = 1< 0) ? slots : 2); @@ -348,6 +350,15 @@ void FilterSlot::set_quality(FilterQuality const q) { filterquality = q; } +void FilterSlot::set_blurquality(int const q) { + g_warning("FilterSlot::set_blurquality"); + blurquality = q; +} + +int FilterSlot::get_blurquality(void) { + return blurquality; +} + } /* namespace Filters */ } /* namespace Inkscape */ diff --git a/src/display/nr-filter-slot.h b/src/display/nr-filter-slot.h index bddb42dc3..8d7a82d2d 100644 --- a/src/display/nr-filter-slot.h +++ b/src/display/nr-filter-slot.h @@ -77,6 +77,12 @@ public: /** Sets the filtering quality. Affects used interpolation methods */ void set_quality(FilterQuality const q); + /** Sets the gaussian filtering quality. Affects used interpolation methods */ + void set_blurquality(int const q); + + /** Gets the gaussian filtering quality. Affects used interpolation methods */ + int get_blurquality(void); + private: NRPixBlock **_slot; int *_slot_number; @@ -86,6 +92,8 @@ private: FilterQuality filterquality; + int blurquality; + NRArenaItem const *_arena_item; FilterUnits units; diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index 30f8ae7e9..af432bdf3 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -39,6 +39,7 @@ #include "display/nr-filter-tile.h" #include "display/nr-filter-turbulence.h" +#include "display/nr-arena.h" #include "display/nr-arena-item.h" #include "libnr/nr-pixblock.h" #include "libnr/nr-blit.h" @@ -132,15 +133,16 @@ int Filter::render(NRArenaItem const *item, NRPixBlock *pb) { if (!_primitive[0]) { // TODO: Should clear the input buffer instead of just returning - return 1; + return 1; } - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - FilterQuality const filterquality = (FilterQuality)prefs->getInt("/options/filterquality/value"); + FilterQuality const filterquality = (FilterQuality)item->arena->filterquality; + int const blurquality = item->arena->blurquality; Geom::Matrix trans = item->ctm; FilterSlot slot(_slot_count, item); slot.set_quality(filterquality); + slot.set_blurquality(blurquality); Geom::Rect item_bbox; { diff --git a/src/extension/internal/cairo-renderer-pdf-out.cpp b/src/extension/internal/cairo-renderer-pdf-out.cpp index 804919e33..b44e83449 100644 --- a/src/extension/internal/cairo-renderer-pdf-out.cpp +++ b/src/extension/internal/cairo-renderer-pdf-out.cpp @@ -74,6 +74,7 @@ pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int /* Create new arena */ NRArena *arena = NRArena::create(); + nr_arena_set_renderoffscreen (arena); unsigned dkey = sp_item_display_key_new(1); sp_item_invoke_show(base, arena, dkey, SP_ITEM_SHOW_DISPLAY); diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index ee17e7079..0e056e981 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -434,13 +434,6 @@ sp_export_png_file(SPDocument *doc, gchar const *filename, return true; } - // export with maximum blur rendering quality - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - int saved_quality = prefs->getInt("/options/blurquality/value", 0); - prefs->setInt("/options/blurquality/value", 2); - int saved_filter_quality = prefs->getInt("/options/filterquality/value", 0); - prefs->setInt("/options/filterquality/value", 2); - sp_document_ensure_up_to_date(doc); /* Calculate translation by transforming to document coordinates (flipping Y)*/ @@ -478,6 +471,8 @@ sp_export_png_file(SPDocument *doc, gchar const *filename, /* Create new arena */ NRArena *const arena = NRArena::create(); + // export with maximum blur rendering quality + nr_arena_set_renderoffscreen(arena); unsigned const dkey = sp_item_display_key_new(1); /* Create ArenaItems and set transform */ @@ -512,10 +507,6 @@ sp_export_png_file(SPDocument *doc, gchar const *filename, /* Free arena */ nr_object_unref((NRObject *) arena); - // restore saved blur and filter quality - prefs->setInt("/options/blurquality/value", saved_quality); - prefs->setInt("/options/filterquality/value", saved_filter_quality); - g_free(path); return write_status;