summaryrefslogtreecommitdiffstats
path: root/src/display/pixblock-transform.cpp
diff options
context:
space:
mode:
authorJF Barraud <jf.barraud@gmail.com>2008-02-24 01:35:24 +0000
committerjfbarraud <jfbarraud@users.sourceforge.net>2008-02-24 01:35:24 +0000
commite0313f357f9cb36a493497a637866bec35f28752 (patch)
tree384405cab5da7a77143b4e5e890a9dc8e45e3b08 /src/display/pixblock-transform.cpp
parentWarning and whitespace cleanup (diff)
downloadinkscape-e0313f357f9cb36a493497a637866bec35f28752.tar.gz
inkscape-e0313f357f9cb36a493497a637866bec35f28752.zip
pixblock-transform and scaler: convert src if needed, to match dest mode.
color matrix, comp. transfert and diplacement map: explicitely free some unused pixblock instead of resting on garbage collection... (bzr r4839)
Diffstat (limited to 'src/display/pixblock-transform.cpp')
-rw-r--r--src/display/pixblock-transform.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/display/pixblock-transform.cpp b/src/display/pixblock-transform.cpp
index abe0f90c0..730f0ad43 100644
--- a/src/display/pixblock-transform.cpp
+++ b/src/display/pixblock-transform.cpp
@@ -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 */