From 75976ea07dba9b97186667524d0a76603de416af Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 7 Aug 2011 12:53:12 +0200 Subject: Rewrite NRArena -> Inkscape::Drawing. Call render and update methods on the Drawing rather than on the root DrawingItem. (bzr r10347.1.25) --- src/ui/cache/svg_preview_cache.cpp | 10 +++++----- src/ui/cache/svg_preview_cache.h | 2 +- src/ui/dialog/filedialogimpl-win32.cpp | 4 ++-- src/ui/dialog/icon-preview.cpp | 21 +++++++++------------ src/ui/view/view.h | 2 +- 5 files changed, 18 insertions(+), 21 deletions(-) (limited to 'src/ui') diff --git a/src/ui/cache/svg_preview_cache.cpp b/src/ui/cache/svg_preview_cache.cpp index ae5355c58..912bc1a40 100644 --- a/src/ui/cache/svg_preview_cache.cpp +++ b/src/ui/cache/svg_preview_cache.cpp @@ -30,18 +30,18 @@ #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 "ui/cache/svg_preview_cache.h" -GdkPixbuf* render_pixbuf(Inkscape::DrawingItem* root, double scale_factor, const Geom::Rect& dbox, unsigned psize) +GdkPixbuf* render_pixbuf(Inkscape::Drawing &drawing, double scale_factor, const Geom::Rect& dbox, unsigned psize) { Geom::Affine t(Geom::Scale(scale_factor, scale_factor)); - root->setTransform(Geom::Scale(scale_factor)); + drawing.root()->setTransform(Geom::Scale(scale_factor)); Geom::IntRect ibox = (dbox * Geom::Scale(scale_factor)).roundOutwards(); - root->update(ibox); + drawing.update(ibox); /* Find visible area */ int width = ibox.width(); @@ -59,7 +59,7 @@ GdkPixbuf* render_pixbuf(Inkscape::DrawingItem* root, double scale_factor, const CAIRO_FORMAT_ARGB32, psize, psize); Inkscape::DrawingContext ct(s, area.min()); - root->render(ct, area, Inkscape::DrawingItem::RENDER_BYPASS_CACHE); + drawing.render(ct, area, Inkscape::DrawingItem::RENDER_BYPASS_CACHE); cairo_surface_flush(s); GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(cairo_image_surface_get_data(s), diff --git a/src/ui/cache/svg_preview_cache.h b/src/ui/cache/svg_preview_cache.h index b9fa6f627..2318307e2 100644 --- a/src/ui/cache/svg_preview_cache.h +++ b/src/ui/cache/svg_preview_cache.h @@ -16,7 +16,7 @@ #include "display/display-forward.h" -GdkPixbuf* render_pixbuf(Inkscape::DrawingItem* root, double scale_factor, const Geom::Rect& dbox, unsigned psize); +GdkPixbuf* render_pixbuf(Inkscape::Drawing &drawing, double scale_factor, const Geom::Rect& dbox, unsigned psize); namespace Inkscape { namespace UI { diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index bb800f9ca..4f4093a99 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -34,8 +34,8 @@ #include "extension/output.h" #include "extension/db.h" -#include "display/nr-arena-item.h" -#include "display/nr-arena.h" +//#include "display/drawing-item.h" +//#include "display/drawing.h" #include "sp-item.h" #include "display/canvas-arena.h" diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index a6d76eb13..9865c0cdb 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -16,6 +16,7 @@ # include #endif +#include #include #include #include @@ -25,7 +26,7 @@ #include "desktop.h" #include "desktop-handles.h" -#include "display/nr-arena.h" +#include "display/drawing.h" #include "document.h" #include "inkscape.h" #include "preferences.h" @@ -36,9 +37,10 @@ #include "icon-preview.h" extern "C" { -// takes doc, root, icon, and icon name to produce pixels +// takes doc, drawing, icon, and icon name to produce pixels +// this is defined in widgets/icon.cpp guchar * -sp_icon_doc_icon( SPDocument *doc, Inkscape::DrawingItem *root, +sp_icon_doc_icon( SPDocument *doc, Inkscape::Drawing &drawing, const gchar *name, unsigned int psize, unsigned &stride); } @@ -438,20 +440,16 @@ void IconPreviewPanel::renderPreview( SPObject* obj ) g_message("%s setting up to render '%s' as the icon", getTimestr().c_str(), id ); #endif // ICON_VERBOSE - Inkscape::DrawingItem *root = NULL; + Inkscape::Drawing drawing; - /* Create new arena */ - NRArena *arena = NRArena::create(); - - /* Create ArenaItem and set transform */ + /* Create drawing items and set transform */ unsigned int visionkey = SPItem::display_key_new(1); - - root = doc->getRoot()->invoke_show( arena, visionkey, SP_ITEM_SHOW_DISPLAY ); + drawing.setRoot(doc->getRoot()->invoke_show( drawing, visionkey, SP_ITEM_SHOW_DISPLAY )); for ( int i = 0; i < numEntries; i++ ) { unsigned unused; int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, sizes[i]); - guchar * px = sp_icon_doc_icon( doc, root, id, sizes[i], unused); + guchar * px = sp_icon_doc_icon( doc, drawing, id, sizes[i], unused); // g_message( " size %d %s", sizes[i], (px ? "worked" : "failed") ); if ( px ) { memcpy( pixMem[i], px, sizes[i] * stride ); @@ -465,7 +463,6 @@ void IconPreviewPanel::renderPreview( SPObject* obj ) updateMagnify(); doc->getRoot()->invoke_hide(visionkey); - nr_object_unref((NRObject *) arena); renderTimer->stop(); minDelay = std::max( 0.1, renderTimer->elapsed() * 3.0 ); #if ICON_VERBOSE diff --git a/src/ui/view/view.h b/src/ui/view/view.h index 13499a2e4..db6061434 100644 --- a/src/ui/view/view.h +++ b/src/ui/view/view.h @@ -65,7 +65,7 @@ namespace Inkscape { /** * View is an abstract base class of all UI document views. This * includes both the editing window and the SVG preview, but does not - * include the non-UI RGBA buffer-based NRArena nor the XML editor or + * include the non-UI RGBA buffer-based Inkscape::Drawing nor the XML editor or * similar views. The View base class has very little functionality of * its own. */ -- cgit v1.2.3