summaryrefslogtreecommitdiffstats
path: root/src/sp-image.cpp
diff options
context:
space:
mode:
authorKrzysztof Kosi??ski <tweenk.pl@gmail.com>2010-08-09 20:45:22 +0000
committerKrzysztof KosiƄski <tweenk.pl@gmail.com>2010-08-09 20:45:22 +0000
commit2cfc657521d2c22e9238ce1904a6a4a90d3b4517 (patch)
treeb07eb4e1fefea78fdac087e5fc6eaa3a179a6b41 /src/sp-image.cpp
parentOpenMP-enabled matrix convolution (diff)
downloadinkscape-2cfc657521d2c22e9238ce1904a6a4a90d3b4517.tar.gz
inkscape-2cfc657521d2c22e9238ce1904a6a4a90d3b4517.zip
Fix performance regression when displaying large images
(bzr r9508.1.54)
Diffstat (limited to 'src/sp-image.cpp')
-rw-r--r--src/sp-image.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/sp-image.cpp b/src/sp-image.cpp
index 596090846..22392e635 100644
--- a/src/sp-image.cpp
+++ b/src/sp-image.cpp
@@ -26,6 +26,7 @@
#include <glibmm/i18n.h>
#include "display/nr-arena-image.h"
+#include "display/cairo-utils.h"
#include "display/curve.h"
//Added for preserveAspectRatio support -- EAF
#include "enums.h"
@@ -908,6 +909,8 @@ sp_image_update (SPObject *object, SPCtx *ctx, unsigned int flags)
}
#endif // ENABLE_LCMS
image->pixbuf = pixbuf;
+ // convert to premultiplied native-endian ARGB for display with Cairo
+ convert_pixbuf_normal_to_argb32(image->pixbuf);
}
}
}
@@ -1077,11 +1080,14 @@ sp_image_print (SPItem *item, SPPrintContext *ctx)
SPImage *image = SP_IMAGE(item);
if (image->pixbuf && (image->width.computed > 0.0) && (image->height.computed > 0.0) ) {
- guchar *px = gdk_pixbuf_get_pixels(image->pixbuf);
- int w = gdk_pixbuf_get_width(image->pixbuf);
- int h = gdk_pixbuf_get_height(image->pixbuf);
- int rs = gdk_pixbuf_get_rowstride(image->pixbuf);
- int pixskip = gdk_pixbuf_get_n_channels(image->pixbuf) * gdk_pixbuf_get_bits_per_sample(image->pixbuf) / 8;
+ GdkPixbuf *pb = gdk_pixbuf_copy(image->pixbuf);
+ convert_pixbuf_argb32_to_normal(pb);
+
+ guchar *px = gdk_pixbuf_get_pixels(pb);
+ int w = gdk_pixbuf_get_width(pb);
+ int h = gdk_pixbuf_get_height(pb);
+ int rs = gdk_pixbuf_get_rowstride(pb);
+ int pixskip = gdk_pixbuf_get_n_channels(pb) * gdk_pixbuf_get_bits_per_sample(pb) / 8;
if (image->aspect_align == SP_ASPECT_NONE) {
Geom::Matrix t;
@@ -1262,7 +1268,7 @@ static void
sp_image_update_arenaitem (SPImage *image, NRArenaImage *ai)
{
nr_arena_image_set_style(ai, SP_OBJECT_STYLE(SP_OBJECT(image)));
- nr_arena_image_set_pixbuf(ai, image->pixbuf);
+ nr_arena_image_set_argb32_pixbuf(ai, image->pixbuf);
nr_arena_image_set_origin(ai, Geom::Point(image->ox, image->oy));
nr_arena_image_set_scale(ai, image->sx, image->sy);
nr_arena_image_set_clipbox(ai, image->clipbox);