summaryrefslogtreecommitdiff
path: root/src/cairo-image-surface.c
Commit message (Collapse)AuthorAgeFilesLines
* Bail early from _cairo_image_compute_color if image is zero-sized. Jonathan Kew2021-05-051-0/+3
| | | This avoids the risk of encountering undefined behavior when computing the `pixel` pointer (even though it won't actually be used) in the case where the image width or height is zero and the data is NULL. (Observed when called from cairo_pdf_surface code when an extreme scaling transform was present, though I guess there are probably other ways to end up with such an image.)
* Add support for RGBA128F and RGB96F formats.Maarten Lankhorst2019-01-071-0/+16
| | | | | | | | | | | | | | 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-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>
* image: Disambiguate 0. in doxygenBryce Harrington2017-08-211-2/+2
| | | | | | | | | Doxygen is interpreting the leading 0. as starting an ordered list, and misformatting the HTML documentation. Issue reported by Артур Галямов. Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
* image: only cache analyzed transparency/color for snapshot surfacesAdrian Johnson2016-06-191-32/+54
| | | | https://lists.cairographics.org/archives/cairo/2016-June/027429.html
* Don't cull very thin lines on vector surfacesAdrian Johnson2015-10-171-1/+2
| | | | | | On vector surfaces, use a minimum line width when calculating extents. Bug 77298
* image: Fix bad HTML generation in code docs for cairo-format-stride-for-widthBryce Harrington2014-02-261-1/+1
| | | | | | Patch from Simon Kågedal Reimer Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=63257
* image: Handle PIXMAN_a8r8g8b8_sRGB in switchUli Schlachter2013-09-161-0/+3
| | | | | | | | | | | Fixes the following compiler warning: cairo-image-surface.c: In function '_cairo_format_from_pixman_format': cairo-image-surface.c:93: warning: enumeration value 'PIXMAN_a8r8g8b8_sRGB' not handled in switch Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=58726 Signed-off-by: Uli Schlachter <psychon@znc.in>
* win32: Prevent double-free of similar imagesChris Wilson2013-08-231-1/+2
| | | | | | | | | | | | | | | Based on a patch and analysis by Michael Henning. When we create a similar-image surface for win32, we set up a couple of back references from the image to the win32 surface, and vice versa. We need to be careful when decoupling the reference cycle to avoid chasing around the loop upon destruction. Currently we handled destroying the similar-image via the parent win32 surface, but similar precaution is required when destroying the surface via the similar-image. Reported-by: Michael Henning <drawoc@darkrefraction.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=63787 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* Provide backwards compatibilty with old pixmanChris Wilson2013-08-231-0/+5
| | | | | | | The goal is to allow compilation against older pixman to ease regression testing. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Mark the data as owned after stealing the snapshot's imageChris Wilson2013-06-201-1/+1
| | | | | | | | | | | | | | | | | | | Victor Goya found that we ended up leaking memory after reading a PNG into an image surface and drawing that onto a PDF surface. In particular, he discovered that commit 0bfd2acd35547fc2bd0de99cc67d153f0170697d Author: Chris Wilson <chris@chris-wilson.co.uk> Date: Mon Aug 13 01:34:12 2012 +0100 xlib: Implement SHM fallbacks and fast upload paths introduced a path to steal the image data for a snapshot (and thereby avoid a redundant copy), but that path then lead to the leak of the "owned" data. Reported-by: Victor Goya <victor.goya@af83.com> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Add a convenience function for creating an image from another's dataChris Wilson2013-02-011-0/+55
| | | | | | | | | The GL backend would like to extract a rectangle from another surface and convert it to a different pixel format. The _cairo_image_surface_create_from_image() does that by returning a new image that has the contents of the specified rectangle in the source Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Add a reference for the clone's parent imageChris Wilson2013-01-311-1/+8
| | | | | | | | | | | | | | We use the parent as a flag during map-to-image/umap-image that the resultant image came from a fallback rather than as direct call to the backend's map_to_image(). Whilst we use it as a simple flag, we need to make sure the parent surface obeys the reference counting semantics and is consistent for all callers. Unlike other users of the parent pointer, there is no resource sharing between the two surfaces. Reported-by: Henry Song <henry.song@samsung.com> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* xlib: Implement SHM fallbacks and fast upload pathsChris Wilson2012-08-171-1/+1
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* surface: replace map-to-image clone's use of user_data with parent pointerChris Wilson2012-05-311-11/+1
| | | | | | | Removes an another undeclared PLT entry and prevents mixing of user_data with internal state. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Propagate errors from clone_subimageChris Wilson2012-05-261-7/+19
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* surface: Make backend-specific map/unmap functions symmetricAndrea Canciani2012-05-261-0/+3
| | | | Map allocates a surface. Symmetrically, unmap should destroy it.
* surface: Make map_to_image return cairo_image_surface_t*Andrea Canciani2012-05-261-2/+2
| | | | | This makes it easier to check that the funciton is returning the correct type of surfaces.
* surface: Define private map/unmap functionsAndrea Canciani2012-05-261-0/+41
| | | | | | | | | | | | | | | Cairo backends often need to map/unmap to a raster surface but they don't care about the pixel format, as Pixman will be doing the format handling. Cairo users cannot know how to access the raw data if the format is invalid. The two different scenarios call for different guarantees on the returned surface. The private map/unmap functions also makes it possible to simply return the status upon unmapping.
* 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>
* image: Allow a snapshot to steal the original memory upon finishChris Wilson2012-04-271-0/+18
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* Split cairo-recording-surface-private into struct+inlinesChris Wilson2012-04-191-5/+5
| | | | | References: https://bugs.freedesktop.org/show_bug.cgi?id=48577 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* fix bug in _cairo_image_analyze_colorAdrian Johnson2012-04-041-1/+4
|
* doc: Add "since" tag to documentationAndrea Canciani2012-03-291-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* image: Add the get-font-options callback again.Chris Wilson2012-02-201-1/+1
| | | | | | | | | | | | In the midst of trying to simply export the _cairo_image_surface_get_font_options() for subclassing, I accidentally decoupled it from the image surface backend. Mea culpa. Fixes regression from 8bea52bb (Add preliminary damage tracking), which should not have even touched the backend structure except for an ugly rebasing. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* win32: Fix lifetime tracking of create_similar_image()Chris Wilson2012-02-151-0/+5
| | | | | | | | | | | As we return the child image to the user and so perform the reference tracking on it and not the parent win32 display surface, we need to add a call to destroy the parent from the image surface. This of course complicates the normal scenario of destroying the parent first, and so in that case we need to unhook the image->parent before freeing the surface->image. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* win32: Rebase on the new compositor infrastructureChris Wilson2012-02-151-1/+24
| | | | | | | | | | 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>
* Add preliminary damage trackingChris Wilson2012-02-151-3/+3
| | | | | | | | This is initially based around the requirements for handling internal fallbacks to the image compositor and reducing the number of pixels required to be transferred. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* directfb: Discard long broken code and return to basicsChris Wilson2012-02-091-5/+5
| | | | | | | | | Rewrite the directfb backend as nothing more than a simpler image compositor onto a shadowfb that is flushed back to the dfb surface as required. Future refinements would be to add damage tracking, and to mix the useful directfb operations (such as solid fills and alpha blends). 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>
* Introduce a new compositor architectureChris Wilson2011-09-121-3935/+46
| | | | | | | | | | | | | | | | | | 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. :)
* image: peek through a snapshot to the recording surface behindChris Wilson2011-08-141-2/+6
| | | | | | Fixes record-* after the recent overhaul. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* snapshot: Defer acquisitionChris Wilson2011-08-141-2/+31
| | | | | | Fixes 'xlib-expose-event' but triggers an infinite loop in self-copy. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: move surface definition to new header for subclassingChris Wilson2011-08-131-20/+27
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: check if A8 image is bilevel when analyzing transparencyAdrian Johnson2011-08-051-2/+13
|
* image: fix bug in analyze_colorAdrian Johnson2011-08-041-1/+1
|
* pdf: check if images are grayscale or monochrome and encode as suchAdrian Johnson2011-08-021-0/+59
| | | | | | Printing PDFs with large monochrome or grayscale images would result in the images being blown up to 24-bit color images. Some printers are very slow to print huge color images.
* image: the boxes are already pixel-aligned so skip the extra rounding stepChris Wilson2011-08-011-12/+12
|
* image: Reduce compositing bounded boxes with a clip-mask to a polygonChris Wilson2011-07-311-0/+42
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Free clip_surface after useChris Wilson2011-07-291-9/+14
| | | | | | | The clip surface is no longer cached on the clip and the caller is responsible for destroying it after use. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: extend support of direct replay for paginated surfacesChris Wilson2011-07-291-12/+60
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* composite: Pass unbounded extents to initialisationChris Wilson2011-07-261-28/+28
| | | | | | | | For an unbounded surface we cannot assume (0, 0, surface_width, surface_height) as that is wrong and causes the operation to appear clipped. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* API: map-to-image and create-similar-imageChris Wilson2011-07-261-1/+36
| | | | | | | | | | | | | | | | A common requirement is the fast upload of pixel data. In order to allocate the most appropriate image buffer, we need knowledge of the destination. The most obvious example is that we could use a shared-memory region for the image to avoid the transfer cost of uploading the pixels to the X server. Similarly, gl, win32, quartz... The other side of the equation is that for manual modification of a remote surface, it would be more efficient if we can create a similar image to reduce the transfer costs. This strategy is already followed for the destination fallbacks and this merely exposes the same capability for the application fallbacks. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Fix clip-intersectChris Wilson2011-07-241-7/+12
| | | | | | Explicitly convert the clearing of the unbounded area. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Apply mask-opacity to clip boxesChris Wilson2011-07-231-146/+299
| | | | | | | | In the simple condition where the user is applying an opacity mask to a misaligned rectangle, we can treat it as a series of simpler composites by combining the opacity with the coverage of the box. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: replay the recording surface directly onto the targetChris Wilson2011-07-231-1/+63
| | | | | | | | | | | | | | 백현기 reported a use-case where he was recording an entire web-page onto the recording surface, in order to facilitate panning. In this scenario, where there may be lots of similar surfaces within the recording we generate thousands of unused snapshot-images bloating memory usage and impairing performance. Under the right conditions we can replay directly onto the destination which not only bypasses the snapshots but also skips the following resampling. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: Fix partial clipping of textChris Wilson2011-07-231-19/+63
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* clip: Rudimentary support for clip-polygon extractionChris Wilson2011-07-191-360/+147
| | | | | | | 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>