summaryrefslogtreecommitdiffstats
path: root/src/display/drawing.cpp
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/display/drawing.cpp
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/display/drawing.cpp')
-rw-r--r--src/display/drawing.cpp48
1 files changed, 30 insertions, 18 deletions
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
/*