Code

Rename LPE: mirror reflect --> mirror symmetry
[inkscape.git] / src / display / pixblock-transform.cpp
index abe0f90c0f9aa86cbb48fb10926f04f8697b9982..74ded2ae0bf24731cc6fe5ae92d525360d7bf9c2 100644 (file)
@@ -13,7 +13,7 @@
 
 #include <glib.h>
 #include <cmath>
-#if defined (SOLARIS_2_8)
+#if defined (SOLARIS) && (SOLARIS == 8)
 #include "round.h"
 using Inkscape::round;
 #endif 
@@ -52,6 +52,15 @@ void transform_nearest(NRPixBlock *to, NRPixBlock *from, Matrix &trans)
         return;
     }
 
+    bool free_from_on_exit = false;
+    if (from->mode != to->mode){
+        NRPixBlock *o_from = from;
+        from = new NRPixBlock;
+        nr_pixblock_setup_fast(from, to->mode, o_from->area.x0, o_from->area.y0, o_from->area.x1, o_from->area.y1, false);
+        nr_blit_pixblock_pixblock(from, o_from);
+        free_from_on_exit = true;
+    }
+
     // Precalculate sizes of source and destination pixblocks
     int from_width = from->area.x1 - from->area.x0;
     int from_height = from->area.y1 - from->area.y0;
@@ -90,6 +99,10 @@ void transform_nearest(NRPixBlock *to, NRPixBlock *from, Matrix &trans)
             NR_PIXBLOCK_PX(to)[to_y * to->rs + to_x * 4 + 3] = result.a;
         }
     }
+    if (free_from_on_exit) {
+        nr_pixblock_release(from);
+        delete from;
+    }
 }
 
 /** Calculates cubically interpolated value of the four given pixel values.
@@ -149,11 +162,13 @@ void transform_bicubic(NRPixBlock *to, NRPixBlock *from, Matrix &trans)
         return;
     }
 
+    bool free_from_on_exit = false;
     if (from->mode != to->mode){
         NRPixBlock *o_from = from;
         from = new NRPixBlock;
         nr_pixblock_setup_fast(from, to->mode, o_from->area.x0, o_from->area.y0, o_from->area.x1, o_from->area.y1, false);
         nr_blit_pixblock_pixblock(from, o_from);
+        free_from_on_exit = true;
     }
     
     // Precalculate sizes of source and destination pixblocks
@@ -255,6 +270,10 @@ void transform_bicubic(NRPixBlock *to, NRPixBlock *from, Matrix &trans)
             }
         }
     }
+    if (free_from_on_exit) {
+        nr_pixblock_release(from);
+        delete from;
+    }
 }
 
 } /* namespace NR */