From ae131499c7f4805c2d87ecbdaa3079974e19e858 Mon Sep 17 00:00:00 2001 From: matthieu Date: Mon, 10 Dec 2007 21:10:19 +0000 Subject: [PATCH] pixman 0.9.6 --- lib/pixman/README | 26 ++++++++++++++ lib/pixman/config.h.in | 3 ++ lib/pixman/pixman/Makefile.am | 15 +++----- lib/pixman/pixman/pixman-compose-accessors.c | 4 +++ lib/pixman/pixman/pixman-compose.c | 12 ++++--- lib/pixman/pixman/pixman-compute-region.c | 3 ++ lib/pixman/pixman/pixman-edge-accessors.c | 4 +++ lib/pixman/pixman/pixman-edge.c | 6 +++- lib/pixman/pixman/pixman-image.c | 36 +++++++++++++++++--- lib/pixman/pixman/pixman-mmx.c | 7 ++-- lib/pixman/pixman/pixman-pict.c | 6 ++-- lib/pixman/pixman/pixman-private.h | 27 +++++++++++++++ lib/pixman/pixman/pixman-region.c | 14 ++++++++ lib/pixman/pixman/pixman-timer.c | 7 ++++ lib/pixman/pixman/pixman-trap.c | 5 ++- lib/pixman/pixman/pixman-utils.c | 17 +++++++++ lib/pixman/pixman/pixman.h | 4 +-- 17 files changed, 166 insertions(+), 30 deletions(-) create mode 100644 lib/pixman/pixman/pixman-compose-accessors.c create mode 100644 lib/pixman/pixman/pixman-edge-accessors.c diff --git a/lib/pixman/README b/lib/pixman/README index e69de29bb..94b830c6c 100644 --- a/lib/pixman/README +++ b/lib/pixman/README @@ -0,0 +1,26 @@ +pixman is a library that provides low-level pixel manipulation +features such as image compositing and trapezoid rasterization. + +Please submit bugs & patches to the libpixman bugzilla: + + https://bugs.freedesktop.org/enter_bug.cgi?product=libpixman + +All questions regarding this software should be directed to either the +Xorg mailing list: + + http://lists.freedesktop.org/mailman/listinfo/xorg + +or the cairo mailing list: + + http://lists.freedesktop.org/mailman/listinfo/cairo + +The master development code repository can be found at: + + git://anongit.freedesktop.org/git/pixman + + http://gitweb.freedesktop.org/?p=pixman;a=summary + +For more information on the git code manager, see: + + http://wiki.x.org/wiki/GitPage + diff --git a/lib/pixman/config.h.in b/lib/pixman/config.h.in index 1665dd013..336cdd2f1 100644 --- a/lib/pixman/config.h.in +++ b/lib/pixman/config.h.in @@ -57,6 +57,9 @@ /* use MMX compiler intrinsics */ #undef USE_MMX +/* use SSE compiler intrinsics */ +#undef USE_SSE + /* Version number of package */ #undef VERSION diff --git a/lib/pixman/pixman/Makefile.am b/lib/pixman/pixman/Makefile.am index 708e0dd89..66283a2bf 100644 --- a/lib/pixman/pixman/Makefile.am +++ b/lib/pixman/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,18 +20,9 @@ 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 +noinst_LTLIBRARIES = libpixman-mmx.la libpixman_mmx_la_SOURCES = \ pixman-mmx.c \ pixman-mmx.h diff --git a/lib/pixman/pixman/pixman-compose-accessors.c b/lib/pixman/pixman/pixman-compose-accessors.c new file mode 100644 index 000000000..5393cf409 --- /dev/null +++ b/lib/pixman/pixman/pixman-compose-accessors.c @@ -0,0 +1,4 @@ + +#define PIXMAN_FB_ACCESSORS + +#include "pixman-compose.c" diff --git a/lib/pixman/pixman/pixman-compose.c b/lib/pixman/pixman/pixman-compose.c index b48251d54..4c73822bc 100644 --- a/lib/pixman/pixman/pixman-compose.c +++ b/lib/pixman/pixman/pixman-compose.c @@ -23,7 +23,9 @@ * SOFTWARE. */ +#ifdef HAVE_CONFIG_H #include +#endif #include #include @@ -2878,7 +2880,7 @@ static void fbFetchSolid(bits_image_t * pict, int x, int y, int width, uint32_t static void fbFetch(bits_image_t * pict, int x, int y, int width, uint32_t *buffer, uint32_t *mask, uint32_t maskBits) { uint32_t *bits; - uint32_t stride; + int32_t stride; fetchProc fetch = fetchProcForPicture(pict); const pixman_indexed_t * indexed = pict->indexed; @@ -3558,7 +3560,7 @@ static void pixmanFetchSourcePict(source_image_t * pict, int x, int y, int width static void fbFetchTransformed(bits_image_t * pict, int x, int y, int width, uint32_t *buffer, uint32_t *mask, uint32_t maskBits) { uint32_t *bits; - uint32_t stride; + int32_t stride; fetchPixelProc fetch; pixman_vector_t v; pixman_vector_t unit; @@ -4091,7 +4093,7 @@ static void fbFetchExternalAlpha(bits_image_t * pict, int x, int y, int width, u static void fbStore(bits_image_t * pict, int x, int y, int width, uint32_t *buffer) { uint32_t *bits; - uint32_t stride; + int32_t stride; storeProc store = storeProcForPicture(pict); const pixman_indexed_t * indexed = pict->indexed; @@ -4105,7 +4107,7 @@ static void fbStore(bits_image_t * pict, int x, int y, int width, uint32_t *buff static void fbStoreExternalAlpha(bits_image_t * pict, int x, int y, int width, uint32_t *buffer) { uint32_t *bits, *alpha_bits; - uint32_t stride, astride; + int32_t stride, astride; int ax, ay; storeProc store; storeProc astore; @@ -4161,7 +4163,7 @@ PIXMAN_COMPOSITE_RECT_GENERAL (const FbComposeData *data, unsigned int srcClass = SOURCE_IMAGE_CLASS_UNKNOWN; unsigned int maskClass = SOURCE_IMAGE_CLASS_UNKNOWN; uint32_t *bits; - uint32_t stride; + int32_t stride; int xoff, yoff; if (data->op == PIXMAN_OP_CLEAR) diff --git a/lib/pixman/pixman/pixman-compute-region.c b/lib/pixman/pixman/pixman-compute-region.c index f9b9de718..1e566a92b 100644 --- a/lib/pixman/pixman/pixman-compute-region.c +++ b/lib/pixman/pixman/pixman-compute-region.c @@ -21,7 +21,10 @@ * PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H #include +#endif + #include #include #include "pixman-private.h" diff --git a/lib/pixman/pixman/pixman-edge-accessors.c b/lib/pixman/pixman/pixman-edge-accessors.c new file mode 100644 index 000000000..ea3a31e2f --- /dev/null +++ b/lib/pixman/pixman/pixman-edge-accessors.c @@ -0,0 +1,4 @@ + +#define PIXMAN_FB_ACCESSORS + +#include "pixman-edge.c" diff --git a/lib/pixman/pixman/pixman-edge.c b/lib/pixman/pixman/pixman-edge.c index 4117408c3..4fbb045e8 100644 --- a/lib/pixman/pixman/pixman-edge.c +++ b/lib/pixman/pixman/pixman-edge.c @@ -1,5 +1,5 @@ /* - * $Id: pixman-edge.c,v 1.1.1.1 2007/10/03 20:48:55 matthieu Exp $ + * $Id: pixman-edge.c,v 1.1.1.2 2007/12/10 21:10:23 matthieu Exp $ * * Copyright © 2004 Keith Packard * @@ -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 +#endif + #include #include "pixman.h" #include "pixman-private.h" diff --git a/lib/pixman/pixman/pixman-image.c b/lib/pixman/pixman/pixman-image.c index c39ee9b64..d40234de0 100644 --- a/lib/pixman/pixman/pixman-image.c +++ b/lib/pixman/pixman/pixman-image.c @@ -20,7 +20,9 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H #include +#endif #include #include @@ -283,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) @@ -325,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) @@ -334,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; diff --git a/lib/pixman/pixman/pixman-mmx.c b/lib/pixman/pixman/pixman-mmx.c index 8c7be6df4..52061c7ae 100644 --- a/lib/pixman/pixman/pixman-mmx.c +++ b/lib/pixman/pixman/pixman-mmx.c @@ -28,14 +28,13 @@ * * Based on work by Owen Taylor */ + +#ifdef HAVE_CONFIG_H #include +#endif #ifdef USE_MMX -#if defined(__amd64__) || defined(__x86_64__) -#define USE_SSE -#endif - #include #ifdef USE_SSE #include /* for _mm_shuffle_pi16 and _MM_SHUFFLE */ diff --git a/lib/pixman/pixman/pixman-pict.c b/lib/pixman/pixman/pixman-pict.c index b8b7b767b..d6564ffe4 100644 --- a/lib/pixman/pixman/pixman-pict.c +++ b/lib/pixman/pixman/pixman-pict.c @@ -22,7 +22,10 @@ * Author: Keith Packard, SuSE, Inc. */ +#ifdef HAVE_CONFIG_H #include +#endif + #include #include #include @@ -1426,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; @@ -1778,7 +1782,6 @@ pixman_image_composite (pixman_op_t op, break; case PIXMAN_x8r8g8b8: switch (pDst->bits.format) { - case PIXMAN_a8r8g8b8: case PIXMAN_x8r8g8b8: #ifdef USE_MMX if (pixman_have_mmx()) @@ -1790,7 +1793,6 @@ pixman_image_composite (pixman_op_t op, } case PIXMAN_x8b8g8r8: switch (pDst->bits.format) { - case PIXMAN_a8b8g8r8: case PIXMAN_x8b8g8r8: #ifdef USE_MMX if (pixman_have_mmx()) diff --git a/lib/pixman/pixman/pixman-private.h b/lib/pixman/pixman/pixman-private.h index 775f7a7e5..0c5942fe6 100644 --- a/lib/pixman/pixman/pixman-private.h +++ b/lib/pixman/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) @@ -47,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 @@ -774,6 +798,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 +843,6 @@ void pixman_timer_register (PixmanTimer *timer); timer##tname.total += OIL_STAMP() - begin##tname; \ } +#endif /* PIXMAN_TIMING */ #endif /* PIXMAN_PRIVATE_H */ diff --git a/lib/pixman/pixman/pixman-region.c b/lib/pixman/pixman/pixman-region.c index 94b6dcce2..ac2380608 100644 --- a/lib/pixman/pixman/pixman-region.c +++ b/lib/pixman/pixman/pixman-region.c @@ -45,7 +45,10 @@ SOFTWARE. ******************************************************************/ +#ifdef HAVE_CONFIG_H #include +#endif + #include #include #include @@ -2515,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, @@ -2525,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; diff --git a/lib/pixman/pixman/pixman-timer.c b/lib/pixman/pixman/pixman-timer.c index c76264431..ce54e7496 100644 --- a/lib/pixman/pixman/pixman-timer.c +++ b/lib/pixman/pixman/pixman-timer.c @@ -19,11 +19,16 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H #include +#endif + #include #include #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/lib/pixman/pixman/pixman-trap.c b/lib/pixman/pixman/pixman-trap.c index e8ba3c513..0a67ab80b 100644 --- a/lib/pixman/pixman/pixman-trap.c +++ b/lib/pixman/pixman/pixman-trap.c @@ -1,5 +1,5 @@ /* - * $Id: pixman-trap.c,v 1.1.1.1 2007/10/03 20:48:54 matthieu Exp $ + * $Id: pixman-trap.c,v 1.1.1.2 2007/12/10 21:10:22 matthieu Exp $ * * Copyright © 2004 Keith Packard * @@ -22,7 +22,10 @@ * PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H #include +#endif + #include #include "pixman-private.h" diff --git a/lib/pixman/pixman/pixman-utils.c b/lib/pixman/pixman/pixman-utils.c index cdf115d5f..1d1dec9ad 100644 --- a/lib/pixman/pixman/pixman-utils.c +++ b/lib/pixman/pixman/pixman-utils.c @@ -21,7 +21,10 @@ * Author: Keith Packard, SuSE, Inc. */ +#ifdef HAVE_CONFIG_H #include +#endif + #include #include "pixman.h" #include "pixman-private.h" @@ -368,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) diff --git a/lib/pixman/pixman/pixman.h b/lib/pixman/pixman/pixman.h index d76cc1257..7b932142f 100644 --- a/lib/pixman/pixman/pixman.h +++ b/lib/pixman/pixman/pixman.h @@ -452,7 +452,7 @@ typedef enum { /* 1bpp formats */ PIXMAN_a1 = PIXMAN_FORMAT(1,PIXMAN_TYPE_A,1,0,0,0), - PIXMAN_g1 = PIXMAN_FORMAT(1,PIXMAN_TYPE_GRAY,0,0,0,0), + PIXMAN_g1 = PIXMAN_FORMAT(1,PIXMAN_TYPE_GRAY,0,0,0,0) } pixman_format_code_t; /* Constructors */ @@ -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,