summaryrefslogtreecommitdiff
path: root/src/cairo-path.c
Commit message (Collapse)AuthorAgeFilesLines
* Use _cairo_malloc instead of mallocAdrian Johnson2018-05-071-2/+2
| | | | | | | | | | _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>
* path: Convert from backend coordinates back into user coordinatesChris Wilson2012-09-101-5/+6
| | | | | | | | | | | | | | | | | | Fixes regression from commit 83bfd85a1378e61b8bdc3f554f5e07900311f61f Author: Chris Wilson <chris@chris-wilson.co.uk> Date: Fri Apr 23 19:45:26 2010 +0100 Implement cairo_backend_t As there exists no public API to perform the operation we needed, and we failed to create one, the constructed path failed to correctly remove the device offset. Fixes copy-path under device translation. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=54732 Reported-by: Benjamin Berg <benjamin@sipsolutions.net> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* doc: Add "since" tag to documentationAndrea Canciani2012-03-291-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The following Python script was used to compute "Since: 1.X" tags, based on the first version where a symbol became officially supported. This script requires a concatenation of the the cairo public headers for the officially supported beckends to be available as "../../includes/1.X.0.h". from sys import argv import re syms = {} def stripcomments(text): def replacer(match): s = match.group(0) if s.startswith('/'): return "" else: return s pattern = re.compile( r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"', re.DOTALL | re.MULTILINE ) return re.sub(pattern, replacer, text) for minor in range(12,-2,-2): version = "1.%d" % minor names = re.split('([A-Za-z0-9_]+)', stripcomments(open("../../includes/%s.0.h" % version).read())) for s in names: syms[s] = version for filename in argv[1:]: is_public = False lines = open(filename, "r").read().split("\n") newlines = [] for i in range(len(lines)): if lines[i] == "/**": last_sym = lines[i+1][2:].strip().replace(":", "") is_public = last_sym.lower().startswith("cairo") elif is_public and lines[i] == " **/": if last_sym in syms: v = syms[last_sym] if re.search("Since", newlines[-1]): newlines = newlines[:-1] if newlines[-1].strip() != "*": newlines.append(" *") newlines.append(" * Since: %s" % v) else: print "%s (%d): Cannot determine the version in which '%s' was introduced" % (filename, i, last_sym) newlines.append(lines[i]) out = open(filename, "w") out.write("\n".join(newlines)) out.close()
* 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.
* 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); - }
* Implement cairo_backend_tChris Wilson2011-07-151-68/+30
| | | | | | | | | | 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>
* Fix errors from src/check-plt.shUli Schlachter2011-02-121-0/+1
| | | | | | | All of these symbols are used in cairo-script-surface.c for emitting mesh patterns. Signed-off-by: Uli Schlachter <psychon@znc.in>
* path: Always interpret in forward directionAndrea Canciani2010-12-101-4/+0
| | | | | | Path are always interpreted in forward direction, so the ability of interpreting in the opposite direction (which is very unlikely to be useful at all) can be removed.
* path: Cleanup unused current_pointAndrea Canciani2010-12-101-18/+0
| | | | | | The code keeps track of the current point but doesn't use it. Remove it to clean up.
* doc: Move tmpl/ docs to inline docsBenjamin Otte2010-07-081-0/+9
| | | | | | I did this manually so I could review the docs at the same time. If anyone finds typos or other mistakes I did, please complain to me (or better: fix them).
* Update FSF addressAndrea Canciani2010-04-271-1/+1
| | | | | | | | | | | I updated the Free Software Foundation address using the following script. for i in $(git grep Temple | cut -d: -f1 ) do sed -e 's/59 Temple Place[, -]* Suite 330, Boston, MA *02111-1307[, ]* USA/51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA/' -i "$i" done Fixes http://bugs.freedesktop.org/show_bug.cgi?id=21356
* Move _cairo_error() to a standalone headerChris Wilson2010-01-221-0/+1
| | | | | A pending commit will want to include some utility code from cairo and so we need to extricate the error handling from the PLT symbol hiding.
* [path] Fix regression introduced with 005436Chris Wilson2009-03-011-2/+2
| | | | | The order of the multiplication of the CTM and device_transform was reversed.
* [path] Inline path ops during append_to_context()Chris Wilson2009-02-131-18/+58
| | | | | | | | By inlining the operations, and most significantly, precomputing the combined user-to-backend matrix, we can achieve a speed up of over 50%, which is a noticeable performance boost in swfdec - where append-to-path accounts for over 35% [inclusive] of the time for a h/w accelerated backend.
* [path] Mark points as const during _cairo_path_fixed_interpret()Chris Wilson2008-12-121-11/+15
| | | | | Use const to document the read-only nature of the arguments passed to the callbacks.
* Mark allocation failures as unlikely.Chris Wilson2008-11-291-4/+4
| | | | | Use the gcc likelihood annotation to indicate that allocation failures are extremely unlikely.
* Mark if(status) as being unlikely.Chris Wilson2008-11-291-3/+3
| | | | | The error paths should be hit very rarely during normal operation, so mark them as being unlikely so gcc may emit better code.
* [doc] Replace 'NOTE' by 'Note' and add it to testBehdad Esfahbod2008-01-281-1/+1
|
* [doc] Make sure all function names in docs are followed by ()Behdad Esfahbod2008-01-281-3/+3
|
* [doc] Make sure all macro names in docs are prefixed by %Behdad Esfahbod2008-01-281-6/+6
|
* [path] use new interpret_flat infrastructure for path_populateBrian Ewins2008-01-211-37/+13
| | | | refactor to reduce duplication of flattening code.
* [path] Use new interpret_flat infrastructure for path_count.Brian Ewins2008-01-211-44/+18
| | | | Refactor to reduce duplication of path flattening code.
* [cairo-path] Return CAIRO_STATUS_SUCCESS.Chris Wilson2007-10-301-1/+1
| | | | | | If we have already returned the error status, then it is cleaner (and the common idiom) to use 'return CAIRO_STATUS_SUCCESS' rather than 'return status'.
* [cairo-path] Make _cairo_path_nil static.Chris Wilson2007-10-301-1/+1
| | | | | _cairo_path_nil is only used within cairo-path.c, so there is no reason to expose it to the rest of the libary.
* [cairo-error] Clean up all the warnings and missing _cairo_error() calls.Chris Wilson2007-10-041-8/+8
| | | | | | | | | | | Every time we assign or return a hard-coded error status wrap that value with a call to _cairo_error(). So the idiom becomes: status = _cairo_error (CAIRO_STATUS_NO_MEMORY); or return _cairo_error (CAIRO_STATUS_INVALID_DASH); This ensures that a breakpoint placed on _cairo_error() will trigger immediately cairo detects the error.
* [cairo-path] Don't raise an error when attempting to create an empty path.Chris Wilson2007-10-011-12/+24
| | | | | | | | | | Generate a real empty path structure instead of returning _cairo_path_nil, if we have been asked to create an empty path. (Also add a couple of missing _cairo_error()s and an appropriate test case.) Spotted by Fred Kiefer.
* [fix] Avoid int overflow when allocating large buffersVladimir Vukicevic2007-06-291-1/+1
| | | | | | | | This patch introduces three macros: _cairo_malloc_ab, _cairo_malloc_abc, _cairo_malloc_ab_plus_c and replaces various calls to malloc(a*b), malloc(a*b*c), and malloc(a*b+c) with them. The macros return NULL if int overflow would occur during the allocation. See CODING_STYLE for more information.
* [cairo-path] Check for errors during the count.Chris Wilson2007-05-161-1/+9
| | | | | | | Return the nil object if we encounter any error whilst trying to generate the path. Also special case the NO_MEMORY error object to return the nil object.
* Cleanup multi-line if conditionCarl Worth2007-04-101-9/+11
| | | | | The standard idiom of assigning to a local status variable looks much, much nicer here.
* cairo-path - check for failure during _cairo_path_fixed_interpretChris Wilson2007-04-091-23/+32
| | | | | | Catch an error return from _cairo_path_fixed_interpret() and return it. Similary check for an error code in cairo_status() before returning success.
* [src] Make sure all source files #include "cairoint.h" as their first includeBehdad Esfahbod2007-04-031-0/+2
| | | | | | | | | | | | | | | | | | This is necessary to avoid many portability problems as cairoint.h includes config.h. Without a test, we will regress again, hence add it. The inclusion idiom for cairo now is: #include "cairoint.h" #include "cairo-something.h" #include "cairo-anotherthing-private.h" #include <some-library.h> #include <other-library/other-file.h> Moreover, some standard headers files are included from cairoint.h and need not be included again.
* [cairo-path] Don't access gstate members directlyBehdad Esfahbod2007-03-211-3/+4
|
* In cairo_append_path(), allow excess path_data elementsBehdad Esfahbod2007-03-051-4/+4
|
* Rename remaining cairo_path_data to cairo_path in function names, etc.Carl Worth2006-12-191-118/+119
|
* Rename cairo-path-data.c to cairo-path.c (and similar)Carl Worth2006-12-191-0/+497
|
* Rename cairo-path.c to cairo-path-fixed.cCarl Worth2006-12-191-639/+0
|
* Fix close-path failure by adding explicit move_to after close_path.Carl Worth2006-08-181-4/+11
| | | | | | | | | | | Besides the bug fix, this is a user-visible change since the new move_to element after the close_path element can be seen in the results of cairo_copy_path, so we document that here. We are also careful to fix up _cairo_path_fixed_line_to to defer to _cairo_path_fixed_move_to to avoid letting the last_move_point state get stale. This avoids introducing the second bug that is also tested by the close-path test case.
* Change {x,y}_device_offset values to a device_transform matrix.Carl Worth2006-06-101-6/+23
| | | | | | | | | | | | | | | | | | This is a step toward allowing device scaling in addition to device offsets. So far, the scale values are still always 1.0 so only the translation is actually being used. But most of the code is in place for doing scaling as well and it just needs to be hooked up. There are some fragile parts in this code, all of which involve using the translation without the scale, (so grep for device_transform.x0 or device_transform->x0). Some of these are likely bugs that will hopefully be obvious once we start using the scale. Others are OK if only because we 'know' that we aren't ever setting device scaling on a surface that has a device offset (we only set device scaling on surfaces we create internally and we don't export device scaling to the user). All of these fragile parts in the code have been marked with comments of the form: XXX: FRAGILE.
* Remove initial, final, and duplicate blank lines.Carl Worth2006-06-061-1/+0
| | | | | | This patch was produced by running git-stripspace on all *.[ch] files within cairo. Note that this script would have also created all the changes from the previous commits to remove trailing whitespace.
* Remove all remaining trailing whitespace.Carl Worth2006-06-061-1/+1
| | | | | | | | | | | This patch was produced with the following (GNU) sed script: sed -i -r -e 's/[ \t]+$//' run on all *.[ch] files within cairo. Note that the above script would have also created all the changes from the previous commits to remove trailing whitespace.
* Implement the device_offset functionality at surface, not gstate layerCarl Worth2006-05-041-0/+46
| | | | | | | | | | This is a mega-patch that has the advantage that the entire test suite passes both immediately before and immediately after this commit. The disadvantage of the mega-patch is that it does not reflect the development history of the device-offset branch, (with its various fumblings and flailings). To capture that history, we will next merge in that branch.
* cairo_new_sub_path: Making cairo_arc easier to use and more.Carl Worth2006-02-231-10/+30
| | | | | | | | | | | | This adds a new function which has as its only effect the elimination of the current point. This makes it much easier to use the various cairo_arc calls when the initial line_to is not actually desired. This function also unifies and generalizes the long-existing behavior of cairo_line_to being treated as cairo_move_to when there is no current point. With the addition of cairo_new_sub_path this becomes a documented feature with similar behavior in cairo_curve_to as well.
* Split out scaled font code to cairo-scaled-font.cKeith Packard2005-08-311-0/+18
| | | | | | | | | | | | | Replace cairo cache implementation (this code from cworth) No more global glyph cache to clean up Store glyphs in new per-scaled font caches which hold user-space metrics and device space bounding boxes Refactor glyph drawing APIs so that the surface API is invoked directly from the gstate code. Add path creation/destruction routines (to hold glyph paths) New implementation of scaled fonts which uses per-scaled_font caches for glyphs and keeps user-space metrics, device-space bboxes along with glyph images and/or glyph paths. Adapt to new scaled font API changes. New cache and scaled_font APIs Repond to bug fix in metrics computation for glyphs where y values were rounded up instead of down because of a sign difference between cairo and FreeType. Reviewed by: otaylor, cworth
* Fills as paths patch originally by Owen Taylor.Kristian Høgsberg2005-05-031-0/+9
| | | | | | Make sure we have a current point for the relative path operators. Add fill_path backend method. Implement fill_path in the PDF backend.
* Use correct arguments to compute absolute positions.Keith Packard2005-05-021-4/+4
| | | | | Test cairo_rel_move_to, cairo_rel_line_to and cairo_rel_curve_to reviewed by: cworth
* Originally: 2005-04-19 Carl Worth <cworth@cworth.org>Carl Worth2005-04-261-37/+56
| | | | | | | | | | | | | Add cairo_stroke_preserve, cairo_fill_preserve, and cairo_clip_preserve. Rip the path out of cairo_gstate_t. Add path to cairo_t. Bring in most of the path code that used to live in cairo-gstate.c Move arc generation code into its own file. Accept path+ctm_inverse+tolerance instead of gstate. Absorb flattening and device space->user space conversion that used to be in _cairo_gstate_intepret_path. Prefer cairo_fixed_t parameters over ciaro_point_t for cross-file interfaces. Track changes in _cairo_path_fixed interfaces. Port to use cairo_fill_preserve rather than cairo_save/cairo_restore which no longer work for saving the path. Remove get and set of current point since it is no longer affected by cairo_save and cairo_restore. Add get and set testing for cairo_matrix_t.
* Clean up names of cairo_path internals.Carl Worth2005-03-231-147/+146
|
* Rename cairo_path_real_t to cairo_path_fixed_t and fix all _cairo_path ↵Carl Worth2005-03-231-37/+37
| | | | | | functions to be named as _cairo_path_fixed functions. Track name change of cairo_path_real_t and _cairo_path_fixed functions.
* Begin the process of breaking up cairoint.h, moving structure definitions of ↵Carl Worth2005-03-231-0/+2
| | | | | | cairo_t, cairo_gstate_t, and cairo_path_real_t into their own header files. Track changes to header files, reaching into the new private headers where necessary.
* * src/cairo.c: (cairo_copy_path), (cairo_copy_path_flat), ↵Carl Worth2005-03-181-27/+35
| | | | | | | (cairo_append_path): Rename cairo_copy_path_data, cairop_copy_path_data_flat, and cairo_append_path_data to cairo_copy_path, cairo_copy_path_flat, and cairo_append_path. Add new cairo_path_t, containing a cairo_path_data_t array and an explicit length. Remove CAIRO_PATH_END_PATH terminator from cairo_path_data_t. Rename the internal path object from cairo_path_t to cairo_path_real_t.