summaryrefslogtreecommitdiff
path: root/src/cairo-image-source.c
Commit message (Collapse)AuthorAgeFilesLines
* Make cairo_tag_begin/end work correctly in groupsAdrian Johnson2023-04-181-1/+1
| | | | Fixes #508
* Fix shared use of recording surface with paginated targetsAdrian Johnson2023-01-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The problem is _cairo_recording_surface_replay_and_create_regions() stores the cairo_recording_region_type_t in the same structure as the recording commands. This does not work well when the recording surface is used as source by multiple surfaces Fix this by moving the cairo_recording_region_type_t into a separate struct cairo_recording_regions_array_t. This struct is stored in a list that allows multiple create regions results to be store in the surface. The new function _cairo_recording_surface_region_array_attach() is used to create a new cairo_recording_regions_array_t, attach it to the recording surface and return a unique region id. The _cairo_recording_surface_replay_and_create_regions() and _cairo_recording_surface_replay_region() functions use this region id to identify the cairo_recording_regions_array_t. To handle nested recording surfaces, when replaying a recording, the region id is passed to the target as an extra parameter in the surface pattern. The wrapper surface makes a temporary copy of the pattern to ensure the snapshot pattern in the recording surface is not modified. cairo_recording_regions_array_t has a reference count so the target can hold on to the cairo_recording_regions_array_t after the paginated surface has called _cairo_recording_surface_region_array_remove().
* Fix user-font with foreground in group failures on image, PDF, and PSAdrian Johnson2023-01-031-0/+4
|
* Add support for RGBA128F and RGB96F formats.Maarten Lankhorst2019-01-071-0/+27
| | | | | | | | | | | | | | 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-5/+5
| | | | | | | | | | _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>
* image: fix record-replay-extend test failuresAdrian Johnson2016-06-051-24/+43
|
* Don't cull very thin lines on vector surfacesAdrian Johnson2015-10-171-2/+3
| | | | | | On vector surfaces, use a minimum line width when calculating extents. Bug 77298
* image: Move filter decision to _cairo_pattern_analyze_filterBill Spitzak2014-10-101-13/+9
| | | | | | | | The analysis to deterimine if the GOOD filter can be replaced with the BILINEAR filter is moved to this function so it can be used by backends other than the image backend. Reviewed-by: Bryce Harrington <b.harrington@samsung.com>
* V6 image: Use convolution filters for sample reconstruction when downscalingBill Spitzak2014-07-251-1/+419
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This version removes testing code and has some changes to match my current pixman version. My proposed pixman patch (not finished yet) will produce exactly the same results as this cairo patch. This code contains an all-new filter generator to replace the one that is in pixman. Results in 222 pass/298 failed image tests, which is much better than the previous versions of this patch. Filter generator (which should probably be in pixman): - Single filter, no "reconstruction" and "sample" filter - Filters for derivative < 1 work - Fixed IMPULSE and BOX - Added TENT, CATMULL_ROM, NOTCH. Remove LANZCOS2. - Renamed CUBIC to MITCHELL Cairo's filter settings: - CAIRO_FILTER_GOOD: uses BOX filter for scales less than .75 in either direction. Uses PIXMAN_FILTER_GOOD (ie BILINEAR) otherwise. - CAIRO_FILTER_BEST: uses CATMULL filter always. Upscaling more than 2x will produce anti-aliased square pixels, similar to OS/X. - CAIRO_FILTER_GAUSSIAN: this obsolete value is used to test other filters. The program must declare and poke the filter into the static varialbe ikernel. This should be removed for production code. NYI: This version uses the fallback for xlib always. The xlib and xcb backends must be rewritten to use the fallback version if filtering is needed. Or the filtering code must be moved to XRender.
* Revert "image: Use convolution filters for sample reconstruction when ↵Uli Schlachter2014-06-051-55/+10
| | | | | | | | | | | | | | | | | | | | | | | | | downscaling" This reverts commit fb57ea13e04d82866cbc8e86c83261148bb3e231. When running cairo-test-suite with the parameter "-a", it also runs each test with a non-zero device-offset and device-scaling. The above commit influenced the device-scaling results badly. E.g. some test results ended up with a black border at the top-most and left-most row that looked like there was an offset of "0.5" in drawing the image and thus pixels outside of the image were sampled. This can be seen by the influence that this revert has on the results from running CAIRO_TEST_TARGET=image ./cairo-test-suite -a: Before: 31 Passed, 489 Failed [1 crashed, 8 expected], 31 Skipped After: 225 Passed, 295 Failed [1 crashed, 8 expected], 31 Skipped Most of the failures that disappeared are from the device-scaling tests. With such disastrous results on the test suite, this cannot really be usable for real-world applications. Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
* image: Use convolution filters for sample reconstruction when downscalingKrzysztof Kosiński2013-09-051-10/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I had a look at how complex would it be to add correct downscaling to Cairo now that Pixman supports convolution filters. It turns out it this is rather easy. Here is an initial, minimal attempt. It uses convolution filters only if the image is being downscaled by more than half a pixel in at least one dimension. Some discussion: 1. The sampling and reconstruction kernels are picked in a way that gives comparable quality when upscaling and downscaling. I paired box sampling with bilinear reconstruction and impulse (point) sampling with box reconstruction. This gives the expected result for NEAREST filter. BEST filter uses Lanczos3 for both kernels. > Do we need to use a reconstruction filter for NEAREST at all? Or maybe > differentiate between NEAREST and FAST in that case? If impulse (point) sampling is used, there must be some reconstruction filter, otherwise no image is produced. That's because the sampling grid does not match the data grid, and since there is no reconstruction filter, values between data points are undefined. The alternative is to use box sampling + no reconstruction. 2. Subsampling bits are always set to 1, since this doesn't seem to affect quality at all. 3. I am not sure whether this code works correctly for matrices with a skew component. It should be OK for any combination of scale, rotation and translation. 4. This patch causes new failures in the test suite: - recording-surface*: possibly an effect of improved quality. - surface-pattern-scale-down*, surface-pattern-big-scale-down: the reference images should be updated. - pthread-same-source: I have no idea why this is failing, since this test shouldn't even trigger the new code. - large-source-roi: this test attempts to downscale an image which is 30000 pixels wide down to 7 pixels. The filter parameters seem to be created correctly, but they might trigger an overflow somewhere in the convolution code; the output rectangle is white instead of red, as if nothing was drawn. - device-offset-scale: there are subtle differences which look like convolution-related smoothing; I'm not sure whether this is OK or not.
* snapshot: Perform the cow under a mutexChris Wilson2012-04-271-5/+28
| | | | | | | | | | | | In order to prevent a race between concurrent destroy and use in another thread, we need to acquire a reference to the snapshot->target under a mutex. Whilst we hold that reference, it prevents the internal destroy mechanism from freeing the memory we are using (if we have a pointer to the original surface) and the client drops their final reference. Oh boy, talk about opening a can of worms... Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* Split cairo-pattern-private into struct+inlinesChris Wilson2012-04-191-1/+1
| | | | | References: https://bugs.freedesktop.org/show_bug.cgi?id=48577 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* Split cairo-recording-surface-private into struct+inlinesChris Wilson2012-04-191-1/+1
| | | | | References: https://bugs.freedesktop.org/show_bug.cgi?id=48577 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Correct origin of unbound recording surface sourceChris Wilson2012-03-031-13/+16
| | | | | | | | | | Clearly demonstrated by using the test-base with the recording surfaces and exemplified by the fallback-resolution with PDF, which is *almost* fixed! We're very close to making a release candidate for 1.12 now... Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Handle recursive drawing of recording surfaceChris Wilson2012-02-241-1/+88
| | | | | | | | | | | Borrow the technique for installing a proxy-snapshot developed for acquiring the image from a recording surface. This prevents the cairo from exploding and using up all memory due to infinite recursion, but it does break a few tests that perform self-copies with differing transformations. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Tidy reduction to EXTEND_NONE for replay surfacesChris Wilson2012-02-221-12/+1
| | | | | | | As _cairo_surface_get_source() returns the limits of the source, a chunk of code to query the source extents became redundant. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* win32: Rebase on the new compositor infrastructureChris Wilson2012-02-151-0/+25
| | | | | | | | | | Try and undo all the damage that has acrued over the years by plugging into the compositor pipeline. References: https://bugs.freedesktop.org/show_bug.cgi?id=42739 References: https://bugs.freedesktop.org/show_bug.cgi?id=42821 References: https://bugs.freedesktop.org/show_bug.cgi?id=33081 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* Replace the ad-hoc surface unwrappers with a function pointerChris Wilson2012-02-091-9/+3
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* rectangle: Implement _cairo_rectangle_contains_rectangle()Andrea Canciani2012-01-151-8/+2
| | | | And reuse it.
* Convert cairo_mime_surface_t to cairo_raster_source_pattern_tChris Wilson2011-11-251-0/+95
| | | | | | | | | | As discussed, overloading the cairo_surface_t semantics to include sources (i.e. read-only surfaces) was duplicating the definition of cairo_pattern_t. So rather than introduce a new surface type with pattern semantics, start along the thorny road of extensible pattern types. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Remove dubious "optimisations" for acquired source imagesChris Wilson2011-11-231-29/+0
| | | | | | | By this point we have already paid the penalty for acquiring the source image, so kiss. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Only unwrap a subsurface if the sample is fully containedChris Wilson2011-11-231-14/+16
| | | | | | | | | In order to handle out-of-bounds sampling of a subsurface target we need to first avoid incorrectly unwrapping it. Fixes crash in subsurface-outside-target Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* backends: Adds a new Cogl based backendRobert Bragg2011-10-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a new GPU accelerated backend for Cairo based on the Cogl 3D graphics API. This backend aims to support Cairo in a way that translates as naturally as possible to using a GPU, it does not strive to compete with the anti-aliasing quality of the image backend if it can't be done efficiently using the GPU - raw performance isn't the only metric of concern, so is power usage. As an overview of how the backend works: - fills are handled by tessellating paths into triangles - the backend has an extra fill_rectangle drawing operation so we have a fast-path for drawing rectangles which are so common. - strokes are also tessellated into triangles. - stroke and fill tessellations are cached to avoid the cpu overhead of tessellation and cost of upload given that its common for apps to re-draw the same path multiple times. The tessellations can survive translations and rotations increasing the probability that they can be re-used. - sources and masks are handled using multi-texturing. - clipping is handled with a scissor and the stencil buffer which we're careful to only update when they really change. - linear gradients are rendered to a 1d texture using a triangle strip + interpolating color attributes. All cairo extend modes are handled by corresponding texture sampler wrap modes without needing programmable fragment processing. - antialiasing should be handled using Cogl's multisampling API XXX: This is a work in progress!! TODO: - handle at least basic radial gradients (No need to handle full pdf semantics, since css, svg and canvas only allow radial gradients defined as one circle + a point that must lie within the first circle.) - currently we fall back to pixman for radial gradients. - support glyph rendering with a decent glyph cache design. The current plan is a per scaled-font growable cache texture + a scratch cache for one-shot/short-lived glyphs. - decide how to handle npot textures when lacking hardware support. Current plan is to add a transparent border to npot textures and use CLAMP_TO_EDGE for the default EXTEND_NONE semantics. For anything else we can allocate a shadow npot texture and scale the original to fit that so we can map extend modes to texture sampler modes.
* image: don't offset by device transform for replay onto source surfaceChris Wilson2011-09-201-5/+3
| | | | | | It is already captured by the pattern extents. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: clip the replay to the sample extents in device spaceChris Wilson2011-09-201-6/+23
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: intersect the source extents with the replay extents for EXTEND_NONEChris Wilson2011-09-171-1/+4
| | | | | | Fixes up the boundary on EXTEND_NONE replays. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Use the recording surface content for the recording sourceChris Wilson2011-09-161-2/+7
| | | | | | | | | The previous commit should have been a enormous warning that something was horribly wrong. I was determined to preserve the optimisation of replaying onto the matching format, however, we need to provide an alpha channel if required. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Use A8 for creating a mask from a recording surfaceChris Wilson2011-09-161-1/+2
| | | | | | When applying masks, typically it is useful to have an alpha channel. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Invert recording matrix before replayChris Wilson2011-09-151-2/+7
| | | | | | Hmm, still not quite right but an improvement. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* Introduce a new compositor architectureChris Wilson2011-09-121-0/+975
Having spent the last dev cycle looking at how we could specialize the compositors for various backends, we once again look for the commonalities in order to reduce the duplication. In part this is motivated by the idea that spans is a good interface for both the existent GL backend and pixman, and so they deserve a dedicated compositor. xcb/xlib target an identical rendering system and so they should be using the same compositor, and it should be possible to run that same compositor locally against pixman to generate reference tests. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> P.S. This brings massive upheaval (read breakage) I've tried delaying in order to fix as many things as possible but now this one patch does far, far, far too much. Apologies in advance for breaking your favourite backend, but trust me in that the end result will be much better. :)