Commit Graph

1929 Commits

Author SHA1 Message Date
Søren Sandmann Pedersen
af2f0080fe Remove FAST_PATH_NARROW_FORMAT flag if there is a wide alpha map
If an image has an alpha map that has wide components, then we need to
use 64 bit processing for that image. We detect this situation in
pixman-image.c and remove the FAST_PATH_NARROW_FORMAT flag.

In pixman-general, the wide/narrow decision is now based on the flags
instead of on the formats.
2010-09-21 08:31:08 -04:00
Søren Sandmann Pedersen
0afc613415 Rename FAST_PATH_NO_WIDE_FORMAT to FAST_PATH_NARROW_FORMAT
This avoids a negative in the name. Also, by renaming the "wide"
variable in pixman-general.c to "narrow" and fixing up the logic
correspondingly, the code there reads a lot more straightforwardly.
2010-09-21 08:31:08 -04:00
Søren Sandmann Pedersen
ae77548f0d Update and extend the alphamap test
- Test many more combinations of formats

- Test destination alpha maps

- Test various different alpha origins

Also add a transformation to the destination, but comment it out
because it is actually broken at the moment (and pretty difficult to
fix).
2010-09-21 08:28:55 -04:00
Søren Sandmann Pedersen
dc9fe269ea Add fence_malloc() and fence_free().
These variants of malloc() and free() try to surround the allocated
memory with protected pages so that out-of-bounds accessess will cause
a segmentation fault.

If mprotect() and getpagesize() are not available, these functions are
simply equivalent to malloc() and free().
2010-09-21 08:28:55 -04:00
Søren Sandmann Pedersen
f4dc73bad4 Do opacity computation with shifts instead of comparing with 0
Also add a COMPILE_TIME_ASSERT() macro and use it to assert that the
shift is correct.
2010-09-21 08:28:55 -04:00
Siarhei Siamashka
517a77a992 SSE2 optimization for scaled over_8888_8888 operation with nearest filter
This is the first demo implementation, it should be possible to
generalize it later to cover more operations with less lines of code.

It should be also possible to introduce the use of '__builtin_constant_p'
gcc builtin function for an efficient way of checking if 'unit_x' is known
to be zero at compile time (when processing padding pixels for NONE, or
PAD repeat).

Benchmarks from Intel Core i7 860:

== before (nearest OVER) ==
op=3, src_fmt=20028888, dst_fmt=20028888, speed=142.01 MPix/s

== after (nearest OVER) ==
op=3, src_fmt=20028888, dst_fmt=20028888, speed=314.99 MPix/s

== performance of nonscaled operation as a reference ==
op=3, src_fmt=20028888, dst_fmt=20028888, speed=652.09 MPix/s
2010-09-21 13:33:57 +03:00
Siarhei Siamashka
abc90dad57 NONE repeat support for fast scaling with nearest filter
Implemented very similar to PAD repeat.

And gcc also seems to be able to completely eliminate the
code responsible for left and right padding pixels for OVER
operation with NONE repeat.
2010-09-21 13:33:08 +03:00
Siarhei Siamashka
45833d5b19 PAD repeat support for fast scaling with nearest filter
When processing pixels from the left and right padding, the same
scanline function is used with 'unit_x' set to 0.

Actually appears that gcc can handle this quite efficiently. When
using 'restrict' keyword, it is able to optimize the whole operation
performed on left or right padding pixels to a small unrolled loop
(the code is reduced to a simple fill implementation):

    9b30:       89 08                   mov    %ecx,(%rax)
    9b32:       89 48 04                mov    %ecx,0x4(%rax)
    9b35:       48 83 c0 08             add    $0x8,%rax
    9b39:       49 39 c0                cmp    %rax,%r8
    9b3c:       75 f2                   jne    9b30

Without 'restrict' keyword, there is one instruction more: reloading
source pixel data from memory in the beginning of each iteration. That
is slower, but also acceptable.
2010-09-21 13:32:11 +03:00
Siarhei Siamashka
3db0cc5c75 Introduce a fake PIXMAN_REPEAT_COVER constant
We need to implement a true PIXMAN_REPEAT_NONE support later (padding
the source with zero pixels). So it's better not to use PIXMAN_REPEAT_NONE
for handling FAST_PATH_SAMPLES_COVER_CLIP special case.
2010-09-21 13:30:59 +03:00
Siarhei Siamashka
e9b0740af7 Nearest scaling fast path macro split into two parts
Scanline processing is now split into a separate function. This provides
an easy way of overriding it with a platform specific implementation,
which may use SIMD optimizations. Only basic C data types are used as
the arguments for this function, so it may be implemented entirely in
assembly or be generated by some JIT engine.

Also as a result of this split, the complexity of code is reduced a
bit and now it should be easier to introduce support for the currently
missing NONE, PAD and REFLECT repeat types.
2010-09-21 13:29:55 +03:00
Siarhei Siamashka
066ce191a6 Nearest scaling fast path macros moved to 'pixman-fast-path.h'
These macros with some modifications can can be reused later by
various platform specific implementations, introducing SIMD
optimizations for nearest scaling fast paths.
2010-09-21 13:28:40 +03:00
Søren Sandmann Pedersen
fb819c0e93 Add FAST_PATH_NO_ALPHA_MAP to the standard destination flags.
We can't in general take a fast path if the destination has an alpha
map.
2010-09-14 08:57:17 -04:00
Siarhei Siamashka
ba6c98fc4b test: detection of possible floating point registers corruption
Added a pair of macros which can help to detect corruption
of floating point registers after a function call. This may
happen if _mm_empty() call is forgotten in MMX/SSE2 fast
path code, or ARM NEON assembly optimized function
forgets to save/restore d8-d15 registers before use.
2010-09-13 18:12:31 +03:00
Siarhei Siamashka
e470c0dc5b ARM: added 'neon_composite_over_0565_8_0565' fast path 2010-09-13 18:10:59 +03:00
Siarhei Siamashka
a5bf7c3b1a ARM: helper macros for conversion between 8888/x888/0565 formats 2010-09-13 18:08:16 +03:00
Siarhei Siamashka
8e299702f3 ARM: common init/cleanup macro for saving/restoring NEON registers
This is a typical prologue/epilogue for many NEON fast path functions, so
it makes sense to provide common reusable macros for it in the header file.
2010-09-13 18:05:53 +03:00
Søren Sandmann Pedersen
e29d9dfcb5 Silence some warnings about uninitialized variables
Neither were real problems, but GCC was complaining about them.
2010-09-08 19:16:21 -04:00
Søren Sandmann Pedersen
27f7852b5a When pixman_compute_composite_region32() returns FALSE, don't fini the region.
The rule is that the region passed in must be initialized and that the
region returned will still be valid. Ie., the lifecycle is the
responsibility of the caller, regardless of what the function returns.

Previously, compute_composite_region32() would finalize the region and
then return FALSE, and then the caller would finalize the region
again, leading to memory corruption in some cases.
2010-09-08 19:15:01 -04:00
Søren Sandmann Pedersen
df6dbc9024 Store a2b2g2r2 pixel through the WRITE macro
Otherwise, accessor functions won't work.
2010-09-08 19:14:58 -04:00
Siarhei Siamashka
f42419a3e4 ARM: added 'neon_composite_over_8888_8_0565' fast path 2010-09-06 23:56:05 +03:00
Julien Cristau
a4f6c93016 Upload to experimental 2010-09-06 21:15:21 +02:00
Maarten Bosmans
765bde32e0 Add *.exe to .gitignore 2010-08-30 13:41:38 -04:00
Maarten Bosmans
8596408261 Use windows.h directly for mingw32 build
This patch adresses the issue discussed in
http://lists.freedesktop.org/archives/pixman/2010-April/000163.html

There were only two clashing identifiers.  The first one is IN, which
obviously causes problems in Pixman for lines like

    PIXMAN_STD_FAST_PATH (IN, solid, a8, a8, fast_composite_in_n_8_8),

Fortunately the mingw headers provide a solution: by defining
_NO_W32_PSEUDO_MODIFIERS, these stupid symbols are skipped.

The other name is UINT64, used in pixman-mmx.c. I renamed that
function to to_uint64, but may be another name is more appropriate.
2010-08-30 13:39:48 -04:00
Søren Sandmann Pedersen
5b99710042 Be more paranoid about checking for GTK+
From time to time people run into issues where the configure script
detects GTK+ when it is either not installed, or not functional due to
a missing pixman. Most recently:

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

This patch makes the configure script more paranoid by

- always using PKG_CHECK_MODULES and not PKG_CHECK_EXISTS, since it
seems PKG_CHECK_EXISTS will sometimes return true even if a dependency
of GTK+, such as pixman-1, is missing.

- explicitly checking that pixman-1 is installed before enabling GTK+.

Cc: my.somewhat.lengthy.loginname@gmail.com
2010-08-24 08:12:20 -04:00
Søren Sandmann Pedersen
5530bcab26 Merge pixman_image_composite32() and do_composite().
There is not much point having a separate function that just validates
the images. Also add a boolean return to lookup_composite_function()
so that we can return if no composite function is found.
2010-08-24 08:12:20 -04:00
Benjamin Otte
a8ea889e5e region: Fix pixman_region_translate() clipping bug
Fixes the region-translate test case by clipping region translations to
the newly defined PIXMAN_REGION_MIN/MAX and using the newly introduced
type overflow_int_t to check for the overflow.
Also uses INT16_MAX or INT32_MAX for these values instead of relying on
the size of short and int types.
2010-08-24 12:17:50 +02:00
Benjamin Otte
4d8fb1bc01 region: Add a new test region-translate
This test exercises a bug in pixman_region32_translate(). The function
clips the region to int16 coordinates SHRT_MIN/SHRT_MAX.
2010-08-24 12:17:18 +02:00
Søren Sandmann Pedersen
5ff359b8a0 Post-release version bump to 0.19.3 2010-08-21 06:39:44 -04:00
Søren Sandmann Pedersen
39308ed3b0 Pre-release version bump to 0.19.2 2010-08-21 06:33:19 -04:00
Søren Sandmann Pedersen
393ccab74e Only try to compute the FAST_SAMPLES_COVER_CLIP for bits images
It doesn't make sense in other cases, and the computation would make
use of image->bits.{width,height} which lead to uninitialized memory
accesses when the image wasn't of type BITS.
2010-08-21 06:29:36 -04:00
Robert Hooker
dbc6d202d7 Bump changelogs. 2010-08-16 10:19:25 -04:00
Robert Hooker
637f4b5907 Merge branch 'upstream-experimental' into debian-experimental 2010-08-16 10:10:53 -04:00
Søren Sandmann Pedersen
97336fad32 Pre-release version bump to 0.18.4 2010-08-16 06:34:53 -04:00
Søren Sandmann Pedersen
da6f33a798 Introduce new FAST_PATH_SAMPLES_OPAQUE flag
This flag is set whenever the pixels of a bits image don't have an
alpha channel. Together with FAST_PATH_SAMPLES_COVER_CLIP it implies
that the image effectively is opaque, so we can do operator reductions
such as OVER->SRC.
2010-08-16 06:28:23 -04:00
Søren Sandmann Pedersen
32509aa4da Check for read accessors before taking the bilinear fast path
The bilinear fast path accesses pixels directly, so if the image has a
read accessor, then it can't be used.
2010-08-15 22:42:02 -04:00
Søren Sandmann Pedersen
052c5b819c If we bail out of do_composite, make sure to undo any workarounds.
The workaround for an old X bug has to be undone if we bail from
do_composite, so we can't just return.
2010-08-15 22:41:01 -04:00
Søren Sandmann Pedersen
91cb142177 When storing a g1 pixel, store the lowest bit, rather than comparing with 0. 2010-08-15 22:38:40 -04:00
Søren Sandmann Pedersen
a9a084c85c Fix memory leak in the pthreads thread local storage code
When a thread exits, we leak whatever is stored in thread local
variables, so install a destructor to free it.
2010-08-15 22:28:01 -04:00
Søren Sandmann Pedersen
4e5d6f00bf pixman_image_set_alpha_map(): Disallow alpha map cycles
If someone tries to set an alpha map that itself has an alpha map,
simply return. Also, if someone tries to add an alpha map to an image
that is being _used_ as an alpha map, simply return.

This ensures that an alpha map can never have an alpha map.
2010-08-15 22:08:16 -04:00
Søren Sandmann Pedersen
9fe7d32c4b Add alpha-loop test program
This tests what happens if you attempt to make an image with an alpha
map that has the image as its alpha map. This results in an infinite
loop in _pixman_image_validate(), so the test sets up a SIGALRM to
exit if it runs for more than five seconds.
2010-08-15 21:57:18 -04:00
Siarhei Siamashka
8a5d1be1da ARM: 'neon_combine_out_reverse_u' combiner
This operation was seen in mozilla browser profiling logs.
Implemented so that 'over' and 'out_reverse' operations
now reuse common parts of code.
2010-08-14 14:50:02 +00:00
Siarhei Siamashka
731e9feaa6 Code simplification (no need advancing 'vx' at the end of scanline) 2010-08-14 14:49:54 +00:00
Søren Sandmann Pedersen
41584f8fe1 Store the various bits image fetchers in a table with formats and flags.
Similarly to how the fast paths are done, put the various bits_image
fetchers in a table, so that we can quickly find the best one based on
the image's flags and format.
2010-08-08 13:57:40 -04:00
Søren Sandmann Pedersen
8e33643f44 Add some new FAST_PATH flags
The flags are:

 *  AFFINE_TRANSFORM, for affine transforms

 *  Y_UNIT_ZERO, for when the 10 entry in the transformation is zero

 *  FILTER_BILINEAR, for when the image has a bilinear filter

 *  NO_NORMAL_REPEAT, for when the repeat mode is not NORMAL

 *  HAS_TRANSFORM, for when the transform is not NULL

Also add some new FAST_PATH_REPEAT_* macros. These are just shorthands
for the image not having any of the other repeat modes. For example
REPEAT_NORMAL is (NO_NONE | NO_PAD | NO_REFLECT).
2010-08-08 13:57:40 -04:00
Søren Sandmann Pedersen
6f62231d15 Remove "_raw_" from all the accessors.
There are no non-raw accessors anymore.
2010-08-08 13:57:40 -04:00
Søren Sandmann Pedersen
807fd3c084 Eliminate the store_scanline_{32,64} function pointers.
Now that we can't recurse on alpha maps, they are not needed anymore.
2010-08-08 13:57:40 -04:00
Søren Sandmann Pedersen
e213d5fd62 Split bits_image_fetch_transformed() into two functions.
One function deals with the common affine, no-alpha-map case. The
other deals with perspective transformations and alpha maps.
2010-08-08 13:57:40 -04:00
Søren Sandmann Pedersen
cbb2a0d792 Eliminate get_pixel_32() and get_pixel_64() from bits_image.
These functions can simply be passed as arguments to the various pixel
fetchers. We don't need to store them. Since they are known at compile
time and the pixel fetchers are force_inline, this is not a
performance issue.

Also temporarily make all pixel access go through the alpha path.
2010-08-08 13:57:40 -04:00
Søren Sandmann Pedersen
6480c92312 Eliminate recursion from alpha map code
Alpha maps with alpha maps are no longer supported. It's not a useful
feature and it could could lead to infinite recursion.
2010-08-08 13:57:40 -04:00
Søren Sandmann Pedersen
1cc750ed92 Replace compute_src_extent_flags() with analyze_extents()
This commit fixes two separate problems: 1. Incorrect computation of
the FAST_PATH_SAMPLES_COVER_CLIP flag, and 2. FAST_PATH_16BIT_SAFE is
a nonsensical thing to compute.

== 1. Incorrect computation of SAMPLES_COVER_CLIP:

Previously we were using pixman_transform_bounds() to compute which
source samples would be used for a composite operation. This is
incorrect for several reasons:

(a) pixman_transform_bounds() is transforming the integer bounding box
of the destination samples, where it should be transforming the
bounding box of the samples themselves. In other words, it is too
pessimistic in some cases.

(b) pixman_transform_bounds() is not rounding the same way as we do
during sampling. For example, for a NEAREST filter we subtract
pixman_fixed_e before rounding off to the nearest sample so that a
transformed value of 1 will round to the sample at 0.5 and not to the
one at 1.5. However, pixman_transform_bounds() would simply truncate
to 1 which would imply that the first sample to be used was the one at
1.5. In other words, it is too optimistic in some cases.

(c) The result of pixman_transform_bounds() does not account for the
interpolation filter applied to the source.

== 2. FAST_PATH_16BIT_SAFE is nonsensical

The FAST_PATH_16BIT_SAFE is a flag that indicates that various
computations can be safely done within a 16.16 fixed-point
variable. It was used by certain fast paths who relied on those
computations succeeding. The problem is that many other compositing
functions were making similar assumptions but not actually requiring
the flag to be set. Notably, all the general compositing functions
simply walk the source region using 16.16 variables. If the
transformation happens to overflow, strange things will happen.

So instead of computing this flag in certain cases, it is better to
simply detect that overflows will happen and not try to composite at
all in that case. This has the advantage that most compositing
functions can be written naturally way.

It does have the disadvantage that we are giving up on some cases that
previously worked, but those are all corner cases where the areas
involved were very close to the limits of the coordinate
system. Relying on these working reliably was always a somewhat
dubious proposition. The most important case that might have worked
previously was untransformed compositing involving images larger than
32 bits. But even in those cases, if you had REPEAT_PAD or
REPEAT_REFLECT turned on, you would hit bits_image_fetch_transformed()
which has the 16 bit limitations.

== Fixes

This patch fixes both problems by introducing a new function called
analyze_extents() that has the responsibility to reject corner cases,
and to compute flags based on the extents.

It does this through a new compute_sample_extents() function that will
compute a conservative (but tight) approximation to the bounding box
of the samples that will actually be needed. By basing the computation
on the positions of the _sample_ locations in the destination, and by
taking the interpolation filter into account, it fixes problem one.

The same function is also used with a one-pixel expanded version of
the destination extents. By checking if the transformed bounding box
will overflow 16.16 fixed point, it fixes problem two.
2010-08-08 13:57:39 -04:00