summaryrefslogtreecommitdiff
path: root/src/cairo-xlib-surface.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix undefined left-shiftsHeiko Lewin2021-03-311-1/+1
|
* cairo-xlib: Check for maximum surface sizeUli Schlachter2021-01-131-2/+0
| | | | | | | | | | | | | X11 use uint16_t for the width/height of things. Anything too large will be truncated when sending the request to the X11 server. This commit adds a size check to a function that did not check things and then later caused a segmentation fault. Not adding a test case because the test case from the below bug report allocates 3,5 GiB of memory, which I find too much for a test. Fixes: https://gitlab.freedesktop.org/cairo/cairo/-/issues/414 Signed-off-by: Uli Schlachter <psychon@znc.in>
* 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>
* Cairo trivial typosUnknown2018-04-021-1/+1
| | | | | | | | | | | | | Found using `codespell -q 3 -I cairo-whitelist.txt` whereby whitelist contained: ``` amin iff lod writen ``` Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
* xlib: Call XSync() before ignoring errorsUli Schlachter2017-03-071-0/+2
| | | | | | | | | | | | | The code here wants to ignore errors for a specific request. To do so, it sets a no-op error handler. However, it could happen that some previous request caused an error and this error will also be ignored by the no-op error handler. To avoid this, call XSync() before setting the error handler. This makes sure that all pending errors are handled. Signed-off-by: Uli Schlachter <psychon@znc.in> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
* xlib: Remove unused variableUli Schlachter2017-03-071-6/+0
| | | | | | | This constant seems to be unused since commit af9fbd176b145f042408ef from 2011. Signed-off-by: Uli Schlachter <psychon@znc.in>
* xlib: Fix double free in _get_image_surface()Uli Schlachter2016-06-191-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | If XShmGetImage() fails, the code tries to continue with its normal, non-shared-memory path. However, the image variable, which was previously set to NULL, now points to an already-destroyed surface, causing a double-free when the function cleans up after itself (actually, its an assertion failure because the reference count of the surface is zero, but technically this is still a double free). Fix this by setting image=NULL after destroying the surface that this refers to, to make sure this surface will not be destroyed again. While we are here (multiple changes in a single commit are bad...), also fix the cleanup done in bail. In practice, &image->base should be safe when image==NULL, because this just adds some offset to the pointer (the offset here is actually zero, so this doesn't do anything at all). However, the C standard does not require this to be safe, so let's handle this case specially. Note that anything that is fixed by this change is still buggy, because the only reason why XShmGetImage() could fail would be BadDrawable, meaning that the target we draw to does not exist or was already destroyed. This patch will likely just cause X11 errors elsewhere and drawing to (possible) invalid drawables is not supported by cairo anyway. This means that if SHM fails, the following fallback code has a high chance of failing, too. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=91967 Signed-off-by: Uli Schlachter <psychon@znc.in>
* 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
* Provide backwards compatibilty with old pixmanChris Wilson2013-08-231-0/+1
| | | | | | | The goal is to allow compilation against older pixman to ease regression testing. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* xlib: Aquire display before using it in DEBUG message.egag2013-04-251-2/+2
|
* xlib/shm: Always request a CompletionEvent from ShmPutImageChris Wilson2013-01-291-2/+1
| | | | | | ...and treat is as an expected event for synchronisation. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* xlib: Do not upload the whole image just because we want an entire rowChris Wilson2013-01-231-13/+11
| | | | | | | | | | | | | | | | | | | | | | | | Fixes regression exposed by commit a73e7ff0186176bc82cd3ae1432c054c1fd3aebd Author: Chris Wilson <chris@chris-wilson.co.uk> Date: Sun Jan 6 11:29:27 2013 +0000 xlib: Simplify source creation by use of map-to-image but ultimately from commit 74941f822015cc50cd8477d0cf97f1a70dbff60b Author: Chris Wilson <chris@chris-wilson.co.uk> Date: Wed Jan 2 22:27:55 2013 +0000 xlib: Use SHM transport for ordinary image uploads Reported-by: Gökçen Eraslan <gokcen.eraslan@gmail.com> Reported-by: Guillaume Ayoub <guillaume.ayoub@kozea.fr> Reported-by: Emmanuel Benisty <benisty.e@gmail.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=59635 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* xlib: Use SHM transport for ordinary image uploadsChris Wilson2013-01-031-23/+77
| | | | | | | | In theory this should just save a single copy, however PutImage will break up requests into a series of scanlines requests which is less efficient than the single-shot transfer provided by ShmPutImage. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* Revert "xlib/shm: Do not trigger a surplus event from XShmPutImage"Chris Wilson2012-12-291-1/+1
| | | | | | This reverts commit c97f2d4acd5c4a1a4b839c72626f84e242e60b23. Testing suggests that keeping that event is a win; so do so.
* xlib/shm: Do not trigger a surplus event from XShmPutImageChris Wilson2012-12-291-1/+1
| | | | | | | As our lazy event mechanism is sufficient for tracking when to reuse shm memory, and the events are not necessary for ShmPut/ShmGetImage paths. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* xlib: Reset fallback counter when discarding the fallbackWeng Xuetian2012-09-131-0/+2
| | | | References: https://bugs.freedesktop.org/show_bug.cgi?id=54657
* xlib: Destroy the fallback damage along with the fallback surfaceChris Wilson2012-09-131-8/+5
| | | | | | | | | | | | | | | Whenever we discard the fallback surface, we need to destroy the associated damage tracking, so move this into the common discard routine. This should fix the issue when trying to flush the fallback before the user modifies any foreign Drawables. The current code issued the flush and then explicitly discard the fallback, but unless it was idle at the time of the flush the associated damage would not have also been destroyed. Asserts followed. References: https://bugs.freedesktop.org/show_bug.cgi?id=54657 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* xlib: Do not call _cairo_xlib_surface_flush directlyChris Wilson2012-09-131-2/+2
| | | | | | | | | Use the higher level layer to be sure we detach any snapshots and other cached data that is invalidated along with the change of Drawable. Pointed out by the eternally wise Uli Schlachter. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* xlib: Force the fallback flush before updating the external DrawableChris Wilson2012-09-131-2/+2
| | | | | | | | | | | | | _cairo_surface_begin_modification() performs an internal flush, for which the xlib backend skips flushing the fallback surface as it will continue to use it for the subsequent operation. In the case where we are flushing prior to updating the Drawable, we need to perform an external flush which will trigger the posting of the damage from the fallback surface. Reported-by: Weng Xuetian <wengxt@gmail.com> References: https://bugs.freedesktop.org/show_bug.cgi?id=54657 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* xlib: Explicitly discard the fallback shm pixmap upon user modificationChris Wilson2012-09-131-9/+29
| | | | | | | | | | If the user changes the size of the underlying drawable, we much make sure that we discard the current ShmPixmap in order to create a new fallback pixmap of the correct size next time. Reported-by: Weng Xuetian <wengxt@gmail.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* xlib: Fix regression in cairo_xlib_surface_set_drawable()Chris Wilson2012-09-131-1/+1
| | | | | | | | | | | | | | | | | In 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 I made the mistake of inverting the logic for cairo_xlib_surface_set_drawable() causing it then to never update. Thanks to Uli Schlachter for spotting my error. References: https://bugs.freedesktop.org/show_bug.cgi?id=54657 Reported-by: Weng Xuetian <wengxt@gmail.com> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* xlib/shm: Explicitly release shm surface if we do not own the pixmapChris Wilson2012-09-081-2/+9
| | | | | | | In this case we want to prevent the short-circuiting of the flush of the ShmPixmap that is ordinarily performed during finish(). Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* xlib/shm: Add missing release of the display after GetImageChris Wilson2012-08-241-1/+3
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* xlib/shm: Use an impromptu upload ShmSegmentChris Wilson2012-08-171-3/+2
| | | | | | | | Reduce the number of copies required for uploading large image data. Ultimately we want the client to allocate the similar-image itself to acheive zero copy, this is just an intermediate step for legacy clients. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* xlib/shm: Limit use of the impromptu fallback pixmap for uploadsChris Wilson2012-08-171-2/+2
| | | | | | | We want to avoid unnecessary readback and so only want to use the ShmPixmap when uploading the complete surface. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* xlib: Implement SHM fallbacks and fast upload pathsChris Wilson2012-08-171-39/+247
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* surface: Make backend-specific map/unmap functions symmetricAndrea Canciani2012-05-261-5/+12
| | | | 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.
* 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>
* xlib: Fix inline conversion for TrueColor PutImageChris Wilson2012-04-251-2/+1
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* xlib: Allow applications to create 0x0 surfacesChris Wilson2012-04-251-1/+8
| | | | | | | | | | | | | | | | | Although 0x0 is not a legimate surface size, we do allow applications the flexibility to reset the size before drawing. As we previously never checked the size against minimum legal constraints, applications expect to be able to create seemingly illegal surfaces, and so we must continue to provide backwards compatibility. Many thanks to Pauli Nieminen for trawling through the protocol traces, diving into the depths of libreoffice and identifying the regression. Fixes https://bugs.freedesktop.org/show_bug.cgi?id=49118 (presentation mode in loimpress is blank). Reported-by: Eric Valette <eric.valette@free.fr> 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>
* doc: do not use / in section titleNis Martensen2012-04-161-1/+1
| | | | | | | | | | The Title: field is used to determine the file name of the generated html. Due to the slash a subdirectory is created and all relative links in the generated file are broken. Use a hyphen instead. Signed-off-by: Uli Schlachter <psychon@znc.in>
* doc: Add "since" tag to documentationAndrea Canciani2012-03-291-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* doc: ensure "compatibility" spellingNis Martensen2012-03-101-1/+1
| | | | | | This changes not only comments, but also code! Signed-off-by: Uli Schlachter <psychon@znc.in>
* xlib: Tidy conversion of xrender format to cairo_content_tChris Wilson2012-02-231-13/+9
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* xlib: Trim the ximage to match the trimming of the intermediateChris Wilson2012-02-221-0/+2
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* xlib: Correct the device-offset applied to the map-to-image resultChris Wilson2012-02-221-1/+1
| | | | | | | A typo, a typo surely, to use extents->y twice instead of the more normal x, y. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* xlib: Trim the intermediate upload image to match the upload extentsChris Wilson2012-02-221-9/+7
| | | | | | | Rather than transform the whole image, just convert the region of interest. 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>
* xlib: Only reduce a readback of an uninitialised source for pixmapsChris Wilson2012-02-021-1/+3
| | | | | | | | For a foreign drawable, we have to assume to that is dirty upon creation or otherwise we fail to read back the correct pixel data when copying to an image. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* xlib: Set IncludeInferiors when acquiring the source imageChris Wilson2012-02-021-0/+8
| | | | | | | If we need to fallback and perform a copy first to a pixmap for a partially unviewable Window, we need to copy its inferiors as well. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* xlib: Improve choice of bits-per-pixel for depthChris Wilson2012-01-171-10/+15
| | | | | | | | The only reliable method would be to query the xserver for the matching bpp for a particular depth. In the absence of such information, simply chose the next higher power-of-two(depth). Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* xlib: Check pixman format before trying to create an image surface for itCarlos Garcia Campos2011-10-271-6/+9
|
* Introduce a new compositor architectureChris Wilson2011-09-121-3039/+185
| | | | | | | | | | | | | | | | | | 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-15/+6
| | | | | | | | | | | 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>
* xlib: Fix typo in snapshotting.Chris Wilson2011-08-201-1/+1
| | | | | | We want to only copy up to the maximum height, not width... Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* xlib: Mark surfaces as finished when the Display is finished/destroyed/closed.Chris Wilson2011-08-141-0/+4
| | | | | | Fixes xlib-surface-source with the recording-surface 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>