summaryrefslogtreecommitdiff
path: root/src/cairo-image-compositor.c
Commit message (Collapse)AuthorAgeFilesLines
* Support color fonts that use the foreground colorAdrian Johnson2021-08-281-0/+5
| | | | | | | | | | | | | COLR fonts can have a layer with the same color as the current text color. This change passes the current color (if solid) through to the font backend where it can be used to render color fonts. scaled_glyph_lookup checks if the foreground color has changed (for glyph that require it) and requests a new color surface if required. This also fixes a bug where scaled_glyph_lookup would always request a color surface for glyphs for glyphs in color fonts that do not have color.
* Use uintptr_t for all casts between pointer and integerAdrian Johnson2021-07-251-2/+2
| | | | | | | | | | | | On 64-bit windows, long is 32-bit. When compiling there are a large number of warnings about mismatched sizes when casting long to/from a pointer. Use the (u)intptr_t type for any integer that will have a pointer stored in it. Use a (u)intptr_t cast when integers are stored in pointers to silence warnings. Fixes #263
* Minor correctionsHeiko Lewin2021-04-111-1/+1
|
* Fix undefined left-shiftsHeiko Lewin2021-03-311-2/+2
|
* Fix mask usage in image-compositorHeiko Lewin2020-12-151-4/+4
|
* image compositor: Remove the right glyph from pixman's cacheJan Alexander Steffens (heftig)2019-10-051-1/+1
| | | | | We need to use the index including the phase. Otherwise we leave glyphs in the cache that cause problems later as indices are reused.
* image compositor: Support subpixel positioningMatthias Clasen2019-07-181-2/+11
| | | | | | | | | | | | | Support subpixel positioning with a 4x4 subpixel grid. When compositing glyphs in the image compositor, we store the subpixel phases in the high bits of the glyph index. The _cairo_scaled_glyph_index() macro has been updated to discard these bits. By storing the phases in the glyph index, the glyph cache just keeps working. When loading a glyph, the Freetype font backend shifts the outline according to the phases.
* Add support for RGBA128F and RGB96F formats.Maarten Lankhorst2019-01-071-0/+4
| | | | | | | | | | | | | | IGT wants to add support for planes with a bit depth >10, which requires a higher precision format than we have currently. I'm using RGBA as format, because of its existence in OpenGL. With the new formats we can directly convert our bytes to half float, or multiply a colro vector with a matrix to go to the Y'CbCr colorspace. This requires pixman 0.36.0, so bump the version requirement. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Reviewed-by: Bryce Harrington <bryce@bryceharrington.org>
* Use _cairo_malloc instead of mallocAdrian Johnson2018-05-071-1/+1
| | | | | | | | | | _cairo_malloc(0) always returns NULL, but has not been used consistently. This patch replaces many calls to malloc() with _cairo_malloc(). Fixes: fdo# 101547 CVE: CVE-2017-9814 Heap buffer overflow at cairo-truetype-subset.c:1299 Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
* Fix a 'memory leak' in the image compositorUli Schlachter2018-03-151-0/+17
| | | | | | | | | | | | | | There is a global pixman_glyph_cache_t instance that is initialized on first use and shows up in valgrind output as a relatively large leak (I think it was about 200 KiB). The reason for this is that this cache is not freed by cairo_debug_reset_static_data(). This commit wires up freeing the cache to cairo_debug_reset_static_data(). This cache was introduced in commit 615205cf0729 from 2012. Signed-off-by: Uli Schlachter <psychon@znc.in>
* image: prevent invalid ptr access for > 4GB imagesAdrian Johnson2017-11-071-2/+2
| | | | | | | | | | | | Image data is often accessed using: image->data + y * image->stride On 64-bit achitectures if the image data is > 4GB, this computation will overflow since both y and stride are 32-bit types. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=98165 Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
* Surround initialisations with atomic critical sectionMikhail Fludkov2017-10-151-5/+14
| | | | | | | | | | | | | | | Fixes the race condition when one thread uses cairo_mask_compositor_t pointer returned by _cairo_image_mask_compositor_get, while another one started but has not finished it's initialisation yet Usage: static cairo_atomic_once_t once = CAIRO_ATOMIC_ONCE_INIT; if (_cairo_atomic_init_once_enter(&once)) { /* Initialization code */ _cairo_atomic_init_once_leave(&once); } https://bugs.freedesktop.org/show_bug.cgi?id=103037
* image: Check for negative len in fill/blit functionsDoran Moppert2017-08-211-14/+14
| | | | | | Applies the same fix as 5c82d91 to other potential negative len cases. Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
* image: Fix crash in _fill_xrgb32_lerp_opaque_spansBryce Harrington2014-12-051-2/+2
| | | | | | | | | If a span length is negative don't go out of bounds processing the fill data. Patch thanks to Ilya Sakhnenko <ilia.softway@gmail.com> on mailing list. Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
* image: Eliminate self-intersections for the pixman traps compositorChris Wilson2014-10-021-0/+32
| | | | | | | | As pixman uses an accumulation mask, it oversamples neighbouring edges within a cell. We can reduce the impact of this by eliminating overlapping triangles/trapezoids from being passed into pixman. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* mask compositor: Set a check_composite methodUli Schlachter2014-03-211-1/+1
| | | | | | | | | | | | | | | | | | | | Commit 503b6b9e2ea6 added a check_composite method to the mask compositor, but only added it to one of the existing implementations. This commit fixes that. In cairo-image-compositor.c, there is already a check_composite method which just returns success for the traps compositor. This commit makes the mask compositor use that one. I don't want to say much about cairo-image-mask-compositor.c except that I wondered why this file and the file above both define a non-static function called _cairo_image_mask_compositor_get(). In my opinion, that file should just be deleted, since it confuses e.g. ctags, but I'll let someone else clean this up. Fixes 493 crashes in the test suite for the test-mask target. Signed-off-by: Uli Schlachter <psychon@znc.in> Tested-by: Bryce Harrington <b.harrington@samsung.com>
* image: Add NULL checks for return value of _pixman_image_for_color()Koji Egashira2014-03-031-0/+6
| | | | | | | | | This fixes crash in pixman_image_composite32(). Originally fixed by Yoshitaro Makise. Reviewed-by: Bryce Harrington <b.harrington@samsung.com> Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
* fill_reduces_to_source(): Handle failure of color_to_pixel()Uli Schlachter2013-09-271-2/+1
| | | | | | | | | | | | | | | | The function color_to_pixel() can fail for unsupported pixman image formats, but fill_reduces_to_source() ignored this possibility. Fix this by using the return value of color_to_pixel(): Fixes the following compiler warnings: cairo-image-compositor.c: In function 'fill_boxes': cairo-image-compositor.c:349:15: warning: 'pixel' may be used uninitialized in this function [-Wmaybe-uninitialized] cairo-image-compositor.c: In function 'fill_rectangles': cairo-image-compositor.c:304:18: warning: 'pixel' may be used uninitialized in this function [-Wmaybe-uninitialized] Signed-off-by: Uli Schlachter <psychon@znc.in>
* Provide backwards compatibilty with old pixmanChris Wilson2013-08-231-16/+28
| | | | | | | The goal is to allow compilation against older pixman to ease regression testing. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image compositor: Always finish the span rendererUli Schlachter2013-07-041-3/+4
| | | | | | | | | | | In some obscure conditions that I don't really understand, the image compositor did not finish a span renderer that it created. This could then cause the last row of the span to be ignored. Fixes: clip-complex-bug61492 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=61592 Signed-off-by: Uli Schlachter <psychon@znc.in>
* image: Quell warning about signed/unsigned int comparison.Bryce W. Harrington2013-06-111-1/+1
| | | | | | Restore (int) cast that was dropped in e7e1ac23. Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
* image: Compare against the true size of the embedded bufferChris Wilson2013-02-191-1/+1
| | | | | | | | | | When querying whether the run is small enough to fit inside the pre-allocated temporary buffer, we need to avoid comparing against sizeof(buf) as buf is a variable length array and so sizeof() is meaningless. Reported-by: Edward Zimmermann <Edward.Zimmermann@cib.de> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Substitute OVER spans for SOURCE with an opaque patternChris Wilson2013-02-071-2/+10
| | | | | | Based on an idea from Ravi Nanjundappa Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: And more fallout from c986a73, restore the absent short runsChris Wilson2013-01-271-18/+16
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Fix opaque span fillsChris Wilson2013-01-271-2/+2
| | | | | | I should have realised the previous result was too good to be true! Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Enable inplace compositing with opacities for general routinesChris Wilson2013-01-261-29/+161
| | | | | | | | | | | | | | | | | | | | | | | | On a SNB i5-2500: Speedups ======== firefox-chalkboard 34284.16 -> 19637.40: 1.74x speedup swfdec-giant-steps 778.35 -> 665.37: 1.17x speedup ocitysmap 485.64 -> 431.94: 1.12x speedup Slowdowns ========= firefox-fishbowl 46878.98 -> 54407.14: 1.16x slowdown That slow down is due to overhead of the increased number of calls to pixman_image_composite32() (pixman_transform_point for analyzing the source extents in particular) outweighing any advantage gained by performing the rasterisation in a single pass and eliding gaps. The solution that has been floated in the past is for an interface into pixman to only perform the analysis once and then to return a kernel to use for all spans. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Allocate a temporary buffer for inline span compositionChris Wilson2013-01-081-4/+20
| | | | | | | Allow the inpline span compositor to operate on wider images than its temporary buffer by allocating a scanline mask. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Call pixman without a mask for opaque regions of inplace_spansChris Wilson2013-01-071-10/+47
| | | | | | | | | | | | | Speedups ======== firefox-paintball 59462.09 -> 40928.76: 1.45x speedup firefox-fishtank 43687.33 -> 34627.78: 1.26x speedup firefox-tron 52526.00 -> 45754.73: 1.15x speedup However in order to avoid a regression with firefox-talos-svg we need to prevent splitting up the scanline when using a gradient source. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Add a couple of tracepoints for spans fallbacksChris Wilson2012-10-311-1/+2
| | | | | References: https://bugs.freedesktop.org/show_bug.cgi?id=56574 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* xlib: Implement SHM fallbacks and fast upload pathsChris Wilson2012-08-171-10/+16
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Temporarily resurrect the old non-pixman glyph compositorChris Wilson2012-08-121-0/+285
| | | | | | | As the easiest approach to making another snapshot that only depends upon a stable pixman, make the new dependency a compile time option. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Fix up glyphs compositingChris Wilson2012-06-151-36/+24
| | | | | | | | | | Jose Dapena Paz reported an assertion following the uninitialised status value being returned. Also the function failed to free its allocations. Based on a patch by Jose Dapena Paz <jdapena@igalia.com>. Reported-by: Jose Dapena Paz <jdapena@igalia.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=51104 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* Use the new pixman_glyph_cache_t API that will be in pixman 0.28.0Søren Sandmann Pedersen2012-06-091-248/+113
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This new pixman API allows glyphs to be cached and composited in one go, which reduces overhead compared to individual calls to pixman_image_composite_region32(). Notes: - There is an explicit call to _cairo_image_scaled_glyph_fini(). This could instead be done with a private, but I chose not to do that since we don't need to store any actual data; we only need notification when the glyph dies. - The slowdown in poppler-reseau is real and stable across runs. I'm not too concerned about it because this benchmark is only one run and so it is dominated by glyph cache setup costs and FreeType rasterizing. Performance results, image backend: Speedups firefox-talos-gfx 5571.55 -> 4265.57: 1.31x speedup gnome-terminal-vim 1875.82 -> 1715.14: 1.09x speedup evolution 1128.24 -> 1047.68: 1.08x speedup xfce4-terminal-a1 1364.38 -> 1277.48: 1.07x speedup Slowdowns poppler-reseau 374.42 -> 394.29: 1.05x slowdown Performance results, image16 backend: Speedups firefox-talos-gfx 5387.25 -> 4065.39: 1.33x speedup gnome-terminal-vim 2116.66 -> 1962.79: 1.08x speedup evolution 987.50 -> 924.27: 1.07x speedup xfce4-terminal-a1 1856.85 -> 1748.25: 1.06x speedup gvim 1484.07 -> 1398.75: 1.06x speedup Slowdowns poppler-reseau 371.37 -> 393.99: 1.06x slowdown Also bump pixman requirement to 0.27.1.
* image: Fix bugs related to glyph mask creationSøren Sandmann Pedersen2012-06-011-2/+2
| | | | | | | | | | | | | | | | In addition to fixing a bug 7d8d98b91ccf7165be853c36e6d5ef releated to expanding a8 glyphs into a8r8g8b8, this commit also added an optimization where if the first glyph had format a8r8g8b8, the mask was created in this format from the beginning instead of later converting from a8 to a8r8g8b8. However, the optimization had two bugs in it: (1) The computed stride was 3 * width, not 4 * times width, and (2) In the case where the mask was allocated on the stack, it was allocated as PIXMAN_a8 and not a8r8g8b8. The commit fixes both bugs.
* image: Upconvert glyphs through a WHITE source when adding to the glyph maskChris Wilson2012-05-311-19/+55
| | | | | | | | | | We need to scale the channels of the glyph into the destination (and indeed expand a8 into a8r8g8b8) when adding into the mask. Normally we have matching formats for the glyph surfaces and the temporary mask, for which we can continue to take the faster path. Reported-by: Søren Sandmann <sandmann@cs.au.dk> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Tidy lerp8x4Chris Wilson2012-05-201-9/+4
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* Revert "Use pixman glyphs"Søren Sandmann Pedersen2012-04-301-101/+212
| | | | | | This was pushed accidentally - apologies. This reverts commit 752c3b69e008b7d219da8cc5c657cf995732d3b8.
* Use pixman glyphsSøren Sandmann Pedersen2012-04-301-212/+101
|
* image: Add a little bit of debugging to show number of boxes being drawnChris Wilson2012-04-291-3/+3
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Avoid overflow when computing lerp spans for a8Chris Wilson2012-04-281-8/+8
| | | | | Reported-by: Benjamin Otte <otte@redhat.com> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Fix typo in _blit_spans()Chris Wilson2012-04-261-1/+1
| | | | | | The height is 'h' not 'y'! Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Split inline SRC compositionChris Wilson2012-04-191-58/+96
| | | | | | | | | | | | | | | | | | | Currently we construct a mask for the entire line and try to process it in one call to pixman (two without the LERP operator). An alternative approach is split the row into separate composite operations for the clear (which we can skip), fully opaque and partial spans. As the source operator is typically mostly opaque or clear, this is a good win as we are able to utilise more fast paths. In the worst case, it degrades to the old method of constructing a whole mask for a row. It may reduce performance for having to process lots of spans though (this is where the pixman spans interface should help). However, such geometry is rare and typically handled elsewhere. And the existing code has a bug where it was clearing the destination for clear regions of the mask outside of the spans. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Fix leak of white solid color for masked composition of CLEARChris Wilson2012-03-231-1/+5
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Support SRC compositing with in the inline span-compositorChris Wilson2012-03-121-10/+96
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Add unbounded support to the mono rasteriser fast-pathsChris Wilson2012-03-061-20/+100
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Try performing span composition a row at a timeChris Wilson2012-03-051-23/+114
| | | | | | | | | | | | | | | In theory, this should be more cache efficient and allow us to trim the operation to the width of row, shaving a few texel fetches. The cost is that we cause pixman to evaluate the composite operation per-row. This should only be a temporary solution until we can do something better through pixman... On a i5-2520m, ymmv, firefox-fishtank 64585.38 -> 56823.41: 1.14x speedup swfdec-fill-rate 1383.24 -> 1665.88: 1.20x slowdown Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Add a simple inplace blitter for spansChris Wilson2012-03-051-32/+116
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Perform the simple solid-fill spans inplaceChris Wilson2012-03-051-1/+348
| | | | | | | | | | | | | | | Reducing the number of passes has the usual change in the antialiasing side-effects, as well as the boon of being faster (and theorectically more accurate through reduced loss of dynamic range.) On an i5-2520m: swfdec-giant-steps-full 3240.43 -> 2651.36: 1.22x speedup grads-heat-map 166.84 -> 136.79: 1.22x speedup swfdec-giant-steps 940.19 -> 796.24: 1.18x speedup ocitysmap 953.51 -> 831.96: 1.15x speedup webkit-canvas-alpha 13924.01 -> 13115.70: 1.06x speedup Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* spans,image,gl: Add fast-path for simple copiesChris Wilson2012-03-041-0/+2
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Add a fast-path for mono-rasterised blitsChris Wilson2012-03-041-51/+144
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>