gecko/gfx/cairo/libpixman/src/pixman-utils.c
Jeff Muizelaar bbf0b70e51 Update pixman to ad3cbfb073fc325e1b3152898ca71b8255675957
Alan Coopersmith (1):
      Sun's copyrights belong to Oracle now

Alexandros Frantzis (2):
      Add simple support for the r8g8b8a8 and r8g8b8x8 formats.
      Add support for the r8g8b8a8 and r8g8b8x8 formats to the tests.

Andrea Canciani (14):
      Improve precision of linear gradients
      Make classification consistent with rasterization
      Remove unused enum value
      Fix an overflow in the new radial gradient code
      Remove unused stop_range field
      Fix opacity check
      Improve conical gradients opacity check
      Improve handling of tangent circles
      Add a test for radial gradients
      Fix compilation on Win32
      test: Fix tests for compilation on Windows
      test: Add Makefile for Win32
      Do not include unused headers
      test: Silence MSVC warnings

Cyril Brulebois (2):
      Fix argument quoting for AC_INIT.
      Fix linking issues when HAVE_FEENABLEEXCEPT is set.

Jon TURNEY (2):
      Plug another leak in alphamap test
      Remove stray #include <fenv.h>

Rolland Dudemaine (4):
      test: Fix for mismatched 'fence_malloc' prototype/implementation
      Correct the initialization of 'max_vx'
      test: Use the right enum types instead of int to fix warnings
      Fix "variable was set but never used" warnings

Scott McCreary (1):
      Added check to find pthread on Haiku.

Siarhei Siamashka (62):
      Fixed broken configure check for __thread support
      Do CPU features detection from 'constructor' function when compiled with gcc
      ARM: fix 'vld1.8'->'vld1.32' typo in add_8888_8888 NEON fast path
      ARM: NEON: source image pixel fetcher can be overrided now
      ARM: nearest scaling support for NEON scanline compositing functions
      ARM: macro template in C code to simplify using scaled fast paths
      ARM: performance tuning of NEON nearest scaled pixel fetcher
      ARM: NEON optimization for scaled over_8888_8888 with nearest filter
      ARM: NEON optimization for scaled over_8888_0565 with nearest filter
      ARM: NEON optimization for scaled src_8888_0565 with nearest filter
      ARM: NEON optimization for scaled src_0565_8888 with nearest filter
      ARM: optimization for scaled src_0565_0565 with nearest filter
      C fast path for a1 fill operation
      ARM: added 'neon_composite_over_n_8_8' fast path
      ARM: introduced 'fetch_mask_pixblock' macro to simplify code
      ARM: better NEON instructions scheduling for over_n_8_0565
      ARM: added 'neon_composite_over_8888_n_0565' fast path
      ARM: reuse common NEON code for over_{n_8|8888_n|8888_8}_0565
      ARM: added 'neon_composite_over_0565_n_0565' fast path
      ARM: added 'neon_composite_add_8888_8_8888' fast path
      ARM: better NEON instructions scheduling for add_8888_8888_8888
      ARM: added 'neon_composite_add_n_8_8888' fast path
      ARM: added 'neon_composite_add_8888_n_8888' fast path
      ARM: added flags parameter to some asm fast path wrapper macros
      ARM: added 'neon_composite_in_n_8' fast path
      ARM: added 'neon_src_rpixbuf_8888' fast path
      Fix for potential unaligned memory accesses
      COPYING: added Nokia to the list of copyright holders
      Revert "Fix "syntax error: empty declaration" warnings."
      Fix for "syntax error: empty declaration" Solaris Studio warnings
      Workaround for a preprocessor issue in old Sun Studio
      Bugfix for a corner case in 'pixman_transform_is_inverse'
      Make 'fast_composite_scaled_nearest_*' less suspicious
      A new configure option --enable-static-testprogs
      ARM: do /proc/self/auxv based cpu features detection only in linux
      The code in 'bitmap_addrect' already assumes non-null 'reg->data'
      test: affine-test updated to stress 90/180/270 degrees rotation more
      New flags for 90/180/270 rotation
      C fast paths for a simple 90/270 degrees rotation
      Use const modifiers for source buffers in nearest scaling fast paths
      test: Extend scaling-test to support a8/solid mask and ADD operation
      Support for a8 and solid mask in nearest scaling main loop template
      Better support for NONE repeat in nearest scaling main loop template
      ARM: new macro template for using scaled fast paths with a8 mask
      ARM: NEON optimization for nearest scaled over_8888_8_0565
      ARM: NEON optimization for nearest scaled over_0565_8_0565
      SSE2 optimization for nearest scaled over_8888_n_8888
      Ensure that tests run as the last step of a build for 'make check'
      Main loop template for fast single pass bilinear scaling
      test: check correctness of 'bilinear_pad_repeat_get_scanline_bounds'
      SSE2 optimization for bilinear scaled 'src_8888_8888'
      ARM: NEON optimization for bilinear scaled 'src_8888_8888'
      ARM: use prefetch in nearest scaled 'src_0565_0565'
      ARM: common macro for nearest scaling fast paths
      ARM: assembly optimized nearest scaled 'src_8888_8888'
      ARM: new bilinear fast path template macro in 'pixman-arm-common.h'
      ARM: NEON: common macro template for bilinear scanline scalers
      ARM: use common macro template for bilinear scaled 'src_8888_8888'
      ARM: NEON optimization for bilinear scaled 'src_8888_0565'
      ARM: NEON optimization for bilinear scaled 'src_0565_x888'
      ARM: NEON optimization for bilinear scaled 'src_0565_0565'
      ARM: a bit faster NEON bilinear scaling for r5g6b5 source images

Søren Sandmann Pedersen (79):
      Remove the class field from source_image_t
      Pre-release version bump to 0.19.6
      Post-release version bump to 0.19.7
      Pre-release version bump to 0.20.0
      Post-release version bump to 0.20.1
      Version bump 0.21.1.
      COPYING: Stop saying that a modification is currently under discussion.
      Remove workaround for a bug in the 1.6 X server.
      [mmx] Mark some of the output variables as early-clobber.
      Delete the source_image_t struct.
      Generate {a,x}8r8g8b8, a8, 565 fetchers for nearest/affine images
      Pre-release version bump
      Post-release version bump to 0.21.3
      test: Make composite test use some existing macros instead of defining its own
      Add enable_fp_exceptions() function in utils.[ch]
      Extend gradient-crash-test
      test: Move palette initialization to utils.[ch]
      test/utils.c: Initialize palette->rgba to 0.
      Make the argument to fence_malloc() an int64_t
      Add a stress-test program.
      Add a test compositing with the various PDF operators.
      Fix divide-by-zero in set_lum().
      sse2: Skip src pixels that are zero in sse2_composite_over_8888_n_8888()
      Add iterators in the general implementation
      Move initialization of iterators for bits images to pixman-bits-image.c
      Eliminate the _pixman_image_store_scanline_32/64 functions
      Move iterator initialization to the respective image files
      Virtualize iterator initialization
      Use an iterator in pixman_image_get_solid()
      Move get_scanline_32/64 to the bits part of the image struct
      Allow NULL property_changed function
      Consolidate the various get_scanline_32() into get_scanline_narrow()
      Linear: Optimize for horizontal gradients
      Get rid of the classify methods
      Add direct-write optimization back
      Skip fetching pixels when possible
      Turn on testing for destination transformation
      Fix destination fetching
      Fix dangling-pointer bug in bits_image_fetch_bilinear_no_repeat_8888().
      Pre-release version bump to 0.21.4
      Post-release version bump to 0.21.5
      Print a warning when a development snapshot is being configured.
      Move fallback decisions from implementations into pixman-cpu.c.
      Add a test for over_x888_8_0565 in lowlevel_blt_bench().
      Add SSE2 fetcher for x8r8g8b8
      Add SSE2 fetcher for a8
      Improve performance of sse2_combine_over_u()
      Add SSE2 fetcher for 0565
      Add pixman-conical-gradient.c to Makefile.win32.
      Move all the GTK+ based test programs to a new subdir, "demos"
      Add @TESTPROGS_EXTRA_LDFLAGS@ to AM_LDFLAGS
      test/Makefile.am: Move all the TEST_LDADD into a new global LDADD.
      Add pixman_composite_trapezoids().
      Add a test program for pixman_composite_trapezoids().
      Add support for triangles to pixman.
      Add a test program, tri-test
      Optimize adding opaque trapezoids onto a8 destination.
      Add new public function pixman_add_triangles()
      Avoid marking images dirty when properties are reset
      In pixman_image_set_transform() allow NULL for transform
      Coding style:  core_combine_in_u_pixelsse2 -> core_combine_in_u_pixel_sse2
      sse2: Convert all uses of MMX registers to use SSE2 registers instead.
      sse2: Delete unused MMX functions and constants and all _mm_empty()s
      sse2: Don't compile pixman-sse2.c with -mmmx anymore
      sse2: Remove all the core_combine_* functions
      sse2: Delete obsolete or redundant comments
      sse2: Remove pixman-x64-mmx-emulation.h
      sse2: Minor coding style cleanups.
      Delete pixman-x64-mmx-emulation.h from pixman/Makefile.am
      Minor fix to the RELEASING file
      Pre-release version bump to 0.21.6
      Post-release version bump to 0.21.7
      test: In image_endian_swap() use pixman_image_get_format() to get the bpp.
      test: Do endian swapping of the source and destination images.
      In delegate_{src,dest}_iter_init() call delegate directly.
      Fill out parts of iters in _pixman_implementation_{src,dest}_iter_init()
      Simplify the prototype for iterator initializers.
      test: Randomize some tests if PIXMAN_RANDOMIZE_TESTS is set
      test: Fix infinite loop in composite
2011-03-28 13:52:09 -04:00

265 lines
6.8 KiB
C

/*
* Copyright © 2000 SuSE, Inc.
* Copyright © 1999 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of SuSE not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. SuSE makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Author: Keith Packard, SuSE, Inc.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include "pixman-private.h"
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)
{
if (a >= INT32_MAX / b)
return NULL;
return malloc (a * b);
}
void *
pixman_malloc_abc (unsigned int a,
unsigned int b,
unsigned int c)
{
if (a >= INT32_MAX / b)
return NULL;
else if (a * b >= INT32_MAX / c)
return NULL;
else
return malloc (a * b * c);
}
/*
* Helper routine to expand a color component from 0 < n <= 8 bits to 16
* bits by replication.
*/
static inline uint64_t
expand16 (const uint8_t val, int nbits)
{
/* Start out with the high bit of val in the high bit of result. */
uint16_t result = (uint16_t)val << (16 - nbits);
if (nbits == 0)
return 0;
/* Copy the bits in result, doubling the number of bits each time, until
* we fill all 16 bits.
*/
while (nbits < 16)
{
result |= result >> nbits;
nbits *= 2;
}
return result;
}
/*
* This function expands images from ARGB8 format to ARGB16. To preserve
* precision, it needs to know the original source format. For example, if the
* source was PIXMAN_x1r5g5b5 and the red component contained bits 12345, then
* the expanded value is 12345123. To correctly expand this to 16 bits, it
* should be 1234512345123451 and not 1234512312345123.
*/
void
pixman_expand (uint64_t * dst,
const uint32_t * src,
pixman_format_code_t format,
int width)
{
/*
* Determine the sizes of each component and the masks and shifts
* required to extract them from the source pixel.
*/
const int a_size = PIXMAN_FORMAT_A (format),
r_size = PIXMAN_FORMAT_R (format),
g_size = PIXMAN_FORMAT_G (format),
b_size = PIXMAN_FORMAT_B (format);
const int a_shift = 32 - a_size,
r_shift = 24 - r_size,
g_shift = 16 - g_size,
b_shift = 8 - b_size;
const uint8_t a_mask = ~(~0 << a_size),
r_mask = ~(~0 << r_size),
g_mask = ~(~0 << g_size),
b_mask = ~(~0 << b_size);
int i;
/* Start at the end so that we can do the expansion in place
* when src == dst
*/
for (i = width - 1; i >= 0; i--)
{
const uint32_t pixel = src[i];
const uint8_t a = (pixel >> a_shift) & a_mask,
r = (pixel >> r_shift) & r_mask,
g = (pixel >> g_shift) & g_mask,
b = (pixel >> b_shift) & b_mask;
const uint64_t a16 = a_size ? expand16 (a, a_size) : 0xffff,
r16 = expand16 (r, r_size),
g16 = expand16 (g, g_size),
b16 = expand16 (b, b_size);
dst[i] = a16 << 48 | r16 << 32 | g16 << 16 | b16;
}
}
/*
* Contracting is easier than expanding. We just need to truncate the
* components.
*/
void
pixman_contract (uint32_t * dst,
const uint64_t *src,
int width)
{
int i;
/* Start at the beginning so that we can do the contraction in
* place when src == dst
*/
for (i = 0; i < width; i++)
{
const uint8_t a = src[i] >> 56,
r = src[i] >> 40,
g = src[i] >> 24,
b = src[i] >> 8;
dst[i] = a << 24 | r << 16 | g << 8 | b;
}
}
uint32_t *
_pixman_iter_get_scanline_noop (pixman_iter_t *iter, const uint32_t *mask)
{
return iter->buffer;
}
#define N_TMP_BOXES (16)
pixman_bool_t
pixman_region16_copy_from_region32 (pixman_region16_t *dst,
pixman_region32_t *src)
{
int n_boxes, i;
pixman_box32_t *boxes32;
pixman_box16_t *boxes16;
pixman_bool_t retval;
boxes32 = pixman_region32_rectangles (src, &n_boxes);
boxes16 = pixman_malloc_ab (n_boxes, sizeof (pixman_box16_t));
if (!boxes16)
return FALSE;
for (i = 0; i < n_boxes; ++i)
{
boxes16[i].x1 = boxes32[i].x1;
boxes16[i].y1 = boxes32[i].y1;
boxes16[i].x2 = boxes32[i].x2;
boxes16[i].y2 = boxes32[i].y2;
}
pixman_region_fini (dst);
retval = pixman_region_init_rects (dst, boxes16, n_boxes);
free (boxes16);
return retval;
}
pixman_bool_t
pixman_region32_copy_from_region16 (pixman_region32_t *dst,
pixman_region16_t *src)
{
int n_boxes, i;
pixman_box16_t *boxes16;
pixman_box32_t *boxes32;
pixman_box32_t tmp_boxes[N_TMP_BOXES];
pixman_bool_t retval;
boxes16 = pixman_region_rectangles (src, &n_boxes);
if (n_boxes > N_TMP_BOXES)
boxes32 = pixman_malloc_ab (n_boxes, sizeof (pixman_box32_t));
else
boxes32 = tmp_boxes;
if (!boxes32)
return FALSE;
for (i = 0; i < n_boxes; ++i)
{
boxes32[i].x1 = boxes16[i].x1;
boxes32[i].y1 = boxes16[i].y1;
boxes32[i].x2 = boxes16[i].x2;
boxes32[i].y2 = boxes16[i].y2;
}
pixman_region32_fini (dst);
retval = pixman_region32_init_rects (dst, boxes32, n_boxes);
if (boxes32 != tmp_boxes)
free (boxes32);
return retval;
}
#ifdef DEBUG
void
_pixman_log_error (const char *function, const char *message)
{
static int n_messages = 0;
if (n_messages < 10)
{
fprintf (stderr,
"*** BUG ***\n"
"In %s: %s\n"
"Set a breakpoint on '_pixman_log_error' to debug\n\n",
function, message);
n_messages++;
}
}
#endif