summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorKrzysztof Kosi??ski <tweenk.pl@gmail.com>2011-08-07 10:53:12 +0000
committerKrzysztof KosiƄski <tweenk.pl@gmail.com>2011-08-07 10:53:12 +0000
commit75976ea07dba9b97186667524d0a76603de416af (patch)
tree4cb68dabb3cb7d5219e6ed6b660f0ded13fc25d3 /src/widgets
parentFix compilation (oops). (diff)
downloadinkscape-75976ea07dba9b97186667524d0a76603de416af.tar.gz
inkscape-75976ea07dba9b97186667524d0a76603de416af.zip
Rewrite NRArena -> Inkscape::Drawing. Call render and update
methods on the Drawing rather than on the root DrawingItem. (bzr r10347.1.25)
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/desktop-widget.cpp1
-rw-r--r--src/widgets/icon.cpp49
-rw-r--r--src/widgets/stroke-style.cpp14
3 files changed, 30 insertions, 34 deletions
diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp
index af329f3fc..08f0eadfb 100644
--- a/src/widgets/desktop-widget.cpp
+++ b/src/widgets/desktop-widget.cpp
@@ -36,7 +36,6 @@
#include "desktop-widget.h"
#include "display/sp-canvas.h"
#include "display/canvas-arena.h"
-#include "display/nr-arena.h"
#include "document.h"
#include "ege-color-prof-tracker.h"
#include "ege-select-one-action.h"
diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp
index fea825444..a57b56b5c 100644
--- a/src/widgets/icon.cpp
+++ b/src/widgets/icon.cpp
@@ -33,7 +33,7 @@
#include "display/cairo-utils.h"
#include "display/drawing-context.h"
#include "display/drawing-item.h"
-#include "display/nr-arena.h"
+#include "display/drawing.h"
#include "io/sys.h"
#include "sp-root.h"
@@ -1088,9 +1088,9 @@ static Geom::IntRect round_rect(Geom::Rect const &r)
return ret;
}
-// takes doc, root, icon, and icon name to produce pixels
+// takes doc, drawing, icon, and icon name to produce pixels
extern "C" guchar *
-sp_icon_doc_icon( SPDocument *doc, Inkscape::DrawingItem *root,
+sp_icon_doc_icon( SPDocument *doc, Inkscape::Drawing &drawing,
gchar const *name, unsigned psize,
unsigned &stride)
{
@@ -1115,8 +1115,8 @@ sp_icon_doc_icon( SPDocument *doc, Inkscape::DrawingItem *root,
if ( dbox ) {
/* Update to renderable state */
double sf = 1.0;
- root->setTransform(Geom::Scale(sf));
- root->update();
+ drawing.root()->setTransform(Geom::Scale(sf));
+ drawing.update();
/* Item integer bbox in points */
// NOTE: previously, each rect coordinate was rounded using floor(c + 0.5)
Geom::IntRect ibox = round_rect(*dbox);
@@ -1141,8 +1141,8 @@ sp_icon_doc_icon( SPDocument *doc, Inkscape::DrawingItem *root,
}
sf = (double)psize / (double)block;
- root->setTransform(Geom::Scale(sf));
- root->update();
+ drawing.root()->setTransform(Geom::Scale(sf));
+ drawing.update();
ibox = round_rect(*dbox * Geom::Scale(sf));
if ( dump ) {
@@ -1185,7 +1185,7 @@ sp_icon_doc_icon( SPDocument *doc, Inkscape::DrawingItem *root,
CAIRO_FORMAT_ARGB32, psize, psize, stride);
Inkscape::DrawingContext ct(s, ua.min());
- root->render(ct, ua, Inkscape::DrawingItem::RENDER_BYPASS_CACHE);
+ drawing.render(ct, ua);
cairo_surface_destroy(s);
// convert to GdkPixbuf format
@@ -1206,9 +1206,21 @@ sp_icon_doc_icon( SPDocument *doc, Inkscape::DrawingItem *root,
class SVGDocCache
{
public:
- SVGDocCache( SPDocument *doc, Inkscape::DrawingItem *root ) : doc(doc), root(root) {}
+ SVGDocCache( SPDocument *doc )
+ : doc(doc)
+ , visionkey(SPItem::display_key_new(1))
+ {
+ doc->doRef();
+ doc->ensureUpToDate();
+ drawing.setRoot(doc->getRoot()->invoke_show(drawing, visionkey, SP_ITEM_SHOW_DISPLAY ));
+ }
+ ~SVGDocCache() {
+ doc->getRoot()->invoke_hide(visionkey);
+ doc->doUnref();
+ }
SPDocument *doc;
- Inkscape::DrawingItem *root;
+ Inkscape::Drawing drawing;
+ unsigned visionkey;
};
static std::map<Glib::ustring, SVGDocCache *> doc_cache;
@@ -1275,27 +1287,14 @@ guchar *IconImpl::load_svg_pixels(std::list<Glib::ustring> const &names,
if ( dump ) {
g_message("Loaded icon file %s", doc_filename);
}
- // prep the document
- doc->ensureUpToDate();
-
- // Create new arena
- NRArena *arena = NRArena::create();
-
- // Create ArenaItem and set transform
- unsigned visionkey = SPItem::display_key_new(1);
- // fixme: Memory manage root if needed (Lauris)
- // This needs to be fixed indeed; this leads to a memory leak of a few megabytes these days
- // because shapes are being rendered which are not being freed
- Inkscape::DrawingItem *root = doc->getRoot()->invoke_show( arena, visionkey, SP_ITEM_SHOW_DISPLAY );
-
// store into the cache
- info = new SVGDocCache(doc, root);
+ info = new SVGDocCache(doc);
doc_cache[key] = info;
}
}
if (info) {
for (std::list<Glib::ustring>::const_iterator it = names.begin(); !px && (it != names.end()); ++it ) {
- px = sp_icon_doc_icon( info->doc, info->root, it->c_str(), psize, stride );
+ px = sp_icon_doc_icon( info->doc, info->drawing, it->c_str(), psize, stride );
}
}
}
diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp
index 4f6466ce8..8d9b9b429 100644
--- a/src/widgets/stroke-style.cpp
+++ b/src/widgets/stroke-style.cpp
@@ -29,7 +29,7 @@
#include "dialogs/dialog-events.h"
#include "display/canvas-bpath.h" // for SP_STROKE_LINEJOIN_*
#include "display/display-forward.h"
-#include "display/nr-arena.h"
+#include "display/drawing.h"
#include "document-private.h"
#include "gradient-chemistry.h"
#include "helper/stock-items.h"
@@ -153,8 +153,7 @@ sp_stroke_radio_button(Gtk::RadioButton *tb, char const *icon,
static Gtk::Image *
sp_marker_prev_new(unsigned psize, gchar const *mname,
SPDocument *source, SPDocument *sandbox,
- gchar const *menu_id, NRArena const * /*arena*/, unsigned /*visionkey*/,
- Inkscape::DrawingItem *root)
+ gchar const *menu_id, Inkscape::Drawing &drawing, unsigned /*visionkey*/)
{
// Retrieve the marker named 'mname' from the source SVG document
SPObject const *marker = source->getObjectById(mname);
@@ -209,7 +208,7 @@ sp_marker_prev_new(unsigned psize, gchar const *mname,
Glib::RefPtr<Gdk::Pixbuf> pixbuf = Glib::wrap(svg_preview_cache.get_preview_from_cache(key));
if (!pixbuf) {
- pixbuf = Glib::wrap(render_pixbuf(root, sf, *dbox, psize));
+ pixbuf = Glib::wrap(render_pixbuf(drawing, sf, *dbox, psize));
svg_preview_cache.set_preview_in_cache(key, pixbuf->gobj());
}
@@ -249,9 +248,9 @@ static void
sp_marker_menu_build (Gtk::Menu *m, GSList *marker_list, SPDocument *source, SPDocument *sandbox, gchar const *menu_id)
{
// Do this here, outside of loop, to speed up preview generation:
- NRArena const *arena = NRArena::create();
+ Inkscape::Drawing drawing;
unsigned const visionkey = SPItem::display_key_new(1);
- Inkscape::DrawingItem *root = sandbox->getRoot()->invoke_show((NRArena *) arena, visionkey, SP_ITEM_SHOW_DISPLAY);
+ drawing.setRoot(sandbox->getRoot()->invoke_show(drawing, visionkey, SP_ITEM_SHOW_DISPLAY));
for (; marker_list != NULL; marker_list = marker_list->next) {
Inkscape::XML::Node *repr = reinterpret_cast<SPItem *>(marker_list->data)->getRepr();
@@ -272,7 +271,7 @@ sp_marker_menu_build (Gtk::Menu *m, GSList *marker_list, SPDocument *source, SPD
// generate preview
- Gtk::Image *prv = sp_marker_prev_new (22, markid, source, sandbox, menu_id, arena, visionkey, root);
+ Gtk::Image *prv = sp_marker_prev_new (22, markid, source, sandbox, menu_id, drawing, visionkey);
prv->show();
hb->pack_start(*prv, false, false, 6);
@@ -290,7 +289,6 @@ sp_marker_menu_build (Gtk::Menu *m, GSList *marker_list, SPDocument *source, SPD
}
sandbox->getRoot()->invoke_hide(visionkey);
- nr_object_unref((NRObject *) arena);
}
/**