From f200503cc154d84f3e4aa87400c1c045bfa80937 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Tue, 16 Feb 2016 02:42:58 +0100 Subject: Performance improvements when working in large files At each mouse move, a list of all elements in the document was computed (to get the correct cursor, in text mode for instance). This list is now cached. (bzr r14655) --- src/document.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/document.h') diff --git a/src/document.h b/src/document.h index b4a8a8e8e..b57cf205d 100644 --- a/src/document.h +++ b/src/document.h @@ -28,6 +28,7 @@ #include #include #include +#include namespace Avoid { class Router; @@ -262,8 +263,8 @@ public: const std::set getResourceList(char const *key) const; std::vector getItemsInBox(unsigned int dkey, Geom::Rect const &box, bool into_groups = false) const; std::vector getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box, bool into_groups = false) const; - SPItem *getItemAtPoint(unsigned int key, Geom::Point const &p, bool into_groups, SPItem *upto = NULL) const; - std::vector getItemsAtPoints(unsigned const key, std::vector points, bool all_layers = true, size_t limit = 0) const; + SPItem *getItemAtPoint(unsigned int key, Geom::Point const &p, bool into_groups, SPItem *upto = NULL) ; + std::vector getItemsAtPoints(unsigned const key, std::vector points, bool all_layers = true, size_t limit = 0) ; SPItem *getGroupAtPoint(unsigned int key, Geom::Point const &p) const; void changeUriAndHrefs(char const *uri); @@ -277,6 +278,9 @@ private: void do_change_uri(char const *const filename, bool const rebase); void setupViewport(SPItemCtx *ctx); void importDefsNode(SPDocument *source, Inkscape::XML::Node *defs, Inkscape::XML::Node *target_defs); + bool build_flat_item_list(unsigned int dkey, SPGroup *group, gboolean into_groups, bool take_insensitive = false, SPItem *upto = NULL); + std::deque _node_cache; + bool _node_cache_valid; }; /* -- cgit v1.2.3 From 109ec952f041590ee5f42ac6e7d6bd5c212c9441 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Thu, 18 Feb 2016 00:38:22 +0100 Subject: Fixes some regressions from rev14655 Fixed bugs: - https://launchpad.net/bugs/1546531 (bzr r14658) --- src/document.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/document.h') diff --git a/src/document.h b/src/document.h index b57cf205d..825049cd5 100644 --- a/src/document.h +++ b/src/document.h @@ -263,8 +263,8 @@ public: const std::set getResourceList(char const *key) const; std::vector getItemsInBox(unsigned int dkey, Geom::Rect const &box, bool into_groups = false) const; std::vector getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box, bool into_groups = false) const; - SPItem *getItemAtPoint(unsigned int key, Geom::Point const &p, bool into_groups, SPItem *upto = NULL) ; - std::vector getItemsAtPoints(unsigned const key, std::vector points, bool all_layers = true, size_t limit = 0) ; + SPItem *getItemAtPoint(unsigned int key, Geom::Point const &p, bool into_groups, SPItem *upto = NULL) const; + std::vector getItemsAtPoints(unsigned const key, std::vector points, bool all_layers = true, size_t limit = 0) const ; SPItem *getGroupAtPoint(unsigned int key, Geom::Point const &p) const; void changeUriAndHrefs(char const *uri); @@ -278,9 +278,9 @@ private: void do_change_uri(char const *const filename, bool const rebase); void setupViewport(SPItemCtx *ctx); void importDefsNode(SPDocument *source, Inkscape::XML::Node *defs, Inkscape::XML::Node *target_defs); - bool build_flat_item_list(unsigned int dkey, SPGroup *group, gboolean into_groups, bool take_insensitive = false, SPItem *upto = NULL); - std::deque _node_cache; - bool _node_cache_valid; + void build_flat_item_list(unsigned int dkey, SPGroup *group, gboolean into_groups) const; + mutable std::deque _node_cache; + mutable bool _node_cache_valid; }; /* -- cgit v1.2.3