From df5a7a18bcbc9f1cf0d002f92b01473545b0eab3 Mon Sep 17 00:00:00 2001 From: gouldtj Date: Tue, 30 Oct 2007 19:29:36 +0000 Subject: [PATCH] r16892@shi: ted | 2007-10-29 21:33:09 -0700 Okay, so now the caches get into the execution environment and can be passed around to the effects. Now it's a matter of implementing the caches in the drivers. --- src/extension/effect.cpp | 8 +++++--- src/extension/execution-env.cpp | 33 ++++++++++++++++++++++++++++--- src/extension/execution-env.h | 11 ++++++++++- src/extension/extension-forward.h | 1 + 4 files changed, 46 insertions(+), 7 deletions(-) diff --git a/src/extension/effect.cpp b/src/extension/effect.cpp index 6b03014f8..f7caf125d 100644 --- a/src/extension/effect.cpp +++ b/src/extension/effect.cpp @@ -13,7 +13,7 @@ #include "desktop-handles.h" #include "selection.h" #include "sp-namedview.h" -#include "document.h" +#include "desktop.h" #include "implementation/implementation.h" #include "effect.h" #include "execution-env.h" @@ -219,9 +219,11 @@ Effect::prefs (Inkscape::UI::View::View * doc) sigc::signal * changeSignal = new sigc::signal; Gtk::Widget * controls; - controls = imp->prefs_effect(this, doc, changeSignal, NULL); + SPDesktop * spdesktop = (SPDesktop *)doc; + Implementation::ImplementationDocumentCache * docCache = imp->newDocCache(this, spdesktop->doc()); + controls = imp->prefs_effect(this, doc, changeSignal, docCache); - ExecutionEnv executionEnv(this, doc, controls, changeSignal); + ExecutionEnv executionEnv(this, doc, controls, changeSignal, NULL, docCache); timer->lock(); executionEnv.run(); diff --git a/src/extension/execution-env.cpp b/src/extension/execution-env.cpp index b7746289e..21df42b9d 100644 --- a/src/extension/execution-env.cpp +++ b/src/extension/execution-env.cpp @@ -18,6 +18,7 @@ #include "selection.h" #include "effect.h" #include "document.h" +#include "desktop.h" #include "ui/view/view.h" #include "sp-namedview.h" #include "desktop-handles.h" @@ -28,7 +29,7 @@ namespace Inkscape { namespace Extension { -ExecutionEnv::ExecutionEnv (Effect * effect, Inkscape::UI::View::View * doc, Gtk::Widget * controls, sigc::signal * changeSignal, Gtk::Dialog * prefDialog) : +ExecutionEnv::ExecutionEnv (Effect * effect, Inkscape::UI::View::View * doc, Gtk::Widget * controls, sigc::signal * changeSignal, Gtk::Dialog * prefDialog, Implementation::ImplementationDocumentCache * docCache) : _visibleDialog(NULL), _prefsVisible(false), _finished(false), @@ -40,7 +41,8 @@ ExecutionEnv::ExecutionEnv (Effect * effect, Inkscape::UI::View::View * doc, Gtk _selfdelete(false), _changeSignal(changeSignal), _doc(doc), - _effect(effect) { + _effect(effect), + _docCache(docCache) { SPDesktop *desktop = (SPDesktop *)_doc; sp_namedview_document_from_window(desktop); @@ -93,9 +95,30 @@ ExecutionEnv::~ExecutionEnv (void) { if (_changeSignal != NULL && !_shutdown) { delete _changeSignal; } + killDocCache(); return; } +void +ExecutionEnv::genDocCache (void) { + if (_docCache == NULL) { + printf("Gen Doc Cache\n"); + SPDesktop * spdesktop = (SPDesktop *)_doc; + Implementation::ImplementationDocumentCache * _docCache = _effect->get_imp()->newDocCache(_effect, spdesktop->doc()); + } + return; +} + +void +ExecutionEnv::killDocCache (void) { + if (_docCache != NULL) { + printf("Killed Doc Cache\n"); + delete _docCache; + _docCache = NULL; + } + return; +} + void ExecutionEnv::preferencesChange (void) { _timersig.disconnect(); @@ -250,7 +273,8 @@ ExecutionEnv::run (void) { _mainloop->run(); } else { _prefsChanged = false; - _effect->get_imp()->effect(_effect, _doc, NULL); + genDocCache(); + _effect->get_imp()->effect(_effect, _doc, _docCache); processingComplete(); } if (_canceled) { @@ -275,6 +299,9 @@ ExecutionEnv::livePreview (bool state) { _humanWait = false; } _livePreview = state; + if (!_livePreview) { + killDocCache(); + } return; } diff --git a/src/extension/execution-env.h b/src/extension/execution-env.h index a6c4ebf64..7b35f33a2 100644 --- a/src/extension/execution-env.h +++ b/src/extension/execution-env.h @@ -19,6 +19,7 @@ #include "forward.h" #include "extension-forward.h" +#include "extension.h" namespace Inkscape { namespace Extension { @@ -41,11 +42,17 @@ private: sigc::connection _dialogsig; sigc::connection _changesig; sigc::connection _timersig; + Implementation::ImplementationDocumentCache * _docCache; public: Effect * _effect; - ExecutionEnv (Effect * effect, Inkscape::UI::View::View * doc, Gtk::Widget * controls = NULL, sigc::signal * changeSignal = NULL, Gtk::Dialog * prefDialog = NULL); + ExecutionEnv (Effect * effect, + Inkscape::UI::View::View * doc, + Gtk::Widget * controls = NULL, + sigc::signal * changeSignal = NULL, + Gtk::Dialog * prefDialog = NULL, + Implementation::ImplementationDocumentCache * docCache = NULL); ~ExecutionEnv (void); void run (void); @@ -64,6 +71,8 @@ private: void documentCancel (void); void documentCommit (void); void reselect (void); + void genDocCache (void); + void killDocCache (void); }; } } /* namespace Inkscape, Extension */ diff --git a/src/extension/extension-forward.h b/src/extension/extension-forward.h index f0346b488..d836c29ab 100644 --- a/src/extension/extension-forward.h +++ b/src/extension/extension-forward.h @@ -16,6 +16,7 @@ class ExpirationTimer; namespace Implementation { class Implementation; +class ImplementationDocumentCache; } } } -- 2.30.2