[cairo-commit] 2 commits - src/cairo-surface.c test/pdiff

Carl Worth cworth at kemper.freedesktop.org
Mon Mar 12 14:49:30 PDT 2007


 src/cairo-surface.c   |    4 ++--
 test/pdiff/lpyramid.c |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

New commits:
diff-tree 14cab8b020f429d346561d8ab70b154b2e3f0668 (from 789aada06b52e068662f0ac0f7a424c51bcba510)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Mar 11 21:55:19 2007 +0000

    Correct an off-by-one in the reflection of the convolution index.
    
    Currently the convolution code uses the formula 2*(N-1)-n to reflect the index
    n when n is greater than or equal to N.
    This is wrong as n=N -> 2*(N-1)-N = N-2 instead of N-1.
    
    Furthermore when the image is small, e.g. at the highest levels of the
    pyramid, this causes the code to index before the start of the array and
    causes valgrind to issue a warning.

diff --git a/test/pdiff/lpyramid.c b/test/pdiff/lpyramid.c
index 02fcf2b..b81d67d 100644
--- a/test/pdiff/lpyramid.c
+++ b/test/pdiff/lpyramid.c
@@ -46,8 +46,8 @@ convolve (lpyramid_t *pyramid, float *a,
 		    ny=y+j;
 		    if (nx<0) nx=-nx;
 		    if (ny<0) ny=-ny;
-		    if (nx>=width) nx=2*(width-1)-nx;
-		    if (ny>=height) ny=2*(height-1)-ny;
+		    if (nx>=width) nx=2*width - nx - 1;
+		    if (ny>=height) ny=2*height - ny - 1;
 		    a[index] += Kernel[i+2] * Kernel[j+2] * b[ny * width + nx];
 		}
 	    }
diff-tree 789aada06b52e068662f0ac0f7a424c51bcba510 (from ef284a2d6bbeae8711226f1f1f2cf4936f6937eb)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Mar 11 20:55:26 2007 +0000

    Avoid the struct copy when source and destination are the same.
    
    On some architectures, gcc will emit a memcpy for structure copies which will
    produce a valgrind warning when the source and destination pointers are the
    same. Workaround this issue by explicitly checking the source and destination
    for inequality before doing the structure assignment.

diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 3162a01..5dbac58 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -995,7 +995,7 @@ _cairo_surface_clone_similar (cairo_surf
 
     status = surface->backend->clone_similar (surface, src, src_x, src_y,
 					      width, height, clone_out);
-    if (status == CAIRO_STATUS_SUCCESS)
+    if (status == CAIRO_STATUS_SUCCESS && *clone_out != src)
         (*clone_out)->device_transform = src->device_transform;
 
     if (status != CAIRO_INT_STATUS_UNSUPPORTED)
@@ -1007,7 +1007,7 @@ _cairo_surface_clone_similar (cairo_surf
 
     status = surface->backend->clone_similar (surface, &image->base, src_x,
 					      src_y, width, height, clone_out);
-    if (status == CAIRO_STATUS_SUCCESS) {
+    if (status == CAIRO_STATUS_SUCCESS && *clone_out != src) {
         (*clone_out)->device_transform = src->device_transform;
         (*clone_out)->device_transform_inverse = src->device_transform_inverse;
     }


More information about the cairo-commit mailing list