summaryrefslogtreecommitdiff
path: root/pixman
Commit message (Collapse)AuthorAgeFilesLines
* fast-path: Fix some sketchy pointer arithmeticAdam Jackson2020-04-021-7/+7
| | | | | | | | | We want a uint8_t * at the end of this math, because that's what the function we're about to pass it to takes. But ->bits is a uint32_t, so if we just do the math in units of that we can avoid the explicit factor of four which would risk an integer overflow. Fixes: pixman/pixman#14
* Initialize temporary buffers in general_composite_rect()Federico Mena Quintero2020-03-181-0/+6
| | | | | | | | Otherwise, Valgrind shows things like "conditional jump or move depends on uninitialised values" errors much later in calling code. For example, see https://gitlab.gnome.org/GNOME/librsvg/issues/572 Fixes https://gitlab.freedesktop.org/pixman/pixman/issues/9
* pixman-compiler.h: fix building tests with MinGWAntonio Ospite2020-03-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | MinGW supports __declspec(dllexport) but the current logic that sets PIXMAN_EXPORT only uses it when building with MSVC, leaving some symbols hidden when building with MinGW. This results in an error when trying to link the tests: ----------------------------------------------------------------------- FAILED: subprojects/pixman/test/combiner-test.exe x86_64-w64-mingw32-gcc -o subprojects/pixman/test/combiner-test.exe 'subprojects/pixman/test/f48fa9c@@combiner-test@exe/combiner-test.c.obj' -Wl,--allow-shlib-undefined -Wl,--start-group subprojects/pixman/test/libtestutils.a subprojects/pixman/pixman/libpixman-1.dll.a -pthread -fopenmp -fopenmp -lm -mconsole -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -Wl,--end-group /usr/bin/x86_64-w64-mingw32-ld: subprojects/pixman/test/f48fa9c@@combiner-test@exe/combiner-test.c.obj: in function `main': .../build/../subprojects/pixman/test/combiner-test.c:124: undefined reference to `_pixman_internal_only_get_implementation' collect2: error: ld returned 1 exit status ninja: build stopped: subcommand failed. ----------------------------------------------------------------------- By using PIXMAN_API also when building with MinGW, the tests can link successfully and the build succeed. Tested with x86_64-w64-mingw32-gcc (GCC) 8.3-win32 20191201.
* pixman-combine: Fix wrong value of RB_MASK_PLUS_ONE.Yin Shiyou2020-02-201-1/+1
| | | | | No functional change, as explained by Søren in https://lists.freedesktop.org/archives/pixman/2020-February/004902.html
* pixman/meson.build: Define PIXMAN_API on MSVC-style compilersChun-wei Fan2019-11-191-1/+7
| | | | | This will make the public APIs exported from the DLL, so that we have an import libary that we can use.
* pixman-[compiler|private].h: Export symbols for testsChun-wei Fan2019-11-192-0/+5
| | | | | | | | | Define the existing PIXMAN_EXPORT to be PIXMAN_API, which can overriden to be __declspec(dllexport) during the build of the pixman DLL on MSVC builds, which will be in the next patch. Also, export more private symbols as they are needed for the test programs.
* pixman/pixman.h: Mark public APIs with PIXMAN_APIChun-wei Fan2019-11-191-0/+274
| | | | | We can override PIXMAN_API with a CFLAG or config.h define to export the symbols with compiler directives, if needed.
* pixman/pixman-version.h.in: Add a PIXMAN_API macroChun-wei Fan2019-11-191-0/+4
| | | | | | This prepares to mark the public APIs that we have in pixman.h so that we can use compiler directives such as __declspec(dllexport) to export those symbols.
* pixman-sse2: Fix undefined unaligned loadsAdam Jackson2019-11-131-15/+18
|
* pixman-mmx: Fix undefined unaligned loadsAdam Jackson2019-11-131-3/+7
|
* pixman-mmx: Fix undefined left-shiftsAdam Jackson2019-11-131-2/+2
|
* pixman-matrix: Fix left shift of a negative numberAdam Jackson2019-11-011-1/+1
| | | | ../pixman/pixman-matrix.c:276:35: runtime error: left shift of negative value -32768
* pixman-bits-image: Fix left shift of a negative numberAdam Jackson2019-11-011-2/+2
| | | | ../pixman/pixman-bits-image.c:678:33: runtime error: left shift of negative value -32768
* pixman-bits-image: Fix various undefined left shiftsAdam Jackson2019-10-151-14/+16
| | | | ../pixman/pixman-bits-image.c:221:20: runtime error: left shift of 204 by 24 places cannot be represented in type 'int'
* pixman-fast-path: Fix various undefined left shiftsAdam Jackson2019-10-151-2/+2
| | | | ../pixman/pixman-fast-path.c:3089:23: runtime error: left shift of 154 by 24 places cannot be represented in type 'int'
* pixman-sse2: Fix an undefined left shiftAdam Jackson2019-10-151-2/+2
| | | | ../pixman/pixman-sse2.c:3346:14: runtime error: left shift of 41891 by 16 places cannot be represented in type 'int'
* pixman-gradient-walker: Fix undefined left shiftAdam Jackson2019-10-151-4/+4
| | | | ../pixman/pixman-gradient-walker.c:216:35: runtime error: left shift of 163 by 24 places cannot be represented in type 'int'
* pixman-image: Fix undefined left shiftAdam Jackson2019-10-151-1/+1
| | | | ../pixman/pixman-image.c:963:46: runtime error: left shift of 255 by 24 places cannot be represented in type 'int'
* pixman-combine: Fix various undefined left shiftsAdam Jackson2019-10-151-2/+2
| | | | | | | | ../pixman/pixman-combine32.c:657:1: runtime error: left shift of 128 by 24 places cannot be represented in type 'int' ../pixman/pixman-combine32.c:694:1: runtime error: left shift of 232 by 24 places cannot be represented in type 'int' ../pixman/pixman-combine32.c:712:1: runtime error: left shift of 255 by 24 places cannot be represented in type 'int' ../pixman/pixman-combine32.c:786:1: runtime error: left shift of 255 by 24 places cannot be represented in type 'int' ../pixman/pixman-combine32.c:805:1: runtime error: left shift of 255 by 24 places cannot be represented in type 'int'
* pixman-access: Fix various undefined left shiftsAdam Jackson2019-10-151-16/+16
| | | | | | ../pixman/pixman-access.c:389:2: runtime error: left shift of 1 by 31 places cannot be represented in type 'int' ../pixman/pixman-access.c:1101:2: runtime error: left shift of 2 by 30 places cannot be represented in type 'int' ../pixman/pixman-access.c:1152:2: runtime error: left shift of 2 by 30 places cannot be represented in type 'int'
* pixman: Fix undefined left shift in pixel_contract_from_floatAdam Jackson2019-10-151-1/+1
| | | | ../pixman/pixman-utils.c:216:14: runtime error: left shift of 255 by 24 places cannot be represented in type 'int'
* Avoid undefined behavior (left-shifting negative value) in pixman_int_to_fixedJonathan Kew2019-09-111-1/+1
| | | Reported in https://bugzilla.mozilla.org/show_bug.cgi?id=1580352. Casting the argument to uint32_t should avoid invoking undefined behavior here. We'll still have *implementation-defined* behavior when casting the result back to pixman_fixed_t, but that's better than *undefined*.
* meson: don't use link_with for library()Dylan Baker2019-09-091-1/+8
| | | | | | | | | | | | Meson doesn't do the expected thing when library() creates a static library. Instead of combining the libraries together into a single archive it effectively discards them, resulting in missing symbols. To work around this we manually unpack the archives and shove the .o files into the final library. This doesn't affect the shared library at all, but makes the static library have the necessary symbols Fixes #33
* Explicitly cast byte to uint32_t before left-shifting.Jonathan Kew2019-08-301-2/+2
| | | | | To avoid potential signed integer overflow (undefined behavior), as implicit integer promotion means the operand becomes a (signed) int. (Issue originally reported at https://bugzilla.mozilla.org/show_bug.cgi?id=1577669)
* meson: allow building a static libraryChristoph Reiter2019-06-101-1/+1
| | | | | | | | So that passing "-Ddefault_library=both" also creates a static lib. Note that Libs.private in the .pc file will still be wrong because of https://github.com/mesonbuild/meson/issues/3934 (it contains things like -lpixman-mmx)
* Don't use GNU extension for binary numbersBasile Clement2019-06-101-3/+3
| | | | | | | | | | | | The dithering code (specifically `dither_factor_bayer_8`) uses a GNU extension for binary notation, eg 0b001. This is not supported by MSVC (at least) and breaks the build on this platform [1]. This patches uses hexadecimal notation instead, fixing the build. [1]: https://lists.freedesktop.org/archives/pixman/2019-June/004883.html Reviewed-by: Matt Turner <mattst88@gmail.com>
* Ordered dithering with blue noise, v2Basile Clement2019-05-254-1/+770
| | | | | | | | | | | | | | | | | | | | | | On some screens (typically low quality laptop screens), using Bayer ordered dithering has been observed to cause color changes depending on *where the gradient is rendered on the screen*, causing visible flickering when moving an image on the screen. To alleviate the issue, this patch adds support for ordered dithering using a 64x64 matrix tuned from blue noise. In addition to being devoid of the positional dependency on screen, the blue noise matrix also generates more pleasing and less discernable patterns. As such, it is now the method used for PIXMAN_DITHER_GOOD and PIXMAN_DITHER_BEST dithering methods. The 64x64 blue noise matrix has been generated using the provided `pixman/dither/make-blue-noise.c` script, which uses the void-and-cluster method. Changes since v1 (thanks Bill): - Use uint16_t for the blue noise matrix for lower memory usage - Use bitwise computation for array index
* Implement basic dithering for the wide pipeline, v3Basile Clement2019-05-255-1/+177
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch implements dithering in pixman. A "dither" property is added to BITS images, which is used to: - Force rendering to the image to go through the floating point pipeline. Note that this is different from FAST_PATH_NARROW_FORMAT as it should not enable the floating point pipeline when reading from the image. - Enable dithering in dest_write_back_wide. The dithering uses the destination format to determine noise amplitude. This does not change pixman's behavior when dithering is disabled (the default). Additional types and functions are added to the public API: - The `pixman_dither_t` enum exposes the available dithering methods. Currently a single dithering method based on 8x8 Bayer matrices is implemented (PIXMAN_DITHER_ORDERED_BAYER_8). The PIXMAN_DITHER_FAST, PIXMAN_DITHER_GOOD and PIXMAN_DITHER_BEST aliases are provided and should be used to benefit from future specializations. - The `pixman_image_set_dither` function allows to set the dithering method to use when rendering to a bits image. - The `pixman_image_set_dither_offset` function allows to set a vertical and horizontal offsets for the dither matrix. This can be used after scrolling to ensure a consistent spatial positioning of the dither matrix. Changes since previous version (v2): - linear_gradient_is_horizontal optimization is still compatible with the wide pipeline. The code disabling it was a remnant of a previous patch which performed dithering directly inside linear_get_scanline, and thus needed to be called independently for each scanline. Changes since v1: - Renamed PIXMAN_DITHER_BAYER_8 to PIXMAN_DITHER_ORDERED_BAYER_8 - Disable dithering for channels with 32bpp or more (since they can represent exactly the wide values already). This makes the patches compatible with the newly added floating point format. Dithering is compatible with linear_gradient_is_horizontal
* add Hygon Dhyana support to enable X86_MMX_EXTENSIONS featureFan Jinke2019-05-021-0/+1
| | | | | Signed-off-by: Fan Jinke <fanjinke@hygon.cn> Signed-off-by: Matt Turner <mattst88@gmail.com>
* Fix bilinear filter computation in wide pipelineBasile Clement2019-04-112-1/+10
| | | | | | | | | | | | | | | | | | The recently introduced wide pipeline for filters has a typo which causes it to improperly compute bilinear interpolation positions, causing various glitches when enabled. This patch uses the proper computation for bilinear interpolation in the wide pipeline. It also makes related `if` statements conformant to the CODING_STYLE: * If a substatement spans multiple lines, then there must be braces around it. * If one substatement of an if statement has braces, then the other must too. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
* void function should not return a valueNiveditha Rau2019-03-271-6/+24
| | | | Signed-off-by: Matt Turner <mattst88@gmail.com>
* meson: simplify and fix mmx library compilationDylan Baker2019-03-271-9/+9
| | | | | This simplifies the logic and fixes the loongson-mmi implementation to build correctly.
* meson: fix copy-n-paste error for arm simd assemblyDylan Baker2019-03-271-1/+1
| | | | mentioned in #29
* pixman: Use maximum precision for pixman-bits-image, v2.Maarten Lankhorst2019-02-112-111/+328
| | | | | | | | | | | | | | | | | | | pixman-bits-image's wide helpers first obtains the 8-bits image, then converts it to float. This destroys all the precision that the wide path was offering. Fix this by making get_pixel() take a pointer instead of returning a value. Floating point will fill in a argb_t, while the 8-bits path will fill a 32-bits ARGB value. This also requires writing a floating point bilinear interpolator. With this change pixman can use the full floating point precision internally in all paths. Changes since v1: - Make accum and reduce an argument to convolution functions, to remove duplication. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Acked-by: Basile Clement <basile-pixman@clement.pm>
* Implement floating point gradient computation, v2.Basile Clement2019-02-115-110/+234
| | | | | | | | | | | | | | | | | | | | This patch modifies the gradient walker to be able to generate floating point values directly in addition to a8r8g8b8 32 bit values. This is then used by the various gradient implementations to render in floating point when asked to do so, instead of rendering to a8r8g8b8 and then expanding to floating point as they were doing previously. Changes since v1 (mlankhorst): - Implement pixman_gradient_walker_pixel_32 without calling pixman_gradient_walker_pixel_float, to prevent performance degradation. Suggested by Adam Jackson. - Fix whitespace errors. - Remove unnecessary function prototypes in pixman-private.h Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> [mlankhorst: Add comment about pixman_contract_from_float, based on Basille's suggestion] Acked-by: Basile Clement <basile-pixman@clement.pm>
* build: Add meson files to EXTRA_DISTDylan Baker2019-01-151-0/+1
| | | | Reviewed-by: Matt Turner <mattst88@gmail.com>
* meson: Add a meson build systemDylan Baker2018-11-291-0/+116
| | | | | | | | | | | | | | | | | | | | | This commit adds a meson build system for pixman. It carries the usual improvements of meson, better clean build time, much better incremental build times, while being simpler and easier to understand. This takes advantage of some features from the most recent versions of meson: the builtin openmp dependency and the feature option type. There are a couple of things that I've done a bit differently than the autotools build system, I've built a libdemos which is the utilities from the demos folder, and I've linked the demos with libtestutils from tetsts, otherwise I expect that most things will be the same. I've tested so far cross compiling from x86_64 -> x86, x86_64 -> Aarch64, and Linux to Windows via mingw, as well as native x86_64 Linux builds which all work. I've also built with mingw nativly, there are some test failures there. An MSVC build can be generated, but fails. v2: - set WORDS_BIGENDIAN in the config for big endian systems.
* pixman: Add support for argb/xrgb float formats, v5.Maarten Lankhorst2018-11-065-9/+166
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Pixman is already using the floating point formats internally, expose this capability in case someone wants to support higher bit per component formats. This is useful for igt which depends on cairo to do the rendering. It can use it to convert floats internally to planar Y'CbCr formats, or to F16. We add a new type PIXMAN_TYPE_RGBA_FLOAT for this format, which is an all float array of R, G, B, and A. Formats that use mixed float/int RGBA aren't supported, and will probably need their own type. Changes since v1: - Use RGBA 128 bits and RGB 96 bits memory layouts, to better match the opengl format. Changes since v2: - Add asserts in accessor and for strides to force alignment. - Move test changes to their own commit. Changes since v3: - Define 32bpc as PIXMAN_FORMAT_PACKED_C32 - Rename pixman accessors from rgb*_float_float to rgb*f_float Changes since v4: - Create a new PIXMAN_FORMAT_BYTE for fitting up to 64 bits per component. (based on Siarhei Siamashka's suggestion) - Use new format type PIXMAN_TYPE_RGBA_FLOAT Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> #v4 [mlankhorst: Fix missing braces in PIXMAN_FORMAT_RESHIFT macro]
* vmx: Fix vector loads on ppc64leDan Horák2018-05-141-1/+1
| | | | | | | | | | | Use vector intrinsic for loading possibly unaligned data instead of a typecast. Bugzilla: https://bugzilla.redhat.com/1572540 Signed-off-by: Dan Horák <dan@danny.cz> Signed-off-by: Adam Jackson <ajax@redhat.com> Tested-by: Matt Turner <mattst88@gmail.com> Reviewed-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
* Promote unsigned short to unsigned int explicitlyBehdad Esfahbod2018-01-091-4/+4
| | | | | ...to avoid default promotion to signed int, which causes undefined behaviour in the shift expression.
* pixman-filter: Made Gaussian a bit widerBill Spitzak2016-09-031-1/+1
| | | | | | | | | | | | | | Expanded the size slightly (from ~4.25 to 5) to make the cutoff less noticable. Previouly the value at the cutoff was gaussian_filter(sqrt(2)*3/2) = 0.00626 which is larger than the difference between 8-bit pixels (1/255 = 0.003921). New cutoff is gaussian_filter(2.5) = 0.001089 which is smaller. v11: added some math to commit message v14: left SIGMA in there Signed-off-by: Bill Spitzak <spitzak@gmail.com> Acked-by: Oded Gabbay <oded.gabbay@gmail.com> Reviewed-by: Søren Sandmann <soren.sandmann@gmail.com>
* pixman-filter: Nested polynomial for cubicBill Spitzak2016-09-031-6/+8
| | | | | | | v11: Restored range checks Signed-off-by: Bill Spitzak <spitzak@gmail.com> Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com>
* pixman-filter: Fix several issues related to normalizationSøren Sandmann Pedersen2016-09-031-8/+15
| | | | | | | | | | | | | | | | | | | | | | | | There are a few bugs in the current normalization code (1) The normalization is based on the sum of the *floating point* values generated by integral(). But in order to get the sum to be close to pixman_fixed_1, the sum of the rounded fixed point values should be used. (2) The multiplications in the normalization loops often round the same way, so the residual error can fairly large. (3) The residual error is added to the sample located at index (width - width / 2), which is not the midpoint for odd widths (and for width 1 is in fact outside the array). This patch fixes these issues by (1) using the sum of the fixed point values as the total to divide by, (2) doing error diffusion in the normalization loop, and (3) putting any residual error (which is now guaranteed to be less than pixman_fixed_e) at the first sample, which is the only one that didn't get any error diffused into it. Signed-off-by: Søren Sandmann <soren.sandmann@gmail.com>
* pixman-filter: Speed up BOX/BOX filterSøren Sandmann Pedersen2016-09-021-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | The convolution of two BOX filters is simply the length of the interval where both are non-zero, so we can simply return width from the integral() function because the integration region has already been restricted to be such that both functions are non-zero on it. This is both faster and more accurate than doing numerical integration. This patch is based on one by Bill Spitzak https://lists.freedesktop.org/archives/pixman/2016-March/004446.html with these changes: - Rebased to not assume any changes in the arguments to integral(). - Dropped the multiplication by scale - Added more details in the commit message. Signed-off-by: Søren Sandmann <soren.sandmann@gmail.com> Reviewed-by: Bill Spitzak <spitzak@gmail.com>
* pixman-filter: integral splitting is only needed for triangle filterBill Spitzak2016-09-021-6/+5
| | | | | | | | | | | | | Only the triangle is discontinuous at 0. The other filters resemble a cubic closely enough that Simpsons integration works without splitting. Changes by Søren: Rebase without the changes to the integral function, update comment to match the new code. Signed-off-by: Bill Spitzak <spitzak@gmail.com> Signed-off-by: Søren Sandmann <soren.sandmann@gmail.com> Reviewed-by: Søren Sandmann <soren.sandmann@gmail.com>
* pixman-filter: Correct Simpsons integrationBill Spitzak2016-09-021-6/+15
| | | | | | | | | | | | | | | | | | | | | Simpsons uses cubic curve fitting, with 3 samples defining each cubic. This makes the weights of the samples be in a pattern of 1,4,2,4,2...4,1, and then dividing the result by 3. The previous code was using weights of 1,2,0,6,0,6...,2,1. With this fix the integration is accurate enough that the number of samples could be reduced a lot. Multiples of 12 seem to work best. v7: Merged with patch to reduce from 128 samples to 16 v9: Changed samples from 16 to 12 v10: Fixed rebase error that made it not compile v11: minor whitespace change v14: more whitespace changes Signed-off-by: Bill Spitzak <spitzak@gmail.com> Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com> Reviewed-by: Søren Sandmann <soren.sandmann@gmail.com>
* pixman-filter: reduce amount of malloc/free/memcpy to generate filterBill Spitzak2016-09-021-33/+23
| | | | | | | | | | | | | | | | | | | Rearranged so that the entire block of memory for the filter pair is allocated first, and then filled in. Previous version allocated and freed two temporary buffers for each filter and did an extra memcpy. v8: small refactor to remove the filter_width function v10: Restored filter_width function but with arguments changed to match later patches v11: Removed unused arg and pointer from filter_width function Whitespace fixes. Signed-off-by: Bill Spitzak <spitzak@gmail.com> Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com> Acked-by: Søren Sandmann <soren.sandmann@gmail.com>
* pixman-image: Added enable-gnuplot config to view filters in gnuplotBill Spitzak2016-09-022-0/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If enable-gnuplot is configured, then you can pipe the output of a pixman-using program to gnuplot and get a continuously-updated plot of the horizontal filter. This works well with demos/scale to test the filter generation. The plot is all the different subposition filters shuffled together. This is misleading in a few cases: IMPULSE.BOX - goes up and down as the subfilters have different numbers of non-zero samples IMPULSE.TRIANGLE - somewhat crooked for the same reason 1-wide filters - looks triangular, but a 1-wide box would be more accurate Changes by Søren: Rewrote the pixman-filter.c part to - make it generate correct coordinates - add a comment on how coordinates are generated - in rounding.txt, add a ceil() variant of the first-sample formula - make the gnuplot output slightly prettier v7: First time this ability was included v8: Use config option Moved code to the filter generator Modified scale demo to not call filter generator a second time. v10: Only print if successful generation of plots Use #ifdef, not #if v11: small whitespace fixes v12: output range from -width/2 to width/2 and include y==0, to avoid misleading plots for subsample_bits==0 and for box filters which may have no small values. Signed-off-by: Bill Spitzak <spitzak@gmail.com>
* More general BILINEAR=>NEAREST reductionSøren Sandmann Pedersen2016-09-021-28/+38
| | | | | | | | | | | | | | Generalize and simplify the code that reduces BILINEAR to NEAREST so that the reduction happens for all affine transformations where t00...t12 are integers and (t00 + t01) and (t10 + t11) are both odd. This is a sufficient condition for the resulting transformed coordinates to be exactly at the center of a pixel so that BILINEAR becomes identical to NEAREST. V2: Address some comments by Bill Spitzak Signed-off-by: Søren Sandmann <soren.sandmann@gmail.com> Reviewed-by: Bill Spitzak <spitzak@gmail.com>
* pixman-fast-path.c: Pick NEAREST affine fast paths before BILINEAR onesSøren Sandmann Pedersen2016-09-021-2/+2
| | | | | | | | | When a BILINEAR filter is reduced to NEAREST, it is possible for both types of fast paths to run; in this case, the NEAREST ones should be preferred as that is the simpler filter. Signed-off-by: Soren Sandmann <soren.sandmann@gmail.com> Reviewed-by: Bill Spitzak <spitzak@gmail.com>