gallium: fix Y-inverted copies
authorBrian Paul <brian.paul@tungstengraphics.com>
Mon, 23 Jun 2008 15:47:12 +0000 (09:47 -0600)
committerBrian Paul <brian.paul@tungstengraphics.com>
Mon, 23 Jun 2008 15:47:12 +0000 (09:47 -0600)
Don't require the caller to pass a non-intuitive negative src_y coord anymore
when doing a src-inverted copy.

src/gallium/auxiliary/util/p_util.c

index 0e3f082b3ee27d3f87d9041085814a703abe3171..4e60b1b841855253b368e5343a239aa6032901c0 100644 (file)
@@ -37,6 +37,7 @@
 /**
  * Copy 2D rect from one place to another.
  * Position and sizes are in pixels.
+ * src_pitch may be negative to do vertical flip of pixels from source.
  */
 void
 pipe_copy_rect(ubyte * dst,
@@ -52,6 +53,7 @@ pipe_copy_rect(ubyte * dst,
                int src_y)
 {
    unsigned i;
+   int src_pitch_pos = src_pitch < 0 ? -src_pitch : src_pitch;
 
    assert(cpp > 0);
    assert(src_x >= 0);
@@ -61,10 +63,11 @@ pipe_copy_rect(ubyte * dst,
 
    dst_pitch *= cpp;
    src_pitch *= cpp;
+   src_pitch_pos *= cpp;
    dst += dst_x * cpp;
    src += src_x * cpp;
    dst += dst_y * dst_pitch;
-   src += src_y * src_pitch;
+   src += src_y * src_pitch_pos;
    width *= cpp;
 
    if (width == dst_pitch && width == src_pitch)