platform/upstream/pixman.git
11 years agotest/utils.[ch]: Add new function operator_name()
Søren Sandmann Pedersen [Sat, 19 Jan 2013 13:55:27 +0000 (08:55 -0500)]
test/utils.[ch]: Add new function operator_name()

This function returns the name of the given operator, which is useful
for printing out debug information. The function is done as a switch
without a default value so that the compiler will warn if new
operators are added in the future.

The function is used in affine-test.c, scaling-test.c, and
blitters-test.c.

11 years agoREADME: Add guidelines on how to contribute patches
Søren Sandmann Pedersen [Sat, 12 Jan 2013 13:03:35 +0000 (08:03 -0500)]
README: Add guidelines on how to contribute patches

Ben Avison pointed out here:

   http://lists.freedesktop.org/archives/pixman/2013-January/002485.html

that there isn't really any documentation about how to submit patches
to pixman. This patch adds some information to the README file.

v2: Incorporate some comments from Ben Avison
v3: Change gitweb URL to cgit

11 years agoConvert INCLUDES to AM_CPPFLAGS
Matt Turner [Sat, 19 Jan 2013 00:53:32 +0000 (16:53 -0800)]
Convert INCLUDES to AM_CPPFLAGS

INCLUDES has been deprecated starting with automake 1.13. Convert all
occurrences with the recommended AM_CPPFLAGS replacement.

11 years agoAdd new demos and tests to .gitignore
Matt Turner [Sat, 19 Jan 2013 00:49:00 +0000 (16:49 -0800)]
Add new demos and tests to .gitignore

11 years agoMIPS: DSPr2: Added more fast-paths:
Nemanja Lukic [Tue, 22 Jan 2013 02:01:05 +0000 (03:01 +0100)]
MIPS: DSPr2: Added more fast-paths:
 - over_reverse_n_8888
 - in_n_8_8

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

lowlevel-blt-bench results

Referent (before):
        over_reverse_n_8888 =  L1:  19.42  L2:  19.07  M: 15.38 ( 40.80%)  HT: 13.35  VT: 13.10  R: 12.92  RT:  8.27 (  49Kops/s)
                   in_n_8_8 =  L1:  21.20  L2:  22.86  M: 21.42 ( 14.21%)  HT: 15.97  VT: 15.69  R: 15.47  RT:  8.00 (  48Kops/s)

Optimized:
        over_reverse_n_8888 =  L1:  60.09  L2:  47.87  M: 28.65 ( 76.02%)  HT: 23.58  VT: 22.51  R: 21.99  RT: 12.28 (  60Kops/s)
                   in_n_8_8 =  L1:  89.38  L2:  86.07  M: 65.48 ( 43.44%)  HT: 44.64  VT: 41.50  R: 40.77  RT: 16.94 (  66Kops/s)

11 years agoMIPS: DSPr2: Added more fast-paths for REVERSE operation:
Nemanja Lukic [Tue, 22 Jan 2013 01:59:44 +0000 (02:59 +0100)]
MIPS: DSPr2: Added more fast-paths for REVERSE operation:
 - out_reverse_8_0565
 - out_reverse_8_8888

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

lowlevel-blt-bench results

Referent (before):
        out_reverse_8_0565 =  L1:  14.29  L2:  13.58  M: 12.14 ( 24.16%)  HT:  9.23  VT:  9.12  R:  8.84  RT:  4.75 (  36Kops/s)
        out_reverse_8_8888 =  L1:  27.46  L2:  23.24  M: 17.41 ( 57.73%)  HT: 12.61  VT: 12.47  R: 11.79  RT:  5.86 (  41Kops/s)

Optimized:
        out_reverse_8_0565 =  L1:  28.24  L2:  25.64  M: 20.63 ( 41.05%)  HT: 16.69  VT: 16.14  R: 15.50  RT:  8.69 (  52Kops/s)
        out_reverse_8_8888 =  L1:  52.78  L2:  41.44  M: 23.50 ( 77.94%)  HT: 18.79  VT: 18.16  R: 16.90  RT:  9.11 (  53Kops/s)

11 years agopixman-filter.c: Cope with NULL returns from malloc()
Søren Sandmann Pedersen [Thu, 20 Dec 2012 16:28:25 +0000 (11:28 -0500)]
pixman-filter.c: Cope with NULL returns from malloc()

v2: Don't return a pointer to uninitialized memory when the allocation
of horz and vert fails, but allocation of params doesn't.

11 years agoHandle solid images in the noop iterator
Søren Sandmann Pedersen [Mon, 27 Aug 2012 02:06:27 +0000 (22:06 -0400)]
Handle solid images in the noop iterator

The noop src iterator already has code to handle solid images, but
that code never actually runs currently because it is not possible for
an image to have both a format code of PIXMAN_solid and a flag of
FAST_PATH_BITS_IMAGE.

If these two were to be set at the same time, the
fast_composite_tiled_repeat() fast path would trigger for solid images
(because it triggers for PIXMAN_any formats, which includes
PIXMAN_solid), but for solid images we can usually do better than that
fast path.

So this patch removes _pixman_solid_fill_iter_init() and instead
handles such images (along with repeating 1x1 bits images without an
alpha map) in pixman-noop.c.

When a 1x1R image is involved in the general composite path, before
this patch, it would hit this code in repeat() in pixman-inlines.h:

        while (*c >= size)
            *c -= size;
        while (*c < 0)
            *c += size;

and those loops could run for a huge number of iteratons (proportional
to the composite width). For such cases, the performance improvement
is really big:

./test/lowlevel-blt-bench -n add_n_8888:

Before:

    add_n_8888 =  L1:   3.86  L2:   3.78  M:  1.40 (  0.06%)  HT:  1.43  VT:  1.41  R:  1.41  RT:  1.38 (  19Kops/s)

After:

    add_n_8888 =  L1:1236.86  L2:2468.49  M:1097.88 ( 49.04%)  HT:476.49  VT:429.05  R:417.04  RT:155.12 ( 817Kops/s)

11 years agoFix build with automake-1.13
Marko Lindqvist [Thu, 3 Jan 2013 04:38:01 +0000 (06:38 +0200)]
Fix build with automake-1.13

Automake-1.13 has removed long obsolete AM_CONFIG_HEADER macro (
http://lists.gnu.org/archive/html/automake/2012-12/msg00038.html )
and autoreconf errors out upon seeing it.

Attached patch replaces obsolete AM_CONFIG_HEADER with now proper
AC_CONFIG_HEADERS.

11 years agoUse more appropriate types and remove a magic constant
Siarhei Siamashka [Thu, 20 Dec 2012 03:14:39 +0000 (05:14 +0200)]
Use more appropriate types and remove a magic constant

11 years agoDefine SIZE_MAX if it is not provided by the standard C headers
Siarhei Siamashka [Thu, 20 Dec 2012 03:00:46 +0000 (05:00 +0200)]
Define SIZE_MAX if it is not provided by the standard C headers

C++ compilers do not define SIZE_MAX. It is also not available
if the code is compiled by some C compilers:
    http://lists.freedesktop.org/archives/pixman/2012-August/002196.html

11 years agoRename 'xor' variable to 'filler' (because 'xor' is a C++ keyword)
Siarhei Siamashka [Sun, 16 Dec 2012 02:03:58 +0000 (04:03 +0200)]
Rename 'xor' variable to 'filler' (because 'xor' is a C++ keyword)

11 years agofloat-combiner.c: Change tests for x == 0.0 tests to - FLT_MIN < x < FLT_MIN
Søren Sandmann Pedersen [Sat, 15 Dec 2012 02:53:34 +0000 (21:53 -0500)]
float-combiner.c: Change tests for x == 0.0 tests to - FLT_MIN < x < FLT_MIN

pixman-float-combiner.c currently uses checks like these:

    if (x == 0.0f)
        ...
    else
        ... / x;

to prevent division by 0. In theory this is correct: a division-by-zero
exception is only supposed to happen when the floating point numerator is
exactly equal to a positive or negative zero.

However, in practice, the combination of x87 and gcc optimizations
causes issues. The x87 registers are 80 bits wide, which means the
initial test:

if (x == 0.0f)

may be false when x is an 80 bit floating point number, but when x is
rounded to a 32 bit single precision number, it becomes equal to
0.0. In principle, gcc should compensate for this quirk of x87, and
there are some options such as -ffloat-store, -fexcess-precision=standard,
and -std=c99 that will make it do so, but these all have a performance
cost.  It is also possible to set the FPU to a mode that makes it do
all computation with single or double precision, but that would
require pixman to save the existing mode before doing anything with
floating point and restore it afterwards.

Instead, this patch side-steps the issue by replacing exact checks for
equality with zero with a new macro that checkes whether the value is
between -FLT_MIN and FLT_MIN.

There is extensive reading material about this issue linked off the
infamous gcc bug 323:

    http://gcc.gnu.org/bugzilla/show_bug.cgi?id=323

11 years agoARM: make use of UQADD8 instruction even in generic C code paths
Siarhei Siamashka [Thu, 6 Dec 2012 15:13:16 +0000 (17:13 +0200)]
ARM: make use of UQADD8 instruction even in generic C code paths

ARMv6 has UQADD8 instruction, which implements unsigned saturated
addition for 8-bit values packed in 32-bit registers. It is very useful
for UN8x4_ADD_UN8x4, UN8_rb_ADD_UN8_rb and ADD_UN8 macros (which would
otherwise need a lot of arithmetic operations to simulate this operation).
Since most of the major ARM linux distros are built for ARMv7, we are
much less dependent on runtime CPU detection and can get practical
benefits from conditional compilation here for a lot of users.

The results of cairo-perf-trace benchmark on ARM Cortex-A15 with pixman
compiled by gcc 4.7.2 and PIXMAN_DISABLE set to "arm-simd arm-neon":

Speedups
========
image    firefox-talos-gfx  (29938.22 0.12%) ->  (27814.76 0.51%) : 1.08x speedup
image    firefox-asteroids  (23241.11 0.07%) ->  (21795.19 0.07%) : 1.07x speedup
image firefox-canvas-alpha (174519.85 0.08%) -> (164788.64 0.20%) : 1.06x speedup
image              poppler   (9464.46 1.61%) ->   (8991.53 0.14%) : 1.05x speedup

11 years agoFaster conversion from a8r8g8b8 to r5g6b5 in C code
Siarhei Siamashka [Mon, 3 Dec 2012 01:01:21 +0000 (03:01 +0200)]
Faster conversion from a8r8g8b8 to r5g6b5 in C code

This change reduces 3 shifts, 3 ANDs and 2 ORs (total 8 arithmetic
operations) to 3 shifts, 2 ANDs and 2 ORs (total 7 arithmetic
operations).

We get garbage in the high 16 bits of the result, which might need
to be cleared when casting to uint16_t (it would bring us back to
total 8 arithmetic operations). However in the case if the result
of a8r8g8b8->r5g6b5 conversion is immediately stored to memory, no
extra instructions for clearing these garbage bits are needed.

This allows the a8r8g8b8->r5g6b5 conversion code to be compiled
into 4 instructions for ARM instead of 5 (assuming a good optimizing
compiler), which has no pipeline stalls on ARM11 as an additional
bonus.

The change in benchmark results for 'lowlevel-blt-bench src_8888_0565'
with PIXMAN_DISABLE="arm-simd arm-neon mips-dspr2 mmx sse2" and pixman
compiled by gcc-4.7.2:

    MIPS 74K        480MHz  :  40.44 MPix/s ->  40.13 MPix/s
    ARM11           700MHz  :  50.28 MPix/s ->  62.85 MPix/s
    ARM Cortex-A8  1000MHz  : 124.38 MPix/s -> 141.85 MPix/s
    ARM Cortex-A15 1700MHz  : 281.07 MPix/s -> 303.29 MPix/s
    Intel Core i7  2800MHz  : 515.92 MPix/s -> 531.16 MPix/s

The same trick was used in xomap (X server for Nokia N800/N810):
    http://repository.maemo.org/pool/diablo/free/x/xorg-server/
    xorg-server_1.3.99.0~git20070321-0osso20083801.tar.gz

11 years agoChange CONVERT_XXXX_TO_YYYY macros into inline functions
Siarhei Siamashka [Mon, 3 Dec 2012 00:50:20 +0000 (02:50 +0200)]
Change CONVERT_XXXX_TO_YYYY macros into inline functions

It is easier and safer to modify their code in the case if the
calculations need some temporary variables. And the temporary
variables will be needed soon.

11 years agotest: add "src_0565_8888" to lowlevel-blt-bench
Siarhei Siamashka [Mon, 3 Dec 2012 03:44:36 +0000 (05:44 +0200)]
test: add "src_0565_8888" to lowlevel-blt-bench

11 years agopixman_composite_trapezoids(): Check for NULL return from create_bits()
Søren Sandmann Pedersen [Thu, 13 Dec 2012 20:37:40 +0000 (15:37 -0500)]
pixman_composite_trapezoids(): Check for NULL return from create_bits()

A check is needed that the creation of the temporary image in
pixman_composite_trapezoids() succeeds.

Fixes crash in stress-test -s 0x313c on my system.

11 years agopixman_composite_trapezoids: Return early if mask_format is not of TYPE_ALPHA
Søren Sandmann Pedersen [Thu, 13 Dec 2012 20:26:17 +0000 (15:26 -0500)]
pixman_composite_trapezoids: Return early if mask_format is not of TYPE_ALPHA

stress-test -s 0x17ee crashes because pixman_composite_trapezoids() is
given a mask_format of PIXMAN_c8, which causes it to create a
temporary image with that format but without a palette. This causes
crashes later.

The only mask_format that we actually support are those of TYPE_ALPHA,
so this patch add a return_if_fail() to ensure this.

Similarly, although currently it won't crash if given an invalid
format, alpha-only formats have always been the only thing that made
sense for the pixman_rasterize_edges() functions, so add a
return_if_fail() ensuring that the destination format is of type
PIXMAN_TYPE_ALPHA.

11 years agoAdd testing of trapezoids to stress-test
Søren Sandmann Pedersen [Thu, 13 Dec 2012 16:21:16 +0000 (11:21 -0500)]
Add testing of trapezoids to stress-test

The entry points add_trapezoids(), rasterize_trapezoid() and
composite_trapezoid() are exercised with random trapezoids.

This uncovers crashes with stress-test seeds 0x17ee and 0x313c.

11 years agodemos/radial-test: Add checkerboard to display the alpha channel
Søren Sandmann Pedersen [Sat, 8 Dec 2012 11:06:34 +0000 (06:06 -0500)]
demos/radial-test: Add checkerboard to display the alpha channel

11 years agodemos/conical-test: Use the draw_checkerboard() utility function
Søren Sandmann Pedersen [Sat, 8 Dec 2012 11:46:38 +0000 (06:46 -0500)]
demos/conical-test: Use the draw_checkerboard() utility function

Instead of having its own copy.

11 years agotest/utils.[ch]: Add utility function to draw a checkerboard
Søren Sandmann Pedersen [Sat, 8 Dec 2012 11:44:24 +0000 (06:44 -0500)]
test/utils.[ch]: Add utility function to draw a checkerboard

This is useful in demo programs to display the alpha channel.

11 years agoradial: When comparing t to mindr, use >= rather than >
Søren Sandmann Pedersen [Sat, 8 Dec 2012 00:51:19 +0000 (19:51 -0500)]
radial: When comparing t to mindr, use >= rather than >

Radial gradients are conceptually rendered as a sequence of circles
generated by linearly extrapolating from the two circles given by the
gradient specification. Any circles in that sequence that would end up
with a negative radius are not drawn, a condition that is enforced by
checking that t * dr is bigger than mindr:

     if (t * dr > mindr)

However, it is legitimate for a circle to have radius exactly 0, so
the test should use >= rather than >.

This gets rid of the dots in demos/radial-test except for when the c2
circle has radius 0 and a repeat mode of either NONE or NORMAL. Both
those dots correspond to a t value of 1.0, which is outside the
defined interval of [0.0, 1.0) and therefore subject to the repeat
algorithm. As a result, in the NONE case, a value of 1.0 turns into
transparent black. In the NORMAL case, 1.0 wraps around and becomes
0.0 which is red, unlike 0.99 which is blue.

Cc: ranma42@gmail.com
11 years agodemos/radial-test: Add zero-radius circles to demonstrate rendering bugs
Søren Sandmann Pedersen [Sat, 8 Dec 2012 00:43:53 +0000 (19:43 -0500)]
demos/radial-test: Add zero-radius circles to demonstrate rendering bugs

Add two new gradient columns, one where the start circle is has radius
0 and one where the end circle has radius 0. All the new gradients
except for one are rendered with a bright dot in the middle. In most
but not all cases this is incorrect.

Cc: ranma42@gmail.com
11 years agotest: Workaround unaligned MOVDQA bug (http://gcc.gnu.org/PR55614)
Siarhei Siamashka [Sat, 8 Dec 2012 13:16:51 +0000 (15:16 +0200)]
test: Workaround unaligned MOVDQA bug (gcc.gnu.org/PR55614)

Just use SSE2 intrinsics to do unaligned memory accesses as
a workaround for this gcc bug related to vector extensions.

11 years agoImprove performance of combine_over_u
Siarhei Siamashka [Fri, 30 Nov 2012 10:00:47 +0000 (12:00 +0200)]
Improve performance of combine_over_u

The generic C over_u combiner can be a lot faster with the
addition of special shortcuts for 0xFF and 0x00 alpha/mask
values. This is already implemented in C and SSE2 fast paths.

Profiling the run of cairo-perf-trace benchmarks with PIXMAN_DISABLE
environment variable set to "fast mmx sse2" on Intel Core i7:

=== before ===

37.32%  cairo-perf-trac  libpixman-1.so.0.29.1 [.] combine_over_u
21.37%  cairo-perf-trac  libpixman-1.so.0.29.1 [.] bits_image_fetch_bilinear_no_repeat_8888
13.51%  cairo-perf-trac  libpixman-1.so.0.29.1 [.] bits_image_fetch_bilinear_affine_none_a8r8g8b8
 2.96%  cairo-perf-trac  libpixman-1.so.0.29.1 [.] radial_compute_color
 2.74%  cairo-perf-trac  libpixman-1.so.0.29.1 [.] fetch_scanline_a8
 2.71%  cairo-perf-trac  libpixman-1.so.0.29.1 [.] fetch_scanline_x8r8g8b8
 2.17%  cairo-perf-trac  libpixman-1.so.0.29.1 [.] _pixman_gradient_walker_pixel
 1.86%  cairo-perf-trac  libcairo.so.2.11200.0 [.] _cairo_tor_scan_converter_generate
 1.57%  cairo-perf-trac  libpixman-1.so.0.29.1 [.] bits_image_fetch_bilinear_affine_pad_a8r8g8b8
 0.97%  cairo-perf-trac  libpixman-1.so.0.29.1 [.] combine_in_reverse_u
 0.96%  cairo-perf-trac  libpixman-1.so.0.29.1 [.] combine_over_ca

=== after ===

28.79%  cairo-perf-trac  libpixman-1.so.0.29.1 [.] bits_image_fetch_bilinear_no_repeat_8888
18.44%  cairo-perf-trac  libpixman-1.so.0.29.1 [.] bits_image_fetch_bilinear_affine_none_a8r8g8b8
15.54%  cairo-perf-trac  libpixman-1.so.0.29.1 [.] combine_over_u
 3.94%  cairo-perf-trac  libpixman-1.so.0.29.1 [.] radial_compute_color
 3.69%  cairo-perf-trac  libpixman-1.so.0.29.1 [.] fetch_scanline_a8
 3.69%  cairo-perf-trac  libpixman-1.so.0.29.1 [.] fetch_scanline_x8r8g8b8
 2.94%  cairo-perf-trac  libpixman-1.so.0.29.1 [.] _pixman_gradient_walker_pixel
 2.52%  cairo-perf-trac  libcairo.so.2.11200.0 [.] _cairo_tor_scan_converter_generate
 2.08%  cairo-perf-trac  libpixman-1.so.0.29.1 [.] bits_image_fetch_bilinear_affine_pad_a8r8g8b8
 1.31%  cairo-perf-trac  libpixman-1.so.0.29.1 [.] combine_in_reverse_u
 1.29%  cairo-perf-trac  libpixman-1.so.0.29.1 [.] combine_over_ca

11 years agoAdd fast paths for separable convolution
Søren Sandmann Pedersen [Mon, 26 Nov 2012 19:27:34 +0000 (14:27 -0500)]
Add fast paths for separable convolution

Similar to the fast paths for general affine access, add some fast
paths for the separable filter for all combinations of formats
x8r8g8b8, a8r8g8b8, r5g6b5, a8 with the four repeat modes.

It is easy to see the speedup in the demos/scale program.

11 years agoAdd demo program for conical gradients
Søren Sandmann Pedersen [Tue, 4 Dec 2012 18:17:49 +0000 (13:17 -0500)]
Add demo program for conical gradients

This new test is derived from radial-test.c and displays conical
gradients at various angles.

It also demonstrates how PIXMAN_REPEAT_NORMAL is supposed to work when
used with a gradient specification where the first stop is not a 0.0:
In this case the gradient is supposed to have a smooth transition from
the last stop back to the first stop with no sharp transitions. It
also shows that the repeat mode is not ignored for conical gradients
as one might be tempted to think.

11 years agoAdd demos/zone_plate.png
Søren Sandmann Pedersen [Mon, 12 Nov 2012 17:27:39 +0000 (12:27 -0500)]
Add demos/zone_plate.png

The zone plate image is a useful test case for image scalers because
it contains all representable frequencies, so any imperfection in
resampling filters will show up as Moire patterns.

This version is symmetric around the midpoint of the image, so since
rotating it is supposed to be a noop, it can also be used to verify
that the resampling filters don't shift the image.

V2: Run the file through OptiPNG to cut the size in half, as suggested
by Siarhei.

11 years agodemos: Add new demo program, "scale"
Søren Sandmann Pedersen [Thu, 22 Nov 2012 15:18:26 +0000 (10:18 -0500)]
demos: Add new demo program, "scale"

This program allows interactively scaling and rotating images with
using various filters and repeat modes. It uses
pixman_filter_create_separate_convolution() to generate the filters.

11 years agodemos/gtk-utils.[ch]: Add pixman_image_from_file()
Søren Sandmann Pedersen [Thu, 22 Nov 2012 15:16:16 +0000 (10:16 -0500)]
demos/gtk-utils.[ch]: Add pixman_image_from_file()

This function uses GdkPixbuf to load various common formats such as
.png and .jpg into a pixman image.

11 years agoAdd new pixman_filter_create_separable_convolution() API
Søren Sandmann Pedersen [Thu, 22 Nov 2012 15:15:06 +0000 (10:15 -0500)]
Add new pixman_filter_create_separable_convolution() API

This new API is a helper function to create filter parameters suitable
for use with PIXMAN_FILTER_SEPARABLE_CONVOLUTION.

For each dimension, given a scale factor, reconstruction and sample
filter kernels, and a subsampling resolution, this function will
compute a convolution of the two kernels scaled appropriately, then
sample that convolution and return the resulting vectors in a form
suitable for being used as parameters to
PIXMAN_FILTER_SEPARABLE_CONVOLUTION.

The filter kernels offered are the following:

  - IMPULSE:            Dirac delta function, ie., point sampling
  - BOX:                Box filter
  - LINEAR:             Linear filter, aka. "Tent" filter
  - CUBIC:              Cubic filter, currently Mitchell-Netravali
  - GAUSSIAN:           Gaussian function, sigma=1, support=3*sigma
  - LANCZOS2:           Two-lobed Lanczos filter
  - LANCZOS3:           Three-lobed Lanczos filter
  - LANCZOS3_STRETCHED: Three-lobed Lanczos filter, stretched by 4/3.0.
                        This is the "Nice" filter from Dirty Pixels by
                        Jim Blinn.

The intended way to use this function is to extract scaling factors
from the transformation and then pass those to this function to get a
filter suitable for compositing with that transformation. The filter
kernels can be chosen according to quality and performance tradeoffs.

To get equivalent quality to GdkPixbuf for downscalings, use BOX for
both reconstruction and sampling. For upscalings, use LINEAR for
reconstruction and IMPULSE for sampling (though note that for
upscaling in both X and Y directions, simply using
PIXMAN_FILTER_BILINEAR will likely be a better choice).

11 years agorounding.txt: Describe how SEPARABLE_CONVOLUTION filter works
Søren Sandmann Pedersen [Thu, 22 Nov 2012 15:17:56 +0000 (10:17 -0500)]
rounding.txt: Describe how SEPARABLE_CONVOLUTION filter works

Add some notes on how to compute the convolution matrices to be used
with the SEPARABLE_CONVOLUTION filter.

11 years agoAdd new filter PIXMAN_FILTER_SEPARABLE_CONVOLUTION
Søren Sandmann Pedersen [Thu, 22 Nov 2012 15:14:06 +0000 (10:14 -0500)]
Add new filter PIXMAN_FILTER_SEPARABLE_CONVOLUTION

This filter is a new way to use a convolution matrix for filtering. In
contrast to the existing CONVOLUTION filter, this new variant is
different in two respects:

- It is subsampled: Instead of just one convolution matrix, this
  filter chooses between a number of matrices based on the subpixel
  sample location, allowing the convolution kernel to be sampled at a
  higher resolution.

- It is separable: Each matrix is specified as the tensor product of
  two vectors. This has the advantages that many fewer values have to
  be stored, and that the filtering can be done separately in the x
  and y dimensions (although the initial implementation doesn't
  actually do that).

The motivation for this new filter is to improve image downsampling
quality. Currently, the best pixman can do is the regular convolution
filter which is limited to coarsely sampled convolution kernels.

With this new feature, any separable filter can be used at any desired
resolution.

11 years agoFix thread safety on mingw-w64 and clang
Benjamin Gilbert [Sun, 2 Dec 2012 04:55:31 +0000 (23:55 -0500)]
Fix thread safety on mingw-w64 and clang

After finding a working TLS storage class specifier, configure was
continuing to test other candidates.  This caused it to prefer
__declspec(thread) over __thread.  However, __declspec(thread) is
ignored with a warning by mingw-w64 [1] and silently ignored by clang [2].
The resulting binary behaved as if PIXMAN_NO_TLS was defined.

Bug introduced by a069da6c.

[1] https://bugs.freedesktop.org/show_bug.cgi?id=57591
[2] http://lists.freedesktop.org/archives/pixman/2012-October/002320.html

11 years agotest: Get rid of the obsolete 'prng_rand_N' and 'prng_rand_u32'
Siarhei Siamashka [Sun, 25 Nov 2012 00:59:25 +0000 (02:59 +0200)]
test: Get rid of the obsolete 'prng_rand_N' and 'prng_rand_u32'

They are the same as 'prng_rand_n' and 'prng_rand'

11 years agotest: Switch to the new PRNG instead of old LCG
Siarhei Siamashka [Sun, 25 Nov 2012 00:50:35 +0000 (02:50 +0200)]
test: Switch to the new PRNG instead of old LCG

Wallclock time for running pixman "make check" (compile time not included):

----------------------------+----------------+-----------------------------+
                            | old PRNG (LCG) |   new PRNG (Bob Jenkins)    |
       Processor type       +----------------+------------+----------------+
                            |    gcc 4.5     |  gcc 4.5   | gcc 4.7 (simd) |
----------------------------+----------------+------------+----------------+
quad Intel Core i7  @2.8GHz |    0m49.494s   |  0m43.722s |    0m37.560s   |
dual ARM Cortex-A15 @1.7GHz |     5m8.465s   |  4m37.375s |    3m45.819s   |
     IBM Cell PPU   @3.2GHz |    23m0.821s   | 20m38.316s |   16m37.513s   |
----------------------------+----------------+------------+----------------+

But some tests got a particularly large boost. For example benchmarking and
profiling blitters-test on Core i7:

=== before ===

$ time ./blitters-test

real    0m10.907s
user    0m55.650s
sys     0m0.000s

  70.45%  blitters-test  blitters-test       [.] create_random_image
  15.81%  blitters-test  blitters-test       [.] compute_crc32_for_image_internal
   2.26%  blitters-test  blitters-test       [.] _pixman_implementation_lookup_composite
   1.07%  blitters-test  libc-2.15.so        [.] _int_free
   0.89%  blitters-test  libc-2.15.so        [.] malloc_consolidate
   0.87%  blitters-test  libc-2.15.so        [.] _int_malloc
   0.75%  blitters-test  blitters-test       [.] combine_conjoint_general_u
   0.61%  blitters-test  blitters-test       [.] combine_disjoint_general_u
   0.40%  blitters-test  blitters-test       [.] test_composite
   0.31%  blitters-test  libc-2.15.so        [.] _int_memalign
   0.31%  blitters-test  blitters-test       [.] _pixman_bits_image_setup_accessors
   0.28%  blitters-test  libc-2.15.so        [.] malloc

=== after ===

$ time ./blitters-test

real    0m3.655s
user    0m20.550s
sys     0m0.000s

  41.77%  blitters-test.n  blitters-test.new  [.] compute_crc32_for_image_internal
  15.77%  blitters-test.n  blitters-test.new  [.] prng_randmemset_r
   6.15%  blitters-test.n  blitters-test.new  [.] _pixman_implementation_lookup_composite
   3.09%  blitters-test.n  libc-2.15.so       [.] _int_free
   2.68%  blitters-test.n  libc-2.15.so       [.] malloc_consolidate
   2.39%  blitters-test.n  libc-2.15.so       [.] _int_malloc
   2.27%  blitters-test.n  blitters-test.new  [.] create_random_image
   2.22%  blitters-test.n  blitters-test.new  [.] combine_conjoint_general_u
   1.52%  blitters-test.n  blitters-test.new  [.] combine_disjoint_general_u
   1.40%  blitters-test.n  blitters-test.new  [.] test_composite
   1.02%  blitters-test.n  blitters-test.new  [.] prng_srand_r
   1.00%  blitters-test.n  blitters-test.new  [.] _pixman_image_validate
   0.96%  blitters-test.n  blitters-test.new  [.] _pixman_bits_image_setup_accessors
   0.90%  blitters-test.n  libc-2.15.so       [.] malloc

11 years agotest: Search/replace 'lcg_*' -> 'prng_*'
Siarhei Siamashka [Sat, 24 Nov 2012 21:22:48 +0000 (23:22 +0200)]
test: Search/replace 'lcg_*' -> 'prng_*'

The 'lcg' prefix is going to be misleading if we replace
PRNG algorithm.

11 years agotest: Added a better PRNG (pseudorandom number generator)
Siarhei Siamashka [Sat, 24 Nov 2012 17:43:41 +0000 (19:43 +0200)]
test: Added a better PRNG (pseudorandom number generator)

This adds a fast SIMD-optimized variant of a small noncryptographic
PRNG originally developed by Bob Jenkins:
    http://www.burtleburtle.net/bob/rand/smallprng.html

The generated pseudorandom data is good enough to pass "Big Crush"
tests from TestU01 (http://en.wikipedia.org/wiki/TestU01).

SIMD code uses http://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html
which is a GCC specific extension. There is also a slower alternative
code path, which should work with any C compiler.

The performance of filling buffer with random data:
   Intel Core i7  @2.8GHz (SSE2)     : ~5.9 GB/s
   ARM Cortex-A15 @1.7GHz (NEON)     : ~2.2 GB/s
   IBM Cell PPU   @3.2GHz (Altivec)  : ~1.7 GB/s

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>