summaryrefslogtreecommitdiff
path: root/src/cairo-gstate.c
Commit message (Collapse)AuthorAgeFilesLines
* Implement a font options compare function and use it in gstateAdrian Johnson2023-02-081-1/+1
| | | | | Valgrind is not happy with the memcmp() to compare font options and it won't work correctly with variations and custom_palette.
* Rename is_userfont_foreground to is_foreground_markerAdrian Johnson2023-01-271-1/+1
| | | | as it is used by FT as well as user fonts.
* Foreground color fixes for ft, svg, colrv1Adrian Johnson2023-01-271-1/+1
|
* [gstate] Fix cairo_font_options_t memory managementBehdad Esfahbod2023-01-181-1/+3
| | | | | cairo_font_options_t has grown to have malloc'ed memory, so the previous code was leaking, and double-freeing.
* Added hairline support to cairoRick Yorgason2021-08-151-2/+28
|
* Remove all gstate from _cairo_surface_tagAdrian Johnson2021-07-181-41/+2
| | | | | The gstate is not required and was causing some tag operations to be ignored.
* Replace an outdated (after f0e2cd44) comment with clarification in ↵Anton Danilkin2021-04-251-1/+14
| | | | _cairo_gstate_copy_transformed_pattern
* gstate: Minor grammar copyeditBryce Harrington2018-09-051-1/+1
|
* 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>
* Factor out the ISFINITE() macroBryce Harrington2017-10-111-6/+0
|
* Add tag functions to cairo_t and cairo_surface_tAdrian Johnson2016-10-011-0/+59
| | | | | | | | 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.
* Don't cull very thin lines on vector surfacesAdrian Johnson2015-10-171-0/+1
| | | | | | On vector surfaces, use a minimum line width when calculating extents. Bug 77298
* Avoid indiscriminate use of VALGRIND_MAKE_MEM_NOACCESS.John Lindgren2015-06-261-1/+1
| | | | | | | | | Marking stack-allocated objects as no-access creates false positives, which distract from finding real memory errors. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=52548 Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
* gstate: Handle device scale on surface as sourceAlexander Larsson2013-09-051-1/+1
| | | | | | | | | | | | | | | | | | 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.
* gstate: Move device-scale font scaling to gstateAlexander Larsson2013-09-051-1/+7
| | | | | | | | | | If we do this in surface it will be applied twice then we chain to a different surface, like e.g. a subsurface. We also remove a hack in cairo-surface-wrapper where it compensated for the device scale not being applied. v2: Compute the backend CTM in ensure_scaled_font().
* gstate: Respect device transform in strokeAlexander Larsson2013-09-051-3/+12
| | | | | We need to apply the device transform to the ctm when stroking, as otherwise line widths are not affected by the device scale.
* gstate: Speed up stroked path extentsChris Wilson2013-06-201-12/+12
| | | | | | | | | | | | | We can skip the intermediate evaluation of the trapezoids for determining the extents of a stroked path by using the relatively new functions for computing the contours of the stroke. Then we can simply use the bbox of the points within the contours to retrieve the path extents - which is already provided by the polygon holding the contours of the stroke. This provides a faster result with less numerical inaccuracy due to fewer stages required in the computation References: https://bugs.freedesktop.org/show_bug.cgi?id=62375 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* gstate: Use the polygon intermediate for geometry queriesChris Wilson2013-01-091-12/+12
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* context: Add missing functions to transform between user and backend coordinatesChris Wilson2012-09-101-0/+7
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* default-context: Convert the relative path segments into the backend coordinatesChris Wilson2012-09-041-0/+7
| | | | | | | | | | | 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>
* gstate: Correctly compact degenerate dash segmentsChris Wilson2012-04-291-19/+18
| | | | | | | | The danger of the incomplete test masking the failure to correctly skip the degenerate elements in the final dash state. Fixes the fixed degenerate-solid-dash. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* gstate: Reduce degenerate dash to solidChris Wilson2012-04-291-5/+30
| | | | | | | If the dash specifies that the pen is always on (i.e. the total of the off segments is zero), then we can eliminate the dash pattern. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* Split cairo-list 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>
* 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>
* doc: Make doc ids more consistent my always putting ':' after themAndrea Canciani2012-03-291-1/+1
| | | | | This makes the documentations comments more consistent and fixes many reports of 'invalid doc id'.
* doc: Make documentation comments symmetricAndrea Canciani2012-03-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Documentation comments should always start with "/**" and end with "**/". This is not required by gtk-doc, but it makes the documentations formatting more consistent and simplifies the checking of documentation comments. The following Python script tries to enforce this. from sys import argv from sre import search for filename in argv[1:]: in_doc = False lines = open(filename, "r").read().split("\n") for i in range(len(lines)): ls = lines[i].strip() if ls == "/**": in_doc = True elif in_doc and ls == "*/": lines[i] = " **/" if ls.endswith("*/"): in_doc = False out = open(filename, "w") out.write("\n".join(lines)) out.close() This fixes most 'documentation comment not closed with **/' warnings by check-doc-syntax.awk.
* gstate: Prevent leak of old clip when creating a group with translationChris Wilson2011-10-121-0/+1
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* Introduce a new compositor architectureChris Wilson2011-09-121-154/+187
| | | | | | | | | | | | | | | | | | 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. :)
* gstate: Copy clusters for an untransformed unbounded surfaceChris Wilson2011-08-141-0/+2
| | | | | | Fixes record-select-font-face Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* Remove useless checks for NULL before freeingAndrea Canciani2011-07-311-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch has been generated by the following Coccinelle semantic patch: // Remove useless checks for NULL before freeing // // free (NULL) is a no-op, so there is no need to avoid it @@ expression E; @@ + free (E); + E = NULL; - if (unlikely (E != NULL)) { - free(E); ( - E = NULL; | - E = 0; ) ... - } @@ expression E; @@ + free (E); - if (unlikely (E != NULL)) { - free (E); - }
* pattern: Do not provide type field in cairo_pattern_union_tAndrea Canciani2011-07-311-1/+1
| | | | | | The type field is accessible through the base.type field. This makes it possible to change the layout of cairo_pattern_t and move the type field without breaking cairo_pattern_union_t.
* gstate: Handle NULL clip for in_clip()Chris Wilson2011-07-211-0/+3
| | | | | | | A NULL clip implies no clipping at all, and therefore every point is inside. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* clip: Rudimentary support for clip-polygon extractionChris Wilson2011-07-191-122/+84
| | | | | | | 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-72/+70
| | | | | | | | | | 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>
* gstate: Remove useless codeAndrea Canciani2011-07-081-11/+1
| | | | | gstate->source has been initialized as the static black pattern, so its status is success.
* Do not warn when ignoring the return value of _cairo_rectangle_intersect()Andrea Canciani2011-03-191-3/+1
| | | | | | | | | | | | gcc complains that cairo-surface-wrapper.c:647: warning: ignoring return value of ‘_cairo_rectangle_intersect’, declared with attribute warn_unused_result It can be silenced by making _cairo_rectangle_intersect() cairo_private_no_warn. This makes it possible to avoid unused temporary variables in other places and reduces the dead assignments reported by clang static analyzer from 114 to 98.
* Improve cairo_rectangle_list_t error handlingAndrea Canciani2011-03-181-1/+7
| | | | | | | | | | | Unify the _cairo_rectangle_list_create_in_error() functions, keeping the best features from both (the one in cairo-clip.c statically allocates the most common cases, the one in cairo.c throws a NO_MEMORY error when it cannot malloc() instead of rethrowing the same error). The same function can be used to return an error-list in _cairo_gstate_copy_clip_rectangle_list() when _cairo_clip_rectangle() fails (for example becaouse of an OOM).
* Make cairo_set_font_size() a wrapper of cairo_set_font_matrix()Andrea Canciani2011-03-181-11/+0
| | | | | | | | cairo_set_font_size() should be equivalent to setting the font matrix to an appropriate scale matrix. Implementing it this way saves some code and makes sure that the same code path is used whenever the font matrix is changed.
* Don't err on non-invertible font matrixBehdad Esfahbod2011-02-041-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | The scaled-font layer handles that later if it actually is a problem: scaled_font->scale_inverse = scaled_font->scale; status = cairo_matrix_invert (&scaled_font->scale_inverse); if (unlikely (status)) { /* If the font scale matrix is rank 0, just using an all-zero inverse matrix * makes everything work correctly. This make font size 0 work without * producing an error. * * FIXME: If the scale is rank 1, we still go into error mode. But then * again, that's what we do everywhere in cairo. * * Also, the check for == 0. below may be too harsh... */ if (_cairo_matrix_is_scale_0 (&scaled_font->scale)) { cairo_matrix_init (&scaled_font->scale_inverse, 0, 0, 0, 0, -scaled_font->scale.x0, -scaled_font->scale.y0); } else return status; }
* gstate: Remove unused codeAndrea Canciani2011-01-221-33/+0
| | | | | | | | | | | | | | | _cairo_gstate_redirect_target asserts that this surface is NULL immediately before destroying it. If the code is compiled with assertions disabled and the assert would be false, it is now safer because instead of an invalid access it will only memleak. _cairo_gstate_get_parent_target () is not used anymore in cairo_pop_group () and the related code can be removed. _cairo_gstate_is_redirected () has never been used. The comment about the clipping is misleading, because the clip is translated as expected since fb7f7c2f27f0823d7702f960204d6e638d697624.
* gstate: Set an error status when restoring a push_groupAndrea Canciani2011-01-221-0/+16
| | | | | | | cairo_push_group (cr) followed by cairo_restore (cr) should put cr in an error status of CAIRO_STATUS_INVALID_RESTORE. Fixes group-state.
* gstate: Disallow incomplete mesh gradient sourcesAndrea Canciani2011-01-011-12/+32
| | | | | | Mesh gradients are constructed using multiple commands, bracketed by explicit begin/end pairs. Using a mesh gradient inside a begin/end pair is not allowed.
* path: Do not access flags directlyAndrea Canciani2010-10-291-1/+1
| | | | | | | Use inline accessors to hide the flags in the code. This ensures that flags that need additional computations (example: is_rectilinear for the fill case) are always used correctly.
* gstate: Correct commentAndrea Canciani2010-08-081-1/+1
|
* clip: consider gstate target extents in _cairo_gstate_copy_clip_rectangle_listKarl Tomlinson2010-07-171-1/+13
| | | | | | | | | | Fixes https://bugs.freedesktop.org/show_bug.cgi?id=29125 To be consistent with _cairo_gstate_clip_extents, the context's clip should be intersected with the target surface extents (instead of only using them when there is no clip). Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
* gstate: Update cached matrix state after device transform changes on the targetChris Wilson2010-06-111-4/+24
| | | | | | | | | | | | Commit 8d67186cb291cb877e52b987e2ac18c2a1175a57 caches whether the device transform is identity on context creation. However, the api is quite lax and allows the user to modify the device transform *after* he has started to use the surface in a context, as apparently WebKit does. Since this is not the only instance where we may need to invalidate caches if the user modifies state, introduce a simple mechanism for hooking into notifications of property changes. Fixes test/clip-device-offset.
* gstate: correct optimizationsAndrea Canciani2010-06-101-68/+17
| | | | | | | | Gradient were previously hand-optimized (without properly checking for extend modes). By properly using _cairo_pattern functions we avoid code duplication and bugs. Fixes linear-gradient-extend, radial-gradient-extend.
* pattern: remove content field from solid patternsAndrea Canciani2010-06-101-9/+5
| | | | | The content field in solid patterns had ill-defined semantic (or no semantic at all), thus it can be removed.
* gstate: Track whether the combination of ctm * device is identity.Chris Wilson2010-06-101-2/+16
| | | | | | In the fairly common condition that both the ctm and the device transforms are identity, the function overhead of calling the matrix multiplication on the point overwhelmingly dominates.