From 083367b313247a4cf0c082fff25e993892dc38d1 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 19 Sep 2013 02:57:10 +0200 Subject: Encapsulate the shared memory hack for Cairo and GdkPixbuf in a class called Inkscape::Pixbuf. Replace usage in the code as appropriate. (bzr r12531) --- src/trace/trace.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'src/trace/trace.cpp') diff --git a/src/trace/trace.cpp b/src/trace/trace.cpp index cad8ea9be..e2cda6247 100644 --- a/src/trace/trace.cpp +++ b/src/trace/trace.cpp @@ -31,6 +31,7 @@ #include <2geom/transforms.h> #include "verbs.h" +#include "display/cairo-utils.h" #include "display/drawing.h" #include "display/drawing-shape.h" @@ -336,8 +337,17 @@ Glib::RefPtr Tracer::getSelectedImage() if (!img->pixbuf) return Glib::RefPtr(NULL); - Glib::RefPtr pixbuf = - Glib::wrap(img->pixbuf, true); + GdkPixbuf *raw_pb = img->pixbuf->getPixbufRaw(false); + GdkPixbuf *trace_pb = gdk_pixbuf_copy(raw_pb); + if (img->pixbuf->pixelFormat() == Inkscape::Pixbuf::PF_CAIRO) { + convert_pixels_argb32_to_pixbuf( + gdk_pixbuf_get_pixels(trace_pb), + gdk_pixbuf_get_width(trace_pb), + gdk_pixbuf_get_height(trace_pb), + gdk_pixbuf_get_rowstride(trace_pb)); + } + + Glib::RefPtr pixbuf = Glib::wrap(trace_pb, false); if (sioxEnabled) { @@ -410,7 +420,16 @@ void Tracer::traceThread() return; } - Glib::RefPtr pixbuf = Glib::wrap(img->pixbuf, true); + GdkPixbuf *trace_pb = gdk_pixbuf_copy(img->pixbuf->getPixbufRaw(false)); + if (img->pixbuf->pixelFormat() == Inkscape::Pixbuf::PF_CAIRO) { + convert_pixels_argb32_to_pixbuf( + gdk_pixbuf_get_pixels(trace_pb), + gdk_pixbuf_get_width(trace_pb), + gdk_pixbuf_get_height(trace_pb), + gdk_pixbuf_get_rowstride(trace_pb)); + } + + Glib::RefPtr pixbuf = Glib::wrap(trace_pb, false); pixbuf = sioxProcessImage(img, pixbuf); -- cgit v1.2.3