diff options
| author | Krzysztof Kosi??ski <tweenk.pl@gmail.com> | 2011-08-25 19:16:02 +0000 |
|---|---|---|
| committer | Krzysztof Kosinski <tweenk.pl@gmail.com> | 2011-08-25 19:16:02 +0000 |
| commit | 093f4174abc07b4ea523617fccdd8028f2670fea (patch) | |
| tree | 5aba6cd030bc6b0dbb59ec48e32a0b0364b516bd /src/ui | |
| parent | German translation update (diff) | |
| parent | Reduce default rendering cache size to 64 MiB (diff) | |
| download | inkscape-093f4174abc07b4ea523617fccdd8028f2670fea.tar.gz inkscape-093f4174abc07b4ea523617fccdd8028f2670fea.zip | |
Merge rendering cache branch (GSoC 2011)
(bzr r10579)
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/cache/svg_preview_cache.cpp | 61 | ||||
| -rw-r--r-- | src/ui/cache/svg_preview_cache.h | 23 | ||||
| -rw-r--r-- | src/ui/dialog/color-item.cpp | 18 | ||||
| -rw-r--r-- | src/ui/dialog/color-item.h | 3 | ||||
| -rw-r--r-- | src/ui/dialog/filedialogimpl-win32.cpp | 4 | ||||
| -rw-r--r-- | src/ui/dialog/icon-preview.cpp | 21 | ||||
| -rw-r--r-- | src/ui/dialog/inkscape-preferences.cpp | 54 | ||||
| -rw-r--r-- | src/ui/dialog/inkscape-preferences.h | 9 | ||||
| -rw-r--r-- | src/ui/dialog/swatches.cpp | 24 | ||||
| -rw-r--r-- | src/ui/view/view.h | 2 |
10 files changed, 109 insertions, 110 deletions
diff --git a/src/ui/cache/svg_preview_cache.cpp b/src/ui/cache/svg_preview_cache.cpp index cd1d65ba7..912bc1a40 100644 --- a/src/ui/cache/svg_preview_cache.cpp +++ b/src/ui/cache/svg_preview_cache.cpp @@ -27,54 +27,40 @@ #include "inkscape.h" #include "sp-rect.h" #include "document-private.h" -#include "display/nr-arena.h" -#include "display/nr-arena-item.h" #include "display/cairo-utils.h" +#include "display/drawing-context.h" +#include "display/drawing-item.h" +#include "display/drawing.h" #include "ui/cache/svg_preview_cache.h" -GdkPixbuf* render_pixbuf(NRArenaItem* root, double scale_factor, const Geom::Rect& dbox, unsigned psize) { - NRGC gc(NULL); - +GdkPixbuf* render_pixbuf(Inkscape::Drawing &drawing, double scale_factor, const Geom::Rect& dbox, unsigned psize) +{ Geom::Affine t(Geom::Scale(scale_factor, scale_factor)); - nr_arena_item_set_transform(root, t); + drawing.root()->setTransform(Geom::Scale(scale_factor)); - gc.transform.setIdentity(); - nr_arena_item_invoke_update( root, NULL, &gc, - NR_ARENA_ITEM_STATE_ALL, - NR_ARENA_ITEM_STATE_NONE ); + Geom::IntRect ibox = (dbox * Geom::Scale(scale_factor)).roundOutwards(); - /* Item integer bbox in points */ - NRRectL ibox; - ibox.x0 = floor(scale_factor * dbox.min()[Geom::X]); - ibox.y0 = floor(scale_factor * dbox.min()[Geom::Y]); - ibox.x1 = ceil(scale_factor * dbox.max()[Geom::X]); - ibox.y1 = ceil(scale_factor * dbox.max()[Geom::Y]); + drawing.update(ibox); /* Find visible area */ - int width = ibox.x1 - ibox.x0; - int height = ibox.y1 - ibox.y0; + int width = ibox.width(); + int height = ibox.height(); int dx = psize; int dy = psize; dx = (dx - width)/2; // watch out for size, since 'unsigned'-'signed' can cause problems if the result is negative dy = (dy - height)/2; - NRRectL area; - area.x0 = ibox.x0 - dx; - area.y0 = ibox.y0 - dy; - area.x1 = area.x0 + psize; - area.y1 = area.y0 + psize; + Geom::IntRect area = Geom::IntRect::from_xywh( + ibox.min() - Geom::IntPoint(dx, dy), Geom::IntPoint(psize, psize)); /* Render */ cairo_surface_t *s = cairo_image_surface_create( CAIRO_FORMAT_ARGB32, psize, psize); - cairo_t *ct = cairo_create(s); - cairo_translate(ct, -area.x0, -area.y0); + Inkscape::DrawingContext ct(s, area.min()); - nr_arena_item_invoke_render(ct, root, &area, NULL, - NR_ARENA_ITEM_RENDER_NO_CACHE ); + drawing.render(ct, area, Inkscape::DrawingItem::RENDER_BYPASS_CACHE); cairo_surface_flush(s); - cairo_destroy(ct); GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(cairo_image_surface_get_data(s), GDK_COLORSPACE_RGB, @@ -120,7 +106,7 @@ void SvgPreview::set_preview_in_cache(const Glib::ustring& key, GdkPixbuf* px) { _pixmap_cache[key] = px; } -GdkPixbuf* SvgPreview::get_preview(const gchar* uri, const gchar* id, NRArenaItem */*root*/, +GdkPixbuf* SvgPreview::get_preview(const gchar* uri, const gchar* id, Inkscape::DrawingItem */*root*/, double /*scale_factor*/, unsigned int psize) { // First try looking up the cached preview in the cache map Glib::ustring key = cache_key(uri, id, psize); @@ -135,6 +121,17 @@ GdkPixbuf* SvgPreview::get_preview(const gchar* uri, const gchar* id, NRArenaIte return px; } -}; -}; -}; +} +} +} + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/cache/svg_preview_cache.h b/src/ui/cache/svg_preview_cache.h index 0fac94782..2318307e2 100644 --- a/src/ui/cache/svg_preview_cache.h +++ b/src/ui/cache/svg_preview_cache.h @@ -1,17 +1,22 @@ -#ifndef __SVG_PREVIEW_CACHE_H__ -#define __SVG_PREVIEW_CACHE_H__ - -/** \file - * SPIcon: Generic icon widget +/** @file + * @brief Preview cache */ /* * Copyright (C) 2007 Bryce W. Harrington <bryce@bryceharrington.org> - * * Released under GNU GPL, read the file 'COPYING' for more information - * */ -GdkPixbuf* render_pixbuf(NRArenaItem* root, double scale_factor, const Geom::Rect& dbox, unsigned psize); +#ifndef SEEN_INKSCAPE_UI_SVG_PREVIEW_CACHE_H +#define SEEN_INKSCAPE_UI_SVG_PREVIEW_CACHE_H + +#include <map> +#include <gdk-pixbuf/gdk-pixbuf.h> +#include <glibmm/ustring.h> +#include <2geom/rect.h> + +#include "display/display-forward.h" + +GdkPixbuf* render_pixbuf(Inkscape::Drawing &drawing, double scale_factor, const Geom::Rect& dbox, unsigned psize); namespace Inkscape { namespace UI { @@ -28,7 +33,7 @@ class SvgPreview { Glib::ustring cache_key(gchar const *uri, gchar const *name, unsigned psize) const; GdkPixbuf* get_preview_from_cache(const Glib::ustring& key); void set_preview_in_cache(const Glib::ustring& key, GdkPixbuf* px); - GdkPixbuf* get_preview(const gchar* uri, const gchar* id, NRArenaItem *root, double scale_factor, unsigned int psize); + GdkPixbuf* get_preview(const gchar* uri, const gchar* id, Inkscape::DrawingItem *root, double scale_factor, unsigned int psize); }; }; // namespace Cache diff --git a/src/ui/dialog/color-item.cpp b/src/ui/dialog/color-item.cpp index 598827da9..b61925855 100644 --- a/src/ui/dialog/color-item.cpp +++ b/src/ui/dialog/color-item.cpp @@ -460,8 +460,8 @@ void ColorItem::_updatePreviews() for ( std::vector<SwatchPage*>::iterator it2 = possible.begin(); it2 != possible.end() && !found; ++it2 ) { SwatchPage* curr = *it2; index = 0; - for ( std::vector<ColorItem*>::iterator zz = curr->_colors.begin(); zz != curr->_colors.end(); ++zz ) { - if ( this == *zz ) { + for ( boost::ptr_vector<ColorItem>::iterator zz = curr->_colors.begin(); zz != curr->_colors.end(); ++zz ) { + if ( this == &*zz ) { found = true; paletteName = curr->_name; break; @@ -734,12 +734,12 @@ void ColorItem::_wireMagicColors( SwatchPage *colorSet ) { if ( colorSet ) { - for ( std::vector<ColorItem*>::iterator it = colorSet->_colors.begin(); it != colorSet->_colors.end(); ++it ) + for ( boost::ptr_vector<ColorItem>::iterator it = colorSet->_colors.begin(); it != colorSet->_colors.end(); ++it ) { - std::string::size_type pos = (*it)->def.descr.find("*{"); + std::string::size_type pos = it->def.descr.find("*{"); if ( pos != std::string::npos ) { - std::string subby = (*it)->def.descr.substr( pos + 2 ); + std::string subby = it->def.descr.substr( pos + 2 ); std::string::size_type endPos = subby.find("}*"); if ( endPos != std::string::npos ) { @@ -749,12 +749,12 @@ void ColorItem::_wireMagicColors( SwatchPage *colorSet ) if ( subby.find('E') != std::string::npos ) { - (*it)->def.setEditable( true ); + it->def.setEditable( true ); } if ( subby.find('L') != std::string::npos ) { - (*it)->_isLive = true; + it->_isLive = true; } std::string part; @@ -764,7 +764,7 @@ void ColorItem::_wireMagicColors( SwatchPage *colorSet ) if ( popVal( colorIndex, part ) ) { guint64 percent = 0; if ( popVal( percent, part ) ) { - (*it)->_linkTint( *(colorSet->_colors[colorIndex]), percent ); + it->_linkTint( colorSet->_colors[colorIndex], percent ); } } } @@ -779,7 +779,7 @@ void ColorItem::_wireMagicColors( SwatchPage *colorSet ) if ( !popVal( grayLevel, part ) ) { grayLevel = 0; } - (*it)->_linkTone( *(colorSet->_colors[colorIndex]), percent, grayLevel ); + it->_linkTone( colorSet->_colors[colorIndex], percent, grayLevel ); } } } diff --git a/src/ui/dialog/color-item.h b/src/ui/dialog/color-item.h index 9080498eb..d06082f2e 100644 --- a/src/ui/dialog/color-item.h +++ b/src/ui/dialog/color-item.h @@ -12,6 +12,7 @@ #ifndef SEEN_DIALOGS_COLOR_ITEM_H #define SEEN_DIALOGS_COLOR_ITEM_H +#include <boost/ptr_container/ptr_vector.hpp> #include <gtkmm/tooltips.h> #include "widgets/ege-paint-def.h" @@ -33,7 +34,7 @@ public: Glib::ustring _name; int _prefWidth; - std::vector<ColorItem*> _colors; + boost::ptr_vector<ColorItem> _colors; }; 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 38ec6d1be..9865c0cdb 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -16,6 +16,7 @@ # include <config.h> #endif +#include <boost/scoped_ptr.hpp> #include <gtk/gtk.h> #include <glib/gmem.h> #include <glibmm/i18n.h> @@ -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, NRArenaItem *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 - NRArenaItem *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/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index d11ffd565..ae27f0720 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -124,7 +124,7 @@ InkscapePreferences::InkscapePreferences() initPageTransforms(); initPageClones(); initPageMasks(); - initPageFilters(); + initPageRendering(); initPageBitmaps(); initPageCMS(); initPageGrids(); @@ -739,8 +739,22 @@ void InkscapePreferences::initPageTransforms() this->AddPage(_page_transforms, _("Transforms"), PREFS_PAGE_TRANSFORMS); } -void InkscapePreferences::initPageFilters() +void InkscapePreferences::initPageRendering() { + /* show infobox */ + _show_filters_info_box.init( _("Show filter primitives infobox"), "/options/showfiltersinfobox/value", true); + _page_rendering.add_line(true, "", _show_filters_info_box, "", + _("Show icons and descriptions for the filter primitives available at the filter effects dialog")); + + /* threaded blur */ //related comments/widgets/functions should be renamed and option should be moved elsewhere when inkscape is fully multi-threaded + _filter_multi_threaded.init("/options/threading/numthreads", 1.0, 8.0, 1.0, 2.0, 4.0, true, false); + _page_rendering.add_line( false, _("Number of Threads:"), _filter_multi_threaded, _("(requires restart)"), + _("Configure number of processors/threads to use when rendering filters"), false); + + // rendering cache + _rendering_cache_size.init("/options/renderingcache/size", 0.0, 4096.0, 1.0, 32.0, 64.0, true, false); + _page_rendering.add_line( false, _("Rendering cache size:"), _rendering_cache_size, C_("mebibyte (2^20 bytes) abbreviation","MiB"), _("Set the amount of memory per document which can be used to store rendered parts of the drawing for later reuse; set to zero to disable caching"), false); + /* blur quality */ _blur_quality_best.init ( _("Best quality (slowest)"), "/options/blurquality/value", BLUR_QUALITY_BEST, false, 0); @@ -753,16 +767,16 @@ void InkscapePreferences::initPageFilters() _blur_quality_worst.init ( _("Lowest quality (fastest)"), "/options/blurquality/value", BLUR_QUALITY_WORST, false, &_blur_quality_best); - _page_filters.add_group_header( _("Gaussian blur quality for display")); - _page_filters.add_line( true, "", _blur_quality_best, "", + _page_rendering.add_group_header( _("Gaussian blur quality for display")); + _page_rendering.add_line( true, "", _blur_quality_best, "", _("Best quality, but display may be very slow at high zooms (bitmap export always uses best quality)")); - _page_filters.add_line( true, "", _blur_quality_better, "", + _page_rendering.add_line( true, "", _blur_quality_better, "", _("Better quality, but slower display")); - _page_filters.add_line( true, "", _blur_quality_normal, "", + _page_rendering.add_line( true, "", _blur_quality_normal, "", _("Average quality, acceptable display speed")); - _page_filters.add_line( true, "", _blur_quality_worse, "", + _page_rendering.add_line( true, "", _blur_quality_worse, "", _("Lower quality (some artifacts), but display is faster")); - _page_filters.add_line( true, "", _blur_quality_worst, "", + _page_rendering.add_line( true, "", _blur_quality_worst, "", _("Lowest quality (considerable artifacts), but display is fastest")); /* filter quality */ @@ -777,29 +791,19 @@ void InkscapePreferences::initPageFilters() _filter_quality_worst.init ( _("Lowest quality (fastest)"), "/options/filterquality/value", Inkscape::Filters::FILTER_QUALITY_WORST, false, &_filter_quality_best); - _page_filters.add_group_header( _("Filter effects quality for display")); - _page_filters.add_line( true, "", _filter_quality_best, "", + _page_rendering.add_group_header( _("Filter effects quality for display")); + _page_rendering.add_line( true, "", _filter_quality_best, "", _("Best quality, but display may be very slow at high zooms (bitmap export always uses best quality)")); - _page_filters.add_line( true, "", _filter_quality_better, "", + _page_rendering.add_line( true, "", _filter_quality_better, "", _("Better quality, but slower display")); - _page_filters.add_line( true, "", _filter_quality_normal, "", + _page_rendering.add_line( true, "", _filter_quality_normal, "", _("Average quality, acceptable display speed")); - _page_filters.add_line( true, "", _filter_quality_worse, "", + _page_rendering.add_line( true, "", _filter_quality_worse, "", _("Lower quality (some artifacts), but display is faster")); - _page_filters.add_line( true, "", _filter_quality_worst, "", + _page_rendering.add_line( true, "", _filter_quality_worst, "", _("Lowest quality (considerable artifacts), but display is fastest")); - /* show infobox */ - _show_filters_info_box.init( _("Show filter primitives infobox"), "/options/showfiltersinfobox/value", true); - _page_filters.add_line(true, "", _show_filters_info_box, "", - _("Show icons and descriptions for the filter primitives available at the filter effects dialog")); - - /* threaded blur */ //related comments/widgets/functions should be renamed and option should be moved elsewhere when inkscape is fully multi-threaded - _filter_multi_threaded.init("/options/threading/numthreads", 1.0, 8.0, 1.0, 2.0, 4.0, true, false); - _page_filters.add_line( false, _("Number of Threads:"), _filter_multi_threaded, _("(requires restart)"), - _("Configure number of processors/threads to use with rendering of gaussian blur"), false); - - this->AddPage(_page_filters, _("Filters"), PREFS_PAGE_FILTERS); + this->AddPage(_page_rendering, _("Rendering"), PREFS_PAGE_RENDERING); } diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index 13851e525..d783a2df1 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -44,7 +44,7 @@ enum { PREFS_PAGE_TOOLS_SELECTOR, PREFS_PAGE_TOOLS_NODE, PREFS_PAGE_TOOLS_TWEAK, - PREFS_PAGE_TOOLS_SPRAY, + PREFS_PAGE_TOOLS_SPRAY, PREFS_PAGE_TOOLS_ZOOM, PREFS_PAGE_TOOLS_MEASURE, PREFS_PAGE_TOOLS_SHAPES, @@ -67,7 +67,7 @@ enum { PREFS_PAGE_TRANSFORMS, PREFS_PAGE_CLONES, PREFS_PAGE_MASKS, - PREFS_PAGE_FILTERS, + PREFS_PAGE_RENDERING, PREFS_PAGE_BITMAPS, PREFS_PAGE_CMS, PREFS_PAGE_GRIDS, @@ -124,7 +124,7 @@ protected: UI::Widget::DialogPage _page_clones; UI::Widget::DialogPage _page_mask; UI::Widget::DialogPage _page_transforms; - UI::Widget::DialogPage _page_filters; + UI::Widget::DialogPage _page_rendering; UI::Widget::DialogPage _page_select; UI::Widget::DialogPage _page_importexport; UI::Widget::DialogPage _page_cms; @@ -254,6 +254,7 @@ protected: UI::Widget::PrefRadioButton _filter_quality_worse; UI::Widget::PrefRadioButton _filter_quality_worst; UI::Widget::PrefCheckButton _show_filters_info_box; + UI::Widget::PrefSpinButton _rendering_cache_size; UI::Widget::PrefSpinButton _filter_multi_threaded; UI::Widget::PrefCheckButton _trans_scale_stroke; @@ -389,7 +390,7 @@ protected: void initPageClones(); void initPageMasks(); void initPageTransforms(); - void initPageFilters(); + void initPageRendering(); void initPageSelecting(); void initPageImportExport(); void initPageCMS(); diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index ad3b79630..910d63873 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -885,7 +885,7 @@ void SwatchesPanel::_setDocument( SPDocument *document ) } static void recalcSwatchContents(SPDocument* doc, - std::vector<ColorItem*> &tmpColors, + boost::ptr_vector<ColorItem> &tmpColors, std::map<ColorItem*, cairo_pattern_t*> &previewMappings, std::map<ColorItem*, SPGradient*> &gradMappings) { @@ -938,7 +938,7 @@ void SwatchesPanel::handleGradientsChange(SPDocument *document) { SwatchPage *docPalette = (docPalettes.find(document) != docPalettes.end()) ? docPalettes[document] : 0; if (docPalette) { - std::vector<ColorItem*> tmpColors; + boost::ptr_vector<ColorItem> tmpColors; std::map<ColorItem*, cairo_pattern_t*> tmpPrevs; std::map<ColorItem*, SPGradient*> tmpGrads; recalcSwatchContents(document, tmpColors, tmpPrevs, tmpGrads); @@ -953,9 +953,6 @@ void SwatchesPanel::handleGradientsChange(SPDocument *document) } docPalette->_colors.swap(tmpColors); - for (std::vector<ColorItem*>::iterator it = tmpColors.begin(); it != tmpColors.end(); ++it) { - delete *it; - } // Figure out which SwatchesPanel instances are affected and update them. @@ -976,7 +973,7 @@ void SwatchesPanel::handleDefsModified(SPDocument *document) { SwatchPage *docPalette = (docPalettes.find(document) != docPalettes.end()) ? docPalettes[document] : 0; if (docPalette && !DocTrack::queueUpdateIfNeeded(document) ) { - std::vector<ColorItem*> tmpColors; + boost::ptr_vector<ColorItem> tmpColors; std::map<ColorItem*, cairo_pattern_t*> tmpPrevs; std::map<ColorItem*, SPGradient*> tmpGrads; recalcSwatchContents(document, tmpColors, tmpPrevs, tmpGrads); @@ -986,8 +983,8 @@ void SwatchesPanel::handleDefsModified(SPDocument *document) } else { int cap = std::min(docPalette->_colors.size(), tmpColors.size()); for (int i = 0; i < cap; i++) { - ColorItem* newColor = tmpColors[i]; - ColorItem* oldColor = docPalette->_colors[i]; + ColorItem *newColor = &tmpColors[i]; + ColorItem *oldColor = &docPalette->_colors[i]; if ( (newColor->def.getType() != oldColor->def.getType()) || (newColor->def.getR() != oldColor->def.getR()) || (newColor->def.getG() != oldColor->def.getG()) || @@ -1006,9 +1003,6 @@ void SwatchesPanel::handleDefsModified(SPDocument *document) for (std::map<ColorItem*, cairo_pattern_t*>::iterator it = tmpPrevs.begin(); it != tmpPrevs.end(); ++it) { cairo_pattern_destroy(it->second); } - for (std::vector<ColorItem*>::iterator it = tmpColors.begin(); it != tmpColors.end(); ++it) { - delete *it; - } } } @@ -1098,8 +1092,8 @@ void SwatchesPanel::_updateFromSelection() } sp_style_unref(tmpStyle); - for ( std::vector<ColorItem*>::iterator it = docPalette->_colors.begin(); it != docPalette->_colors.end(); ++it ) { - ColorItem* item = *it; + for ( boost::ptr_vector<ColorItem>::iterator it = docPalette->_colors.begin(); it != docPalette->_colors.end(); ++it ) { + ColorItem* item = &*it; bool isFill = (fillId == item->def.descr); bool isStroke = (strokeId == item->def.descr); item->setState( isFill, isStroke ); @@ -1140,8 +1134,8 @@ void SwatchesPanel::_rebuild() _holder->freezeUpdates(); // TODO restore once 'clear' works _holder->addPreview(_clear); _holder->addPreview(_remove); - for ( std::vector<ColorItem*>::iterator it = curr->_colors.begin(); it != curr->_colors.end(); it++ ) { - _holder->addPreview(*it); + for ( boost::ptr_vector<ColorItem>::iterator it = curr->_colors.begin(); it != curr->_colors.end(); it++ ) { + _holder->addPreview(&*it); } _holder->thawUpdates(); } 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. */ |
