platform/upstream/pixman.git
11 years agotest: Change is_little_endian() into inline function
Siarhei Siamashka [Fri, 23 Nov 2012 07:07:23 +0000 (09:07 +0200)]
test: Change is_little_endian() into inline function

Also dropped redundant volatile keyword because any object
can be accessed via char* pointer without breaking aliasing
rules. The compilers are able to optimize this function to either
constant 0 or 1.

11 years agoAdd text file rounding.txt describing how rounding works
Søren Sandmann Pedersen [Wed, 21 Nov 2012 16:43:31 +0000 (11:43 -0500)]
Add text file rounding.txt describing how rounding works

It is not entirely obvious how pixman gets from "location in the
source image" to "pixel value stored in the destination". This file
describes how the filters work, and in particular how positions are
rounded to samples.

11 years agoConvolution filter: round color values instead of truncating
Søren Sandmann Pedersen [Wed, 21 Nov 2012 04:28:43 +0000 (23:28 -0500)]
Convolution filter: round color values instead of truncating

The pixel computed by the convolution filter should be rounded off,
not truncated. As a simple example consider a convolution matrix
consisting of five times 0x3333. If all five all five input pixels are
0xff, then the result of truncating will be

    (5 * 0x3333 * 255) >> 16 = 254

But the real value of the computation is (5 * 0x3333 / 65536.0) * 254
= 254.9961, so the error is almost 1. If the user isn't very careful
about normalizing the convolution kernel so that it sums to one in
fixed point, such error might cause solid images to change color, or
opaque images to become translucent.

The fix is simply to round instead of truncate.

11 years agoRound fixed-point multiplication
Søren Sandmann Pedersen [Tue, 20 Nov 2012 08:23:51 +0000 (03:23 -0500)]
Round fixed-point multiplication

After two fixed-point numbers are multiplied, the result is shifted
into place, but up until now pixman has simply discarded the low-order
bits instead of rounding to the closest number.

Fix that by adding 0x8000 (or 0x2 in one place) before shifting and
update the test checksums to match.

11 years agotest: Fix compiler warnings caused by unused code
Stefan Weil [Tue, 13 Nov 2012 18:44:44 +0000 (19:44 +0100)]
test: Fix compiler warnings caused by unused code

Signed-off-by: Stefan Weil <sw@weilnetz.de>
11 years agopixman: Use uintptr_t in type casts from pointer to integral value
Stefan Weil [Tue, 13 Nov 2012 18:38:32 +0000 (19:38 +0100)]
pixman: Use uintptr_t in type casts from pointer to integral value

These modifications fix lots of compiler warnings for systems where
sizeof(unsigned long) != sizeof(void *).
This is especially true for MinGW-w64 (64 bit Windows).

Signed-off-by: Stefan Weil <sw@weilnetz.de>
11 years agoAlways use xmmintrin.h for 64 bit Windows
Stefan Weil [Tue, 13 Nov 2012 18:44:15 +0000 (19:44 +0100)]
Always use xmmintrin.h for 64 bit Windows

MinGW-w64 uses the GNU compiler and does not define _MSC_VER.
Nevertheless, it provides xmmintrin.h and must be handled
here like the MS compiler. Otherwise compilation fails due to
conflicting declarations.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
11 years agoMIPS: DSPr2: Added several nearest neighbor fast paths with a8 mask:
Nemanja Lukic [Mon, 12 Nov 2012 21:48:51 +0000 (22:48 +0100)]
MIPS: DSPr2: Added several nearest neighbor fast paths with a8 mask:

Performance numbers before/after on MIPS-74kc @ 1GHz:

lowlevel-blt-bench -n

Referent (before):
        over_8888_8_0565 =  L1:   9.62  L2:   8.85  M:  7.40 ( 39.27%)  HT:  5.67  VT:  5.61  R:  5.45  RT:  2.98 (  22Kops/s)
        over_0565_8_0565 =  L1:   7.90  L2:   7.49  M:  6.72 ( 26.75%)  HT:  5.24  VT:  5.20  R:  5.06  RT:  2.90 (  22Kops/s)

Optimized:
        over_8888_8_0565 =  L1:  18.51  L2:  16.82  M: 12.13 ( 64.43%)  HT: 10.06  VT:  9.88  R:  9.54  RT:  5.63 (  31Kops/s)
        over_0565_8_0565 =  L1:  14.82  L2:  13.94  M: 11.34 ( 45.20%)  HT:  9.45  VT:  9.35  R:  9.03  RT:  5.50 (  31Kops/s)

11 years agoMIPS: DSPr2: Added more fast-paths for OVER operation:
Nemanja Lukic [Mon, 12 Nov 2012 21:48:53 +0000 (22:48 +0100)]
MIPS: DSPr2: Added more fast-paths for OVER operation:

Performance numbers before/after on MIPS-74kc @ 1GHz:

lowlevel-blt-bench results

Referent (before):
        over_n_0565 =  L1:  14.48  L2:  21.36  M: 17.57 ( 23.30%)  HT:  6.95  VT:  6.44  R:  6.39  RT:  2.16 (  22Kops/s)
        over_n_8888 =  L1:  92.60  L2:  86.13  M: 24.41 ( 64.74%)  HT:  8.94  VT:  8.06  R:  8.00  RT:  2.53 (  25Kops/s)

Optimized:
        over_n_0565 =  L1:  27.65  L2: 189.22  M: 58.19 ( 77.12%)  HT: 52.80  VT: 49.88  R: 47.53  RT: 23.67 (  72Kops/s)
        over_n_8888 =  L1: 235.99  L2: 230.86  M: 29.09 ( 77.11%)  HT: 27.95  VT: 27.24  R: 26.58  RT: 18.10 (  67Kops/s)

11 years agoMIPS: DSPr2: Added more fast-paths for SRC operation:
Nemanja Lukic [Mon, 12 Nov 2012 21:48:52 +0000 (22:48 +0100)]
MIPS: DSPr2: Added more fast-paths for SRC operation:

Performance numbers before/after on MIPS-74kc @ 1GHz:

lowlevel-blt-bench results

Referent (before):
        src_n_8_8888 =  L1:  13.79  L2:  22.47  M: 17.55 ( 58.28%)  HT:  6.95  VT:  6.46  R:  6.34  RT:  2.07 (  20Kops/s)
           src_n_8_8 =  L1:  20.22  L2:  20.21  M: 18.20 ( 24.17%)  HT:  6.65  VT:  6.22  R:  6.11  RT:  2.03 (  20Kops/s)

Optimized:
        src_n_8_8888 =  L1:  58.31  L2:  53.34  M: 25.69 ( 85.29%)  HT: 22.55  VT: 21.44  R: 19.91  RT: 10.34 (  48Kops/s)
           src_n_8_8 =  L1: 102.60  L2:  89.43  M: 65.01 ( 86.32%)  HT: 37.87  VT: 37.02  R: 32.43  RT: 12.41 (  51Kops/s)

11 years agoAllow src and dst to be identical in pixman_f_transform_invert()
Søren Sandmann Pedersen [Sun, 11 Nov 2012 19:05:54 +0000 (14:05 -0500)]
Allow src and dst to be identical in pixman_f_transform_invert()

It is useful to be able to invert a matrix in place, but currently
pixman_f_transform_invert() will produce wrong results if you pass the
same matrix as both source and destination.

Fix that by inverting into a temporary matrix and then copying that to
the destination.

11 years agopixman.h: Add typedefs for pixman_f_transform and pixman_f_vector
Søren Sandmann Pedersen [Thu, 8 Nov 2012 08:11:51 +0000 (03:11 -0500)]
pixman.h: Add typedefs for pixman_f_transform and pixman_f_vector

11 years agoFix undeclared variable use and sysctlbyname error handling on ppc
Joshua Root [Fri, 9 Nov 2012 03:39:14 +0000 (14:39 +1100)]
Fix undeclared variable use and sysctlbyname error handling on ppc

Fixes bug 56889.

11 years agopixman_image_composite: Reduce opaque masks to NULL
Søren Sandmann Pedersen [Wed, 31 Oct 2012 17:14:07 +0000 (13:14 -0400)]
pixman_image_composite: Reduce opaque masks to NULL

When the mask is known to be opaque, we might as well reduce it to
NULL to take advantage of the various fast paths that operate on NULL
masks.

11 years agoPost-release version bump to 0.29.1
Søren Sandmann Pedersen [Wed, 7 Nov 2012 18:45:09 +0000 (13:45 -0500)]
Post-release version bump to 0.29.1

11 years agoPre-release version bump to 0.28.0 pixman-0.28.0
Søren Sandmann Pedersen [Wed, 7 Nov 2012 18:40:34 +0000 (13:40 -0500)]
Pre-release version bump to 0.28.0

11 years agoPost-release version bump to 0.27.5
Søren Sandmann Pedersen [Thu, 25 Oct 2012 14:42:26 +0000 (10:42 -0400)]
Post-release version bump to 0.27.5

11 years agoPre-release version bump to 0.27.4 pixman-0.27.4
Søren Sandmann Pedersen [Thu, 25 Oct 2012 14:35:27 +0000 (10:35 -0400)]
Pre-release version bump to 0.27.4

11 years agoMIPS: DSPr2: Added more fast-paths for ADD operation: - add_8888_8888_8888 - add_8_8...
Nemanja Lukic [Sun, 14 Oct 2012 09:58:52 +0000 (11:58 +0200)]
MIPS: DSPr2: Added more fast-paths for ADD operation: - add_8888_8888_8888 - add_8_8 - add_8888_8888

Performance numbers before/after on MIPS-74kc @ 1GHz:

lowlevel-blt-bench results

Referent (before):
        add_8888_8888_8888 =  L1:  17.55  L2:  13.35  M:  8.13 ( 93.95%)  HT:  6.60  VT:  6.64  R:  6.45  RT:  3.47 (  26Kops/s)
        add_8_8            =  L1:  86.07  L2:  84.89  M: 62.36 ( 90.11%)  HT: 36.36  VT: 34.74  R: 29.56  RT: 11.56 (  52Kops/s)
        add_8888_8888      =  L1:  95.59  L2:  73.05  M: 17.62 (101.84%)  HT: 15.46  VT: 15.01  R: 13.94  RT:  6.71 (  42Kops/s)

Optimized:
        add_8888_8888_8888 =  L1:  41.52  L2:  33.21  M: 11.97 (138.45%)  HT: 10.47  VT: 10.19  R:  9.42  RT:  4.86 (  32Kops/s)
        add_8_8            =  L1: 135.06  L2: 104.82  M: 57.13 ( 82.58%)  HT: 34.79  VT: 36.60  R: 28.28  RT: 10.54 (  51Kops/s)
        add_8888_8888      =  L1: 176.36  L2:  67.82  M: 17.48 (101.06%)  HT: 15.16  VT: 14.62  R: 13.88  RT:  8.05 (  45Kops/s)

11 years agoMIPS: DSPr2: Added more fast-paths for ADD operation: - add_0565_8_0565 - add_8888_8_...
Nemanja Lukic [Sun, 14 Oct 2012 09:58:51 +0000 (11:58 +0200)]
MIPS: DSPr2: Added more fast-paths for ADD operation: - add_0565_8_0565 - add_8888_8_8888 - add_8888_n_8888

Performance numbers before/after on MIPS-74kc @ 1GHz:

lowlevel-blt-bench results

Referent (before):
        add_0565_8_0565 =  L1:   8.89  L2:   8.37  M:  7.35 ( 29.22%)  HT:  5.90  VT:  5.85  R:  5.67  RT:  3.31 (  26Kops/s)
        add_8888_8_8888 =  L1:  17.22  L2:  14.17  M:  9.89 ( 65.56%)  HT:  7.57  VT:  7.50  R:  7.36  RT:  4.10 (  30Kops/s)
        add_8888_n_8888 =  L1:  17.79  L2:  14.87  M: 10.35 ( 54.89%)  HT:  5.19  VT:  4.93  R:  4.92  RT:  1.90 (  19Kops/s)

Optimized:
        add_0565_8_0565 =  L1:  21.72  L2:  20.01  M: 14.96 ( 59.54%)  HT: 12.03  VT: 11.81  R: 11.26  RT:  6.33 (  37Kops/s)
        add_8888_8_8888 =  L1:  47.42  L2:  38.64  M: 15.90 (105.48%)  HT: 13.34  VT: 13.03  R: 11.84  RT:  6.63 (  38Kops/s)
        add_8888_n_8888 =  L1:  54.83  L2:  42.66  M: 17.36 ( 92.11%)  HT: 15.20  VT: 14.82  R: 13.66  RT:  7.83 (  41Kops/s)

11 years agoMIPS: DSPr2: Added fast-paths for ADD operation: - add_n_8_8 - add_n_8_8888 - add_8_8_8
Nemanja Lukic [Sun, 14 Oct 2012 09:58:50 +0000 (11:58 +0200)]
MIPS: DSPr2: Added fast-paths for ADD operation: - add_n_8_8 - add_n_8_8888 - add_8_8_8

Performance numbers before/after on MIPS-74kc @ 1GHz:

lowlevel-blt-bench results

Referent (before):
        add_n_8_8    =  L1:  41.37  L2:  37.83  M: 30.38 ( 60.45%)  HT: 23.70  VT: 22.85  R: 21.51  RT: 10.32 (  45Kops/s)
        add_n_8_8888 =  L1:  16.01  L2:  14.46  M: 11.64 ( 46.32%)  HT:  5.50  VT:  5.18  R:  5.06  RT:  1.89 (  18Kops/s)
        add_8_8_8    =  L1:  13.26  L2:  12.47  M: 11.16 ( 29.61%)  HT:  8.09  VT:  8.04  R:  7.68  RT:  3.90 (  29Kops/s)

Optimized:
        add_n_8_8    =  L1:  96.03  L2:  79.37  M: 51.89 (103.31%)  HT: 32.59  VT: 31.29  R: 28.52  RT: 11.08 (  46Kops/s)
        add_n_8_8888 =  L1:  53.61  L2:  46.92  M: 23.78 ( 94.70%)  HT: 19.06  VT: 18.64  R: 17.30  RT:  9.15 (  43Kops/s)
        add_8_8_8    =  L1:  89.65  L2:  66.82  M: 37.10 ( 98.48%)  HT: 22.10  VT: 21.74  R: 20.12  RT:  8.12 (  41Kops/s)

11 years agoWorkaround for FTBFS with gcc 4.6 (http://gcc.gnu.org/PR54965)
Siarhei Siamashka [Thu, 18 Oct 2012 22:59:16 +0000 (01:59 +0300)]
Workaround for FTBFS with gcc 4.6 (gcc.gnu.org/PR54965)

GCC 4.6 has problems with force_inline, so just use normal inline instead.
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=55630

11 years agopixman_composite_trapezoids(): don't clip to extents for some operators
Søren Sandmann Pedersen [Fri, 12 Oct 2012 22:34:33 +0000 (18:34 -0400)]
pixman_composite_trapezoids(): don't clip to extents for some operators

pixman_composite_trapezoids() is supposed to composite across the
entire destination, but it actually only composites across the extent
of the trapezoids. For operators such as ADD or OVER this doesn't
matter since a zero source has no effect on the destination. But for
operators such as SRC or IN, it does matter.

So for such operators where a zero source has an effect, don't clip to
the trap extents.

11 years agopixman_composite_trapezoids(): Factor out extents computation
Søren Sandmann Pedersen [Fri, 12 Oct 2012 22:29:56 +0000 (18:29 -0400)]
pixman_composite_trapezoids(): Factor out extents computation

The computation of the extents rectangle is moved to its own
function.

11 years agoAdd new pixman_image_create_bits_no_clear() API
Søren Sandmann Pedersen [Fri, 12 Oct 2012 22:07:29 +0000 (18:07 -0400)]
Add new pixman_image_create_bits_no_clear() API

When pixman_image_create_bits() function is given NULL for bits, it
will allocate a new buffer and initialize it to zero. However, in some
cases, only a small region of the image is actually used; in that case
it is wasteful to touch all of the memory.

The new pixman_image_create_bits_no_clear() works exactly like
_create_bits() except that it doesn't initialize any newly allocated
memory.

11 years agoconfigure.ac: PIXMAN_LINK_WITH_ENV fix
Benny Siegert [Sun, 14 Oct 2012 14:28:48 +0000 (16:28 +0200)]
configure.ac: PIXMAN_LINK_WITH_ENV fix

(fixes bug #52101)

On MirBSD, the compiler produces a (harmless) warning when the compiler
is called without the standard CFLAGS:

foo.c:0: note: someone does not honour COPTS correctly, passed 0 times

However, PIXMAN_LINK_WITH_ENV considers _any_ output on stderr as an
error, even if the exit status of the compiler is 0. Furthermore, it
resets CFLAGS and LDFLAGS at the start. On MirBSD, this will lead to a
warning in each test, making all such tests fail. In particular, the
pthread_setspecific test fails, thus pixman is compiled without thread
support. This leads to compile errors later on, or at least it did when
I tried this on pkgsrc. Re-adding the saved CFLAGS, LDFLAGS and LIBS
before the test makes it work.

The second hunk inverts the order of the pthread flag checks. On BSD
systems (this is true at least on OpenBSD and MirBSD), both -lpthread
and -pthread work but the latter is "preferred", whatever this means.

11 years agoAdd missing force_inline to in() function used for C fast paths
Siarhei Siamashka [Fri, 28 Sep 2012 23:29:22 +0000 (02:29 +0300)]
Add missing force_inline to in() function used for C fast paths

11 years agoMIPS: skip runtime detection for DSPr2 if -mdspr2 option is in CFLAGS
Siarhei Siamashka [Sun, 8 Jul 2012 20:10:00 +0000 (23:10 +0300)]
MIPS: skip runtime detection for DSPr2 if -mdspr2 option is in CFLAGS

This provides a way to enable MIPS DSP ASE optimizations if running
under qemu-user (where /proc/cpuinfo contains information about the
host processor instead of the emulated one). Can be used for running
pixman test suite in qemu-user when having no access to real MIPS
hardware.

11 years agoregion: Remove overlap argument from pixman_op()
Søren Sandmann Pedersen [Thu, 11 Oct 2012 08:04:04 +0000 (04:04 -0400)]
region: Remove overlap argument from pixman_op()

This is used to compute whether the regions in question overlap, but
nothing makes use of this information, so it can be removed.

11 years agoregion: Formatting fix
Søren Sandmann Pedersen [Thu, 11 Oct 2012 08:07:00 +0000 (04:07 -0400)]
region: Formatting fix

The while part of a do/while loop was formatted as if it were a while
loop with an empty body. Probably some indent tool misinterpreted the
code at some point.

11 years agoOnly regard images as pixbufs if they have identity transformations
Søren Sandmann Pedersen [Sun, 7 Oct 2012 21:58:32 +0000 (17:58 -0400)]
Only regard images as pixbufs if they have identity transformations

In order for a src/mask pair to be considered a pixbuf, they have to
have identical transformations, but we don't check for that. Since the
only fast paths we have for pixbufs require identity transformations,
it sufficies to check that both source and mask are
untransformed.

This is also the reason that this bug can't be triggered by any test
code - if the source and mask had different transformations, we would
consider them a pixbuf, but then wouldn't take the fast path because
at least one of the transformations would be different from the
identity.

11 years agoRemove BUILT_SOURCES
Søren Sandmann Pedersen [Thu, 4 Oct 2012 16:41:08 +0000 (12:41 -0400)]
Remove BUILT_SOURCES

pixman-combine32.[ch] were the only built sources, so BUILT_SOURCES
can now be removed.

11 years agoSpeed up pixman_expand_to_float()
Søren Sandmann Pedersen [Sun, 23 Sep 2012 07:52:34 +0000 (03:52 -0400)]
Speed up pixman_expand_to_float()

GCC doesn't move the divisions out of the loop, so do it manually by
looking up the four (1.0f / mask) values in a table. Table lookups are
used under the theory that one L2 hit plus three L1 hits is preferable
to four floating point divisions.

11 years agoDon't auto-generate pixman-combine32.[ch] anymore
Søren Sandmann Pedersen [Fri, 21 Sep 2012 22:36:16 +0000 (18:36 -0400)]
Don't auto-generate pixman-combine32.[ch] anymore

Since pixman-combine64.[ch] are not used anymore, there is no point
generating these files from pixman-combine.[ch].template.

Also get rid of dependency on perl in configure.ac.

11 years agoRemove 64 bit pipeline
Søren Sandmann Pedersen [Sat, 18 Aug 2012 18:39:29 +0000 (14:39 -0400)]
Remove 64 bit pipeline

The 64 bit pipeline is not used anymore, so it can now be removed.

Don't generate pixman-combine64.[ch] anymore. Don't generate the
pixman-srgb.c anymore. Delete all the 64 bit fetchers in
pixman-access.c, all the 64 bit iterator functions in
pixman-bits-image.c and all the functions that expand from 8 to 16
bits.

11 years agoSwitch the wide pipeline over to using floating point
Søren Sandmann Pedersen [Sat, 18 Aug 2012 18:11:07 +0000 (14:11 -0400)]
Switch the wide pipeline over to using floating point

In pixman-bits-image.c, remove bits_image_fetch_untransformed_64() and
add bits_image_fetch_untransformed_float(); change
dest_get_scanline_wide() to produce a floating point buffer,

In the gradients, change *_get_scanline_wide() to call
pixman_expand_to_float() instead of pixman_expand().

In pixman-general.c change the wide Bpp to 16 instead of 8, and
initialize the buffers to 0 to prevent NaNs from causing trouble.

In pixman-noop.c make the wide solid iterator generate floating point
pixels.

In pixman-solid-fill.c, cache a floating point pixel, and make the
wide iterator generate floating point pixels.

Bug fix in bits_image_fetch_untransformed_repeat_normal

11 years agopixman-access.c: Add floating point accessor functions
Søren Sandmann Pedersen [Sat, 18 Aug 2012 17:22:15 +0000 (13:22 -0400)]
pixman-access.c: Add floating point accessor functions

Three new function pointer fields are added to bits_image_t:

      fetch_scanline_float
      fetch_pixel_float
      store_scanline_float

similar to the existing 32 and 64 bit accessors. The fetcher_info_t
struct in pixman_access similarly gets a new get_scanline_float field.

For most formats, the new get_scanline_float field is set to a new
function fetch_scanline_generic_float() that first calls the 32 bit
fetcher uses the 32 bit scanline fetcher and then expands these pixels
to floating point.

For the 10 bpc formats, new floating point accessors are added that
use pixman_unorm_to_float() and pixman_float_to_unorm() to convert
back and forth.

The PIXMAN_a8r8g8b8_sRGB format is handled with a 256-entry table that
maps 8 bit sRGB channels to linear single precision floating point
numbers. The sRGB->linear direction can then be done with a simple
table lookup.

The other direction is currently done with 4096-entry table which
works fine for 16 bit integers, but not so great for floating
point. So instead this patch uses a binary search in the sRGB->linear
table. The existing 32 bit accessors for the sRGB format are also
converted to use this method.

11 years agopixman-utils.c, pixman-private.h: Add floating point conversion routines
Søren Sandmann Pedersen [Sat, 18 Aug 2012 17:02:31 +0000 (13:02 -0400)]
pixman-utils.c, pixman-private.h: Add floating point conversion routines

A new struct argb_t containing a floating point pixel is added to
pixman-private.h and conversion routines are added to pixman-utils.c
to convert normalized integers to and from that struct.

New functions:

  - pixman_expand_to_float()
    Expands a buffer of integer pixels to a buffer of argb_t pixels

  - pixman_contract_from_float()
    Converts a buffer of argb_t pixels to a buffer integer pixels

  - pixman_float_to_unorm()
    Converts a floating point number to an unsigned normalized integer

  - pixman_unorm_to_float()
    Converts an unsigned normalized integer to a floating point number

11 years agoAdd combiner test
Søren Sandmann Pedersen [Sun, 9 Sep 2012 21:56:53 +0000 (17:56 -0400)]
Add combiner test

This test runs the new floating point combiners on random input with
divide-by-zero exceptions turned on.

With the floating point combiners the only thing we guarantee is that
divide-by-zero exceptions are not generated, so change
enable_fp_exceptions() to only enable those, and rename accordingly.

11 years agoAdd pixman-combine-float.c
Søren Sandmann Pedersen [Fri, 14 May 2010 04:42:04 +0000 (00:42 -0400)]
Add pixman-combine-float.c

This file contains floating point implementations of combiners for all
pixman operators. These combiners operate on buffers containing single
precision floating point pixels stored in (a, r, g, b) order.

The combiners are added to the pixman_implementation_t struct, but
nothing uses them yet.

This commit incorporates a number of bug fixes contributed by Andrea
Canciani.

Some notes:

- The combiners are making sure to never divide by zero regardless of
  input, so an application could enable divide-by-zero exceptions and
  pixman wouldn't generate any.

- The operators are implemented according to the Render spec. Ie.,

    - If the input pixels are between 0 and 1, then so is the output.

    - The source and destination coefficients for the conjoint and
      disjoint operators are clamped to [0, 1].

- The PDF operators are not described in the render spec, and the
  implementation here doesn't do any clamping except in the final
  conversion from floating point to destination format.

All of the above will need to be rethought if we add support for pixel
formats that can support negative and greater-than-one pixels. It is
in fact already the case in principle that convolution filters can
produce pixels with negative values, but since these go through the
broken "wide" path that narrows everything to 32 bits, these negative
values don't currently survive to the combiners.

11 years agoblitters-test: Prepare for floating point
Søren Sandmann Pedersen [Sat, 2 Jun 2012 04:15:54 +0000 (00:15 -0400)]
blitters-test: Prepare for floating point

Comment out some formats in blitters-test that are going to rely on
floating point in some upcoming patches.

11 years agoglyph-test: Prepare for floating point
Søren Sandmann Pedersen [Wed, 11 Jul 2012 07:27:49 +0000 (03:27 -0400)]
glyph-test: Prepare for floating point

In preparation for an upcoming change of the wide pipe to use floating
point, comment out some formats in glyph-test that are going to be
using floating point and update the CRC32 value to match.

11 years agoMake pixman.h more const-correct
Søren Sandmann Pedersen [Sat, 29 Sep 2012 14:34:17 +0000 (10:34 -0400)]
Make pixman.h more const-correct

Add const to pointer arguments when the function doesn't change the
pointed-to data.

Also in add_glyphs() in pixman-glyph.c make 'white' in add_glyphs()
static and const.

11 years agoiwmmxt: Don't define dummy _mm_empty for >=gcc-4.8
Matt Turner [Sun, 30 Sep 2012 18:59:23 +0000 (11:59 -0700)]
iwmmxt: Don't define dummy _mm_empty for >=gcc-4.8

Definition was not present in <4.8.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=55451

11 years agorotate-test: Call image_endian_swap() in make_image()
Søren Sandmann Pedersen [Sat, 29 Sep 2012 22:15:54 +0000 (18:15 -0400)]
rotate-test: Call image_endian_swap() in make_image()

Otherwise the test fails on big-endian.

Tested-by: Matt Turner <mattst88@gmail.com>
11 years agoAdd scaled nearest repeat fast paths
Siarhei Siamashka [Tue, 26 Jun 2012 02:36:52 +0000 (22:36 -0400)]
Add scaled nearest repeat fast paths

Before this patch it was often faster to scale and repeat
in two passes because each pass used a fast path vs.
the slow path that the single pass approach takes. This
makes it so that the single pass approach has competitive
performance.

11 years agosse2: mark pack_565_2x128_128 as static force_inline
Matt Turner [Fri, 21 Sep 2012 23:34:24 +0000 (16:34 -0700)]
sse2: mark pack_565_2x128_128 as static force_inline

11 years agoFix for infinite-loop test
Søren Sandmann Pedersen [Sat, 15 Sep 2012 07:13:09 +0000 (03:13 -0400)]
Fix for infinite-loop test

The infinite loop detected by "affine-test 212944861" is caused by an
overflow in this expression:

    max_x = pixman_fixed_to_int (vx + (width - 1) * unit_x) + 1;

where (width - 1) * unit_x doesn't fit in a signed int. This causes
max_x to be too small so that this:

    src_width = 0

    while (src_width < REPEAT_NORMAL_MIN_WIDTH && src_width <= max_x)
        src_width += src_image->bits.width;

results in src_width being 0. Later on when src_width is used for
repeat calculations, we get the infinite loop.

By casting unit_x to int64_t, the expression no longer overflows and
affine-test 212944861 and infinite-loop no longer loop forever.

11 years agotest: Add inifinite-loop test
Søren Sandmann Pedersen [Thu, 13 Sep 2012 23:31:29 +0000 (19:31 -0400)]
test: Add inifinite-loop test

This test demonstrates a bug where a certain transformation matrix can
result in an infinite loop. It was extracted as a standalone version
of "affine-test 212944861".

If given the option -nf, the test program will not call fail_after()
and therefore potentially run forever.

11 years agoaffine-test: Print out the transformation matrix when verbose
Søren Sandmann Pedersen [Thu, 13 Sep 2012 23:29:19 +0000 (19:29 -0400)]
affine-test: Print out the transformation matrix when verbose

Printing out the translation and scale is a bit misleading because the
actual transformation matrix can be modified in various other ways.

Instead simply print the whole transformation matrix that is actually
used.

11 years agoMIPS: DSPr2: Added OVER combiner and two new fast paths: - over_8888_8888 - over_8888...
Nemanja Lukic [Fri, 14 Sep 2012 07:31:26 +0000 (09:31 +0200)]
MIPS: DSPr2: Added OVER combiner and two new fast paths: - over_8888_8888 - over_8888_8888_8888

Performance numbers before/after on MIPS-74kc @ 1GHz:

lowlevel-blt-bench results

Referent (before):
          over_8888_8888 =  L1:  19.61  L2:  17.10  M: 11.16 ( 59.20%)  HT: 16.47  VT: 15.81  R: 14.82  RT:  8.90 (  50Kops/s)
     over_8888_8888_8888 =  L1:  13.56  L2:  11.22  M:  7.46 ( 79.18%)  HT:  6.24  VT:  6.20  R:  6.11  RT:  3.95 (  29Kops/s)

Optimized:
          over_8888_8888 =  L1:  46.42  L2:  36.70  M: 16.69 ( 88.57%)  HT: 17.11  VT: 16.55  R: 15.31  RT:  9.48 (  52Kops/s)
     over_8888_8888_8888 =  L1:  26.06  L2:  22.53  M: 11.49 (121.91%)  HT:  9.93  VT:  9.62  R:  9.19  RT:  5.75 (  36Kops/s)

11 years agoMIPS: DSPr2: Added fast-paths for OVER operation: - over_0565_n_0565 - over_0565_8_0565
Nemanja Lukic [Fri, 14 Sep 2012 07:31:25 +0000 (09:31 +0200)]
MIPS: DSPr2: Added fast-paths for OVER operation: - over_0565_n_0565 - over_0565_8_0565

Performance numbers before/after on MIPS-74kc @ 1GHz:

lowlevel-blt-bench results

Referent (before):
        over_0565_n_0565 =  L1:   7.56  L2:   7.24  M:  6.16 ( 16.38%)  HT:  4.01  VT:  3.84  R:  3.79  RT:  1.66 (  18Kops/s)
        over_0565_8_0565 =  L1:   7.43  L2:   7.05  M:  5.98 ( 23.85%)  HT:  5.27  VT:  5.23  R:  5.09  RT:  3.14 (  28Kops/s)

Optimized:
        over_0565_n_0565 =  L1:  15.47  L2:  14.52  M: 12.30 ( 32.65%)  HT: 10.76  VT: 10.57  R: 10.27  RT:  6.63 (  46Kops/s)
        over_0565_8_0565 =  L1:  15.47  L2:  14.61  M: 11.78 ( 46.92%)  HT: 10.00  VT:  9.84  R:  9.40  RT:  5.81 (  43Kops/s)

11 years agoMIPS: DSPr2: Added fast-paths for OVER operation: - over_8888_n_0565 - over_8888_8_0565
Nemanja Lukic [Fri, 14 Sep 2012 07:31:24 +0000 (09:31 +0200)]
MIPS: DSPr2: Added fast-paths for OVER operation: - over_8888_n_0565 - over_8888_8_0565

Performance numbers before/after on MIPS-74kc @ 1GHz:

lowlevel-blt-bench results

Referent (before):
        over_8888_n_0565 =  L1:   8.95  L2:   8.33  M:  6.95 ( 27.74%)  HT:  4.27  VT:  4.07  R:  4.01  RT:  1.74 (  19Kops/s)
        over_8888_8_0565 =  L1:   8.86  L2:   8.11  M:  6.72 ( 35.71%)  HT:  5.68  VT:  5.62  R:  5.47  RT:  3.35 (  30Kops/s)

Optimized:
        over_8888_n_0565 =  L1:  18.76  L2:  17.55  M: 13.11 ( 52.19%)  HT: 11.35  VT: 11.10  R: 10.88  RT:  6.94 (  47Kops/s)
        over_8888_8_0565 =  L1:  18.14  L2:  16.79  M: 12.10 ( 64.25%)  HT: 10.24  VT:  9.98  R:  9.63  RT:  5.89 (  43Kops/s)

11 years agoMIPS: DSPr2: Added fast-paths for OVER operation: - over_8888_n_8888 - over_8888_8_8888
Nemanja Lukic [Fri, 14 Sep 2012 07:31:23 +0000 (09:31 +0200)]
MIPS: DSPr2: Added fast-paths for OVER operation: - over_8888_n_8888 - over_8888_8_8888

Performance numbers before/after on MIPS-74kc @ 1GHz:

lowlevel-blt-bench results

Referent (before):
        over_8888_n_8888 =  L1:   9.92  L2:  11.27  M:  8.50 ( 45.23%)  HT:  4.70  VT:  4.45  R:  4.49  RT:  1.85 (  20Kops/s)
        over_8888_8_8888 =  L1:  12.54  L2:  10.86  M:  8.18 ( 54.36%)  HT:  6.53  VT:  6.45  R:  6.41  RT:  3.83 (  33Kops/s)

Optimized:
        over_8888_n_8888 =  L1:  28.02  L2:  24.92  M: 14.72 ( 78.15%)  HT: 13.03  VT: 12.65  R: 12.00  RT:  7.49 (  49Kops/s)
        over_8888_8_8888 =  L1:  26.92  L2:  23.93  M: 13.65 ( 90.58%)  HT: 11.68  VT: 11.29  R: 10.56  RT:  6.37 (  45Kops/s)

11 years agopixman-combine.c.template: Formatting clean-ups
Søren Sandmann Pedersen [Fri, 21 Sep 2012 20:52:16 +0000 (16:52 -0400)]
pixman-combine.c.template: Formatting clean-ups

Various formatting fixes, and removal of some obsolete comments about
strength reduction of operators.

11 years agoFix bugs in pixman-image.c
Søren Sandmann Pedersen [Fri, 21 Sep 2012 01:43:24 +0000 (21:43 -0400)]
Fix bugs in pixman-image.c

In the checks for whether the transforms are rotation matrices "-1"
and "1" were used instead of the correct -pixman_fixed_1 and
pixman_fixed_1.

Fixes test suite failure for rotate-test.

11 years agoAdd rotate-test.c test program
Søren Sandmann Pedersen [Thu, 20 Sep 2012 22:41:33 +0000 (18:41 -0400)]
Add rotate-test.c test program

This program exercises a bug in pixman-image.c where "-1" and "1" were
used instead of the correct "- pixman_fixed_1" and "pixman_fixed_1".

With the fast implementation enabled:

     % ./rotate-test
     rotate test failed! (checksum=35A01AAB, expected 03A24D51)

Without it:

     % env PIXMAN_DISABLE=fast ./rotate-test
     pixman: Disabled fast implementation
     rotate test passed (checksum=03A24D51)

V2: The first version didn't have lcg_srand (testnum) in test_transform().

11 years agoFix bugs in component alpha combiners for separable PDF operators
Søren Sandmann Pedersen [Wed, 19 Sep 2012 16:04:11 +0000 (12:04 -0400)]
Fix bugs in component alpha combiners for separable PDF operators

In general, the component alpha version of an operator is supposed to
do this:

       - multiply source with mask in all channels
       - multiply mask with source alpha in all channels
       - compute the regular operator in all channels using the
         mask value whenever source alpha is called for

The first two steps are usually accomplished with the function
combine_mask_ca(), but for operators where source alpha is not used,
such as SRC, ADD and OUT, the simpler function
combine_mask_value_ca(), which doesn't compute the new mask values,
can be used.

However, the PDF blend modes generally *do* make use of source alpha,
so they can't use combine_mask_value_ca() as they do now. They have to
use combine_mask_ca().

This patch fixes this in combine_multiply_ca() and the CA combiners
generated by PDF_SEPARABLE_BLEND_MODE.

11 years agoFix bug in fast_composite_scaled_nearest()
Søren Sandmann Pedersen [Wed, 19 Sep 2012 23:46:13 +0000 (19:46 -0400)]
Fix bug in fast_composite_scaled_nearest()

The fast_composite_scaled_nearest() function can be called when the
format is x8b8g8r8. In that case pixels fetched in fetch_nearest()
need to have their alpha channel set to 0xff.

Fixes test suite failure in scaling-test.

Reviewed-by: Matt Turner <mattst88@gmail.com>
11 years agoAdd PIXMAN_x8b8g8r8 and PIXMAN_a8b8g8r8 formats to scaling-test
Søren Sandmann Pedersen [Wed, 19 Sep 2012 23:26:49 +0000 (19:26 -0400)]
Add PIXMAN_x8b8g8r8 and PIXMAN_a8b8g8r8 formats to scaling-test

Update the CRC values based on what the general implementation
reports. This reveals a bug in the fast implementation:

    % env PIXMAN_DISABLE="mmx sse2" ./test/scaling-test
    pixman: Disabled mmx implementation
    pixman: Disabled sse2 implementation
    scaling test failed! (checksum=AA722B06, expected 03A23E0C)

vs.

    % env PIXMAN_DISABLE="mmx sse2 fast" ./test/scaling-test
    pixman: Disabled fast implementation
    pixman: Disabled mmx implementation
    pixman: Disabled sse2 implementation
    scaling test passed (checksum=03A23E0C)

Reviewed-by: Matt Turner <mattst88@gmail.com>
11 years agoimplementation: Rename delegate to fallback
Søren Sandmann Pedersen [Sat, 15 Sep 2012 23:10:56 +0000 (19:10 -0400)]
implementation: Rename delegate to fallback

At this point the chain of implementations has nothing to do with the
delegation design pattern anymore, so rename the delegate pointer to
'fallback'.

11 years ago_pixman_implementation_create(): Initialize implementation with memset()
Søren Sandmann Pedersen [Sat, 15 Sep 2012 17:58:45 +0000 (13:58 -0400)]
_pixman_implementation_create(): Initialize implementation with memset()

All the function pointers are NULL by default now, so we can just zero
the struct. Also write the function a little more compactly.

11 years agoRename _pixman_lookup_composite_function() to _pixman_implementation_lookup_composite()
Søren Sandmann Pedersen [Sat, 15 Sep 2012 17:53:17 +0000 (13:53 -0400)]
Rename _pixman_lookup_composite_function() to _pixman_implementation_lookup_composite()

And move it into pixman-implementation.c which is where it belongs
logically.

11 years agoMove delegation of src/dest iter init into pixman-implementation.c
Søren Sandmann Pedersen [Sat, 15 Sep 2012 17:20:52 +0000 (13:20 -0400)]
Move delegation of src/dest iter init into pixman-implementation.c

Instead of relying on each implementation to delegate when an iterator
can't be initialized, change the type of iterator initializers to
boolean and make pixman-implementation.c do the delegation whenever an
iterator initializer returns FALSE.

11 years agoMove fill delegation into pixman-implementation.c
Søren Sandmann Pedersen [Sat, 15 Sep 2012 17:08:51 +0000 (13:08 -0400)]
Move fill delegation into pixman-implementation.c

As in the blt commit, do the delegation in pixman-implementation.c
whenever the implementation fill returns FALSE instead of relying on
each implementation to do it by itself.

With this change there is no longer any reason for the implementations
to have one fill function that delegates and one that actually blits,
so consolidate those in the NEON, DSPr2, SSE2, and MMX
implementations.

11 years agoMove blt delegation into pixman-implementation.c
Søren Sandmann Pedersen [Sat, 15 Sep 2012 17:03:10 +0000 (13:03 -0400)]
Move blt delegation into pixman-implementation.c

Rather than require each individual implementation to do the
delegation for blt, just do it in pixman-implementation.c whenever the
implementation blt returns FALSE.

With this change, there is no longer any reason for the
implementations to have one blt function that delegates and one that
actually blits, so consolidate those in the NEON, DSPr2, SSE2, and MMX
implementations.

11 years agoimplementation: Write lookup_combiner() in a less convoluted way.
Søren Sandmann Pedersen [Sat, 15 Sep 2012 16:48:42 +0000 (12:48 -0400)]
implementation: Write lookup_combiner() in a less convoluted way.

Instead of initializing an array on the stack, just use a simple
switch to select which set of combiners to look up in.

11 years agobuild: Remove useless DEP_CFLAGS/DEP_LIBS variables
Matt Turner [Sun, 16 Sep 2012 04:25:38 +0000 (00:25 -0400)]
build: Remove useless DEP_CFLAGS/DEP_LIBS variables

11 years agobuild: Improve win32 build system
Andrea Canciani [Thu, 21 Jun 2012 04:07:07 +0000 (06:07 +0200)]
build: Improve win32 build system

Handle cross-directory dependencies using PHONY targets and clean up
some redundancies.

11 years agommx: Fix x86 build on MSVC
Andrea Canciani [Tue, 17 Jul 2012 14:14:20 +0000 (16:14 +0200)]
mmx: Fix x86 build on MSVC

The MSVC compiler is very strict about variable declarations after
statements.

Move all the declarations of each block before any statement in
the same block to fix multiple instances of:

pixman-mmx.c(xxxx) : error C2275: '__m64' : illegal use of this type
as an expression

12 years agotest/utils.c: Use pow(), not powf() in sRGB conversion routines
Søren Sandmann Pedersen [Sun, 26 Aug 2012 22:23:53 +0000 (18:23 -0400)]
test/utils.c: Use pow(), not powf() in sRGB conversion routines

These functions are operating on double precision values, so use pow()
instead of powf().

12 years agopixel_checker: Move sRGB conversion into get_limits()
Søren Sandmann Pedersen [Sun, 26 Aug 2012 22:13:47 +0000 (18:13 -0400)]
pixel_checker: Move sRGB conversion into get_limits()

The sRGB conversion has to be done every time the limits are being
computed. Without this fix, pixel_checker_get_min/max() will produce
the wrong results when called from somewhere other than
pixel_checker_check().

12 years agoRemove obsolete TODO file
Søren Sandmann Pedersen [Sat, 25 Aug 2012 21:14:50 +0000 (17:14 -0400)]
Remove obsolete TODO file

12 years agoRemove pointless declaration of _pixman_image_get_scanline_generic_64()
Søren Sandmann Pedersen [Sun, 19 Aug 2012 17:45:21 +0000 (13:45 -0400)]
Remove pointless declaration of _pixman_image_get_scanline_generic_64()

This declaration used to be necessary when
_pixman_image_get_scanline_generic_64() referred to a structure that
itself referred back to _pixman_image_get_scanline_generic_64().

12 years agodemos: Add srgb_trap_test.c
Søren Sandmann Pedersen [Sat, 9 Jun 2012 13:15:53 +0000 (09:15 -0400)]
demos: Add srgb_trap_test.c

This demo program composites a bunch of trapezoids side by side with
and without gamma aware compositing.

12 years agoMake show_image() cope with more formats
Søren Sandmann Pedersen [Sat, 9 Jun 2012 13:42:56 +0000 (09:42 -0400)]
Make show_image() cope with more formats

This makes show_image() deal with more formats than just a8r8g8b8, in
particular, a8r8g8b8_sRGB can now be handled.

Images that are passed to show_image with a format of a8r8g8b8_sRGB
are displayed without modification under the assumption that the
monitor is approximately sRGB.

Images with a format of a8r8g8b8 are also displayed without
modification since many other users of show_image() have been
generating essentially sRGB data with this format. Other formats are
also assumed to be gamma compressed; these are converted to a8r8g8b8
before being displayed.

With these changes, srgb-test.c doesn't need to do its own conversion
anymore.

12 years agoDefine TIMER_BEGIN and TIMER_END even when timers are not enabled
Søren Sandmann Pedersen [Tue, 31 Jul 2012 19:01:16 +0000 (15:01 -0400)]
Define TIMER_BEGIN and TIMER_END even when timers are not enabled

This allows code that uses these macros to build when timers are
disabled.

12 years agoPost-release version bump to 0.27.3
Søren Sandmann Pedersen [Wed, 1 Aug 2012 19:56:13 +0000 (15:56 -0400)]
Post-release version bump to 0.27.3

12 years agoPre-release version bump to 0.27.2 pixman-0.27.2
Søren Sandmann Pedersen [Wed, 1 Aug 2012 19:22:57 +0000 (15:22 -0400)]
Pre-release version bump to 0.27.2

12 years agoUse angle brackets form of including config.h
Sebastian Bauer [Tue, 31 Jul 2012 05:30:32 +0000 (07:30 +0200)]
Use angle brackets form of including config.h

12 years agoAdded HAVE_CONFIG_H check before including config.h
Sebastian Bauer [Tue, 31 Jul 2012 05:30:31 +0000 (07:30 +0200)]
Added HAVE_CONFIG_H check before including config.h

12 years agoglyph-test: Avoid setting solid images as alpha maps.
Søren Sandmann Pedersen [Mon, 30 Jul 2012 20:21:39 +0000 (16:21 -0400)]
glyph-test: Avoid setting solid images as alpha maps.

glyph-test would sometimes set a solid image as an alpha map, which is
not allowed. When this happened and the debug spew was enabled,
messages like this one would be generated:

    *** BUG ***
    In pixman_image_set_alpha_map: The expression
            !alpha_map || alpha_map->type == BITS was false
    Set a breakpoint on '_pixman_log_error' to debug

Fix this by not passing the ALLOW_SOLID flag to create_image() when
the resulting is to be used as an alpha map.

12 years agostress-test: Avoid overflows in clip rectangles
Søren Sandmann Pedersen [Mon, 30 Jul 2012 20:10:05 +0000 (16:10 -0400)]
stress-test: Avoid overflows in clip rectangles

The rectangles in the clip region set in set_general_properties()
would sometimes overflow, which would lead to messages like these:

      *** BUG ***
      In pixman_region32_union_rect: Invalid rectangle passed
      Set a breakpoint on '_pixman_log_error' to debug

when the micro version number of pixman is even.

Fix this by detecting the overflow and clamping such that the x2/y2
coordinates are less than INT32_MAX.

12 years agoAdd make-srgb.pl to EXTRA_DIST
Søren Sandmann Pedersen [Mon, 30 Jul 2012 19:54:27 +0000 (15:54 -0400)]
Add make-srgb.pl to EXTRA_DIST

Otherwise make distcheck doesn't pass.

12 years agoAdd tests to validate new sRGB behavior
Antti S. Lankila [Sun, 29 Jul 2012 19:14:34 +0000 (22:14 +0300)]
Add tests to validate new sRGB behavior

Composite checks random combinations of operations that now also have
sRGB sources, masks and destinations, and stress-test validates the
read/write primitives.

12 years agoAdd sRGB blending demo program
Antti S. Lankila [Sun, 29 Jul 2012 18:56:18 +0000 (21:56 +0300)]
Add sRGB blending demo program

Simple sRGB color blender test can be used to determine if the sRGB processing
works as expected. It blends alpha ramps of purple and green together such that
at midpoint of image, 50 % blend of both is realized. At that point, sRGB-aware
processing yields a result close to #bbb rather than #888, which is the linear
light blending result.

The demo also contains the sample computation for sRGB premultiplied alpha.

12 years agoAdd support for sRGB surfaces
Antti S. Lankila [Sun, 29 Jul 2012 18:46:58 +0000 (21:46 +0300)]
Add support for sRGB surfaces

sRGB format is defined as a new format type, PIXMAN_TYPE_ARGB_SRGB. One form of
this type is provided, PIXMAN_a8r8g8b8_sRGB. Use of an sRGB format triggers
wide processing, and the pixel fetch/store functions handle the relevant
conversion between color spaces. Pixman itself is thought to compose in the
linearized sRGB color space.

sRGB conversion is tabularized. For sRGB to linear, we are using only 256
values because the current source format uses 8 bits per component precision.
For linear to sRGB, it turns out that only 4096 brightness levels are required
to generate all of the 256 sRGB color values, and therefore only 12 bits per
component are considered during store. As a special case, a no-op
sRGB->linear->sRGB conversion is constructed to be lossless by adjusting the
sRGB->linear conversion table where necessary.

12 years agoRemove unnecessary dst initialization
Antti S. Lankila [Sat, 28 Jul 2012 11:02:42 +0000 (14:02 +0300)]
Remove unnecessary dst initialization

The initialization work is already performed correctly in image_init().

12 years agoMake pixman-mmx.c compile on x86-32 without optimization
Søren Sandmann Pedersen [Mon, 9 Jul 2012 10:58:59 +0000 (06:58 -0400)]
Make pixman-mmx.c compile on x86-32 without optimization

When not optimizing, write _mm_shuffle_pi16() as a statement
expression with inline assembly. That way we avoid
__builtin_ia32_pshufw(), which is only available when compiling with
-msse, while still allowing the non-optimizing gcc to understand that
the second argument is a compile time constant.

Tested-by: Knut Petersen <knut_petersen@t-online.de>
12 years agoCleanups and simplifications in x86 CPU feature detection
Søren Sandmann Pedersen [Thu, 28 Jun 2012 19:53:14 +0000 (15:53 -0400)]
Cleanups and simplifications in x86 CPU feature detection

A new function pixman_cpuid() is added that runs the cpuid instruction
and returns the results. On GCC this function uses inline assembly; on
MSVC, the function calls the __cpuid intrinsic.

There is also a new function called have_cpuid() which detects whether
cpuid is available. On x86-64 and MSVC, it simply returns TRUE; on
x86-32 bit, it checks whether the 22nd bit of eflags can be
modified. On MSVC this does have the consequence that pixman will no
longer work CPUS without cpuid (ie., older than 486 and some 486
models).

These two functions together makes it possible to write a generic
detect_cpu_features() in plain C. This function is then used in a new
have_feature() function that checks whether a specific set of feature
bits is available.

Aside from the cleanups and simplifications, the main benefit from
this patch is that pixman now can do feature detection on x86-64, so
that newer instruction sets such as SSSE3 and SSE4.1 can be used. (And
apparently the assumption that x86-64 CPUs always have MMX and SSE2 is
no longer correct: Knight's Corner is x86-64, but doesn't have them).

V2: Rename the constants in the getisax() code, as pointed out by Alan
Coopersmith. Also reinstate the result variable and initialize
features to 0.

V3: Fixes for the fact that the upper 32 bits of a 64 bit register are
zeroed whenever the corresponding 32 bit register is written to.

V4: Fixes for the fact that in 32 bit mode, when gcc is not optimizing
there were not enough registers available. The new code uses the "a",
"b", "c", and "d" constraints instead, and has two separate versions
for 32 and 64 bit modes.

12 years agoChanged the style of two function headers
Sebastian Bauer [Sun, 8 Jul 2012 22:48:45 +0000 (18:48 -0400)]
Changed the style of two function headers

Declare functions *_inverse() and *_contains_rectangle() in the same
way as the other functions are declared. This doesn't imply any semantic
changes. It's just a unification of coding styles.

12 years agoMIPS: DSPr2: Added more bilinear fast paths (without mask)
Nemanja Lukic [Mon, 2 Jul 2012 18:54:20 +0000 (20:54 +0200)]
MIPS: DSPr2: Added more bilinear fast paths (without mask)

Performance numbers before/after on MIPS-74kc @ 1GHz:

lowlevel-blt-bench -b

Referent (before):
  src_8888_8888 =  L1:   8.18  L2:   7.79  M:  6.32 ( 33.51%)  HT:  5.78  VT:  5.70  R:  5.61  RT:  3.79 (  29Kops/s)
  src_8888_0565 =  L1:   6.90  L2:   7.14  M:  6.47 ( 25.75%)  HT:  5.54  VT:  5.51  R:  5.46  RT:  3.53 (  28Kops/s)
  src_0565_x888 =  L1:   3.76  L2:   3.71  M:  3.37 ( 13.41%)  HT:  3.26  VT:  3.22  R:  3.20  RT:  2.58 (  23Kops/s)
  src_0565_0565 =  L1:   3.59  L2:   3.56  M:  3.47 (  9.19%)  HT:  3.19  VT:  3.18  R:  3.16  RT:  2.46 (  22Kops/s)
 over_8888_8888 =  L1:   5.99  L2:   5.66  M:  4.95 ( 26.28%)  HT:  4.40  VT:  4.38  R:  4.31  RT:  3.02 (  26Kops/s)
  add_8888_8888 =  L1:   6.84  L2:   6.39  M:  5.48 ( 29.09%)  HT:  4.80  VT:  4.79  R:  4.70  RT:  3.20 (  27Kops/s)

Optimized:
  src_8888_8888 =  L1:  18.27  L2:  16.69  M: 12.87 ( 68.25%)  HT: 11.80  VT: 11.61  R: 10.60  RT:  7.05 (  41Kops/s)
  src_8888_0565 =  L1:  15.18  L2:  14.10  M: 11.75 ( 46.71%)  HT: 10.64  VT: 10.50  R: 10.03  RT:  7.15 (  41Kops/s)
  src_0565_x888 =  L1:  10.45  L2:   9.96  M:  9.23 ( 36.72%)  HT:  8.39  VT:  8.29  R:  8.02  RT:  5.75 (  37Kops/s)
  src_0565_0565 =  L1:   9.37  L2:   8.98  M:  8.50 ( 22.53%)  HT:  7.71  VT:  7.66  R:  7.52  RT:  5.59 (  37Kops/s)
 over_8888_8888 =  L1:  12.21  L2:  11.01  M:  8.56 ( 45.36%)  HT:  7.71  VT:  7.64  R:  7.43  RT:  5.51 (  36Kops/s)
  add_8888_8888 =  L1:  17.72  L2:  15.16  M: 10.78 ( 57.13%)  HT:  9.46  VT:  9.30  R:  9.00  RT:  6.03 (  38Kops/s)

12 years agoMIPS: DSPr2: Added several bilinear fast paths with a8 mask
Nemanja Lukic [Mon, 2 Jul 2012 18:54:19 +0000 (20:54 +0200)]
MIPS: DSPr2: Added several bilinear fast paths with a8 mask

Performance numbers before/after on MIPS-74kc @ 1GHz:

lowlevel-blt-bench -b

Referent (before):

  src_8888_8_8888 =  L1:   6.37  L2:   6.08  M:  5.46 ( 32.57%)  HT:  4.64  VT:  4.61  R:  4.52  RT:  2.85 (  23Kops/s)
  src_8888_8_0565 =  L1:   5.89  L2:   5.66  M:  5.11 ( 23.71%)  HT:  4.36  VT:  4.34  R:  4.26  RT:  2.71 (  22Kops/s)
  src_0565_8_x888 =  L1:   3.32  L2:   3.27  M:  3.17 ( 14.71%)  HT:  2.86  VT:  2.84  R:  2.81  RT:  2.07 (  19Kops/s)
  src_0565_8_0565 =  L1:   3.19  L2:   3.15  M:  3.05 ( 10.11%)  HT:  2.75  VT:  2.74  R:  2.71  RT:  2.00 (  18Kops/s)
 over_8888_8_8888 =  L1:   4.99  L2:   4.71  M:  4.11 ( 27.22%)  HT:  3.59  VT:  3.58  R:  3.50  RT:  2.36 (  21Kops/s)
  add_8888_8_8888 =  L1:   5.60  L2:   5.26  M:  4.52 ( 29.95%)  HT:  3.92  VT:  3.89  R:  3.80  RT:  2.49 (  21Kops/s)

Optimized:

  src_8888_8_8888 =  L1:  13.19  L2:  12.13  M:  9.75 ( 58.22%)  HT:  8.60  VT:  8.44  R:  7.90  RT:  5.06 (  33Kops/s)
  src_8888_8_0565 =  L1:  11.64  L2:  10.81  M:  9.18 ( 42.63%)  HT:  8.04  VT:  7.90  R:  7.57  RT:  5.02 (  32Kops/s)
  src_0565_8_x888 =  L1:   8.34  L2:   7.95  M:  7.29 ( 33.85%)  HT:  6.55  VT:  6.48  R:  6.25  RT:  4.35 (  30Kops/s)
  src_0565_8_0565 =  L1:   7.71  L2:   7.35  M:  6.90 ( 22.90%)  HT:  6.14  VT:  6.10  R:  5.94  RT:  4.07 (  29Kops/s)
 over_8888_8_8888 =  L1:   9.73  L2:   8.99  M:  7.15 ( 47.41%)  HT:  6.40  VT:  6.30  R:  6.11  RT:  4.28 (  30Kops/s)
  add_8888_8_8888 =  L1:  13.01  L2:  11.72  M:  8.70 ( 57.68%)  HT:  7.59  VT:  7.46  R:  7.20  RT:  4.74 (  32Kops/s)

12 years agoSimplify CPU detection on PPC.
Søren Sandmann Pedersen [Thu, 28 Jun 2012 02:11:29 +0000 (22:11 -0400)]
Simplify CPU detection on PPC.

Get rid of the initialized and have_vmx static variables in
pixman-ppc.c There is no point to them since CPU detection only
happens once per process.

On Linux, just read /proc/self/auxv instead of generating the filename
with getpid() and don't bother with the stack buffer. Instead just
read the aux entries one by one.

12 years agoSimplifications to ARM CPU detection
Søren Sandmann Pedersen [Thu, 28 Jun 2012 02:05:18 +0000 (22:05 -0400)]
Simplifications to ARM CPU detection

Organize pixman-arm.c such that each operating system/compiler exports
a detect_cpu_features() function that returns a bitmask with the
various features that we are interested in. A new function
have_feature() then calls this function, caches the result, and return
whether the given feature is available.

The result is that all the pixman_have_arm_<feature> functions become
redundant and can be deleted.

12 years agoSimplify MIPS CPU detection
Søren Sandmann Pedersen [Wed, 27 Jun 2012 18:14:54 +0000 (14:14 -0400)]
Simplify MIPS CPU detection

There is no reason to have pixman_have_<feature> functions when all
they do is call pixman_have_mips_feature().

Instead rename pixman_have_mips_feature() to have_feature() and call
it directly from _pixman_mips_get_implementations(). Also on
non-Linux, just make have_feature() return FALSE.

12 years agoMove the remaining bits of pixman-cpu into pixman-implementation.c
Søren Sandmann Pedersen [Thu, 28 Jun 2012 03:04:24 +0000 (23:04 -0400)]
Move the remaining bits of pixman-cpu into pixman-implementation.c

12 years agoMove MIPS specific CPU detection to its own file, pixman-mips.c
Søren Sandmann Pedersen [Tue, 26 Jun 2012 21:26:34 +0000 (17:26 -0400)]
Move MIPS specific CPU detection to its own file, pixman-mips.c

12 years agoMove PowerPC specific CPU detection to its own file pixman-ppc.c
Søren Sandmann Pedersen [Tue, 26 Jun 2012 21:30:22 +0000 (17:30 -0400)]
Move PowerPC specific CPU detection to its own file pixman-ppc.c

12 years agoMove ARM specific CPU detection to a new file pixman-arm.c
Søren Sandmann Pedersen [Tue, 26 Jun 2012 21:02:24 +0000 (17:02 -0400)]
Move ARM specific CPU detection to a new file pixman-arm.c

Similar to the x86 commit, this moves the ARM specific CPU detection
to its own file which exports a pixman_arm_get_implementations()
function that is supposed to be a noop on non-ARM.