Commit Graph

2610 Commits

Author SHA1 Message Date
Søren Sandmann Pedersen
89662adf77 pixman-combine32.c: Fix bugs related to integer promotion
In the component alpha part of the PDF_SEPARABLE_BLEND_MODE macro, the
expression ~RED_8 (m) is used. Because RED_8(m) gets promoted to int
before ~ is applied, the whole expression typically becomes some
negative value rather than (255 - RED_8(m)) as desired.

Fix this by using unsigned temporary variables.

This reduces the number of failures in pixel-test to 363.
2014-01-04 16:13:27 -05:00
Søren Sandmann Pedersen
e7a99b3b0f pixman/pixman-combine32.c: Bug fixes for separable blend modes
This commit fixes four separate bugs:

1. In the computation

      (1 - sa) * d + (1 - da) * s + sa * da * B(s, d)

   we were using regular addition for all four channels, but for
   superluminescent pixels, the addition could overflow causing
   nonsensical results.

2. The variables and return types used for the results of the blend
   mode calculations were unsigned, but for various blend modes (and
   especially with superluminescent pixels), the blend mode
   calculations could be negative, resulting in underflows.

3. The blend mode computations were returned as 8-bit values, which is
   not sufficient precision (especially considering that we need
   signed results).

4. The value before the final division by 255 was not properly clamped
   to [0, 255].

This patch fixes all those bugs. The blend mode computations are now
returned as signed 16 bit values with 1 represented as 255 * 255.

With these fixes, the number of failing pixels in pixel-test goes down
from 431 to 384.
2014-01-04 16:13:27 -05:00
Søren Sandmann
fe3504d03f pixel-test.c: Add a number of pixels that have failed at some point
This commit adds a large number of pixel regressions to
pixel-test. All of these have at some point been failing in
blend-mode-test, and most of them do fail currently.

To be specific, with this commit, pixel-test reports 431 failed tests.
2014-01-04 16:13:27 -05:00
Søren Sandmann Pedersen
bd94c17937 test/tolerance-test: New test program
This new test program is similar to test/composite in that it relies
on the pixel_checker_t API to do tolerance based verification. But
unlike the composite test, which verifies combinations of a fixed set
of pixels, this one generates random images and verifies that those
composite correctly.

Also unlike composite, tolerance-test supports all the separable blend
mode operators in addition to the original Render operators.

When tests fail, a C struct is printed that can be pasted into
pixel-test for regression purposes.

There is an option "--forever" which causes the random seed to be set
to the current time, and then the test runs until interrupted. This is
useful for overnight runs.

This test currently fails badly due to various bugs in the blend mode
operators. Later commits will fix those.
2014-01-04 16:13:27 -05:00
Søren Sandmann
c2fd65dba3 pixel-test: Command line argument to specify the regression to run
A new command line argument allows the user to specify which one of
the regressions should be run.
2014-01-04 16:13:27 -05:00
Søren Sandmann
a692e01600 pixel-test: Add support for mask pixels
Support is added to pixel-test for verifying operations involving
masks. If a regression includes a mask, it is verified with the
pixel_checker API in in both unified and component alpha modes.
2014-01-04 16:13:27 -05:00
Søren Sandmann Pedersen
779ca46e98 test/check-formats.c: Add support for separable blend modes 2014-01-04 16:13:27 -05:00
Søren Sandmann Pedersen
a42af27fc0 test/utils.c: Add support for separable blend mode ops to do_composite()
The implementations are copied from the floating point pipeline, but
use double precision instead of single precision.
2014-01-04 16:13:27 -05:00
Søren Sandmann
b29d74ef0c configure.ac: Check and use -Wno-unused-local-typedefs GCC option
With GCC 4.8.2 the COMPILE_TIME_ASSERT macro produces a spurious
warning about an unused local typedef:

    In file included from pixman.c:29:0:
    pixman.c: In function 'optimize_operator':
    pixman-private.h:1019:22: warning: typedef 'compile_time_assertion' locally defined but not used [-Wunused-local-typedefs]

The flag -Wno-unused-local-typedefs suppresses that warning.
2013-12-26 09:41:53 -05:00
Julien Cristau
08ff9fa402 Upload to unstable 2013-12-17 22:04:30 +01:00
Julien Cristau
e66148cda6 Bump changelogs 2013-12-08 15:33:18 +01:00
Julien Cristau
9c9f210896 pixman 0.32.4 release
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.22 (GNU/Linux)
 
 iQIcBAABAgAGBQJSiXHSAAoJEA/daC2XTKcqUtQQALogcIuKShzPrZCnNke9jXJF
 Ujq4M0fHMBru4Uzqq+MCp02ssWLnoBvW8emwzalzt3xulZU+fUeYs1u56Epi1SnG
 oHt5ah1ZSicAwNBlDdflKgqnBGdsFJg5yj9F09zwZeBEBYwhJBaTQfIK6i0sww3s
 MQ66uANWsJQsW8/wFq5pJLmmmSWlelEHXz5pcjLavaYkOIITSzTeZF+xOvhBUwv2
 1zTsv9c2k05cR+8UKDpDURrEn5Cp5uQo0iV9FpKsyKL01ukqCbuBRWVxjSbXCmtu
 GWZ4qDLjScM8sCAQbZF4/MZuGoytC2cKxaWnjKn4h1L4+qZMIvjmcAlsP7CfJ14o
 AtWkYvU6rlY5m4je8Lh3QMbLkSTNFR8ix97jDhFmZlEQA3EXnPvme2YFecOmlVgF
 c1mVhVBR2Je/Hav0LiIne7151dFJ+THCAPOLcVqDCzRw2BMjAfp0Kx7qnFiXyvEt
 zgpoAmybf1kHOCpEugHGKwe4elCTvjq7xv3+JwkzqvV7uIvk1/J0ctIkBsboeMsP
 nvIJ8nBj9fNuJdP++jNX1xsi3C0LM16Bhd5n8wZcX4sqekSVj+LDht4JBPalMC7A
 m50kD9XlFSJ8UyoKrKMGx71XLnkGgT1hbQgE9ML8MumXZZMpjwIb9p7g7D2A1hXM
 /1kzDHmAaqbLcmFBTyO9
 =klDd
 -----END PGP SIGNATURE-----

Merge tag 'pixman-0.32.4' into debian-unstable

pixman 0.32.4 release

Conflicts:
	configure.ac
2013-12-08 15:28:54 +01:00
Søren Sandmann
945ab7a6f3 Soft Light: The first comparison should be <=, not <
According to the definition of soft light, the first comparison is
less-than-or-equal, not less-than.
2013-12-03 18:14:24 -05:00
Søren Sandmann
9ba3a34797 general: Support component alpha for all image types
Currently, if you attempt to use component alpha on source images or
images without RGB channels, Pixman will silently just use unified
alpha instead. This patch makes such images supported for component
alpha.

There is no particularly compelling usecase at the moment, but this
patch does get rid of a bit of special-case code both in
pixman-general.c and in test/composite.c.
2013-11-23 20:30:33 -05:00
Maarten Lankhorst
166899c913 release to sid 2013-11-18 15:55:02 +01:00
Maarten Lankhorst
7d8317abd4 Cherry-pick upstream bigfixes for fixing a crash when rendering invalid trapezoids. (LP: #1197921) 2013-11-18 15:54:49 +01:00
Ritesh Khadgaray
f740a26fe1 pixman_trapezoid_valid(): Fix underflow when bottom is close to MIN_INT
If t->bottom is close to MIN_INT (probably invalid value), subtracting
top can lead to underflow which causes crashes.  Attached patch will
fix the issue.

This fixes bug 67484.

(cherry picked from commit 5e14da97f1)
2013-11-18 15:08:42 +01:00
Søren Sandmann Pedersen
f4acde9c71 test/trap-crasher.c: Add trapezoid that demonstrates a crash
This trapezoid causes a crash due to an underflow in the
pixman_trapezoid_valid().

Test case from Ritesh Khadgaray.

(cherry picked from commit 2f876cf867)
2013-11-18 15:08:41 +01:00
Matt Turner
dae5a758e2 Post-release version bump to 0.32.5 2013-11-17 17:48:54 -08:00
Matt Turner
4b3a66b05e Pre-release version bump to 0.32.4 2013-11-17 17:46:52 -08:00
Søren Sandmann
97a655d5ca test/utils.c: Make the stack unaligned only on 32 bit Windows
The call_test_function() contains some assembly that deliberately
causes the stack to be aligned to 32 bits rather than 128 bits on
x86-32. The intention is to catch bugs that surface when pixman is
called from code that only uses a 32 bit alignment.

However, recent versions of GCC apparently make the assumption (either
accidentally or deliberately) that that the incoming stack is aligned
to 128 bits, where older versions only seemed to make this assumption
when compiling with -msse2. This causes the vector code in the PRNG to
now segfault when called from call_test_function() on x86-32.

This patch fixes that by only making the stack unaligned on 32 bit
Windows, where it would definitely be incorrect for GCC to assume that
the incoming stack is aligned to 128 bits.

V2: Put "defined(...)" around __GNUC__

Reviewed-and-Tested-by: Matt Turner <mattst88@gmail.com>
Bugzilla: https://bugs.gentoo.org/show_bug.cgi?id=491110
(cherry picked from commit f473fd1e75)
2013-11-17 17:45:56 -08:00
Jakub Bogusz
5a313af74e Fix the SSSE3 CPUID detection.
SSSE3 is detected by bit 9 of ECX, but we were checking bit 9 of EDX
which is APIC leading to SSSE3 routines being called on CPUs without
SSSE3.

Reviewed-by: Matt Turner <mattst88@gmail.com>
(cherry picked from commit 8487dfbcd0)
2013-11-17 17:45:54 -08:00
Søren Sandmann
f473fd1e75 test/utils.c: Make the stack unaligned only on 32 bit Windows
The call_test_function() contains some assembly that deliberately
causes the stack to be aligned to 32 bits rather than 128 bits on
x86-32. The intention is to catch bugs that surface when pixman is
called from code that only uses a 32 bit alignment.

However, recent versions of GCC apparently make the assumption (either
accidentally or deliberately) that that the incoming stack is aligned
to 128 bits, where older versions only seemed to make this assumption
when compiling with -msse2. This causes the vector code in the PRNG to
now segfault when called from call_test_function() on x86-32.

This patch fixes that by only making the stack unaligned on 32 bit
Windows, where it would definitely be incorrect for GCC to assume that
the incoming stack is aligned to 128 bits.

V2: Put "defined(...)" around __GNUC__

Reviewed-and-Tested-by: Matt Turner <mattst88@gmail.com>
Bugzilla: https://bugs.gentoo.org/show_bug.cgi?id=491110
2013-11-17 17:44:51 -08:00
Jakub Bogusz
8487dfbcd0 Fix the SSSE3 CPUID detection.
SSSE3 is detected by bit 9 of ECX, but we were checking bit 9 of EDX
which is APIC leading to SSSE3 routines being called on CPUs without
SSSE3.

Reviewed-by: Matt Turner <mattst88@gmail.com>
2013-11-12 12:59:42 -08:00
Søren Sandmann
917a52003d Post-release version bump to 0.32.3 2013-11-11 19:55:18 -05:00
Søren Sandmann
a980f83a68 Pre-release version bump to 0.32.2 2013-11-11 19:44:54 -05:00
Søren Sandmann
7410073110 demos/Makefile.am: Move EXTRA_DIST outside "if HAVE_GTK"
Without this, if tarballs are generated on a system that doesn't have
GTK+ 2 development headers available, the files in EXTRA_DIST will not
be included, which then causes builds from the tarball to fail on
systems that do have GTK+ 2 headers available.

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=71465
2013-11-11 19:28:30 -05:00
Søren Sandmann
e2e3817021 demos/Makefile.am: Move EXTRA_DIST outside "if HAVE_GTK"
Without this, if tarballs are generated on a system that doesn't have
GTK+ 2 development headers available, the files in EXTRA_DIST will not
be included, which then causes builds from the tarball to fail on
systems that do have GTK+ 2 headers available.

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=71465
2013-11-11 19:13:31 -05:00
Andrea Canciani
950d1310f7 test: Fix the win32 build
The win32 build has no config.h, so HAVE_CONFIG_H should be checked
before including it, as in utils.h.
2013-11-11 19:09:46 -05:00
Andrea Canciani
9bab46e9b8 test: Fix the win32 build
The win32 build has no config.h, so HAVE_CONFIG_H should be checked
before including it, as in utils.h.
2013-11-11 19:09:28 -05:00
Søren Sandmann
7a00965d7a Post-release version bump to 0.32.1 2013-11-11 19:07:35 -05:00
Søren Sandmann
ca5a4dec44 Post-release version bump to 0.33.1 2013-11-10 18:17:12 -05:00
Søren Sandmann
895e7e05b7 Pre-release version bump to 0.32.0 2013-11-10 18:05:47 -05:00
Søren Sandmann Pedersen
8cbc7da4e5 Post-release version bump to 0.31.3 2013-11-01 20:52:00 -04:00
Søren Sandmann Pedersen
99e8605be0 Pre-release version bump to 0.31.2 2013-11-01 20:39:46 -04:00
Ritesh Khadgaray
5e14da97f1 pixman_trapezoid_valid(): Fix underflow when bottom is close to MIN_INT
If t->bottom is close to MIN_INT (probably invalid value), subtracting
top can lead to underflow which causes crashes.  Attached patch will
fix the issue.

This fixes bug 67484.
2013-11-01 20:24:57 -04:00
Søren Sandmann Pedersen
2f876cf867 test/trap-crasher.c: Add trapezoid that demonstrates a crash
This trapezoid causes a crash due to an underflow in the
pixman_trapezoid_valid().

Test case from Ritesh Khadgaray.
2013-11-01 20:24:27 -04:00
Brad Smith
8ef7e0d18e Fix pixman build with older GCC releases
The following patch fixes building pixman with older GCC releases
such as GCC 3.3 and older (OpenBSD; some older archs use GCC 3.3.6)
by changing the method of detecting the presence of __builtin_clz
to utilizing an autoconf check to determine its presence. Compilers
that pretend to be GCC, implement __builtin_clz and are already
utilizing the intrinsic include LLVM/Clang, Open64, EKOPath and
PCC.
2013-11-01 20:14:33 -04:00
Søren Sandmann Pedersen
3c2f4b6517 pixman-glyph.c: Add __force_align_arg_pointer to composite functions
The functions pixman_composite_glyphs_no_mask() and
pixman_composite_glyphs() can call into code compiled with -msse2,
which requires the stack to be aligned to 16 bytes. Since the ABIs on
Windows and Linux for x86-32 don't provide this guarantee, we need to
use this attribute to make GCC generate a prologue that realigns the
stack.

This fixes the crash introduced in the previous commit and also

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

and

   https://bugs.freedesktop.org/show_bug.cgi?id=68300
2013-10-17 11:14:14 -04:00
Søren Sandmann Pedersen
3dce229772 utils.c: On x86-32 unalign the stack before calling test_function
GCC when compiling with -msse2 and -mssse3 will assume that the stack
is aligned to 16 bytes even on x86-32 and accordingly issue movdqa
instructions for stack allocated variables.

But despite what GCC thinks, the standard ABI on x86-32 only requires
a 4-byte aligned stack. This is true at least on Windows, but there
also was (and maybe still is) Linux code in the wild that assumed
this. When such code calls into pixman and hits something compiled
with -msse2, we get a segfault from the unaligned movdqas.

Pixman has worked around this issue in the past with the gcc attribute
"force_align_arg_pointer" but the problem has resurfaced now in

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

because pixman_composite_glyphs() is missing this attribute.

This patch makes fuzzer_test_main() call the test_function through a
trampoline, which, on x86-32, has a bit of assembly that deliberately
avoids aligning the stack to 16 bytes as GCC normally expects. The
result is that glyph-test now crashes.

V2: Mark caller-save registers as clobbered, rather than using
noinline on the trampoline.
2013-10-17 11:14:14 -04:00
Siarhei Siamashka
9e81419ed5 configure.ac: check and use -Wdeclaration-after-statement GCC option
The accidental use of declaration after statement breaks compilation
with C89 compilers such as MSVC. Assuming that MSVC is one of the
supported compilers, it makes sense to ask GCC to at least report
warnings for such problematic code.
2013-10-14 00:27:04 +03:00
Siarhei Siamashka
a863bbcce0 sse2: bilinear fast path for src_x888_8888
Running cairo-perf-trace benchmark on Intel Core2 T7300:

Before:
[  0]    image    t-firefox-canvas-swscroll    1.989    2.008   0.43%    8/8
[  1]    image        firefox-canvas-scroll    4.574    4.609   0.50%    8/8

After:
[  0]    image    t-firefox-canvas-swscroll    1.404    1.418   0.51%    8/8
[  1]    image        firefox-canvas-scroll    4.228    4.259   0.36%    8/8
2013-10-14 00:26:51 +03:00
Søren Sandmann Pedersen
8f75f638ab configure.ac: Add check for pmulhuw assembly
Clang 3.0 chokes on the following bit of assembly

    asm ("pmulhuw %1, %0\n\t"
        : "+y" (__A)
        : "y" (__B)
    );

from pixman-mmx.c with this error message:

    fatal error: error in backend: Unsupported asm: input constraint
        with a matching output constraint of incompatible type!

So add a check in configure to only enable MMX when the compiler can
deal with it.
2013-10-12 15:04:27 -04:00
Søren Sandmann Pedersen
09a62d4dbc scale.c: Use int instead of kernel_t for values in named_int_t
The 'value' field in the 'named_int_t' struct is used for both
pixman_repeat_t and pixman_kernel_t values, so the type should be int,
not pixman_kernel_t.

Fixes some warnings like this

scale.c:124:33: warning: implicit conversion from enumeration
      type 'pixman_repeat_t' to different enumeration type
      'pixman_kernel_t' [-Wconversion]
    { "None",                   PIXMAN_REPEAT_NONE },
    ~                           ^~~~~~~~~~~~~~~~~~

when compiled with clang.
2013-10-12 15:04:27 -04:00
Søren Sandmann Pedersen
9367243801 pixman-combine32.c: Make Color Burn routine follow the math more closely
For superluminescent destinations, the old code could underflow in

    uint32_t r = (ad - d) * as / s;

when (ad - d) was negative. The new code avoids this problem (and
therefore causes changes in the checksums of thread-test and
blitters-test), but it is likely still buggy due to the use of
unsigned variables and other issues in the blend mode code.
2013-10-12 15:04:27 -04:00
Søren Sandmann Pedersen
105fa74fad pixman-combine32: Make Color Dodge routine follow the math more closely
Change blend_color_dodge() to follow the math in the comment more
closely.

Note, the new code here is in some sense worse than the old code
because it can now underflow the unsigned variables when the source is
superluminescent and (as - s) is therefore negative. The old code was
careful to clamp to 0.

But for superluminescent variables we really need the ability for the
blend function to become negative, and so the solution the underflow
problem is to just use signed variables. The use of unsigned variables
is a general problem in all of the blend mode code that will have to
be solved later.

The CRC32 values in thread-test and blitters-test are updated to
account for the changes in output.
2013-10-12 15:04:27 -04:00
Søren Sandmann Pedersen
2527a72432 pixman-combine32: Rename a number of variable from sa/sca to as/s
There are no semantic changes, just variables renames. The motivation
for these renames is so that the names are shorter and better match
the one used in the comments.
2013-10-12 15:04:27 -04:00
Søren Sandmann Pedersen
eaa4778c42 pixman-combine32: Improve documentation for blend mode operators
This commit overhauls the comments in pixman-comine32.c regarding
blend modes:

- Add a link to the PDF supplement that clarifies the specification of
  ColorBurn and ColorDodge

- Clarify how the formulas for premultiplied colors are derived form
  the ones in the PDF specifications

- Write out the derivation of the formulas in each blend routine
2013-10-12 15:04:27 -04:00
Søren Sandmann Pedersen
4bf1502fe8 pixman-combine32.c: Formatting fixes
Fix a bunch of spacing issues.

V2: More spacing issues, in the _ca combiners
2013-10-12 15:04:00 -04:00
Andrea Canciani
54be1a52f7 Fix thread-test on non-OpenMP systems
The non-reentrant versions of prng_* functions are thread-safe only in
OpenMP-enabled builds.

Fixes thread-test failing when compiled with Clang (both on Linux and
on MacOS).
2013-10-09 18:23:27 +02:00