summaryrefslogtreecommitdiff
path: root/src/cairo-script-surface.c
Commit message (Collapse)AuthorAgeFilesLines
* cairo-list-inline.h: fixes and documentationAdrian Johnson2023-04-161-2/+1
| | | | | | - Fix a bug in cairo_list_is_singular - Rename cairo_list_swap() to cairo_list_move_list() to better describe what it is doing.
* [scaled-font] Clean up font-options before copyBehdad Esfahbod2023-01-191-0/+1
|
* Fix shared use of recording surface with paginated targetsAdrian Johnson2023-01-151-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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().
* Merge branch 'script-bug-277' into 'master'Uli Schlachter2022-12-311-1/+11
|\ | | | | | | | | | | | | script: Implement device finish Closes #277 See merge request cairo/cairo!292
| * script: Implement device finishUli Schlachter2022-03-081-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this commit, calling cairo_device_finish() on a cairo-script context did not actually do anything in the backend. Thus, it was possible to continue emitting output on the script context even after it was finished, which means that API user had no way of preventing use-after-free bugs in their write callback. Bug 277 triggers this via detaching a snapshot, but I guess one could also simply continue drawing to a script surface. This commit implements the finish function by closing the underlying stream. However, that was not enough to fix things. This commit also turns writing into a stream into a no-op after the stream was closed. I checked that the new test case actually fails before this commit and is indeed fixed by it. Fixes: https://gitlab.freedesktop.org/cairo/cairo/-/issues/277 Signed-off-by: Uli Schlachter <psychon@znc.in>
* | Merge branch 'bug-535' into 'master'Adrian Johnson2022-12-281-1/+1
|\ \ | | | | | | | | | | | | | | | | | | Fix bug #535 in cairo-script Closes #535 See merge request cairo/cairo!276
| * | Fix bug #535 in cairo-scriptUli Schlachter2022-02-161-1/+1
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | cairo-script has a special case for drawing a set of rectangles. The rectangle detection can trip over a "degenerate rectangle": Just a horizontal line. It detects the line as the beginning of a rectangle and then claims CAIRO_STATUS_INVALID_PATH_DATA when the other sides of the rectangle are missing. This commit simply changes the return value to CAIRO_INT_STATUS_UNSUPPORTED to trigger a fallback to the generate case. Test case is a straight-forward adaption from the original bug report. Signed-off-by: Uli Schlachter <psychon@znc.in> Fixes: https://gitlab.freedesktop.org/cairo/cairo/-/issues/535
* | Replace use of ctype functions with internal version where only ASCII chars ↵Adrian Johnson2022-04-091-1/+1
|/ | | | | | | | | are used In !309 Taylor R Campbell found a number of instances of ctype incorrectly passed a signed char. In many cases, where only ASCII characters are used, the code should have been using the cairo version of the ctype function to avoid locale issues.
* 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.
* Added hairline support to cairoRick Yorgason2021-08-151-0/+22
|
* Use uintptr_t for all casts between pointer and integerAdrian Johnson2021-07-251-5/+5
| | | | | | | | | | | | 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
* script-surface: Fix unitialized variable compiler warningMathieu Duponchelle2020-07-181-1/+1
| | | | | gcc doesn't warn about this because status is potentially initialized in a loop.
* 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>
* Add support for RGBA128F and RGB96F formats.Maarten Lankhorst2019-01-071-0/+20
| | | | | | | | | | | | | | 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>
* script-surface: Check for invalid ids (CID #1159557, 1159558)Bryce Harrington2018-06-131-0/+1
| | | | | | | | | | | | | If the bitmap's min is non-zero, _bitmap_next_id() could break out of its loop early, before initializing the prev variable. prev would then be dereferenced without a null ptr check. This condition should never occur in practice, so add an assert() to assure it doesn't. Same issue is present in trace.c. Coverity IDs: #1159557, #1159558 Reviewed-By: Uli Schlachter <psychon@znc.in> Signed-off-by: Bryce Harrington <bryce@bryceharrington.org>
* Use _cairo_malloc instead of mallocAdrian Johnson2018-05-071-8/+8
| | | | | | | | | | _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: prevent invalid ptr access for > 4GB imagesAdrian Johnson2017-11-071-1/+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>
* Don't cull very thin lines on vector surfacesAdrian Johnson2015-10-171-2/+4
| | | | | | On vector surfaces, use a minimum line width when calculating extents. Bug 77298
* cairo-script: Return a cairo_status_t error, not FALSEBryce Harrington2015-06-261-1/+1
| | | | | | | | This typo results in certain paths being incorrectly recorded with script surfaces. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=91054 Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
* cairo-script: Fix sp. "directoriy"Bryce Harrington2015-06-251-1/+1
| | | | Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
* script: Thaw the scaled font cache on the error pathChris Wilson2013-01-081-1/+3
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* Update the remaining backends to handle a NULL extents for ↵Chris Wilson2012-04-271-3/+5
| | | | | | _cairo_surface_get_source Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* snapshot: Perform the cow under a mutexChris Wilson2012-04-271-2/+3
| | | | | | | | | | | | 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-list 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-2/+2
| | | | | References: https://bugs.freedesktop.org/show_bug.cgi?id=48577 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* doc: Fix some wrong versionsAndrea Canciani2012-03-291-1/+1
| | | | | The script from the previous commit reported that some 'Since' fields indicate incorrect versions.
* doc: Add "since" tag to documentationAndrea Canciani2012-03-291-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Do not use the '@' prefix on some tagsAndrea Canciani2012-03-291-1/+1
| | | | | | | Make the 'Since' and 'Returns' tags consistent by removing the '@' prefix. Fixes some "missing 'Since' field" warnings.
* doc: Make documentation comments symmetricAndrea Canciani2012-03-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* script: Update mesh pattern for earlier change of csi operatorsChris Wilson2012-02-221-7/+7
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* Replace the ad-hoc surface unwrappers with a function pointerChris Wilson2012-02-091-0/+14
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* script: Add documentationChris Wilson2011-12-021-21/+139
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* Convert cairo_mime_surface_t to cairo_raster_source_pattern_tChris Wilson2011-11-251-2/+30
| | | | | | | | | | 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>
* script: Tag the similar surface rather than snapshotChris Wilson2011-09-151-4/+3
| | | | | | | As we discard the snapshot immediately upon drawing to it, it serves no purpose. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* Introduce a new compositor architectureChris Wilson2011-09-121-99/+80
| | | | | | | | | | | | | | | | | | 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. :)
* api: Extend cairo_antialias_t to include performace/quality hintsChris Wilson2011-08-301-1/+4
| | | | | | | | | | | The existing API only described the method to be used for performing rasterisation and unlike other API provided no opportunity for the user to give a hint as to how to trade off performance against speed. So in order to no be overly prescriptive, we extend the NONE/GRAY/SUBPIXEL methods with FAST/GOOD/BEST hints and leave the backend to decide how best to achieve those goals. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* observer: record all operations and their timingsChris Wilson2011-08-201-8/+43
| | | | | | | | The immediate use of this is to print out the slowest operation of each type in a replayable manner. A continuing demonstration of how we may analyse traces... Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* script: Hook image caching into the snapshot mechanismChris Wilson2011-08-141-67/+7
| | | | | | | | So that we remember to forget the old image when the surface is dirtied. Fixes filter-bilinear-extents. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* script: take advantage of the polymorphism of the interpreterChris Wilson2011-08-141-16/+19
| | | | | | | | If a function expects a surface but receives a context, it automatically queries the context's target. We can take advantage of this to short-cut a few operations. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: peek through a snapshot to the recording surface behindChris Wilson2011-08-141-1/+1
| | | | | | Fixes record-* after the recent overhaul. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* subsurface+recording: handle recursionChris Wilson2011-08-141-59/+70
| | | | | | | | Ouch, a nasty bug surfaces after rearranging code to fix the others. Another self-copy loop this time through a subsurface of a recording surface. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* recording: remove the duplicate 'content' fieldChris Wilson2011-08-141-2/+2
| | | | | | Just use the member in the base class. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* script: Support unbounded native recording surfacesChris Wilson2011-08-141-44/+54
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* snapshot: Defer acquisitionChris Wilson2011-08-141-27/+101
| | | | | | Fixes 'xlib-expose-event' but triggers an infinite loop in self-copy. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* script: Emit sequences of boxes to as 'rectangle' for clarityChris Wilson2011-08-131-21/+72
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: move surface definition to new header for subclassingChris Wilson2011-08-131-0/+1
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* script: Remove reference to image-surface-privateChris Wilson2011-08-121-1/+0
| | | | | | That header doesn't exist yet. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* script: Compile fixChris Wilson2011-08-101-1/+2
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* Remove useless checks for NULL before freeingAndrea Canciani2011-07-311-12/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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); - }
* Silence Clang static analyzer reportsAndrea Canciani2011-07-291-0/+2
| | | | | | Clang static analysis triggers some reports in non-buggy code. Silence them trying to follow better coding practices.