summaryrefslogtreecommitdiffstats
path: root/src/display/sodipodi-ctrl.cpp
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2008-11-21 05:24:08 +0000
committerTed Gould <ted@canonical.com>2008-11-21 05:24:08 +0000
commit44a3a78fb6a3863c0c7f3c1193837337e68a67e4 (patch)
tree1722ee5ec6f88c881cd4124923354b3c1311501b /src/display/sodipodi-ctrl.cpp
parentMerge from trunk (diff)
downloadinkscape-44a3a78fb6a3863c0c7f3c1193837337e68a67e4.tar.gz
inkscape-44a3a78fb6a3863c0c7f3c1193837337e68a67e4.zip
Merge from fe-moved
(bzr r6891)
Diffstat (limited to 'src/display/sodipodi-ctrl.cpp')
-rw-r--r--src/display/sodipodi-ctrl.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/display/sodipodi-ctrl.cpp b/src/display/sodipodi-ctrl.cpp
index 1bed9355d..c26402743 100644
--- a/src/display/sodipodi-ctrl.cpp
+++ b/src/display/sodipodi-ctrl.cpp
@@ -12,6 +12,7 @@
#include "sp-canvas-util.h"
#include "display-forward.h"
#include "sodipodi-ctrl.h"
+#include "libnr/nr-pixops.h"
enum {
ARG_0,
@@ -122,6 +123,11 @@ sp_ctrl_destroy (GtkObject *object)
ctrl = SP_CTRL (object);
+ if (ctrl->cache) {
+ g_free(ctrl->cache);
+ ctrl->cache = NULL;
+ }
+
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
@@ -314,11 +320,13 @@ sp_ctrl_build_cache (SPCtrl *ctrl)
side = (ctrl->span * 2 +1);
c = ctrl->span ;
- g_free (ctrl->cache);
size = (side) * (side) * 4;
- ctrl->cache = (guchar*)g_malloc (size);
if (side < 2) return;
+ if (ctrl->cache)
+ g_free (ctrl->cache);
+ ctrl->cache = (guchar*)g_malloc (size);
+
switch (ctrl->shape) {
case SP_CTRL_SHAPE_SQUARE:
p = ctrl->cache;
@@ -482,9 +490,9 @@ sp_ctrl_build_cache (SPCtrl *ctrl)
}
// composite background, foreground, alpha for xor mode
-#define COMPOSE_X(b,f,a) ( ( ((guchar) b) * ((guchar) (0xff - a)) + ((guchar) ((b ^ ~f) + b/4 - (b>127? 63 : 0))) * ((guchar) a) ) / 0xff )
+#define COMPOSE_X(b,f,a) ( FAST_DIVIDE<255>( ((guchar) b) * ((guchar) (0xff - a)) + ((guchar) ((b ^ ~f) + b/4 - (b>127? 63 : 0))) * ((guchar) a) ) )
// composite background, foreground, alpha for color mode
-#define COMPOSE_N(b,f,a) ( ( ((guchar) b) * ((guchar) (0xff - a)) + ((guchar) f) * ((guchar) a) ) / 0xff )
+#define COMPOSE_N(b,f,a) ( FAST_DIVIDE<255>( ((guchar) b) * ((guchar) (0xff - a)) + ((guchar) f) * ((guchar) a) ) )
static void
sp_ctrl_render (SPCanvasItem *item, SPCanvasBuf *buf)