pixman: Branch 'yuv-porting' - 10 commits

Alan Hourihane alanh at kemper.freedesktop.org
Wed Oct 17 11:39:48 PDT 2007


 .gitignore                        |    5 +++++
 pixman/Makefile.am                |   15 ++++-----------
 pixman/Makefile.win32             |   31 +++++++++++++++++++++++++++++++
 pixman/pixman-compose-accessors.c |    4 ++++
 pixman/pixman-compose.c           |    2 ++
 pixman/pixman-compute-region.c    |    3 +++
 pixman/pixman-edge-accessors.c    |    4 ++++
 pixman/pixman-edge.c              |    4 ++++
 pixman/pixman-image.c             |   36 ++++++++++++++++++++++++++++++++----
 pixman/pixman-mmx.c               |    3 +++
 pixman/pixman-pict.c              |    4 ++++
 pixman/pixman-private.h           |   27 +++++++++++++++++++++++++++
 pixman/pixman-region.c            |   14 ++++++++++++++
 pixman/pixman-timer.c             |    7 +++++++
 pixman/pixman-trap.c              |    3 +++
 pixman/pixman-utils.c             |   17 +++++++++++++++++
 pixman/pixman.h                   |    2 +-
 17 files changed, 165 insertions(+), 16 deletions(-)

New commits:
commit 8aa38d2256c191bf3437034f6176bae30c3c3d19
Merge: cea752b... 39a67d3...
Author: Alan Hourihane <alanh at tungstengraphics.com>
Date:   Wed Oct 17 19:39:41 2007 +0100

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/pixman into yuv-porting
    
    Conflicts:
    
    	pixman/pixman-image.c

diff --cc pixman/pixman-image.c
index 0bcd901,d40234d..1c4abc2
--- a/pixman/pixman-image.c
+++ b/pixman/pixman-image.c
@@@ -320,23 -345,26 +345,26 @@@ pixman_image_create_bits (pixman_format
      pixman_image_t *image;
      uint32_t *free_me = NULL;
  
 -    /* must be a whole number of uint32_t's 
 +    /* must be a whole number of uint32_t's
       */
      return_val_if_fail (bits == NULL ||
 -			(rowstride_bytes % sizeof (uint32_t)) == 0, NULL); 
 +			(rowstride_bytes % sizeof (uint32_t)) == 0, NULL);
  
-     if (!bits)
+     if (!bits && width && height)
      {
  	free_me = bits = create_bits (format, width, height, &rowstride_bytes);
  	if (!bits)
  	    return NULL;
      }
 -    
 +
      image = allocate_image();
  
-     if (!image)
+     if (!image) {
+ 	if (free_me)
+ 	    free (free_me);
  	return NULL;
- 
+     }
+     
      image->type = BITS;
      image->bits.format = format;
      image->bits.width = width;
commit 39a67d35f05aa47cf50191e0837a2125593a7bbc
Author: Tilman Sauerbeck <tilman at code-monkey.de>
Date:   Sat Sep 29 22:45:42 2007 +0200

    Fixed the declaration of pixman_image_set_source_clipping().

diff --git a/pixman/pixman.h b/pixman/pixman.h
index d76cc12..a22dfd9 100644
--- a/pixman/pixman.h
+++ b/pixman/pixman.h
@@ -498,7 +498,7 @@ pixman_bool_t   pixman_image_set_filter              (pixman_image_t
 void            pixman_image_set_filter_params       (pixman_image_t               *image,
 						      pixman_fixed_t               *params,
 						      int                           n_params);
-void		pixman_image_set_source_cliping      (pixman_image_t		   *image,
+void		pixman_image_set_source_clipping     (pixman_image_t		   *image,
 						      pixman_bool_t                 source_clipping);
 void            pixman_image_set_alpha_map           (pixman_image_t               *image,
 						      pixman_image_t               *alpha_map,
commit 7f820e15070c9b9618d78425b8cb1a4df722eb22
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Sep 27 12:46:46 2007 +0100

    [pixman-image] [mlk] Free the locally allocated bits.
    
    If we fail to allocate the image, remember to free the bits if we have
    created the buffer on behalf of the caller.

diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c
index de799b1..d40234d 100644
--- a/pixman/pixman-image.c
+++ b/pixman/pixman-image.c
@@ -359,8 +359,11 @@ pixman_image_create_bits (pixman_format_code_t  format,
     
     image = allocate_image();
 
-    if (!image)
+    if (!image) {
+	if (free_me)
+	    free (free_me);
 	return NULL;
+    }
     
     image->type = BITS;
     image->bits.format = format;
commit b4f0cc6eeaff8d5ea114734fcfa293fce1904ce4
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Sep 27 12:44:44 2007 +0100

    [pixman-image] Avoid a potential malloc(0).
    
    Do not attempt to allocate bits if either the image width or height is
    0 - Cairo has a habit of attempting to create such surfaces when
    generating glyphs. The malloc(0) may return a NULL pointer and be treated
    as an out-of-memory error.

diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c
index 986f8ab..de799b1 100644
--- a/pixman/pixman-image.c
+++ b/pixman/pixman-image.c
@@ -350,7 +350,7 @@ pixman_image_create_bits (pixman_format_code_t  format,
     return_val_if_fail (bits == NULL ||
 			(rowstride_bytes % sizeof (uint32_t)) == 0, NULL); 
 
-    if (!bits)
+    if (!bits && width && height)
     {
 	free_me = bits = create_bits (format, width, height, &rowstride_bytes);
 	if (!bits)
commit 958a650b8eb1b61143122c3ad1f9b637b6467984
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Sep 27 12:40:59 2007 +0100

    [pixman-image] Avoid integer overflow when allocating bits.
    
    Check for potential overflows at every step of the calculation of the
    buffer size required for the pixels.
    
    (Fixes https://bugs.freedesktop.org/show_bug.cgi?id=11627)

diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c
index fa32208..986f8ab 100644
--- a/pixman/pixman-image.c
+++ b/pixman/pixman-image.c
@@ -285,9 +285,32 @@ create_bits (pixman_format_code_t format,
     int stride;
     int buf_size;
     int bpp;
-    
+
+    /* what follows is a long-winded way, avoiding any possibility of integer
+     * overflows, of saying:
+     * stride = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof (uint32_t);
+     */
+
     bpp = PIXMAN_FORMAT_BPP (format);
-    stride = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof (uint32_t);
+    if (pixman_multiply_overflows_int (width, bpp))
+	return NULL;
+
+    stride = width * bpp;
+    if (pixman_addition_overflows_int (stride, FB_MASK))
+	return NULL;
+
+    stride += FB_MASK;
+    stride >>= FB_SHIFT;
+
+#if FB_SHIFT < 2
+    if (pixman_multiply_overflows_int (stride, sizeof (uint32_t)))
+	return NULL;
+#endif
+    stride *= sizeof (uint32_t);
+
+    if (pixman_multiply_overflows_int (height, stride))
+	return NULL;
+
     buf_size = height * stride;
 
     if (rowstride_bytes)
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index 6487bfd..0c5942f 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -69,6 +69,8 @@
 /* Memory allocation helpers */
 void *pixman_malloc_ab (unsigned int n, unsigned int b);
 void *pixman_malloc_abc (unsigned int a, unsigned int b, unsigned int c);
+pixman_bool_t pixman_multiply_overflows_int (unsigned int a, unsigned int b);
+pixman_bool_t pixman_addition_overflows_int (unsigned int a, unsigned int b);
 
 #if DEBUG
 
diff --git a/pixman/pixman-utils.c b/pixman/pixman-utils.c
index fc93608..1d1dec9 100644
--- a/pixman/pixman-utils.c
+++ b/pixman/pixman-utils.c
@@ -371,6 +371,20 @@ pixman_line_fixed_edge_init (pixman_edge_t *e,
 		    bot->y + y_off_fixed);
 }
 
+pixman_bool_t
+pixman_multiply_overflows_int (unsigned int a,
+		               unsigned int b)
+{
+    return a >= INT32_MAX / b;
+}
+
+pixman_bool_t
+pixman_addition_overflows_int (unsigned int a,
+		               unsigned int b)
+{
+    return a > INT32_MAX - b;
+}
+
 void *
 pixman_malloc_ab(unsigned int a,
 		 unsigned int b)
commit 5b60c91fd6865021aa6027ee65fa8371a4e2d297
Author: Jeff Muizelaar <jeff at freiheit.infidigm.net>
Date:   Thu Sep 20 15:40:17 2007 -0400

    Fix special case selection when the mask has a transform
    
    http://gitweb.freedesktop.org/?p=xorg/xserver.git;a=commitdiff;h=c19ece1d8c32dc81740a4036a642661f54064e75
    was a mismerge that avoided setting the maskTransform condition when the mask
    has a transform.  This allowed a special case routine to be chosen when the
    mask had a transform, which is not expected by the special case routines.

diff --git a/pixman/pixman-pict.c b/pixman/pixman-pict.c
index 3bc5267..d6564ff 100644
--- a/pixman/pixman-pict.c
+++ b/pixman/pixman-pict.c
@@ -1429,6 +1429,7 @@ pixman_image_composite (pixman_op_t      op,
     {
 	maskRepeat = pMask->common.repeat == PIXMAN_REPEAT_NORMAL;
 
+	maskTransform = pMask->common.transform != 0;
 	if (pMask->common.filter == PIXMAN_FILTER_CONVOLUTION)
 	    maskTransform = TRUE;
 
commit 3be35594c99b7abd2af43b66349ca53bfa1462d6
Author: Carl Worth <cworth at cworth.org>
Date:   Tue Sep 11 16:29:06 2007 +0100

    Fix build breakage when under the influence of USE_MMX
    
    This was recently broken (dc7c047d1c68f343b66e81d9e79084e4171e2634) when
    removing an assignment to noinst_LTLIBRARIES.

diff --git a/pixman/Makefile.am b/pixman/Makefile.am
index b7138e4..66283a2 100644
--- a/pixman/Makefile.am
+++ b/pixman/Makefile.am
@@ -22,7 +22,7 @@ libpixmaninclude_HEADERS = pixman.h
 
 # mmx code
 if USE_MMX
-noinst_LTLIBRARIES += libpixman-mmx.la
+noinst_LTLIBRARIES = libpixman-mmx.la
 libpixman_mmx_la_SOURCES = \
 	pixman-mmx.c \
 	pixman-mmx.h
commit dc7c047d1c68f343b66e81d9e79084e4171e2634
Author: Vladimir Vukicevic <vladimir at pobox.com>
Date:   Mon Sep 10 15:20:44 2007 -0700

    [memlk] don't try to allocate new data for 0-rectangle regions

diff --git a/pixman/pixman-region.c b/pixman/pixman-region.c
index fff49e7..ac23806 100644
--- a/pixman/pixman-region.c
+++ b/pixman/pixman-region.c
@@ -2518,6 +2518,8 @@ pixman_region_init_rects (pixman_region16_t *region,
 {
     int overlap;
 
+    /* if it's 1, then we just want to set the extents, so call
+     * the existing method. */
     if (count == 1) {
        pixman_region_init_rect(region,
                                boxes[0].x1,
@@ -2528,6 +2530,15 @@ pixman_region_init_rects (pixman_region16_t *region,
     }
 
     pixman_region_init(region);
+
+    /* if it's 0, don't call pixman_rect_alloc -- 0 rectangles is
+     * a special case, and causing pixman_rect_alloc would cause
+     * us to leak memory (because the 0-rect case should be the
+     * static pixman_region_emptyData data).
+     */
+    if (count == 0)
+        return TRUE;
+
     if (!pixman_rect_alloc(region, count))
 	return FALSE;
 
commit 1b098ede1938d1225c32cf5639e4c7a891859897
Author: Vladimir Vukicevic <vladimir at pobox.com>
Date:   Tue Sep 4 11:19:33 2007 -0700

    [win32] Makefile and compilation fixes for win32

diff --git a/.gitignore b/.gitignore
index ee2f0a3..7f08f61 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,3 +28,8 @@ config.h.in
 .*.swp
 test/composite-test
 test/gradient-test
+*.pdb
+*.dll
+*.lib
+*.ilk
+*.obj
diff --git a/pixman/Makefile.win32 b/pixman/Makefile.win32
new file mode 100644
index 0000000..e0a1828
--- /dev/null
+++ b/pixman/Makefile.win32
@@ -0,0 +1,31 @@
+LIBRARY = pixman-1
+
+CC = cl
+LINK = link
+
+CFLAGS = -MD -Zi -nologo -O2 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -I../pixman/src -I. -DPACKAGE=$(LIBRARY) -DPACKAGE_VERSION="" -DPACKAGE_BUGREPORT=""
+
+SOURCES = \
+	pixman-region.c		\
+	pixman-image.c		\
+	pixman-compose.c	\
+	pixman-compose-accessors.c	\
+	pixman-pict.c		\
+	pixman-utils.c		\
+	pixman-edge.c		\
+	pixman-edge-accessors.c		\
+	pixman-trap.c		\
+	pixman-compute-region.c \
+	pixman-timer.c		\
+	$(NULL)
+
+OBJECTS = $(subst .c,.obj,$(SOURCES))
+
+%.obj: %.c
+	@$(CC) -c $(CFLAGS) -Fo"$@" $<
+
+$(LIBRARY).lib: $(OBJECTS)
+	lib -NOLOGO -OUT:$@ $(OBJECTS)
+
+clean:
+	@rm -f *.obj *.lib *.pdb *.ilk || exit 0
diff --git a/pixman/pixman-compose.c b/pixman/pixman-compose.c
index b48251d..1e91864 100644
--- a/pixman/pixman-compose.c
+++ b/pixman/pixman-compose.c
@@ -23,7 +23,9 @@
  * SOFTWARE.
  */
 
+#ifdef HAVE_CONFIG_H
 #include <config.h>
+#endif
 
 #include <stdlib.h>
 #include <string.h>
diff --git a/pixman/pixman-compute-region.c b/pixman/pixman-compute-region.c
index f9b9de7..1e566a9 100644
--- a/pixman/pixman-compute-region.c
+++ b/pixman/pixman-compute-region.c
@@ -21,7 +21,10 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
+#ifdef HAVE_CONFIG_H
 #include <config.h>
+#endif
+
 #include <stdlib.h>
 #include <stdio.h>
 #include "pixman-private.h"
diff --git a/pixman/pixman-edge.c b/pixman/pixman-edge.c
index 24758c3..12c1967 100644
--- a/pixman/pixman-edge.c
+++ b/pixman/pixman-edge.c
@@ -21,7 +21,11 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
+
+#ifdef HAVE_CONFIG_H
 #include <config.h>
+#endif
+
 #include <string.h>
 #include "pixman.h"
 #include "pixman-private.h"
diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c
index c39ee9b..fa32208 100644
--- a/pixman/pixman-image.c
+++ b/pixman/pixman-image.c
@@ -20,7 +20,9 @@
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#ifdef HAVE_CONFIG_H
 #include <config.h>
+#endif
 
 #include <stdlib.h>
 #include <stdio.h>
diff --git a/pixman/pixman-mmx.c b/pixman/pixman-mmx.c
index 8c7be6d..be79124 100644
--- a/pixman/pixman-mmx.c
+++ b/pixman/pixman-mmx.c
@@ -28,7 +28,10 @@
  *
  * Based on work by Owen Taylor
  */
+
+#ifdef HAVE_CONFIG_H
 #include <config.h>
+#endif
 
 #ifdef USE_MMX
 
diff --git a/pixman/pixman-pict.c b/pixman/pixman-pict.c
index c7d73fc..3bc5267 100644
--- a/pixman/pixman-pict.c
+++ b/pixman/pixman-pict.c
@@ -22,7 +22,10 @@
  * Author:  Keith Packard, SuSE, Inc.
  */
 
+#ifdef HAVE_CONFIG_H
 #include <config.h>
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index 775f7a7..6487bfd 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -37,6 +37,28 @@
 #  define FUNC     ((const char*) ("???"))
 #endif
 
+#ifndef INT16_MIN
+# define INT16_MIN              (-32767-1)
+# define INT16_MAX              (32767)
+#endif
+
+#ifndef INT32_MIN
+# define INT32_MIN              (-2147483647-1)
+# define INT32_MAX              (2147483647)
+#endif
+
+#ifndef UINT32_MIN
+# define UINT32_MIN             (0)
+# define UINT32_MAX             (4294967295U)
+#endif
+
+#ifndef M_PI
+# define M_PI			3.14159265358979323846
+#endif
+
+#ifdef _MSC_VER
+#define inline __inline
+#endif
 
 #define FB_SHIFT    5
 #define FB_UNIT     (1 << FB_SHIFT)
@@ -774,6 +796,8 @@ pixman_rasterize_edges_accessors (pixman_image_t *image,
 				  pixman_fixed_t	b);
 
 
+#ifdef PIXMAN_TIMING
+
 /* Timing */
 static inline uint64_t
 oil_profile_stamp_rdtsc (void)
@@ -817,5 +841,6 @@ void pixman_timer_register (PixmanTimer *timer);
         timer##tname.total += OIL_STAMP() - begin##tname;		\
     }
 
+#endif /* PIXMAN_TIMING */
 
 #endif /* PIXMAN_PRIVATE_H */
diff --git a/pixman/pixman-region.c b/pixman/pixman-region.c
index 94b6dcc..fff49e7 100644
--- a/pixman/pixman-region.c
+++ b/pixman/pixman-region.c
@@ -45,7 +45,10 @@ SOFTWARE.
 
 ******************************************************************/
 
+#ifdef HAVE_CONFIG_H
 #include <config.h>
+#endif
+
 #include <stdlib.h>
 #include <limits.h>
 #include <string.h>
diff --git a/pixman/pixman-timer.c b/pixman/pixman-timer.c
index c762644..ce54e74 100644
--- a/pixman/pixman-timer.c
+++ b/pixman/pixman-timer.c
@@ -19,11 +19,16 @@
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#ifdef HAVE_CONFIG_H
 #include <config.h>
+#endif
+
 #include <stdlib.h>
 #include <stdio.h>
 #include "pixman-private.h"
 
+#ifdef PIXMAN_TIMER
+
 static PixmanTimer *timers;
 
 static void
@@ -57,3 +62,5 @@ pixman_timer_register (PixmanTimer *timer)
     timer->next = timers;
     timers = timer;
 }
+
+#endif
diff --git a/pixman/pixman-trap.c b/pixman/pixman-trap.c
index 204ca04..ed32e92 100644
--- a/pixman/pixman-trap.c
+++ b/pixman/pixman-trap.c
@@ -22,7 +22,10 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
+#ifdef HAVE_CONFIG_H
 #include <config.h>
+#endif
+
 #include <stdio.h>
 #include "pixman-private.h"
 
diff --git a/pixman/pixman-utils.c b/pixman/pixman-utils.c
index cdf115d..fc93608 100644
--- a/pixman/pixman-utils.c
+++ b/pixman/pixman-utils.c
@@ -21,7 +21,10 @@
  * Author:  Keith Packard, SuSE, Inc.
  */
 
+#ifdef HAVE_CONFIG_H
 #include <config.h>
+#endif
+
 #include <stdlib.h>
 #include "pixman.h"
 #include "pixman-private.h"
commit 5fc4d5ab1fae8677f5a95f5eb0e4fad3a9e0bf82
Author: Vladimir Vukicevic <vladimir at pobox.com>
Date:   Tue Sep 4 11:18:40 2007 -0700

    compilation: build edge/compose with accessors separately
    
    Simplify the build by creating a new file for pixman-compose and
    pixman-edge built with accessor functions.

diff --git a/pixman/Makefile.am b/pixman/Makefile.am
index 708e0dd..b7138e4 100644
--- a/pixman/Makefile.am
+++ b/pixman/Makefile.am
@@ -1,15 +1,17 @@
 lib_LTLIBRARIES = libpixman-1.la
 libpixman_1_la_LDFLAGS = -version-info $(LT_VERSION_INFO)
-libpixman_1_la_LIBADD = @DEP_LIBS@ -lm libpixmanwrapper.la
+libpixman_1_la_LIBADD = @DEP_LIBS@ -lm
 libpixman_1_la_SOURCES =		\
 	pixman.h		\
 	pixman-region.c		\
 	pixman-private.h	\
 	pixman-image.c		\
 	pixman-compose.c	\
+	pixman-compose-accessors.c	\
 	pixman-pict.c		\
 	pixman-utils.c		\
 	pixman-edge.c		\
+	pixman-edge-accessors.c		\
 	pixman-edge-imp.h	\
 	pixman-trap.c		\
 	pixman-compute-region.c \
@@ -18,15 +20,6 @@ libpixman_1_la_SOURCES =		\
 libpixmanincludedir = $(includedir)/pixman-1/
 libpixmaninclude_HEADERS = pixman.h
 
-# wrapper library
-noinst_LTLIBRARIES = libpixmanwrapper.la
-libpixmanwrapper_la_SOURCES =	\
-	pixman-compose.c	\
-	pixman-edge.c
-libpixmanwrapper_la_CFLAGS = $(DEP_CFLAGS) -DPIXMAN_FB_ACCESSORS
-
-
-
 # mmx code
 if USE_MMX
 noinst_LTLIBRARIES += libpixman-mmx.la
diff --git a/pixman/pixman-compose-accessors.c b/pixman/pixman-compose-accessors.c
new file mode 100644
index 0000000..5393cf4
--- /dev/null
+++ b/pixman/pixman-compose-accessors.c
@@ -0,0 +1,4 @@
+
+#define PIXMAN_FB_ACCESSORS
+
+#include "pixman-compose.c"
diff --git a/pixman/pixman-edge-accessors.c b/pixman/pixman-edge-accessors.c
new file mode 100644
index 0000000..ea3a31e
--- /dev/null
+++ b/pixman/pixman-edge-accessors.c
@@ -0,0 +1,4 @@
+
+#define PIXMAN_FB_ACCESSORS
+
+#include "pixman-edge.c"


More information about the xorg-commit mailing list