summaryrefslogtreecommitdiff
path: root/src/cairo-clip.c
Commit message (Collapse)AuthorAgeFilesLines
* Use _cairo_malloc instead of mallocAdrian Johnson2018-05-071-4/+4
| | | | | | | | | | _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>
* clip: Transform clip path in _cairo_clip_intersect_clip_path_transformed()Henry (Yu) Song - SISA2012-07-241-0/+2
| | | | | | | | | | _cairo_clip_intersect_clip_path_transformed() completely ignored the transformation matrix instead of transforming all the clip paths with it. This caused bugs when replaying recording surfaces. Fixes record{2x,1414x,90}-paint-alpha-clip-mask.
* 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>
* spans+image: Fix clipping with polygons and spansChris Wilson2012-02-281-0/+18
| | | | | Fixes: clip-source, random-clip Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* Merge branch 'master' of git://cairographics.org/git/cairoChris Wilson2011-10-151-1/+6
|\
| * clip: Replace the original clip when transformingChris Wilson2011-10-121-1/+5
| | | | | | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
| * clip: Free the freed clip pool on resetChris Wilson2011-10-121-0/+1
| | | | | | | | | | | | To keep valgrind happy. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* | backends: Adds a new Cogl based backendRobert Bragg2011-10-111-1/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a new GPU accelerated backend for Cairo based on the Cogl 3D graphics API. This backend aims to support Cairo in a way that translates as naturally as possible to using a GPU, it does not strive to compete with the anti-aliasing quality of the image backend if it can't be done efficiently using the GPU - raw performance isn't the only metric of concern, so is power usage. As an overview of how the backend works: - fills are handled by tessellating paths into triangles - the backend has an extra fill_rectangle drawing operation so we have a fast-path for drawing rectangles which are so common. - strokes are also tessellated into triangles. - stroke and fill tessellations are cached to avoid the cpu overhead of tessellation and cost of upload given that its common for apps to re-draw the same path multiple times. The tessellations can survive translations and rotations increasing the probability that they can be re-used. - sources and masks are handled using multi-texturing. - clipping is handled with a scissor and the stencil buffer which we're careful to only update when they really change. - linear gradients are rendered to a 1d texture using a triangle strip + interpolating color attributes. All cairo extend modes are handled by corresponding texture sampler wrap modes without needing programmable fragment processing. - antialiasing should be handled using Cogl's multisampling API XXX: This is a work in progress!! TODO: - handle at least basic radial gradients (No need to handle full pdf semantics, since css, svg and canvas only allow radial gradients defined as one circle + a point that must lie within the first circle.) - currently we fall back to pixman for radial gradients. - support glyph rendering with a decent glyph cache design. The current plan is a per scaled-font growable cache texture + a scratch cache for one-shot/short-lived glyphs. - decide how to handle npot textures when lacking hardware support. Current plan is to add a transparent border to npot textures and use CLAMP_TO_EDGE for the default EXTEND_NONE semantics. For anything else we can allocate a shadow npot texture and scale the original to fit that so we can map extend modes to texture sampler modes.
* wrapper: transform the clip into device spaceChris Wilson2011-09-201-0/+107
| | | | | | We need more than just mere translation! Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* Introduce a new compositor architectureChris Wilson2011-09-121-13/+7
| | | | | | | | | | | | | | | | | | 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. :)
* clip: Fix copy of clip rectangles listAndrea Canciani2011-07-301-0/+3
| | | | | | | | _cairo_clip_get_region() returns NULL both for non-region clips and for memory allocaiton failures. They must be distinguished by checking _cairo_clip_is_region(). Fixes get-clip.
* clip: Fix clip-equal to handle one or the other being NULL/all-clippedChris Wilson2011-07-291-0/+10
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* clip: Fix cairo_clip_equal()Chris Wilson2011-07-291-1/+35
| | | | | | In haste, I completely removed the implementation... Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* record: Store the untransformed operation extents along with the commandChris Wilson2011-07-261-7/+0
| | | | | | | | | This allows us to actually clip out the geometry before we record it, as suggested by allowing the user to supply an extents... But it will be advantageous in later patches for reducing the amount of work we need to perform to replay. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* wrapper: Correct translation of clip for wrapper extentsChris Wilson2011-07-241-0/+36
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* clip: Embed a single box to avoid a common allocationChris Wilson2011-07-241-10/+23
| | | | Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* image: replay the recording surface directly onto the targetChris Wilson2011-07-231-2/+65
| | | | | | | | | | | | | | 백현기 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>
* xcb: Take advantage of clip-boxesChris Wilson2011-07-201-0/+32
| | | | | | | | | | | | | | | | | A demonstration of step 2, improves performance for selected benchmarks on selected GPUs by up to 30%. firefox-fishbowl on snb {i5-2520m): 42s -> 29s. firefox-talos-gfx on snb: 7.6 -> 5.2s. firefox-fishbowl on pnv (n450): 380 -> 360s. Whist this looks like it is getting close to as good as we can achieve, we are constrained by both our API and Xrender and fishbowl is about 50% slower than peak performance (on snb). And it fixes the older performance regression in firefox-planet-gnome. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* clip: Rudimentary support for clip-polygon extractionChris Wilson2011-07-191-1235/+179
| | | | | | | 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-2/+5
| | | | | | | | | | 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>
* Remove conditional compilation of freed-poolsAndrea Canciani2011-07-051-2/+0
| | | | | | | | | | | Conditional compilation was needed to avoid warnings: cairo-clip.c:51: warning: ‘clip_path_pool’ defined but not used cairo.c:181: warning: ‘context_pool’ defined but not used They can be avoided by making sure that _freed_pool_reset(ptr) actually consumes its argument. This has the pleasant side-effect that forgetting to properly reset a freed-pool now results in a warning if atomic ops are disabled/not available.
* clip: Fix boxes extents computation in intersect_with_boxesAndrea Canciani2011-06-251-12/+14
| | | | | | | | | | | | | | | The extents of the boxes were being computed by taking into account just the first box instead of all of them. Based on a patch by James Cloos. Fixes clip-disjoint, clip-stroke-unbounded, clip-fill-nz-unbounded, clip-fill-eo-unbounded, clip-fill, clip-stroke, trap-clip. See https://bugs.freedesktop.org/show_bug.cgi?id=38641 Reviewed-by: James Cloos <cloos@jhcloos.com> Tested-by: James Cloos <cloos@jhcloos.com>
* Fix intersect_with_boxes() to produce tight clip extentsTaekyun Kim2011-06-211-2/+3
| | | | | | Previous code was intersecting extents with infinitely large rectangle. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
* Do not warn when ignoring the return value of _cairo_rectangle_intersect()Andrea Canciani2011-03-191-6/+4
| | | | | | | | | | | | 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-3/+2
| | | | | | | | | | | 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).
* clip: Improve _cairo_clip_contains_*Andrea Canciani2011-01-221-4/+2
| | | | | | | | _cairo_clip_contains_rectangle() considered a NULL clip empty instead of containing everything. _cairo_clip_contains_rectangle() checks for NULL clips, so we don't have to check for them in _cairo_clip_contains_extents().
* doc: Fix some broken references and gtk-doc warningsMaarten Bosmans2011-01-161-1/+1
| | | | The gtk-doc comments contain some typos and are missing some escaping.
* polygon: Merge _cairo_polygon_init and _cairo_polygon_limitAndrea Canciani2010-12-101-2/+1
| | | | | | | _cairo_polygon_limit() had to be called immediately after _cairo_polygon_init() (or never at all). Merging the two calls is a simple way to enforce this rule.
* path: Do not access flags directlyAndrea Canciani2010-10-291-9/+9
| | | | | | | 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.
* clip: consider gstate target extents in _cairo_gstate_copy_clip_rectangle_listKarl Tomlinson2010-07-171-46/+26
| | | | | | | | | | 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>
* clip: consider all_clipped in _cairo_clip_get_extentsKarl Tomlinson2010-07-171-0/+5
| | | | | | | | | | | | If the gstate clip in _cairo_gstate_int_clip_extents() has all_clipped set (and path NULL), then it returns the gstate target extents instead of an empty rectangle. If the target is infinite, then it says the clip is unbounded. Fixes https://bugs.freedesktop.org/show_bug.cgi?id=29124 Tested-by test/get-clip Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
* clip: return empty clip from _cairo_clip_copy_rectangle_list when all_clippedKarl Tomlinson2010-07-171-1/+4
| | | | | | | Fixes https://bugs.freedesktop.org/show_bug.cgi?id=29122 Tested by test/get-clip Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
* clip: Do the NULL check before the dereference.Chris Wilson2010-07-121-1/+2
| | | | Breakage introduced in the commit earlier today.
* Differentiate between reducing clip to composite extents and a rectangleChris Wilson2010-07-121-7/+15
| | | | | This is required for handling glyphs when rendering directly to the surface.
* gstate: Track whether the combination of ctm * device is identity.Chris Wilson2010-06-101-0/+1
| | | | | | 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.
* clip: Fill instead of creating intermediate surfaces.Chris Wilson2010-05-121-1/+3
|
* clip: Propagate failure from retrieving the previous clip surface.Chris Wilson2010-05-061-1/+2
|
* clip: Trivial compiler warningChris Wilson2010-05-051-1/+2
| | | | | | cairo-clip.c: In function ‘_cairo_clip_path_reapply_clip_path_translate’: cairo-clip.c:446: warning: suggest parentheses around assignment used as truth value
* clip: Propagate memfault from translating clip regionChris Wilson2010-05-051-0/+6
|
* 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
* clip: Skip combining with solid pixel aligned boxes.Chris Wilson2010-04-251-0/+6
|
* clip: Fix sign reverse when combining with the clip surface.Chris Wilson2010-04-251-22/+2
| | | | | | Finally, found the reversed sign in the clipping code, thanks cu! Fixes: test/clip-shape
* clip: Report the surface offset when retrieving the clip maskChris Wilson2010-04-251-6/+20
| | | | | | | | Stop the callers from guessing the origin of the clip surface by reporting it explicitly! This enables the clip to bypass any rectangles overlaid on top of the clip surface, which is common when the backends limit the clip to the extents of the operation -- but irrelevant to the actual content of the clip mask
* clip: Compile fix for previous clip.Chris Wilson2010-04-101-3/+0
| | | | PEBKAC.
* clip: Compare the whole clip when testing for equality.Chris Wilson2010-04-101-3/+37
| | | | Should fix test/clip-contexts
* clip: propagate the no-clip through the copy.Chris Wilson2010-03-241-0/+1
|
* clip: Don't reduce all-clip to no-clip.Chris Wilson2010-03-241-1/+2
|
* clip: Remove the redundant _cairo_clip_init_rectangle()Chris Wilson2010-03-231-19/+11
| | | | | | | | | | | | As _cairo_clip_init_rectangle() is equivalent and more importantly more clearly written as: _cairo_clip_init(&clip); if (status = _cairo_clip_rectangle(&clip, &rect)) { _cairo_clip_fini(&fini); return status; } perform the transformation and in the process catch a few mistakes along error paths.
* clip: Restrict composite extents to clip extentsChris Wilson2010-02-121-0/+84
| | | | Fixes test/clip-rectangle-twice.