Commit graph

50 commits

Author SHA1 Message Date
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
Adrian Johnson
f0ce8658f9 Fix user-font with foreground in group failures on image, PDF, and PS 2023-01-03 17:37:36 +10:30
Adrian Johnson
8ea4ae5413 Allow user fonts to use the foreground color 2021-09-18 07:05:35 +09:30
Adrian Johnson
1c64d2635b Remove all gstate from _cairo_surface_tag
The gstate is not required and was causing some tag operations to be
ignored.
2021-07-18 18:13:10 +09:30
Adrian Johnson
3bd5efa1b6 Add tag functions to recording surface and surface-wrapper 2016-10-01 17:26:16 +09:30
Adrian Johnson
14fa88fd02 pdf: fix record-replay-extend test failures 2016-06-05 20:43:36 +09:30
Adrian Johnson
d2dc2e90a7 Fix test failures when recording surface extents has negative x,y
Fixes record-neg-bounded-extents (image only) and
recording-ink-extents.
2016-06-05 20:43:36 +09:30
Adrian Johnson
2215b4e0c0 ps: fix subsurface recordings 2015-10-17 18:16:32 +10:30
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
Alexander Larsson
900fc4a890 gstate: Move device-scale font scaling to gstate
If we do this in surface it will be applied twice then
we chain to a different surface, like e.g. a subsurface.

We also remove a hack in cairo-surface-wrapper where it compensated
for the device scale not being applied.

v2: Compute the backend CTM in ensure_scaled_font().
2013-09-05 16:08:19 +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
5bd29eda63 surface-wrapper: Only apply the wrapped transform to the scaled-font
And not the device_transform of the target. This smells fishy, but
appears to make the test suite happy.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-03-06 14:11:49 +00:00
Chris Wilson
be5ab6df68 surface-wrapper: Apply the scaled-font ctm and non-default font-options
Improves record*-text-transform.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-02-28 18:11:22 +00:00
Chris Wilson
b1b5e9b908 surface-wrapper: Apply replay transforms to scaled font
Improves: record2x-select-font-face, record2x-text-transform
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-02-27 14:48:59 +00:00
Chris Wilson
7e3c963191 surface-wrapper: Transform the clip by the device-transform correctly
Fixes paginated fallbacks.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-02-22 19:55:22 +00:00
Uli Schlachter
f7eaf37f04 Wrapper: Don't translate clips extents' origin
If a bounded recording surface doesn't have its extents .x and .y at the
surface's origin, this code was translating all clips to make up for that.
However, the clip already is in device space.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=41583

Signed-off-by: Uli Schlachter <psychon@znc.in>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-02-10 18:00:01 +01:00
Chris Wilson
da95bdfcd7 wrapper: transform the clip into device space
We need more than just mere translation!

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-09-20 14:04:29 +01:00
Chris Wilson
09b42c748e wrapper: intersect with target extents
Treat the target extents as an implicit clip for computing the maximal
operation extents.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-09-17 12:00:49 +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
Chris Wilson
0053a44f6b record: Offset the clip by the replay transformation as well
Fixes push-group-offset which reduces to a replay of a recording surface
inside a recording surface and forgot to offset the clip imposed by the
extents of the first recording surface into device space.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-08-14 14:45:00 +01:00
Chris Wilson
3db39deee2 wrapper: Use the backend->snapshot function
Create the snapshot now, rather than a new lazy snapshot surface.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-08-14 12:37:57 +01:00
Chris Wilson
4862aadb0f surface-wrapper: Initialise clip to NULL
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-08-13 11:08:58 +01:00
Chris Wilson
69c1ec9f13 script: Compile fix
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-08-10 14:06:16 +01:00
Chris Wilson
b492b69d4f wrapper: translate the clip by the device transform
A stepping stone, the translation was accidentally dropped when
changing the clipping to be performed first.

Fixes twin.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-26 16:38:31 +01:00
Chris Wilson
168b5a5348 wrapper: target to recording needs the inverse transform
Gah, I thought about this and noted that I need the inverse of the
normal transformation, yet failed to remember to actually use it.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-26 09:05:02 +01:00
Chris Wilson
c596483f85 record: Check the operation against the target device extents.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-26 08:42:53 +01:00
Chris Wilson
8dc9139fb2 recording: Combine the clip to the recording + target surface extents
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-24 18:10:43 +01:00
Chris Wilson
4c72c4df66 wrapper: Correct translation of clip for wrapper extents
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-24 16:27:07 +01:00
Chris Wilson
cc745f5c2f wrapper: show-text-glyphs can now operate on constant array of glyphs
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-24 15:48:27 +01:00
Chris Wilson
415d5d8fce wrapper: Use the stack for small glyph allocations
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-24 15:45:57 +01:00
Chris Wilson
8102bd8681 wrapper: Factor out the common clip handling
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-24 15:33:21 +01:00
Chris Wilson
87e9c8a5ea recording: Move the glyph allocation into the wrapper after checking clip status
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-24 15:10:18 +01:00
Chris Wilson
926287aeea surface-wrapper: Fix use of uninitialised variable
Introduced recently in a30a7402f7,

==32234== Conditional jump or move depends on uninitialised value(s)
==32234==    at 0x6BCA326: _cairo_surface_wrapper_needs_device_transform (cairo-surface-wrapper.c:549)
==32234==    by 0x6BCB47D: _cairo_surface_wrapper_set_inverse_transform (cairo-surface-wrapper.c:579)
==32234==    by 0x6BCB55A: _cairo_surface_wrapper_init (cairo-surface-wrapper.c:621)
==32234==    by 0x6BB87A6: _cairo_recording_surface_replay_internal (cairo-recording-surface.c:854)

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-23 22:58:55 +01:00
Chris Wilson
a30a7402f7 image: replay the recording surface directly onto the target
백현기 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-23 15:33:14 +01:00
Chris Wilson
b132fae5e8 clip: Rudimentary support for clip-polygon extraction
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-19 21:14:34 +01:00
Chris Wilson
2458120dee pattern: Add observer hooks
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-15 11:05:19 +01:00
Adrian Johnson
3445401ae6 Fix regression in fallback-resolution test
a2254e56 caused the fallback-resolution test to display empty fallback
images for to push_group/pop_group part of the test.
2010-11-21 20:09:13 +10:30
Chris Wilson
8ded35fd69 ps: Enable native encoding of subsurface patterns.
Carefully handle subsurfaces of a recording surface through the analysis
and paginated surfaces so that we can generate a native pattern for the
vector backends, demonstrated by the PostScript backend.

Nothing remarkable, just a lot of bookkeeping to track the wrapped
surface types and to apply the correct offsets when generating the
subsurface pattern.
2010-04-30 10:16:24 +01:00
Andrea Canciani
b8a7f8621a Update FSF address
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-27 11:13:38 +02:00
Chris Wilson
1ddcd5cf31 clip: Remove the redundant _cairo_clip_init_rectangle()
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-03-23 16:43:39 +00:00
Chris Wilson
2a59f0af6a wrapper: Apply device transform inverse as appropriate.
Fixes many failures of the paginated surfaces as they replayed through
the recording surfaces.
2010-03-21 20:38:27 +00:00
Chris Wilson
cfd204824f Constify stroke style and matrices.
As a simple step to ensure that we do not inadvertently modify (or at least
generate compiler warns if we try) user data, mark the incoming style
and matrices as constant.
2010-01-22 23:01:49 +00:00
Chris Wilson
c50c8b90c0 Move _cairo_error() to a standalone header
A pending commit will want to include some utility code from cairo and
so we need to extricate the error handling from the PLT symbol hiding.
2010-01-22 22:30:43 +00:00
Chris Wilson
558f950170 surface-wrapper: Avoid copying patterns and clips unless transformed.
An older variant of the fixes for moving the device transformation out
of the surface layer, but languished in a side branch. The only benefit
of this patch is that it avoids the copy where possible.
2010-01-22 22:30:43 +00:00
Benjamin Otte
16fffc5c05 Apply device transform in surface wrapper 2009-11-27 21:04:48 +01:00
M Joonas Pihlaja
68c8eb955d [wrapper] Avoid a void return gccism.
Returning void using the pattern "return func_returning_void(...)"
is a gccism not supported by Sun Studio 12.
2009-09-01 23:30:56 +03:00
Chris Wilson
ce6a2cc5d2 [wrapper] Always copy clip
We always need to make a local copy of the clip as the backends are free
to modify it as they process the operation.
2009-08-29 17:07:33 +01:00
Chris Wilson
658cdc7c9a Introduce cairo_tee_surface_t
Add a new surface type that multiplies it input onto several output
surfaces. The only limitation is that it requires a master surface that is
used whenever we need to query surface options, such as font options and
extents.
2009-08-29 08:08:39 +01:00
Chris Wilson
8f8b91d904 [script] Wrap snapshot.
Use the snapshot of our target surface if available.
2009-08-29 08:08:37 +01:00
Chris Wilson
bed2701e1c Remove clip handling from generic surface layer.
Handling clip as part of the surface state, as opposed to being part of
the operation state, is cumbersome and a hindrance to providing true proxy
surface support. For example, the clip must be copied from the surface
onto the fallback image, but this was forgotten causing undue hassle in
each backend. Another example is the contortion the meta surface
endures to ensure the clip is correctly recorded. By contrast passing the
clip along with the operation is quite simple and enables us to write
generic handlers for providing surface wrappers. (And in the future, we
should be able to write more esoteric wrappers, e.g. automatic 2x FSAA,
trivially.)

In brief, instead of the surface automatically applying the clip before
calling the backend, the backend can call into a generic helper to apply
clipping. For raster surfaces, clip regions are handled automatically as
part of the composite interface. For vector surfaces, a clip helper is
introduced to replay and callback into an intersect_clip_path() function
as necessary.

Whilst this is not primarily a performance related change (the change
should just move the computation of the clip from the moment it is applied
by the user to the moment it is required by the backend), it is important
to track any potential regression:

ppc:
Speedups
========
image-rgba         evolution-20090607-0    1026085.22 0.18% -> 672972.07 0.77%:  1.52x speedup
▌
image-rgba         evolution-20090618-0    680579.98 0.12% -> 573237.66  0.16%:  1.19x speedup
▎
image-rgba      swfdec-fill-rate-4xaa-0    460296.92 0.36% -> 407464.63  0.42%:  1.13x speedup
▏
image-rgba      swfdec-fill-rate-2xaa-0    128431.95 0.47% -> 115051.86  0.42%:  1.12x speedup
▏
Slowdowns
=========
image-rgba     firefox-periodic-table-0    56837.61 0.78% -> 66055.17    3.20%:  1.09x slowdown
▏
2009-07-23 15:32:14 +01:00