summaryrefslogtreecommitdiff
path: root/src/cairo-default-context.c
Commit message (Collapse)AuthorAgeFilesLines
* Clamp path coordinatesAdrian Johnson2022-05-281-10/+16
| | | | Fixes https://gitlab.freedesktop.org/poppler/poppler/-/issues/1250
* Added hairline support to cairoRick Yorgason2021-08-151-0/+18
|
* Plug a memory leak in an error caseMatthias Clasen2021-01-221-2/+5
| | | | | | | | | | | | | | | | GTK has a testcase that tests the error when creating an oversize image, and asan tells me that it triggers a memory leak in cairo: Direct leak of 160 byte(s) in 1 object(s) allocated from: #0 0x7f1122755667 in __interceptor_malloc (/lib64/libasan.so.6+0xb0667) #1 0x7f1120cc83e8 in _cairo_pattern_create_solid ../src/cairo-pattern.c:607 #2 0x7f1120cc8487 in _cairo_pattern_create_in_error ../src/cairo-pattern.c:630 #3 0x7f1120cc87cb in INT_cairo_pattern_create_for_surface ../src/cairo-pattern.c:736 #4 0x7f1120c1f1c7 in _cairo_default_context_set_source_surface ../src/cairo-default-context.c:327 #5 0x7f1120d8386a in INT_cairo_set_source_surface ../src/cairo.c:982 #6 0x7f1121d005a2 in gdk_cairo_set_source_pixbuf ../gdk/gdkcairo.c:234 #7 0x401427 in test_set_source_big_pixbuf ../testsuite/gdk/cairo.c:23
* Misc. typosluz.paz2019-01-311-1/+1
| | | | | | | Found via `codespell -i 3 -w -I ../cairo-word-whitelist.txt -L tim,ned,uint` Follow up of 12cb59be7da 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>
* Add tag functions to cairo_t and cairo_surface_tAdrian Johnson2016-10-011-0/+21
| | | | | | | | The cairo_tag_begin/cairo_tag_end API is for supporting hyperlinks and creating tagged PDF files. The source, ctm, and stroke style are passed to the backend to allow these parameters to be used to specify hyperlink border attributes.
* surface: Merge scratch construction into _cairo_surface_create_scratchAlexander Larsson2013-09-051-5/+5
| | | | | | | | | | | We merge _cairo_surface_create_similar_scratch and _cairo_surface_create_similar_solid into a single function named _cairo_surface_create_scratch, to avoid confusion with cairo_surface_create_similar which now will have a different behaviour wrt the sizes and the device-scale. _create_scratch assumes the width and height are in backend coordinates, while create_similar does not.
* surface: expose the device scaleAlexander Larsson2013-09-051-3/+3
| | | | | | This adds the new public functions cairo_surface_set_device_scale and cairo_surface_get_device_scale and updates old users of the internal functions.
* gstate: Handle device scale on surface as sourceAlexander Larsson2013-09-051-15/+8
| | | | | | | | | | | | | | | | | | When creating a transformed pattern we must apply the device transform *before* the transform set on the pattern itself, otherwise e.g. its translation will not be affected by the device scale. We also fix up the device_transform related handling in _cairo_default_context_pop_group(). With a device scale we can no longer just use the device_transform_inverse to unset the device offset for the extents, so we make that a simple translate instead. We also remove some weird code that tries to handle the device transform but seems unnecessary (maybe a workaround for applying the device transform in the wrong order?). With that code removed things work fine, but with it things get translated wrongly when there is a scale.
* default-context: Inherit device scale in push_group surfaceAlexander Larsson2013-09-051-0/+4
| | | | | Without this we will only render to part of the newly created surface and then copy+scale that part back, which causes fuzziness.
* push_group: Refuse working with unusable surfaceUli Schlachter2013-08-131-0/+5
| | | | | | | | | | | | | | Make cairo_push_group() fail when the context's target surface is finished. This fixes the api-special-cases for the xcb backend: Detected error during xcb run: error=9, seqno=0x13c, major=53, minor=0 The problem was that the Pixmap for the cairo surface was already freed and cairo still tried to use it again as the drawable in a CreatePixmap request. Signed-off-by: Uli Schlachter <psychon@znc.in> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
* context: Use recording surfaces for unbounded groupsUli Schlachter2012-12-171-9/+14
| | | | | | | | | | | | The old code uses an uninitialized variable for the extents of the group that is created. This patch makes it use an unbounded recording surface instead. This has the implicit assumption that everything that is unbounded smells like a recording surface. Let's see when this assumption breaks. :-) http://lists.cairographics.org/archives/cairo/2012-October/023585.html Signed-off-by: Uli Schlachter <psychon@znc.in>
* context: Add missing functions to transform between user and backend coordinatesChris Wilson2012-09-101-0/+44
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* default-context: Convert the relative path segments into the backend coordinatesChris Wilson2012-09-041-5/+5
| | | | | | | | | | | When transforming the incoming paths, the goal is to transform them from user space onto the target coordinate system. Currently for relative paths we used user_to_device_distance as we presumed that there was no backend scale factor. However, Alex Larsson noticed that these then broke when playing around with such a device transform... Reported-by: Alexander Larsson <alexl@redhat.com> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* Split cairo-clip-privates into struct+inlinesChris Wilson2012-04-191-0/+1
| | | | | References: https://bugs.freedesktop.org/show_bug.cgi?id=48577 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* backends: Adds a new Cogl based backendRobert Bragg2011-10-111-12/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Introduce a new compositor architectureChris Wilson2011-09-121-2/+1
| | | | | | | | | | | | | | | | | | 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. :)
* default-context: Tidy push-groupChris Wilson2011-08-121-7/+8
| | | | | | Fix a couple of instances of the older style clipping code. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* default-context: Do not allow restoring pushed gstatesAndrea Canciani2011-07-301-0/+3
| | | | | | | | | | The brackets defined by push/pop and save/restore are independent ad should match properly. This means that cairo_push()-ed gstates cannot be cairo_restore()-d and cairo_save()-d gstates cannot be cairo_pop()-ed. Fixes group-state.
* clip: Rudimentary support for clip-polygon extractionChris Wilson2011-07-191-2/+3
| | | | | | | Step 1, fix the failings sighted recently by tracking clip-boxes as an explicit property of the clipping and of composition. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* pattern: Add observer hooksChris Wilson2011-07-151-0/+1
| | | | | | | | | In order for custom context to automatically track when a pattern is modify after being set on the context (and before it is used in an operator), we need for there to be a callback when the pattern is modified. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* Implement cairo_backend_tChris Wilson2011-07-151-0/+1406
Allow a backend to completely reimplement the Cairo API as it wants. The goal is to pass operations to the native backends such as Quartz, Direct2D, Qt, Skia, OpenVG with no overhead. And to permit complete logging contexts, and whatever else the imagination holds. Perhaps to experiment with double-paths? Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>