summaryrefslogtreecommitdiff
path: root/pixman/pixman-bits-image.c
AgeCommit message (Collapse)AuthorFilesLines
2012-12-18Change CONVERT_XXXX_TO_YYYY macros into inline functionsSiarhei Siamashka1-1/+1
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.
2012-12-08Add fast paths for separable convolutionSøren Sandmann Pedersen1-3/+180
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.
2012-12-08Add new pixman_filter_create_separable_convolution() APISøren Sandmann Pedersen1-2/+2
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).
2012-12-08Add new filter PIXMAN_FILTER_SEPARABLE_CONVOLUTIONSøren Sandmann Pedersen1-0/+102
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.
2012-11-22Convolution filter: round color values instead of truncatingSøren Sandmann Pedersen1-4/+4
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.
2012-10-21Add new pixman_image_create_bits_no_clear() APISøren Sandmann Pedersen1-11/+43
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.
2012-10-01Remove 64 bit pipelineSøren Sandmann Pedersen1-48/+1
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.
2012-10-01Switch the wide pipeline over to using floating pointSøren Sandmann Pedersen1-35/+31
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
2012-10-01pixman-access.c: Add floating point accessor functionsSøren Sandmann Pedersen1-7/+33
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.
2012-08-19Remove pointless declaration of _pixman_image_get_scanline_generic_64()Søren Sandmann Pedersen1-4/+0
This declaration used to be necessary when _pixman_image_get_scanline_generic_64() referred to a structure that itself referred back to _pixman_image_get_scanline_generic_64().
2012-07-01Bilinear interpolation precision is now configurable at compile timeSiarhei Siamashka1-8/+8
Macro BILINEAR_INTERPOLATION_BITS in pixman-private.h selects the number of fractional bits used for bilinear interpolation. scaling-test and affine-test have checksums for 4-bit, 7-bit and 8-bit configurations.
2012-06-11bits-image: Turn all the fetchers into iterator gettersSøren Sandmann Pedersen1-101/+113
Instead of caching these fetchers in the image structure, and then have the iterator getter call them from there, simply change them to be iterator getters themselves. This avoids an extra indirect function call and lets us get rid of the get_scanline_32/64 fields in pixman_image_t.
2012-05-30Pass the full image flags to iteratorsSøren Sandmann Pedersen1-3/+3
When pixman_image_composite32() is called some flags are computed that indicate various things about the composite operation that can't be deduced from the image flags themselves. These additional flags are not currently available to iterators. All they can do is read the image flags in image->common.flags. Fix that by passing the info->{src, mask, dest}_flags on to the iterator initialization and store the flags in the iter struct as "image_flags". At the same time rename the *iterator* flags variable to "iter_flags" to avoid confusion.
2012-04-20bits_image_fetch_pixel_convolution(): Make sure channels are signedSøren Sandmann Pedersen1-5/+5
In the computation: srtot += RED_8 (pixel) * f RED_8 (pixel) is an unsigned quantity, which means the signed filter coefficient f gets converted to an unsigned integer before the multiplication. We get away with this because when the 32 bit unsigned result is converted to int32_t, the correct sign is produced. But if srtot had been an int64_t, the result would have been a very large positive number. Fix this by explicitly casting the channels to int.
2012-03-01Move fetching for solid bits images to pixman-noop.cSøren Sandmann Pedersen1-28/+0
This should be a bit faster because it can reuse the scanline on each iteration.
2012-01-10Fix bugs with alpha mapsSøren Sandmann Pedersen1-11/+42
The alpha channel from the alpha map must be inserted as the new alpha channel when a scanline is fetched from an image. Previously the alpha map would overwrite the buffer instead. This wasn't caught be the alpha map test because it would only verify that the resulting alpha channel was correct, and not pay attention to incorrect color channels.
2011-10-10init/fini functions for pixman_image_tTaekyun Kim1-28/+46
pixman_image_t itself can be on stack or heap. So segregating init/fini from create/unref can be useful when we want to use pixman_image_t on stack or other memory.
2011-09-09bits: optimise fetching width==1 repeatsChris Wilson1-14/+44
Profiling ign.com, 20% of the entire render time was absorbed in this single operation: << /content //COLOR_ALPHA /width 480 /height 800 >> surface context << /width 1 /height 677 /format //ARGB32 /source <|!!!@jGb!m5gD']#$jFHGWtZcK&2i)Up=!TuR9`G<8;ZQp[FQk;emL9ibhbEL&NTh-j63LhHo$E=mSG,0p71`cRJHcget4%<S\X+~> >> image pattern //EXTEND_REPEAT set-extend set-source n 0 0 480 677 rectangle fill+ pop which is a simple composition of a single pixel wide image. Sadly this is a workaround for lack of independent repeat-x/y handling in cairo and pixman. Worse still is that the worst-case behaviour of the general repeat path is for width 1 images... Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-08-19Move bilinear interpolation to pixman-inlines.hSøren Sandmann Pedersen1-91/+0
2011-08-19Use repeat() function from pixman-inlines.h in pixman-bits-image.cSøren Sandmann Pedersen1-42/+15
The repeat() functionality was duplicated between pixman-bits-image.c and pixman-inlines.h
2011-08-15In pixman_image_create_bits() allow images larger than 2GBSøren Sandmann Pedersen1-5/+5
There is no reason for pixman_image_create_bits() to check that the image size fits in int32_t. The correct check is against size_t since that is what the argument to calloc() is. This patch fixes this by adding a new _pixman_multiply_overflows_size() and using it in create_bits(). Also prepend an underscore to the names of other similar functions since they are internal to pixman. V2: Use int, not ssize_t for the arguments in create_bits() since width/height are still limited to 32 bits, as pointed out by Chris Wilson.
2011-05-19Move noop dest fetching to noop implementationSøren Sandmann Pedersen1-26/+5
It will at some point become useful to have CPU specific destination iterators. However, a problem with that, is that such iterators should not be used if we can composite directly in the destination image. By moving the noop destination iterator to the noop implementation, we can ensure that it will be chosen before any CPU specific iterator.
2011-03-18Simplify the prototype for iterator initializers.Søren Sandmann Pedersen1-13/+7
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-01-19Fix dangling-pointer bug in bits_image_fetch_bilinear_no_repeat_8888().Søren Sandmann Pedersen1-3/+2
The mask_bits variable is only declared in a limited scope, so the pointer to it becomes invalid instantly. Somehow this didn't actually trigger any bugs, but Brent Fulgham reported that Bounds Checker was complaining about it. Fix the bug by moving mask_bits to the function scope.
2011-01-18Fix destination fetchingSøren Sandmann Pedersen1-4/+32
When fetching from destinations, we need to ignore transformations, repeat and filtering. Currently we don't ignore them, which means all kinds of bad things can happen. This bug fixes this problem by directly calling the scanline fetchers for destinations instead of going through the full get_scanline_32/64().
2011-01-18Skip fetching pixels when possibleSøren Sandmann Pedersen1-1/+10
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-18Add direct-write optimization backSøren Sandmann Pedersen1-2/+23
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-18Move get_scanline_32/64 to the bits part of the image structSøren Sandmann Pedersen1-6/+43
At this point these functions are basically a cache that the bits image uses for its fetchers, so they can be moved to the bits image. With the scanline getters only being initialized in the bits image, the _pixman_image_get_scanline_generic_64 can be moved to pixman-bits-image.c. That gets rid of the final user of _pixman_image_get_scanline_32/64, so these can be deleted.
2011-01-18Eliminate the _pixman_image_store_scanline_32/64 functionsSøren Sandmann Pedersen1-43/+36
They were only called from next_line_write_narrow/wide, so they could simply be absorbed into those functions.
2011-01-18Move initialization of iterators for bits images to pixman-bits-image.cSøren Sandmann Pedersen1-0/+80
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-16Fix for "syntax error: empty declaration" Solaris Studio warningsSiarhei Siamashka1-19/+19
2011-01-16Revert "Fix "syntax error: empty declaration" warnings."Siarhei Siamashka1-4/+2
This reverts commit b924bb1f8191cc7c386d8211d9822aeeaadcab44. There is a better fix for these Solaris Studio warnings.
2010-11-16Generate {a,x}8r8g8b8, a8, 565 fetchers for nearest/affine imagesSøren Sandmann Pedersen1-33/+144
There are versions for all combinations of x8r8g8b8/a8r8g8b8 and pad/repeat/none/normal repeat modes. The bulk of each function is an inline function that takes a format and a repeat mode as parameters.
2010-10-04Fix "syntax error: empty declaration" warnings.Mika Yrjola1-1/+2
These minor changes should fix a large number of macro declaration - related "syntax error: empty declaration" warnings which are seen while compiling the code with the Solaris Studio compiler.
2010-09-21Enable bits_image_fetch_bilinear_affine_normal_r5g6b5Søren Sandmann Pedersen1-4/+0
2010-09-21Enable bits_image_fetch_bilinear_affine_reflect_r5g6b5Søren Sandmann Pedersen1-2/+2
2010-09-21Enable bits_image_fetch_bilinear_affine_none_r5g6b5Søren Sandmann Pedersen1-2/+2
2010-09-21Enable bits_image_fetch_bilinear_affine_pad_r5g6b5Søren Sandmann Pedersen1-2/+2
2010-09-21Enable bits_image_fetch_bilinear_affine_normal_a8Søren Sandmann Pedersen1-2/+2
2010-09-21Enable bits_image_fetch_bilinear_affine_reflect_a8Søren Sandmann Pedersen1-2/+2
2010-09-21Enable bits_image_fetch_bilinear_affine_none_a8Søren Sandmann Pedersen1-2/+2
2010-09-21Enable bits_image_fetch_bilinear_affine_pad_a8Søren Sandmann Pedersen1-2/+2
2010-09-21Enable bits_image_fetch_bilinear_affine_normal_x8r8g8b8Søren Sandmann Pedersen1-2/+2
2010-09-21Enable bits_image_fetch_bilinear_affine_reflect_x8r8g8b8Søren Sandmann Pedersen1-2/+2
2010-09-21Enable bits_image_fetch_bilinear_affine_none_x8r8g8b8Søren Sandmann Pedersen1-2/+2
2010-09-21Enable bits_image_fetch_bilinear_affine_pad_x8r8g8b8Søren Sandmann Pedersen1-2/+2
2010-09-21Enable bits_image_fetch_bilinear_affine_normal_a8r8g8b8Søren Sandmann Pedersen1-2/+2
2010-09-21Enable bits_image_fetch_bilinear_affine_reflect_a8r8g8b8Søren Sandmann Pedersen1-2/+2
2010-09-21Enable bits_image_fetch_bilinear_affine_none_a8r8g8b8Søren Sandmann Pedersen1-2/+2
2010-09-21Enable bits_image_fetch_bilinear_affine_pad_a8r8g8b8Søren Sandmann Pedersen1-2/+2