summaryrefslogtreecommitdiff
path: root/src/cairo-recording-surface-private.h
diff options
context:
space:
mode:
authorAdrian Johnson <ajohnson@redneon.com>2023-01-01 15:14:08 +1030
committerAdrian Johnson <ajohnson@redneon.com>2023-01-15 19:29:28 +1030
commit7146358250975ec0f29b8ba80e80a26c52526bdc (patch)
treee37c45b2f6c4523aab202b331a4094949b189040 /src/cairo-recording-surface-private.h
parenta2b376ed787fc35270421730863411a0c047f564 (diff)
downloadcairo-7146358250975ec0f29b8ba80e80a26c52526bdc.tar.gz
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().
Diffstat (limited to 'src/cairo-recording-surface-private.h')
-rw-r--r--src/cairo-recording-surface-private.h63
1 files changed, 55 insertions, 8 deletions
diff --git a/src/cairo-recording-surface-private.h b/src/cairo-recording-surface-private.h
index 3d325383b..7d4de1ed9 100644
--- a/src/cairo-recording-surface-private.h
+++ b/src/cairo-recording-surface-private.h
@@ -1,3 +1,4 @@
+/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
/* cairo - a vector graphics library with display and print output
*
* Copyright © 2005 Red Hat, Inc
@@ -55,14 +56,19 @@ typedef enum {
} cairo_command_type_t;
typedef enum {
- CAIRO_RECORDING_REGION_ALL,
+ CAIRO_RECORDING_REGION_ALL = 0,
CAIRO_RECORDING_REGION_NATIVE,
CAIRO_RECORDING_REGION_IMAGE_FALLBACK
} cairo_recording_region_type_t;
+typedef enum {
+ CAIRO_RECORDING_REPLAY,
+ CAIRO_RECORDING_CREATE_REGIONS,
+ CAIRO_RECORDING_REPLAY_REGION
+} cairo_recording_replay_type_t;
+
typedef struct _cairo_command_header {
cairo_command_type_t type;
- cairo_recording_region_type_t region;
cairo_operator_t op;
cairo_rectangle_int_t extents;
cairo_clip_t *clip;
@@ -155,8 +161,27 @@ typedef struct _cairo_recording_surface {
struct bbtree *left, *right;
cairo_command_header_t *chain;
} bbtree;
+
+ /* The mutex protects modification to all subsequent fields. */
+ cairo_mutex_t mutex;
+
+ cairo_list_t region_array_list;
+
} cairo_recording_surface_t;
+typedef struct _cairo_recording_region_element {
+ cairo_recording_region_type_t region;
+ unsigned int source_id;
+ unsigned int mask_id;
+} cairo_recording_region_element_t;
+
+typedef struct _cairo_recording_region_array {
+ unsigned int id;
+ cairo_reference_count_t ref_count;
+ cairo_array_t regions; /* cairo_recording_region_element_t */
+ cairo_list_t link;
+} cairo_recording_regions_array_t;
+
slim_hidden_proto (cairo_recording_surface_create);
cairo_private cairo_int_status_t
@@ -182,18 +207,21 @@ cairo_private cairo_status_t
_cairo_recording_surface_replay_with_clip (cairo_surface_t *surface,
const cairo_matrix_t *surface_transform,
cairo_surface_t *target,
- const cairo_clip_t *target_clip);
+ const cairo_clip_t *target_clip,
+ cairo_bool_t surface_is_unbounded);
cairo_private cairo_status_t
-_cairo_recording_surface_replay_and_create_regions (cairo_surface_t *surface,
+_cairo_recording_surface_replay_and_create_regions (cairo_surface_t *surface,
+ unsigned int regions_id,
const cairo_matrix_t *surface_transform,
- cairo_surface_t *target,
- cairo_bool_t surface_is_unbounded);
+ cairo_surface_t *target,
+ cairo_bool_t surface_is_unbounded);
cairo_private cairo_status_t
_cairo_recording_surface_replay_region (cairo_surface_t *surface,
- const cairo_rectangle_int_t *surface_extents,
+ unsigned int regions_id,
+ const cairo_rectangle_int_t *surface_extents,
cairo_surface_t *target,
- cairo_recording_region_type_t region);
+ cairo_recording_region_type_t region);
cairo_private cairo_status_t
_cairo_recording_surface_get_bbox (cairo_recording_surface_t *recording,
@@ -211,4 +239,23 @@ _cairo_recording_surface_has_only_bilevel_alpha (cairo_recording_surface_t *surf
cairo_private cairo_bool_t
_cairo_recording_surface_has_only_op_over (cairo_recording_surface_t *surface);
+cairo_private cairo_status_t
+_cairo_recording_surface_region_array_attach (cairo_surface_t *surface,
+ unsigned int *id);
+
+cairo_private void
+_cairo_recording_surface_region_array_reference (cairo_surface_t *surface,
+ unsigned int id);
+
+cairo_private void
+_cairo_recording_surface_region_array_remove (cairo_surface_t *surface,
+ unsigned int id);
+
+cairo_private void
+_cairo_debug_print_recording_surface (FILE *file,
+ cairo_surface_t *surface,
+ unsigned int regions_id,
+ int indent,
+ cairo_bool_t recurse);
+
#endif /* CAIRO_RECORDING_SURFACE_H */