diff --git a/gsk/gpu/gskgpunodeprocessor.c b/gsk/gpu/gskgpunodeprocessor.c index 52a4fe90ea..7a458c6c75 100644 --- a/gsk/gpu/gskgpunodeprocessor.c +++ b/gsk/gpu/gskgpunodeprocessor.c @@ -112,6 +112,10 @@ typedef struct _GskGpuNodeProcessor GskGpuNodeProcessor; +typedef enum { + GSK_GPU_AS_IMAGE_UNUSED, +} GskGpuAsImageFlags; + typedef enum { GSK_GPU_GLOBAL_MATRIX = (1 << 0), GSK_GPU_GLOBAL_SCALE = (1 << 1), @@ -157,6 +161,7 @@ static gboolean gsk_gpu_node_processor_add_first_node (GskGpuN GskGpuFirstNodeInfo *info, GskRenderNode *node); static GskGpuImage * gsk_gpu_get_node_as_image (GskGpuFrame *frame, + GskGpuAsImageFlags flags, GdkColorState *ccs, const graphene_rect_t *clip_bounds, const graphene_vec2_t *scale, @@ -671,12 +676,13 @@ gsk_gpu_node_processor_create_offscreen (GskGpuFrame *frame, } static GskGpuImage * -gsk_gpu_get_node_as_image_via_offscreen (GskGpuFrame *frame, - GdkColorState *ccs, - const graphene_rect_t *clip_bounds, - const graphene_vec2_t *scale, - GskRenderNode *node, - graphene_rect_t *out_bounds) +gsk_gpu_get_node_as_image_via_offscreen (GskGpuFrame *frame, + GskGpuAsImageFlags flags, + GdkColorState *ccs, + const graphene_rect_t *clip_bounds, + const graphene_vec2_t *scale, + GskRenderNode *node, + graphene_rect_t *out_bounds) { GskGpuImage *result; @@ -784,6 +790,7 @@ gsk_gpu_copy_image (GskGpuFrame *frame, /* * gsk_gpu_node_processor_get_node_as_image: * @self: a node processor + * @flags: flags for the image * @clip_bounds: (nullable): clip rectangle to use or NULL to use * the current clip * @node: the node to turn into an image @@ -799,6 +806,7 @@ gsk_gpu_copy_image (GskGpuFrame *frame, **/ static GskGpuImage * gsk_gpu_node_processor_get_node_as_image (GskGpuNodeProcessor *self, + GskGpuAsImageFlags flags, const graphene_rect_t *clip_bounds, GskRenderNode *node, graphene_rect_t *out_bounds) @@ -818,6 +826,7 @@ gsk_gpu_node_processor_get_node_as_image (GskGpuNodeProcessor *self, rect_round_to_pixels (&clip, &self->scale, &self->offset, &clip); return gsk_gpu_get_node_as_image (self->frame, + flags, self->ccs, &clip, &self->scale, @@ -956,6 +965,7 @@ gsk_gpu_node_processor_add_without_opacity (GskGpuNodeProcessor *self, gsk_gpu_node_processor_sync_globals (self, 0); image = gsk_gpu_node_processor_get_node_as_image (self, + 0, NULL, node, &tex_rect); @@ -1049,6 +1059,7 @@ gsk_gpu_node_processor_add_node_clipped (GskGpuNodeProcessor *self, if (gsk_gpu_node_processor_clip_node_bounds (self, node, &bounds) && gsk_rect_intersection (&bounds, clip_bounds, &bounds)) image = gsk_gpu_node_processor_get_node_as_image (self, + 0, &bounds, node, &tex_rect); @@ -1250,6 +1261,7 @@ gsk_gpu_node_processor_add_rounded_clip_node_with_mask (GskGpuNodeProcessor *sel rect_round_to_pixels (&clip_bounds, &self->scale, &self->offset, &clip_bounds); child_image = gsk_gpu_node_processor_get_node_as_image (self, + 0, &clip_bounds, gsk_rounded_clip_node_get_child (node), &child_rect); @@ -1507,6 +1519,7 @@ gsk_gpu_node_processor_add_transform_node (GskGpuNodeProcessor *self, /* This cannot loop because the next time we'll hit the branch above */ gsk_gpu_node_processor_sync_globals (self, 0); image = gsk_gpu_node_processor_get_node_as_image (self, + 0, NULL, node, &tex_rect); @@ -2168,12 +2181,13 @@ gsk_gpu_node_processor_add_texture_node (GskGpuNodeProcessor *self, } static GskGpuImage * -gsk_gpu_get_texture_node_as_image (GskGpuFrame *frame, - GdkColorState *ccs, - const graphene_rect_t *clip_bounds, - const graphene_vec2_t *scale, - GskRenderNode *node, - graphene_rect_t *out_bounds) +gsk_gpu_get_texture_node_as_image (GskGpuFrame *frame, + GskGpuAsImageFlags flags, + GdkColorState *ccs, + const graphene_rect_t *clip_bounds, + const graphene_vec2_t *scale, + GskRenderNode *node, + graphene_rect_t *out_bounds) { GdkTexture *texture = gsk_texture_node_get_texture (node); GdkColorState *image_cs; @@ -2197,7 +2211,7 @@ gsk_gpu_get_texture_node_as_image (GskGpuFrame *frame, } if (should_mipmap) - return gsk_gpu_get_node_as_image_via_offscreen (frame, ccs, clip_bounds, scale, node, out_bounds); + return gsk_gpu_get_node_as_image_via_offscreen (frame, flags, ccs, clip_bounds, scale, node, out_bounds); if (!gdk_color_state_equal (ccs, image_cs) || gsk_gpu_image_get_flags (image) & GSK_GPU_IMAGE_STRAIGHT_ALPHA) @@ -2314,17 +2328,18 @@ gsk_gpu_node_processor_add_texture_scale_node (GskGpuNodeProcessor *self, } static GskGpuImage * -gsk_gpu_get_cairo_node_as_image (GskGpuFrame *frame, - GdkColorState *ccs, - const graphene_rect_t *clip_bounds, - const graphene_vec2_t *scale, - GskRenderNode *node, - graphene_rect_t *out_bounds) +gsk_gpu_get_cairo_node_as_image (GskGpuFrame *frame, + GskGpuAsImageFlags flags, + GdkColorState *ccs, + const graphene_rect_t *clip_bounds, + const graphene_vec2_t *scale, + GskRenderNode *node, + graphene_rect_t *out_bounds) { GskGpuImage *result; if (!gdk_color_state_equal (ccs, GDK_COLOR_STATE_SRGB)) - return gsk_gpu_get_node_as_image_via_offscreen (frame, ccs, clip_bounds, scale, node, out_bounds); + return gsk_gpu_get_node_as_image_via_offscreen (frame, flags, ccs, clip_bounds, scale, node, out_bounds); result = gsk_gpu_upload_cairo_op (frame, scale, @@ -2657,6 +2672,7 @@ gsk_gpu_node_processor_add_blur_node (GskGpuNodeProcessor *self, gsk_gpu_node_processor_get_clip_bounds (self, &clip_rect); graphene_rect_inset (&clip_rect, -clip_radius, -clip_radius); image = gsk_gpu_node_processor_get_node_as_image (self, + 0, &clip_rect, child, &tex_rect); @@ -2695,6 +2711,7 @@ gsk_gpu_node_processor_add_shadow_node (GskGpuNodeProcessor *self, clip_bounds.size.height + node->bounds.size.height - child->bounds.size.height); image = gsk_gpu_node_processor_get_node_as_image (self, + 0, &clip_bounds, child, &tex_rect); @@ -2778,10 +2795,12 @@ gsk_gpu_node_processor_add_blend_node (GskGpuNodeProcessor *self, top_child = gsk_blend_node_get_top_child (node); bottom_image = gsk_gpu_node_processor_get_node_as_image (self, + 0, NULL, bottom_child, &bottom_rect); top_image = gsk_gpu_node_processor_get_node_as_image (self, + 0, NULL, top_child, &top_rect); @@ -2848,10 +2867,12 @@ gsk_gpu_node_processor_add_cross_fade_node (GskGpuNodeProcessor *self, } start_image = gsk_gpu_node_processor_get_node_as_image (self, + 0, NULL, start_child, &start_rect); end_image = gsk_gpu_node_processor_get_node_as_image (self, + 0, NULL, end_child, &end_rect); @@ -2928,6 +2949,7 @@ gsk_gpu_node_processor_add_mask_node (GskGpuNodeProcessor *self, return; mask_image = gsk_gpu_node_processor_get_node_as_image (self, + 0, &bounds, mask_child, &mask_rect); @@ -2960,6 +2982,7 @@ gsk_gpu_node_processor_add_mask_node (GskGpuNodeProcessor *self, graphene_rect_t source_rect; source_image = gsk_gpu_node_processor_get_node_as_image (self, + 0, &bounds, source_child, &source_rect); @@ -3138,6 +3161,7 @@ gsk_gpu_node_processor_add_color_matrix_node (GskGpuNodeProcessor *self, } image = gsk_gpu_node_processor_get_node_as_image (self, + 0, NULL, child, &tex_rect); @@ -3412,6 +3436,7 @@ gsk_gpu_node_processor_add_fill_node (GskGpuNodeProcessor *self, } source_image = gsk_gpu_node_processor_get_node_as_image (self, + 0, &clip_bounds, child, &source_rect); @@ -3514,6 +3539,7 @@ gsk_gpu_node_processor_add_stroke_node (GskGpuNodeProcessor *self, } source_image = gsk_gpu_node_processor_get_node_as_image (self, + 0, &clip_bounds, child, &source_rect); @@ -3629,12 +3655,13 @@ gsk_gpu_node_processor_add_first_subsurface_node (GskGpuNodeProcessor *self, } static GskGpuImage * -gsk_gpu_get_subsurface_node_as_image (GskGpuFrame *frame, - GdkColorState *ccs, - const graphene_rect_t *clip_bounds, - const graphene_vec2_t *scale, - GskRenderNode *node, - graphene_rect_t *out_bounds) +gsk_gpu_get_subsurface_node_as_image (GskGpuFrame *frame, + GskGpuAsImageFlags flags, + GdkColorState *ccs, + const graphene_rect_t *clip_bounds, + const graphene_vec2_t *scale, + GskRenderNode *node, + graphene_rect_t *out_bounds) { #ifndef G_DISABLE_ASSERT GdkSubsurface *subsurface; @@ -3646,6 +3673,7 @@ gsk_gpu_get_subsurface_node_as_image (GskGpuFrame *frame, #endif return gsk_gpu_get_node_as_image (frame, + flags, ccs, clip_bounds, scale, @@ -3720,14 +3748,16 @@ gsk_gpu_node_processor_add_first_debug_node (GskGpuNodeProcessor *self, } static GskGpuImage * -gsk_gpu_get_debug_node_as_image (GskGpuFrame *frame, - GdkColorState *ccs, - const graphene_rect_t *clip_bounds, - const graphene_vec2_t *scale, - GskRenderNode *node, - graphene_rect_t *out_bounds) +gsk_gpu_get_debug_node_as_image (GskGpuFrame *frame, + GskGpuAsImageFlags flags, + GdkColorState *ccs, + const graphene_rect_t *clip_bounds, + const graphene_vec2_t *scale, + GskRenderNode *node, + graphene_rect_t *out_bounds) { return gsk_gpu_get_node_as_image (frame, + flags, ccs, clip_bounds, scale, @@ -3749,6 +3779,7 @@ static const struct GskGpuFirstNodeInfo *info, GskRenderNode *node); GskGpuImage * (* get_node_as_image) (GskGpuFrame *self, + GskGpuAsImageFlags flags, GdkColorState *ccs, const graphene_rect_t *clip_bounds, const graphene_vec2_t *scale, @@ -4059,6 +4090,7 @@ gsk_gpu_node_processor_add_first_node (GskGpuNodeProcessor *self, /* * gsk_gpu_get_node_as_image: * @frame: frame to render in + * @flags: flags for the image * @ccs: the color state to composite the image in * @clip_bounds: region of node that must be included in image * @scale: scale factor to use for the image @@ -4082,12 +4114,13 @@ gsk_gpu_node_processor_add_first_node (GskGpuNodeProcessor *self, * Returns: the image or %NULL if there was nothing to render **/ static GskGpuImage * -gsk_gpu_get_node_as_image (GskGpuFrame *frame, - GdkColorState *ccs, - const graphene_rect_t *clip_bounds, - const graphene_vec2_t *scale, - GskRenderNode *node, - graphene_rect_t *out_bounds) +gsk_gpu_get_node_as_image (GskGpuFrame *frame, + GskGpuAsImageFlags flags, + GdkColorState *ccs, + const graphene_rect_t *clip_bounds, + const graphene_vec2_t *scale, + GskRenderNode *node, + graphene_rect_t *out_bounds) { GskRenderNodeType node_type; @@ -4101,13 +4134,13 @@ gsk_gpu_get_node_as_image (GskGpuFrame *frame, if (gsk_gpu_frame_should_optimize (frame, GSK_GPU_OPTIMIZE_TO_IMAGE) && nodes_vtable[node_type].get_node_as_image) { - return nodes_vtable[node_type].get_node_as_image (frame, ccs, clip_bounds, scale, node, out_bounds); + return nodes_vtable[node_type].get_node_as_image (frame, flags, ccs, clip_bounds, scale, node, out_bounds); } else { GSK_DEBUG (FALLBACK, "Unsupported node '%s'", g_type_name_from_instance ((GTypeInstance *) node)); - return gsk_gpu_get_node_as_image_via_offscreen (frame, ccs, clip_bounds, scale, node, out_bounds); + return gsk_gpu_get_node_as_image_via_offscreen (frame, flags, ccs, clip_bounds, scale, node, out_bounds); } } @@ -4320,6 +4353,7 @@ gsk_gpu_node_processor_process (GskGpuFrame *frame, rect_round_to_pixels (&clip_bounds, &self.scale, &self.offset, &clip_bounds); image = gsk_gpu_get_node_as_image (self.frame, + 0, ccs, &clip_bounds, &self.scale,