From e0313f357f9cb36a493497a637866bec35f28752 Mon Sep 17 00:00:00 2001 From: JF Barraud Date: Sun, 24 Feb 2008 01:35:24 +0000 Subject: 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) --- src/display/pixblock-transform.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/display/pixblock-transform.cpp') 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 */ -- cgit v1.2.3