Commit graph

37 commits

Author SHA1 Message Date
Adrian Johnson
b53b48116e Make cairo_tag_begin/end work correctly in groups
Fixes #508
2023-04-18 18:27:12 +09:30
Adrian Johnson
7146358250 Fix shared use of recording surface with paginated targets
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().
2023-01-15 19:29:28 +10:30
Uli Schlachter
e5b9d96f22 Avoid a use-after-scope
This is the same fix as commit b345be5afe, but in a different place in
the same file.

Fixes: https://gitlab.freedesktop.org/cairo/cairo/-/issues/453
Signed-off-by: Uli Schlachter <psychon@znc.in>
2021-03-09 07:53:50 +01:00
Matthias Clasen
b345be5afe Avoid a use-after-free
asan was complaining that the limits struct goes out
of scope before it is used via the pointer in the polygon struct,
and it is right:

==386746==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7ffd3ccebdfc at pc 0x7f783d5eaaee bp 0x7ffd3cceba80 sp 0x7ffd3cceba70
READ of size 4 at 0x7ffd3ccebdfc thread T0
    #0 0x7f783d5eaaed in _add_clipped_edge ../src/cairo-polygon.c:351
    #1 0x7f783d5ebba3 in _cairo_polygon_add_edge ../src/cairo-polygon.c:520
    #2 0x7f783d5ebc82 in _cairo_polygon_add_external_edge ../src/cairo-polygon.c:530
    #3 0x7f783d582149 in _cairo_filler_line_to ../src/cairo-path-fill.c:63
    #4 0x7f783d588d9c in _cairo_path_fixed_interpret ../src/cairo-path-fixed.c:831
    #5 0x7f783d582a44 in _cairo_path_fixed_fill_to_polygon ../src/cairo-path-fill.c:147
    #6 0x7f783d6204fe in _cairo_spans_compositor_fill ../src/cairo-spans-compositor.c:1151
    #7 0x7f783d5126de in _cairo_compositor_fill ../src/cairo-compositor.c:203
    #8 0x7f783d5571f9 in _cairo_image_surface_fill ../src/cairo-image-surface.c:1003
    #9 0x7f783d647f2f in _cairo_surface_fill ../src/cairo-surface.c:2424
    #10 0x7f783d52ebea in _cairo_gstate_fill ../src/cairo-gstate.c:1312
    #11 0x7f783d51cca4 in _cairo_default_context_fill ../src/cairo-default-context.c:1057
    #12 0x7f783d6812d6 in cairo_fill ../src/cairo.c:2421
2021-01-22 13:28:44 -05:00
Alexander Larsson
bc792a5e0e surface: Merge scratch construction into _cairo_surface_create_scratch
We merge _cairo_surface_create_similar_scratch and
_cairo_surface_create_similar_solid into a single function named
_cairo_surface_create_scratch, to avoid confusion with
cairo_surface_create_similar which now will have a different
behaviour wrt the sizes and the device-scale.

_create_scratch assumes the width and height are in backend
coordinates, while create_similar does not.
2013-09-05 16:11:09 +01:00
Chris Wilson
38217d67fc spans,traps: Undo device transform from source matrix for recording replays
As the replay of the recording surface applies the device_transform of
the matrix once again to all its operations, we end up with a repeated
transform through the source matrix of the recording surface. We need to
remove one of these, and the easiest way to do that appears to be to
undo the application to the source matrix.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-09-05 16:08:19 +01:00
Chris Wilson
14237f1143 spans: Mark the surface as cleared in preparing for recording surface playback
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2013-02-12 10:11:12 +00:00
Chris Wilson
b6daf47fa0 spans: Do not assume that we manage to perform the clip geometrically
Even for bounded masks, we may fail to perform the clipping
geometrically for a variety of reasons, the prime one being that the
clip has a mixture of antialias settings. So when compositing the
polygon, we need to check whether a clip path still remains and so
requires a clipmask.

Fixes regression from

commit cd1004ce19
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Fri May 11 21:20:35 2012 +0100

    traps,spans-compositor: Avoid mistreating unaligned clips as aligned

and

commit 4ea3ace6c8
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Fri May 11 21:51:44 2012 +0100

    spans: Only fallback for a clipmask if unbounded

Reported-by: Dominik Röttsches <dominik.rottsches@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=56574
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-11-01 08:43:26 +00:00
Chris Wilson
dbc0d83f2a image: Add a couple of tracepoints for spans fallbacks
References: https://bugs.freedesktop.org/show_bug.cgi?id=56574
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-10-31 15:18:21 +00:00
Chris Wilson
cabb3c3bdf spans-compositor: Remove polygon limits after construction
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-09-27 12:21:00 +01:00
Chris Wilson
36536d3eb8 spans-compositor: Use the tight clip-boxes for polygon construction
If we will be reducing the clip intersection to a single clip box check
during construction, it helps if we use the tight clip box.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-09-27 11:14:18 +01:00
Chris Wilson
1bc696a8fd spans-compositor: After polygon intersection the fill rule is always non-zero
As it turns out due to the rules of polygon intersection, there is never
any overlapping spans so the choice is arbitrary. However, lets be
consistent with the rest of the code.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-06-08 17:26:11 +01:00
Chris Wilson
099420a07c spans: Debug input paths and polygons
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-05-14 17:57:24 +01:00
Chris Wilson
4ea3ace6c8 spans: Only fallback for a clipmask if unbounded
For a bounded operation with a clip we will already have performed the
clip geometrically.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-05-11 21:53:55 +01:00
Chris Wilson
cd1004ce19 traps,spans-compositor: Avoid mistreating unaligned clips as aligned
An unaligned clip requires careful handling, and so exclude processing
along the fast paths.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-05-11 21:31:13 +01:00
Chris Wilson
de1150cc0e spans-compositor: Add tracepoints for debugging
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-05-11 21:31:13 +01:00
Chris Wilson
197e5b7324 spans-compositor: Handle unaligned unbounded boxes
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-05-11 21:31:13 +01:00
Chris Wilson
2e7d60e0a2 Split cairo-pattern-private into struct+inlines
References: https://bugs.freedesktop.org/show_bug.cgi?id=48577
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-04-19 12:55:44 +01:00
Chris Wilson
8653c2692e Split cairo-recording-surface-private into struct+inlines
References: https://bugs.freedesktop.org/show_bug.cgi?id=48577
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-04-19 12:46:34 +01:00
Chris Wilson
0770dda52b Split cairo-clip-privates into struct+inlines
References: https://bugs.freedesktop.org/show_bug.cgi?id=48577
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-04-19 12:19:19 +01:00
Chris Wilson
d67f02e23e spans-compositor: Only destroy the clip if we made the copy
The extents->clip may be replaced elsewhere and so we cannot assume that
simply because it changed from the stashed value, that it was us that
made that copy. So becareful to only free our copy.

Fixes a double-free of a clip after a complex fallback operation.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-03-13 11:16:39 +00:00
Chris Wilson
e572ae253a spans: Handle fallbacks from upload-boxes by reverting to the normal composite
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-03-05 12:02:31 +00:00
Chris Wilson
38a242a380 spans,image,gl: Add fast-path for simple copies
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-03-04 22:54:02 +00:00
Chris Wilson
aed5a1cf1e spans: Reduce composite_aligned_boxes with over to source for opaque patterns
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-03-04 22:54:02 +00:00
Chris Wilson
bda545dee4 spans: Retrim extents to clipped polygon
After combining the mask polygon with the clip polygon, recompute the
extents of the operation.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-03-04 16:16:19 +00:00
Chris Wilson
b55e7c776f spans: Pass antialiasing hint down to the backends
The actual span rasterisers may be able to specialise if they know that
the spans will be pixel aligned.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-03-04 15:38:56 +00:00
Chris Wilson
cdbf4c60fe spans,traps-compositor: Check for all-clipped after intersecting clip with boxes
If the mask does not intersect the clip, then there is no drawing to be
performed and we can report NOTHING_TO_DO.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-02-29 14:40:06 +00:00
Chris Wilson
a49a26f961 gl: Various fixes for glyphs
Not 100% improvement, there are still a variety of failures with
GLXWindows, but getting there. At least it fixes more things than its
breaks...

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-02-29 10:27:39 +00:00
Chris Wilson
3c665102c2 spans+image: Fix clipping with polygons and spans
Fixes: clip-source, random-clip
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-02-28 22:27:18 +00:00
Chris Wilson
3443ad903d spans: Pass unbounded operations to the spans compositors
Only bail if we need to combine clipping with the spans (either for a
bounded or unbounded operation).

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-02-09 22:08:41 +00:00
Chris Wilson
2061cd81f2 Replace the ad-hoc surface unwrappers with a function pointer
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-02-09 13:01:17 +00:00
Andrea Canciani
a2f419b546 rectangle: Implement _cairo_rectangle_contains_rectangle()
And reuse it.
2012-01-15 18:25:57 +01:00
Chris Wilson
8f34fa033e spans: Refresh polygon limits after trimming the composite extents
Trimming the composite extents may result in the clip being
reconstructed, but we the polygon continued to hold a reference into the
freed clip's array of boxes. So if we intend to reuse the polygon limits
after performing the clip we need to refresh them.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-10-12 17:04:16 +01:00
Chris Wilson
b2aa687de6 spans: Propagate internal status when retrieving the clip surface
Including the information that there is nothing to do due to being
all-clipped-out.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-10-12 14:50:41 +01:00
Chris Wilson
719bef0c90 image: Enable use of LERP_SRC for masked source composition
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-09-30 13:07:23 +01:00
Chris Wilson
d71ce5e0dd spans: Fix empty polygon unbounded fixup
There is a subtle flaw in the current querying of polygon extents; it
simply returns the limits and not the point extremeties and certainly
not the tessellation extents. Computing that is likely to take long than
rendering the polygon. This does mean that we need to also fixup the
extents prior to performing the empty unbounded fast path.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-09-23 23:24:25 +01:00
Chris Wilson
af9fbd176b Introduce a new compositor architecture
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-09-12 08:29:48 +01:00