From dc713ea50efc5fd3f041db05ff92d31a3a54dc5b Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Tue, 16 Aug 2011 06:04:53 +0200 Subject: Add user preference for rendering cache size (bzr r10347.1.34) --- src/display/drawing.cpp | 48 ++++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 18 deletions(-) (limited to 'src/display/drawing.cpp') 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()); 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 /* -- cgit v1.2.3