From: gouldtj Date: Tue, 30 Oct 2007 19:28:31 +0000 (+0000) Subject: r16677@shi: ted | 2007-10-17 19:31:04 -0700 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=70d3ef426bda4739aa91ca9b913516de190ff2c6;p=inkscape.git r16677@shi: ted | 2007-10-17 19:31:04 -0700 Creating and adding interfaces for a document based cache that an effect can define. This removes the effect from having to know if the document has changed, and keep track of that. This allows them to optimize their performance when doing things like live effects. --- diff --git a/src/extension/effect.cpp b/src/extension/effect.cpp index 7ac4825a3..6b03014f8 100644 --- a/src/extension/effect.cpp +++ b/src/extension/effect.cpp @@ -219,7 +219,7 @@ Effect::prefs (Inkscape::UI::View::View * doc) sigc::signal * changeSignal = new sigc::signal; Gtk::Widget * controls; - controls = imp->prefs_effect(this, doc, changeSignal); + controls = imp->prefs_effect(this, doc, changeSignal, NULL); ExecutionEnv executionEnv(this, doc, controls, changeSignal); diff --git a/src/extension/execution-env.cpp b/src/extension/execution-env.cpp index 12cccbf90..b7746289e 100644 --- a/src/extension/execution-env.cpp +++ b/src/extension/execution-env.cpp @@ -250,7 +250,7 @@ ExecutionEnv::run (void) { _mainloop->run(); } else { _prefsChanged = false; - _effect->get_imp()->effect(_effect, _doc); + _effect->get_imp()->effect(_effect, _doc, NULL); processingComplete(); } if (_canceled) { diff --git a/src/extension/implementation/implementation.cpp b/src/extension/implementation/implementation.cpp index 3bf9b0b75..acec99041 100644 --- a/src/extension/implementation/implementation.cpp +++ b/src/extension/implementation/implementation.cpp @@ -38,8 +38,17 @@ Implementation::unload(Inkscape::Extension::Extension *module) { return; } /* Implementation::unload */ +/** \brief Create a new document cache object + \param ext The extension that is referencing us + \param doc The document to create the cache of + \return A new document cache that is valid as long as the document + is not changed. + + This function just returns \c NULL. Subclasses are likely + to reimplement it to do something useful. +*/ ImplementationDocumentCache * -Implementation::newDocCache (SPDocument * doc) { +Implementation::newDocCache (Inkscape::Extension::Extension * ext, SPDocument * doc) { return NULL; } @@ -71,12 +80,12 @@ Implementation::open(Inkscape::Extension::Input *module, gchar const *filename) } /* Implementation::open */ Gtk::Widget * -Implementation::prefs_output(Inkscape::Extension::Output *module, ImplementationDocumentCache * docCache) { +Implementation::prefs_output(Inkscape::Extension::Output *module) { return module->autogui(NULL, NULL); } /* Implementation::prefs_output */ void -Implementation::save(Inkscape::Extension::Output *module, SPDocument *doc, gchar const *filename, ImplementationDocumentCache * docCache) { +Implementation::save(Inkscape::Extension::Output *module, SPDocument *doc, gchar const *filename) { /* throw save_fail */ return; } /* Implementation::save */ diff --git a/src/extension/implementation/implementation.h b/src/extension/implementation/implementation.h index ca4f12069..bd380c07e 100644 --- a/src/extension/implementation/implementation.h +++ b/src/extension/implementation/implementation.h @@ -37,6 +37,7 @@ public: return; }; virtual ~ImplementationDocumentCache ( ) { return; }; + SPDocument const * doc ( ) { return _doc; }; }; /** @@ -55,7 +56,7 @@ public: virtual bool load(Inkscape::Extension::Extension *module); virtual void unload(Inkscape::Extension::Extension *module); - ImplementationDocumentCache * newDocCache (SPDocument * doc); + ImplementationDocumentCache * newDocCache (Inkscape::Extension::Extension * ext, SPDocument * doc); /** Verify any dependencies. */ virtual bool check(Inkscape::Extension::Extension *module); @@ -73,8 +74,8 @@ public: /* ----- Output functions ----- */ /** Find out information about the file. */ - virtual Gtk::Widget *prefs_output(Inkscape::Extension::Output *module, ImplementationDocumentCache * docCache); - virtual void save(Inkscape::Extension::Output *module, SPDocument *doc, gchar const *filename, ImplementationDocumentCache * docCache); + virtual Gtk::Widget *prefs_output(Inkscape::Extension::Output *module); + virtual void save(Inkscape::Extension::Output *module, SPDocument *doc, gchar const *filename); /* ----- Effect functions ----- */ /** Find out information about the file. */ diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index bde0871ba..bec24f165 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -495,7 +495,8 @@ Script::prefs_output(Inkscape::Extension::Output *module) Gtk::Widget * Script::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View *view, - sigc::signal * changeSignal) + sigc::signal * changeSignal, + ImplementationDocumentCache * docCache) { SPDocument * current_document = view->doc(); @@ -681,7 +682,9 @@ Script::save(Inkscape::Extension::Output *module, point both should be full, and the second one is loaded. */ void -Script::effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View *doc) +Script::effect(Inkscape::Extension::Effect *module, + Inkscape::UI::View::View *doc, + ImplementationDocumentCache * docCache) { std::list params; module->paramListString(params); diff --git a/src/extension/implementation/script.h b/src/extension/implementation/script.h index 417b42a89..6a6256f3c 100644 --- a/src/extension/implementation/script.h +++ b/src/extension/implementation/script.h @@ -90,13 +90,15 @@ public: */ virtual Gtk::Widget *prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View * view, - sigc::signal * changeSignal); + sigc::signal * changeSignal, + ImplementationDocumentCache * docCache); /** * */ virtual void effect(Inkscape::Extension::Effect *module, - Inkscape::UI::View::View *doc); + Inkscape::UI::View::View *doc, + ImplementationDocumentCache * docCache); virtual bool cancelProcessing (void); diff --git a/src/extension/internal/bitmap/imagemagick.cpp b/src/extension/internal/bitmap/imagemagick.cpp index a6c30a587..ddb7a0145 100644 --- a/src/extension/internal/bitmap/imagemagick.cpp +++ b/src/extension/internal/bitmap/imagemagick.cpp @@ -41,12 +41,13 @@ ImageMagick::load(Inkscape::Extension::Extension *module) return TRUE; } +/* void ImageMagick::commitDocument(void) { _loaded = FALSE; } -/*void +void ImageMagick::cancelDocument(void) { for (int i = 0; i < _imageCount; i++) { _nodes[i]->setAttribute("xlink:href", _originals[i], true); @@ -76,9 +77,10 @@ ImageMagick::readImage(const char *xlink, Magick::Image *image) } void -ImageMagick::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document) +ImageMagick::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document, Inkscape::Extension::Implementation::ImplementationDocumentCache * docCache) { refreshParameters(module); + _loaded = FALSE; if (!_loaded) { @@ -177,7 +179,7 @@ ImageMagick::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::Vi Uses AutoGUI for creating the GUI. */ Gtk::Widget * -ImageMagick::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View * view, sigc::signal * changeSignal) +ImageMagick::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View * view, sigc::signal * changeSignal, Inkscape::Extension::Implementation::ImplementationDocumentCache * docCache) { SPDocument * current_document = view->doc(); diff --git a/src/extension/internal/bitmap/imagemagick.h b/src/extension/internal/bitmap/imagemagick.h index 4afdcfbb4..3060ddd33 100644 --- a/src/extension/internal/bitmap/imagemagick.h +++ b/src/extension/internal/bitmap/imagemagick.h @@ -18,6 +18,12 @@ namespace Extension { namespace Internal { namespace Bitmap { +class ImageMagickDocCache: public Inkscape::Extension::Implementation::ImplementationDocumentCache { +public: + ImageMagickDocCache(SPDocument * doc) : Inkscape::Extension::Implementation::ImplementationDocumentCache(doc) { }; + ~ImageMagickDocCache ( ) { }; +}; + class ImageMagick : public Inkscape::Extension::Implementation::Implementation { private: @@ -36,13 +42,13 @@ public: virtual void refreshParameters(Inkscape::Extension::Effect *module) { }; bool load(Inkscape::Extension::Extension *module); - void commitDocument(void); + /*void commitDocument(void);*/ /*void cancelDocument(void);*/ void readImage(char const *xlink, Magick::Image *image); - void effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document); + void effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document, Inkscape::Extension::Implementation::ImplementationDocumentCache * docCache); - Gtk::Widget* prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View * view, sigc::signal * changeSignal); + Gtk::Widget* prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View * view, sigc::signal * changeSignal, Inkscape::Extension::Implementation::ImplementationDocumentCache * docCache); }; }; /* namespace Bitmap */ diff --git a/src/extension/internal/bluredge.cpp b/src/extension/internal/bluredge.cpp index aa1f3ece3..5c64d982a 100644 --- a/src/extension/internal/bluredge.cpp +++ b/src/extension/internal/bluredge.cpp @@ -51,7 +51,7 @@ BlurEdge::load (Inkscape::Extension::Extension *module) \param document What should be edited. */ void -BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document) +BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document, Inkscape::Extension::Implementation::ImplementationDocumentCache * docCache) { Inkscape::Selection * selection = ((SPDesktop *)document)->selection; @@ -117,7 +117,7 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View } Gtk::Widget * -BlurEdge::prefs_effect(Inkscape::Extension::Effect * module, Inkscape::UI::View::View * view, sigc::signal * changeSignal) +BlurEdge::prefs_effect(Inkscape::Extension::Effect * module, Inkscape::UI::View::View * view, sigc::signal * changeSignal, Inkscape::Extension::Implementation::ImplementationDocumentCache * docCache) { return module->autogui(NULL, NULL, changeSignal); } diff --git a/src/extension/internal/bluredge.h b/src/extension/internal/bluredge.h index d97e73c9a..48e30c054 100644 --- a/src/extension/internal/bluredge.h +++ b/src/extension/internal/bluredge.h @@ -21,8 +21,8 @@ class BlurEdge : public Inkscape::Extension::Implementation::Implementation { public: bool load(Inkscape::Extension::Extension *module); - void effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document); - Gtk::Widget * prefs_effect(Inkscape::Extension::Effect * module, Inkscape::UI::View::View * view, sigc::signal * changeSignal); + void effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document, Inkscape::Extension::Implementation::ImplementationDocumentCache * docCache); + Gtk::Widget * prefs_effect(Inkscape::Extension::Effect * module, Inkscape::UI::View::View * view, sigc::signal * changeSignal, Inkscape::Extension::Implementation::ImplementationDocumentCache * docCache); static void init (void); }; diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp index 1957813e5..6937cdcc9 100644 --- a/src/extension/internal/grid.cpp +++ b/src/extension/internal/grid.cpp @@ -74,7 +74,7 @@ Glib::ustring build_lines(int axis, NR::Rect bounding_area, \param document What should be edited. */ void -Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document) +Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document, Inkscape::Extension::Implementation::ImplementationDocumentCache * docCache) { Inkscape::Selection * selection = ((SPDesktop *)document)->selection; @@ -169,7 +169,7 @@ PrefAdjustment::val_changed (void) Uses AutoGUI for creating the GUI. */ Gtk::Widget * -Grid::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View * view, sigc::signal * changeSignal) +Grid::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View * view, sigc::signal * changeSignal, Inkscape::Extension::Implementation::ImplementationDocumentCache * docCache) { SPDocument * current_document = view->doc(); diff --git a/src/extension/internal/grid.h b/src/extension/internal/grid.h index c4a97aeba..1f37b1441 100644 --- a/src/extension/internal/grid.h +++ b/src/extension/internal/grid.h @@ -21,8 +21,8 @@ class Grid : public Inkscape::Extension::Implementation::Implementation { public: bool load(Inkscape::Extension::Extension *module); - void effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document); - Gtk::Widget * prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View * view, sigc::signal * changeSignal); + void effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document, Inkscape::Extension::Implementation::ImplementationDocumentCache * docCache); + Gtk::Widget * prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View * view, sigc::signal * changeSignal, Inkscape::Extension::Implementation::ImplementationDocumentCache * docCache); static void init (void); };