Commit Graph

52 Commits

Author SHA1 Message Date
Søren Sandmann Pedersen
6b27768d81 Simplify the prototype for iterator initializers.
All of the information previously passed to the iterator initializers
is now available in the iterator itself, so there is no need to pass
it as arguments anymore.
2011-03-18 16:23:10 -04:00
Søren Sandmann Pedersen
74d0f44b6d Fill out parts of iters in _pixman_implementation_{src,dest}_iter_init()
This makes _pixman_implementation_{src,dest}_iter_init() responsible
for filling parts of the information in the iterators. Specifically,
the information passed as arguments is stored in the iterator.

Also add a height field to pixman_iter_t().
2011-03-18 16:23:10 -04:00
Andrea Canciani
8868778ea1 Do not include unused headers
pixman-combine32.h is included without being used both in
pixman-image.c and in pixman-general.c.
2011-02-28 10:38:02 +01:00
Søren Sandmann Pedersen
fffeda703e Skip fetching pixels when possible
Add two new iterator flags, ITER_IGNORE_ALPHA and ITER_IGNORE_RGB that
are set when the alpha and rgb values are not needed. If both are set,
then we can skip fetching entirely and just use
_pixman_iter_get_scanline_noop.
2011-01-18 12:42:26 -05:00
Søren Sandmann Pedersen
3e635d6491 Add direct-write optimization back
Introduce a new ITER_LOCALIZED_ALPHA flag that indicates that the
alpha value computed is used only for the alpha channel of the output;
it doesn't affect the RGB channels.

Then in pixman-bits-image.c, if a destination is either a8r8g8b8 or
x8r8g8b8 with localized alpha, the iterator will return a pointer
directly into the image.
2011-01-18 12:42:26 -05:00
Søren Sandmann Pedersen
51a5e949f3 Virtualize iterator initialization
Make src_iter_init() and dest_iter_init() virtual methods in the
implementation struct. This allows individual implementations to plug
in their own CPU specific scanline fetchers.
2011-01-18 12:42:26 -05:00
Søren Sandmann Pedersen
6503c6edcc Move iterator initialization to the respective image files
Instead of calling _pixman_image_get_scanline_32/64(), move the
iterator initialization into the respecive image implementations and
call the scanline generators directly.
2011-01-18 12:42:26 -05:00
Søren Sandmann Pedersen
b2c9eaa502 Move initialization of iterators for bits images to pixman-bits-image.c
pixman_iter_t is now defined in pixman-private.h, and iterators for
bits images are being initialized in pixman-bits-image.c
2011-01-18 12:42:25 -05:00
Søren Sandmann Pedersen
15b1645c7b Add iterators in the general implementation
We add a new structure called a pixman_iter_t that encapsulates the
information required to read scanlines from an image. It contains two
functions, get_scanline() and write_back(). The get_scanline()
function will generate pixels for the current scanline. For iterators
for source images, it will also advance to the next scanline. The
write_back() function is only called for destination images. Its
function is to write back the modified pixels to the image and then
advance to the next scanline.

When an iterator is initialized, it is passed this information:

   - The image to iterate

   - The rectangle to be iterated

   - A buffer that the iterator may (but is not required to) use. This
     buffer is guaranteed to have space for at least width pixels.

   - A flag indicating whether a8r8g8b8 or a16r16g16b16 pixels should
     be fetched

There are a number of (eventual) benefits to the iterators:

   - The initialization of the iterator can be virtualized such that
     implementations can plug in their own CPU specific get_scanline()
     and write_back() functions.

   - If an image is horizontal, it can simply plug in an appropriate
     get_scanline(). This way we can get rid of the annoying
     classify() virtual function.

   - In general, iterators can remember what they did on the last
     scanline, so for example a REPEAT_NONE image might reuse the same
     data for all the empty scanlines generated by the zero-extension.

   - More detailed information can be passed to iterator, allowing
     more specialized fetchers to be used.

   - We can fix the bug where destination filters and transformations
     are not currently being ignored as they should be.

However, this initial implementation is not optimized at all. We lose
several existing optimizations:

   - The ability to composite directly in the destination
   - The ability to only fetch one scanline for horizontal images
   - The ability to avoid fetching the src and mask for the CLEAR
     operator

Later patches will re-introduce these optimizations.
2011-01-18 12:42:25 -05:00
Siarhei Siamashka
3d094997b1 Fix for potential unaligned memory accesses
The temporary scanline buffer allocated on stack was declared
as uint8_t array. As a result, the compiler was free to select
any arbitrary alignment for it (even though there is typically
no reason to use really weird alignments here and the stack is
normally at least 4 bytes aligned on most platforms). Having
improper alignment is non-portable and can impact performance
or even make the code misbehave depending on the target platform.

Using uint64_t type for this array should ensure that any possible
memory accesses done by pixman code are going to be handled correctly
(pixman-combine64.c can access this buffer via uint64_t * pointer).

Some alignment related problem was reported in:
http://lists.freedesktop.org/archives/pixman/2010-November/000747.html
2010-12-07 02:10:51 +02:00
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
32bd31d677 Eliminate mask_bits from all the scanline fetchers.
Back in the day, the mask_bits argument was used to distinguish
between masks used for component alpha (where it was 0xffffffff) and
masks for unified alpha (where it was 0xff000000). In this way, the
fetchers could check if just the alpha channel was 0 and in that case
avoid fetching the source.

However, we haven't actually used it like that for a long time; it is
currently always either 0xffffffff or 0 (if the mask is NULL). It also
doesn't seem worthwhile resurrecting it because for premultiplied
buffers, if alpha is 0, then so are the color channels
normally.

This patch eliminates the mask_bits and changes the fetchers to just
assume it is 0xffffffff if mask is non-NULL.
2010-06-09 07:17:59 -04:00
Søren Sandmann Pedersen
fa4df6225d Eliminate all the composite methods.
They are no longer necessary because we will just walk the fast path
tables, and the general composite path is treated as another fast
path.

This unfortunately means that sse2_composite() can no longer be
responsible for realigning the stack to 16 bytes, so we have to move
that to pixman_image_composite().
2010-02-14 11:12:38 -05:00
Søren Sandmann Pedersen
543a04a3bb Store a pointer to the array of fast paths in the implementation struct.
Also add an empty fast path table to the vmx implementation, so that
we can assume sure the pointer is never NULL.
2010-02-14 11:12:16 -05:00
Søren Sandmann Pedersen
87430cfc35 Make general_composite_rect() just another fast path.
We introduce a new PIXMAN_OP_any fake operator and a PIXMAN_any fake
format that match anything. Then general_composite_rect() can be used
as another fast path.

Because general_composite_rect() does not require the sources to cover
the clip region, we add a new flag FAST_PATH_COVERS_CLIP which is part
of the set of standard flags for fast paths.

Because this flag cannot be computed until after the clip region is
available, we have to call pixman_compute_composite_region32() before
checking for fast paths. This will resolve itself when we get to the
point where _pixman_run_fast_path() is only called once per composite
operation.
2010-02-14 11:10:15 -05:00
Søren Sandmann Pedersen
2ef8b394d7 Use the destination buffer directly in more cases instead of fetching.
When the destination buffer is either a8r8g8b8 or x8r8g8b8, we can use
it directly instead of fetching into a temporary buffer. When the
format is x8r8g8b8, we require the operator to not make use of
destination alpha, but when it is a8r8g8b8, there are no restrictions.

This is approximately a 5% speedup on the poppler cairo benchmark:

[ # ]  backend                         test   min(s) median(s) stddev. count

Before:
[  0]    image                      poppler    6.661    6.709   0.59%    6/6

After:
[  0]    image                      poppler    6.307    6.320   0.12%    5/6
2009-11-17 00:42:21 -05:00
Søren Sandmann Pedersen
eb16d17188 Revert "Enable component alpha on solid masks."
For consistency we will probably want to allow component alpha to be
set on all masks at some point, but this commit only enabled it for
solid images.

This reverts commit 29e22cf38e.
2009-09-15 08:55:13 -04:00
Chris Wilson
29e22cf38e Enable component alpha on solid masks. 2009-09-13 16:29:42 +01:00
Søren Sandmann Pedersen
845910c200 Rename source_pict_class_t to source_image_class_t 2009-07-24 05:55:48 -04:00
Miha Vrhovnik
2356ba38fd Update Makefile.win32 to make it work again. 2009-07-20 19:30:59 -04:00
Søren Sandmann Pedersen
934f4f4604 Move read and write functions to the bits_image_t struct.
Those fields were duplicated between image_common and bits_image_t
before.
2009-07-17 22:40:41 -04:00
Søren Sandmann Pedersen
ac043ac2da Reindent and reformat pixman-general.c 2009-07-13 19:55:34 -04:00
Søren Sandmann Pedersen
a98b71eff4 Convert CamelCase names to underscore_names.
s/sizeRI/size_ri/g;
s/numRI/num_ri/g;
s/RepeatNone/REPEAT_NONE/g;
s/fbOver/over/g;
s/fbIn/in/g;
s/iSrc/src_image/g;
s/iMask/mask_image/g;
s/iDst/dest_image/g;
s/SaDa/Sa.Da/g;
s/FbMaskBits/MASK_BITS/g;
s/RenderSamplesX/RENDER_SAMPLES_X/g;
s/MMXData/mmx_data_t/g;
s/RegionInfo/region_info_t/g;

s/([^0x])([a-z])([A-Z])/$1$2_\l$3/g;
s/([^0x])([A-Z])([A-Z])([a-z])/$1$2_\l$3$4/g;
s/([^0x])([A-Z])([a-z]+)_([a-z])/$1\l$2$3_$4/g;
s/([a-z])_([A-Z])/$1_\l$2/g;

s/su_sE/SuSE/g;
s/X_Free86/XFree86/g;
s/X_free86/XFree86/g;

s/_ULL/ULL/g;
s/_uLL/ULL/g;

s/U_nc/UNc/g;
s/combine ##/combine_ ##/g;
s/## U/## _u/g;
s/## C/## _c/g;
s/UNc_aDD/UNc_ADD/g;

s/BLEND_MODE \((.+)\)/BLEND_MODE (\l$1)/g;
s/blend_(.+)/blend_\l$1/g;

s/AN_ds/ANDs/g;
s/O_rs/ORs/g;
s/over565/over_565/g;
s/8pix/8_pix/g;
s/Over565/over_565/g;
s/inU/in_u/g;
s/inPart/in_part/g;
s/inC/in_c/g;
s/inreverse/in_reverse/g;
s/get_exception_code/GetExceptionCode/g; # GetExceptionCode is WinCE API
s/CP_us/CPUs/g;
s/authentic_aMD/AuthenticAMD/g;
s/op_sR_cx_mAS_kx_dST/op_src_mask_dest/g;
s/no_VERBOSE/noVERBOSE/g;
s/mc_cormack/McCormack/g;
s/r1band/r1_band/g;
s/r2band/r2_band/g;
s/as GOOD things/as good things/g;
s/brokendata/broken_data/g;
s/X_render/XRender/g;
s/__open_bSD__/__OpenBSD__/g;
s/^Quick/quick/g;
s/NextRect/next_rect/g;
s/RectIn/rect_in/g;
s/pboxout/pbox_out/g;
s/F_sorted/FSorted/g;
s/usse2/u_sse2/g;
s/csse2/c_sse2/g;
s/cPixelsse2/c_pixel_sse2/g;
s/Mask565/mask_565/g;
s/565fix_rB/565_fix_rb/g;
s/565fix_g/565_fix_g/g;
s/565r/565_r/g;
s/565g/565_g/g;
s/565b/565_b/g;
s/uPixelsse2/u_pixel_sse2/g;
s/Mask00ff/mask_00ff/g;
s/Mask0080/mask_0080/g;
s/Mask0101/mask_0101/g;
s/Maskffff/mask_ffff/g;
s/Maskff000000/mask_ff000000/g;
s/load128Aligned/load_128_aligned/g;
s/load128Unaligned/load_128_unaligned/g;
s/save128Aligned/save_128_aligned/g;
s/save128Unaligned/save_128_unaligned/g;
s/fillsse2/fill_sse2/g;
s/unpack565/unpack_565/g;
s/pack565/pack_565/g;
s/bltsse2/blt_sse2/g;
s/x565Unpack/x565_unpack/g;
s/r1End/r1_end/g;
s/r2End/r2_end/g;
s/argb8Pixels/argb8_pixels/g;
2009-07-08 00:39:32 -04:00
Søren Sandmann Pedersen
084392fbd7 Delete scanFetchProc type. Use fetch_scanline_t instead.
fetch_scanline_t now takes a pixman_image_t argument instead of an
bits_image_t, so there is also a bunch of updates in pixman-access.c
2009-06-24 12:37:47 -04:00
Søren Sandmann Pedersen
70cba5cfa8 Consolidate the three scanline store types into one.
The 64 bit storers do their own type conversion.
2009-06-24 12:37:47 -04:00
Søren Sandmann Pedersen
bb3b3da18a Rename PIXMAN_FORMAT_16BPC macro to PIXMAN_FORMAT_IS_WIDE 2009-06-23 13:57:03 -04:00
M Joonas Pihlaja
b7b6847b66 Remove redundant NULL checks from general_composite_rect().
The general_composite_rect() function has two invocations
of the return_if_fail() macro before any of its variable
declarations.  Removing them allows for compilation to
succeed using a pre-C99 compiler.
2009-06-21 12:32:35 +03:00
Søren Sandmann Pedersen
78ca4eea64 Simplify clipping rule
The new rule is:

- Output is clipped to the destination clip region.

- If a source image has the clip_sources property set, then there
  is an additional step, after repeating and transforming, but before
  compositing, where pixels that are not in the source clip are
  rejected. Rejected means no compositing takes place (not that the
  pixel is treated as 0). By default source clipping is turned off;
  when they are turned on, only client-set clips are honored.

The old rules were unclear and inconsistently implemented.
2009-06-13 10:20:19 -04:00
Søren Sandmann Pedersen
85a2f55e6b Remove srcRepeat and maskRepeat arguments from _pixman_walk_composite_region() 2009-06-13 10:18:18 -04:00
Søren Sandmann Pedersen
dc0a9dd65a Remove all the srcRepeat/srcTransform stuff from the general implementation. 2009-06-13 10:18:18 -04:00
Søren Sandmann Pedersen
bd1cc87da3 Get rid of toplevel argument to implementation constructors.
It was always NULL anyway.
2009-06-02 16:51:28 -04:00
Søren Sandmann Pedersen
e3dba0f61a Create a vmx pixman_implementation_t 2009-05-30 21:54:28 -04:00
Jonathan Morton
f889ad9f36 Fixup the arm-simd and arm-neon implementations. 2009-05-29 13:38:45 -07:00
Søren Sandmann Pedersen
a5a249613b Call the toplevel implementation for combining 2009-05-23 12:12:42 -04:00
Søren Sandmann Pedersen
e5c367120a Set up combiner functions for an implementation directly in combine.inc.
Previously it would go through two big tables, and the general
implementation would select the correct one dynmcailly.
2009-05-23 12:12:42 -04:00
Søren Sandmann Pedersen
fb272d1464 Consolidate the general implementation into one function 2009-05-23 12:12:27 -04:00
Søren Sandmann Pedersen
6a22abd899 Move the argument struct into pixman_image_composite_rect 2009-05-23 12:05:02 -04:00
Søren Sandmann Pedersen
41a9a17e03 Delete pixman-sse2.h and pixman-mmx.h 2009-05-23 12:05:02 -04:00
Søren Sandmann Pedersen
5dc9671b25 Make the fast_path implementation run the c_fast_paths 2009-05-23 12:05:02 -04:00
Søren Sandmann Pedersen
364e218ad6 Split fill implementations out in the implementations 2009-05-23 12:05:02 -04:00
Søren Sandmann Pedersen
1369b0b9d4 Add a general_blt() that just returns FALSE 2009-05-23 12:05:01 -04:00
Søren Sandmann Pedersen
46f0707481 Move gcc alignment workaround to pixman-sse2.c 2009-05-23 12:05:01 -04:00
Søren Sandmann Pedersen
c8a2c336a7 Use the implementation's combiner's 2009-05-23 12:05:01 -04:00
Søren Sandmann Pedersen
03fa1bcb9a Move mmx fast path code to pixman-mmx.c 2009-05-23 12:05:01 -04:00
Søren Sandmann Pedersen
6e13149f99 Move sse2 fast path running to the sse2 implementation 2009-05-23 12:05:01 -04:00
Søren Sandmann Pedersen
cb8608bba4 Change pixman_lookup_fast_path() to actually run the fast path
Then just return in the general implementation if we ran a fast path.
2009-05-23 12:05:01 -04:00
Søren Sandmann Pedersen
713fb29576 Remove fast path lookup code from pixman-general 2009-05-23 12:05:01 -04:00
Søren Sandmann Pedersen
248ef3ec24 Initial fast path implementation
Move fbSrcScaleNearest() here, and move
_pixman_walk_composite_region() to pixman-utils.c
2009-05-23 12:05:01 -04:00
Søren Sandmann Pedersen
2c64b2a648 Change prototypes for compositing functions to use 32 bit integers 2009-05-23 12:05:00 -04:00