summaryrefslogtreecommitdiff
path: root/src/cairo-clip.c
AgeCommit message (Collapse)AuthorFilesLines
2011-10-15Merge branch 'master' of git://cairographics.org/git/cairoChris Wilson1-1/+6
2011-10-12clip: Replace the original clip when transformingChris Wilson1-1/+5
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-10-12clip: Free the freed clip pool on resetChris Wilson1-0/+1
To keep valgrind happy. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-10-11backends: Adds a new Cogl based backendRobert Bragg1-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.
2011-09-20wrapper: transform the clip into device spaceChris Wilson1-0/+107
We need more than just mere translation! Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-09-12Introduce a new compositor architectureChris Wilson1-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. :)
2011-07-30clip: Fix copy of clip rectangles listAndrea Canciani1-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.
2011-07-29clip: Fix clip-equal to handle one or the other being NULL/all-clippedChris Wilson1-0/+10
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-29clip: Fix cairo_clip_equal()Chris Wilson1-1/+35
In haste, I completely removed the implementation... Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-26record: Store the untransformed operation extents along with the commandChris Wilson1-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>
2011-07-24wrapper: Correct translation of clip for wrapper extentsChris Wilson1-0/+36
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-24clip: Embed a single box to avoid a common allocationChris Wilson1-10/+23
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-23image: replay the recording surface directly onto the targetChris Wilson1-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>
2011-07-20xcb: Take advantage of clip-boxesChris Wilson1-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>
2011-07-19clip: Rudimentary support for clip-polygon extractionChris Wilson1-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>
2011-07-15pattern: Add observer hooksChris Wilson1-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>
2011-07-15Implement cairo_backend_tChris Wilson1-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>
2011-07-05Remove conditional compilation of freed-poolsAndrea Canciani1-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.
2011-06-25clip: Fix boxes extents computation in intersect_with_boxesAndrea Canciani1-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>
2011-06-21Fix intersect_with_boxes() to produce tight clip extentsTaekyun Kim1-2/+3
Previous code was intersecting extents with infinitely large rectangle. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-03-19Do not warn when ignoring the return value of _cairo_rectangle_intersect()Andrea Canciani1-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.
2011-03-18Improve cairo_rectangle_list_t error handlingAndrea Canciani1-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).
2011-01-22clip: Improve _cairo_clip_contains_*Andrea Canciani1-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().
2011-01-16doc: Fix some broken references and gtk-doc warningsMaarten Bosmans1-1/+1
The gtk-doc comments contain some typos and are missing some escaping.
2010-12-10polygon: Merge _cairo_polygon_init and _cairo_polygon_limitAndrea Canciani1-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.
2010-10-29path: Do not access flags directlyAndrea Canciani1-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.
2010-07-17clip: consider gstate target extents in _cairo_gstate_copy_clip_rectangle_listKarl Tomlinson1-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>
2010-07-17clip: consider all_clipped in _cairo_clip_get_extentsKarl Tomlinson1-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>
2010-07-17clip: return empty clip from _cairo_clip_copy_rectangle_list when all_clippedKarl Tomlinson1-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>
2010-07-12clip: Do the NULL check before the dereference.Chris Wilson1-1/+2
Breakage introduced in the commit earlier today.
2010-07-12Differentiate between reducing clip to composite extents and a rectangleChris Wilson1-7/+15
This is required for handling glyphs when rendering directly to the surface.
2010-06-10gstate: Track whether the combination of ctm * device is identity.Chris Wilson1-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.
2010-05-12clip: Fill instead of creating intermediate surfaces.Chris Wilson1-1/+3
2010-05-06clip: Propagate failure from retrieving the previous clip surface.Chris Wilson1-1/+2
2010-05-05clip: Trivial compiler warningChris Wilson1-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
2010-05-05clip: Propagate memfault from translating clip regionChris Wilson1-0/+6
2010-04-27Update FSF addressAndrea Canciani1-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
2010-04-25clip: Skip combining with solid pixel aligned boxes.Chris Wilson1-0/+6
2010-04-25clip: Fix sign reverse when combining with the clip surface.Chris Wilson1-22/+2
Finally, found the reversed sign in the clipping code, thanks cu! Fixes: test/clip-shape
2010-04-25clip: Report the surface offset when retrieving the clip maskChris Wilson1-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
2010-04-10clip: Compile fix for previous clip.Chris Wilson1-3/+0
PEBKAC.
2010-04-10clip: Compare the whole clip when testing for equality.Chris Wilson1-3/+37
Should fix test/clip-contexts
2010-03-24clip: propagate the no-clip through the copy.Chris Wilson1-0/+1
2010-03-24clip: Don't reduce all-clip to no-clip.Chris Wilson1-1/+2
2010-03-23clip: Remove the redundant _cairo_clip_init_rectangle()Chris Wilson1-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.
2010-02-12clip: Restrict composite extents to clip extentsChris Wilson1-0/+84
Fixes test/clip-rectangle-twice.
2010-02-02clip: Propagate all-clipped when copyingChris Wilson1-5/+2
Fixes test/clip-empty-save. The all-clipped flag was not being copied to the new clip, which occurs for instance when an empty clip is pushed via a gstate save.
2010-01-25clip: Create a fallback clip surfaceChris Wilson1-0/+5
If the destination cannot support a clip surface, then we will need to use an intermediate image surface and trigger fallbacks upon use.
2010-01-22clip: Implement clipping using only the high-level operators.Chris Wilson1-132/+125
Revamp clipping in preparation for the removal of the low-level interface and promote backend to use the higher levels. The principle here is that the higher level interface gives the backend more scope for choosing better performing primitives.
2010-01-22pattern: Add convenience patterns for stock coloursChris Wilson1-18/+11
By preallocating in our data segment a couple of solid patterns for the stock colours, it becomes more convenient when using those in surface operations, such as when clearing.