summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKrzysztof Kosi??ski <tweenk.pl@gmail.com>2011-08-16 04:04:53 +0000
committerKrzysztof KosiƄski <tweenk.pl@gmail.com>2011-08-16 04:04:53 +0000
commitdc713ea50efc5fd3f041db05ff92d31a3a54dc5b (patch)
treec61e3dc02b30ceab7ba252c1216279cc11d9d956 /src
parentAdd sanity checks against singular transforms in the drawing tree. (diff)
downloadinkscape-dc713ea50efc5fd3f041db05ff92d31a3a54dc5b.tar.gz
inkscape-dc713ea50efc5fd3f041db05ff92d31a3a54dc5b.zip
Add user preference for rendering cache size
(bzr r10347.1.34)
Diffstat (limited to 'src')
-rw-r--r--src/display/canvas-arena.cpp19
-rw-r--r--src/display/canvas-arena.h2
-rw-r--r--src/display/drawing.cpp48
-rw-r--r--src/display/drawing.h3
-rw-r--r--src/preferences-skeleton.h1
-rw-r--r--src/ui/dialog/inkscape-preferences.cpp54
-rw-r--r--src/ui/dialog/inkscape-preferences.h9
7 files changed, 88 insertions, 48 deletions
diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp
index b254a55c8..ac2704895 100644
--- a/src/display/canvas-arena.cpp
+++ b/src/display/canvas-arena.cpp
@@ -21,6 +21,7 @@
#include "display/drawing-item.h"
#include "display/drawing-group.h"
#include "display/drawing-surface.h"
+#include "preferences.h"
using namespace Inkscape;
@@ -48,6 +49,22 @@ static void sp_canvas_arena_request_render (SPCanvasArena *ca, Geom::IntRect con
static SPCanvasItemClass *parent_class;
static guint signals[LAST_SIGNAL] = {0};
+struct CacheBudgetObserver : public Inkscape::Preferences::Observer {
+ CacheBudgetObserver(SPCanvasArena *arena)
+ : Inkscape::Preferences::Observer("/options/renderingcache/size")
+ , _arena(arena)
+ {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ Inkscape::Preferences::Entry v = prefs->getEntry(observed_path);
+ notify(v);
+ prefs->addObserver(*this);
+ }
+ void notify(Preferences::Entry const &v) {
+ _arena->drawing.setCacheBudget((1 << 20) * v.getIntLimited(128, 0, 4096));
+ }
+ SPCanvasArena *_arena;
+};
+
GType
sp_canvas_arena_get_type (void)
{
@@ -102,6 +119,7 @@ sp_canvas_arena_init (SPCanvasArena *arena)
arena->sticky = FALSE;
new (&arena->drawing) Inkscape::Drawing(arena);
+ arena->observer = new CacheBudgetObserver(arena);
Inkscape::DrawingGroup *root = new DrawingGroup(arena->drawing);
root->setPickChildren(true);
@@ -129,6 +147,7 @@ sp_canvas_arena_destroy (GtkObject *object)
{
SPCanvasArena *arena = SP_CANVAS_ARENA (object);
+ delete arena->observer;
arena->drawing.~Drawing();
if (GTK_OBJECT_CLASS (parent_class)->destroy)
diff --git a/src/display/canvas-arena.h b/src/display/canvas-arena.h
index 6c65bb0e5..463dc1bc3 100644
--- a/src/display/canvas-arena.h
+++ b/src/display/canvas-arena.h
@@ -31,6 +31,7 @@ G_BEGIN_DECLS
typedef struct _SPCanvasArena SPCanvasArena;
typedef struct _SPCanvasArenaClass SPCanvasArenaClass;
+struct CacheBudgetObserver;
struct _SPCanvasArena {
SPCanvasItem item;
@@ -45,6 +46,7 @@ struct _SPCanvasArena {
Inkscape::DrawingItem *active;
/* fixme: */
Inkscape::DrawingItem *picked;
+ CacheBudgetObserver *observer;
double delta;
};
diff --git a/src/display/drawing.cpp b/src/display/drawing.cpp
index e1a17edf1..06183fed2 100644
--- a/src/display/drawing.cpp
+++ b/src/display/drawing.cpp
@@ -26,7 +26,7 @@ Drawing::Drawing(SPCanvasArena *arena)
, _blur_quality(BLUR_QUALITY_BEST)
, _filter_quality(Filters::FILTER_QUALITY_BEST)
, _cache_score_threshold(50000.0)
- , _cache_budget(128 << 20) // 128 MiB
+ , _cache_budget(0)
, _canvasarena(arena)
{
@@ -128,6 +128,12 @@ Drawing::setCacheLimit(Geom::OptIntRect const &r)
(*i)->_markForUpdate(DrawingItem::STATE_CACHE, false);
}
}
+void
+Drawing::setCacheBudget(size_t bytes)
+{
+ _cache_budget = bytes;
+ _pickItemsForCaching();
+}
void
Drawing::update(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset)
@@ -136,6 +142,29 @@ Drawing::update(Geom::IntRect const &area, UpdateContext const &ctx, unsigned fl
_root->update(area, ctx, flags, reset);
}
// process the updated cache scores
+ _pickItemsForCaching();
+}
+
+void
+Drawing::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flags)
+{
+ if (_root) {
+ _root->render(ct, area, flags);
+ }
+}
+
+DrawingItem *
+Drawing::pick(Geom::Point const &p, double delta, unsigned flags)
+{
+ if (_root) {
+ return _root->pick(p, delta, flags);
+ }
+ return NULL;
+}
+
+void
+Drawing::_pickItemsForCaching()
+{
// we cache the objects with the highest score until the budget is exhausted
_candidate_items.sort(std::greater<CacheRecord>());
size_t used = 0;
@@ -162,23 +191,6 @@ Drawing::update(Geom::IntRect const &area, UpdateContext const &ctx, unsigned fl
}
}
-void
-Drawing::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flags)
-{
- if (_root) {
- _root->render(ct, area, flags);
- }
-}
-
-DrawingItem *
-Drawing::pick(Geom::Point const &p, double delta, unsigned flags)
-{
- if (_root) {
- return _root->pick(p, delta, flags);
- }
- return NULL;
-}
-
} // end namespace Inkscape
/*
diff --git a/src/display/drawing.h b/src/display/drawing.h
index 011bf35a6..cfba4ebe6 100644
--- a/src/display/drawing.h
+++ b/src/display/drawing.h
@@ -55,6 +55,7 @@ public:
Geom::OptIntRect const &cacheLimit() const;
void setCacheLimit(Geom::OptIntRect const &r);
+ void setCacheBudget(size_t bytes);
OutlineColors const &colors() const { return _colors; }
@@ -67,7 +68,7 @@ public:
sigc::signal<void, DrawingItem *> signal_item_deleted;
private:
- void _reportCacheScore(CacheRecord const &);
+ void _pickItemsForCaching();
typedef std::list<CacheRecord> CandidateList;
diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h
index 16723170f..895eb7276 100644
--- a/src/preferences-skeleton.h
+++ b/src/preferences-skeleton.h
@@ -231,6 +231,7 @@ static char const preferences_skeleton[] =
" </group>\n"
"\n"
" <group id=\"options\">\n"
+" <group id=\"renderingcache\" size=\"128\" />"
" <group id=\"useoldpdfexporter\" value=\"0\" />"
" <group id=\"highlightoriginal\" value=\"1\" />"
" <group id=\"relinkclonesonduplicate\" value=\"0\" />"
diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp
index d11ffd565..0129f196f 100644
--- a/src/ui/dialog/inkscape-preferences.cpp
+++ b/src/ui/dialog/inkscape-preferences.cpp
@@ -124,7 +124,7 @@ InkscapePreferences::InkscapePreferences()
initPageTransforms();
initPageClones();
initPageMasks();
- initPageFilters();
+ initPageRendering();
initPageBitmaps();
initPageCMS();
initPageGrids();
@@ -739,8 +739,22 @@ void InkscapePreferences::initPageTransforms()
this->AddPage(_page_transforms, _("Transforms"), PREFS_PAGE_TRANSFORMS);
}
-void InkscapePreferences::initPageFilters()
+void InkscapePreferences::initPageRendering()
{
+ /* show infobox */
+ _show_filters_info_box.init( _("Show filter primitives infobox"), "/options/showfiltersinfobox/value", true);
+ _page_rendering.add_line(true, "", _show_filters_info_box, "",
+ _("Show icons and descriptions for the filter primitives available at the filter effects dialog"));
+
+ /* threaded blur */ //related comments/widgets/functions should be renamed and option should be moved elsewhere when inkscape is fully multi-threaded
+ _filter_multi_threaded.init("/options/threading/numthreads", 1.0, 8.0, 1.0, 2.0, 4.0, true, false);
+ _page_rendering.add_line( false, _("Number of Threads:"), _filter_multi_threaded, _("(requires restart)"),
+ _("Configure number of processors/threads to use when rendering filters"), false);
+
+ // rendering cache
+ _rendering_cache_size.init("/options/renderingcache/size", 0.0, 4096.0, 1.0, 32.0, 128.0, true, false);
+ _page_rendering.add_line( false, _("Rendering cache size:"), _rendering_cache_size, C_("mebibyte (2^20 bytes) abbreviation","MiB"), _("Set the amount of memory per drawing which can be used to store rendered parts of the drawing for later reuse; set to zero to disable caching"), false);
+
/* blur quality */
_blur_quality_best.init ( _("Best quality (slowest)"), "/options/blurquality/value",
BLUR_QUALITY_BEST, false, 0);
@@ -753,16 +767,16 @@ void InkscapePreferences::initPageFilters()
_blur_quality_worst.init ( _("Lowest quality (fastest)"), "/options/blurquality/value",
BLUR_QUALITY_WORST, false, &_blur_quality_best);
- _page_filters.add_group_header( _("Gaussian blur quality for display"));
- _page_filters.add_line( true, "", _blur_quality_best, "",
+ _page_rendering.add_group_header( _("Gaussian blur quality for display"));
+ _page_rendering.add_line( true, "", _blur_quality_best, "",
_("Best quality, but display may be very slow at high zooms (bitmap export always uses best quality)"));
- _page_filters.add_line( true, "", _blur_quality_better, "",
+ _page_rendering.add_line( true, "", _blur_quality_better, "",
_("Better quality, but slower display"));
- _page_filters.add_line( true, "", _blur_quality_normal, "",
+ _page_rendering.add_line( true, "", _blur_quality_normal, "",
_("Average quality, acceptable display speed"));
- _page_filters.add_line( true, "", _blur_quality_worse, "",
+ _page_rendering.add_line( true, "", _blur_quality_worse, "",
_("Lower quality (some artifacts), but display is faster"));
- _page_filters.add_line( true, "", _blur_quality_worst, "",
+ _page_rendering.add_line( true, "", _blur_quality_worst, "",
_("Lowest quality (considerable artifacts), but display is fastest"));
/* filter quality */
@@ -777,29 +791,19 @@ void InkscapePreferences::initPageFilters()
_filter_quality_worst.init ( _("Lowest quality (fastest)"), "/options/filterquality/value",
Inkscape::Filters::FILTER_QUALITY_WORST, false, &_filter_quality_best);
- _page_filters.add_group_header( _("Filter effects quality for display"));
- _page_filters.add_line( true, "", _filter_quality_best, "",
+ _page_rendering.add_group_header( _("Filter effects quality for display"));
+ _page_rendering.add_line( true, "", _filter_quality_best, "",
_("Best quality, but display may be very slow at high zooms (bitmap export always uses best quality)"));
- _page_filters.add_line( true, "", _filter_quality_better, "",
+ _page_rendering.add_line( true, "", _filter_quality_better, "",
_("Better quality, but slower display"));
- _page_filters.add_line( true, "", _filter_quality_normal, "",
+ _page_rendering.add_line( true, "", _filter_quality_normal, "",
_("Average quality, acceptable display speed"));
- _page_filters.add_line( true, "", _filter_quality_worse, "",
+ _page_rendering.add_line( true, "", _filter_quality_worse, "",
_("Lower quality (some artifacts), but display is faster"));
- _page_filters.add_line( true, "", _filter_quality_worst, "",
+ _page_rendering.add_line( true, "", _filter_quality_worst, "",
_("Lowest quality (considerable artifacts), but display is fastest"));
- /* show infobox */
- _show_filters_info_box.init( _("Show filter primitives infobox"), "/options/showfiltersinfobox/value", true);
- _page_filters.add_line(true, "", _show_filters_info_box, "",
- _("Show icons and descriptions for the filter primitives available at the filter effects dialog"));
-
- /* threaded blur */ //related comments/widgets/functions should be renamed and option should be moved elsewhere when inkscape is fully multi-threaded
- _filter_multi_threaded.init("/options/threading/numthreads", 1.0, 8.0, 1.0, 2.0, 4.0, true, false);
- _page_filters.add_line( false, _("Number of Threads:"), _filter_multi_threaded, _("(requires restart)"),
- _("Configure number of processors/threads to use with rendering of gaussian blur"), false);
-
- this->AddPage(_page_filters, _("Filters"), PREFS_PAGE_FILTERS);
+ this->AddPage(_page_rendering, _("Rendering"), PREFS_PAGE_RENDERING);
}
diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h
index 13851e525..d783a2df1 100644
--- a/src/ui/dialog/inkscape-preferences.h
+++ b/src/ui/dialog/inkscape-preferences.h
@@ -44,7 +44,7 @@ enum {
PREFS_PAGE_TOOLS_SELECTOR,
PREFS_PAGE_TOOLS_NODE,
PREFS_PAGE_TOOLS_TWEAK,
- PREFS_PAGE_TOOLS_SPRAY,
+ PREFS_PAGE_TOOLS_SPRAY,
PREFS_PAGE_TOOLS_ZOOM,
PREFS_PAGE_TOOLS_MEASURE,
PREFS_PAGE_TOOLS_SHAPES,
@@ -67,7 +67,7 @@ enum {
PREFS_PAGE_TRANSFORMS,
PREFS_PAGE_CLONES,
PREFS_PAGE_MASKS,
- PREFS_PAGE_FILTERS,
+ PREFS_PAGE_RENDERING,
PREFS_PAGE_BITMAPS,
PREFS_PAGE_CMS,
PREFS_PAGE_GRIDS,
@@ -124,7 +124,7 @@ protected:
UI::Widget::DialogPage _page_clones;
UI::Widget::DialogPage _page_mask;
UI::Widget::DialogPage _page_transforms;
- UI::Widget::DialogPage _page_filters;
+ UI::Widget::DialogPage _page_rendering;
UI::Widget::DialogPage _page_select;
UI::Widget::DialogPage _page_importexport;
UI::Widget::DialogPage _page_cms;
@@ -254,6 +254,7 @@ protected:
UI::Widget::PrefRadioButton _filter_quality_worse;
UI::Widget::PrefRadioButton _filter_quality_worst;
UI::Widget::PrefCheckButton _show_filters_info_box;
+ UI::Widget::PrefSpinButton _rendering_cache_size;
UI::Widget::PrefSpinButton _filter_multi_threaded;
UI::Widget::PrefCheckButton _trans_scale_stroke;
@@ -389,7 +390,7 @@ protected:
void initPageClones();
void initPageMasks();
void initPageTransforms();
- void initPageFilters();
+ void initPageRendering();
void initPageSelecting();
void initPageImportExport();
void initPageCMS();