mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-16 15:14:17 +00:00
Merge branch 'wip/otte/for-main' into 'main'
gpu: Don't oversize node image Closes #6380 and #6425 See merge request GNOME/gtk!6899
This commit is contained in:
commit
afb75bedfe
@ -748,6 +748,8 @@ gsk_gpu_node_processor_create_offscreen (GskGpuFrame *frame,
|
||||
gsk_render_node_get_preferred_depth (node),
|
||||
scale,
|
||||
viewport);
|
||||
if (image == NULL)
|
||||
return NULL;
|
||||
|
||||
gsk_gpu_node_processor_add_node (&self, node);
|
||||
|
||||
@ -950,9 +952,13 @@ gsk_gpu_node_processor_get_node_as_image (GskGpuNodeProcessor *self,
|
||||
{
|
||||
if (!gsk_gpu_node_processor_clip_node_bounds (self, node, &clip))
|
||||
return NULL;
|
||||
clip_bounds = &clip;
|
||||
}
|
||||
rect_round_to_pixels (clip_bounds, &self->scale, &self->offset, &clip);
|
||||
else
|
||||
{
|
||||
if (!gsk_rect_intersection (clip_bounds, &node->bounds, &clip))
|
||||
return NULL;
|
||||
}
|
||||
rect_round_to_pixels (&clip, &self->scale, &self->offset, &clip);
|
||||
|
||||
image = gsk_gpu_get_node_as_image (self->frame,
|
||||
&clip,
|
||||
@ -997,36 +1003,25 @@ gsk_gpu_node_processor_blur_op (GskGpuNodeProcessor *self,
|
||||
graphene_vec2_t direction;
|
||||
graphene_rect_t clip_rect, intermediate_rect;
|
||||
graphene_point_t real_offset;
|
||||
int width, height;
|
||||
float clip_radius;
|
||||
|
||||
clip_radius = gsk_cairo_blur_compute_pixels (blur_radius / 2.0);
|
||||
|
||||
/* FIXME: Handle clip radius growing the clip too much */
|
||||
gsk_gpu_node_processor_get_clip_bounds (self, &clip_rect);
|
||||
clip_rect.origin.x -= shadow_offset->x;
|
||||
clip_rect.origin.y -= shadow_offset->y;
|
||||
graphene_rect_inset (&clip_rect, 0.f, -clip_radius);
|
||||
if (!gsk_rect_intersection (rect, &clip_rect, &intermediate_rect))
|
||||
return;
|
||||
|
||||
width = ceilf (graphene_vec2_get_x (&self->scale) * intermediate_rect.size.width);
|
||||
height = ceilf (graphene_vec2_get_y (&self->scale) * intermediate_rect.size.height);
|
||||
rect_round_to_pixels (&intermediate_rect, &self->scale, &self->offset, &intermediate_rect);
|
||||
|
||||
intermediate = gsk_gpu_device_create_offscreen_image (gsk_gpu_frame_get_device (self->frame),
|
||||
FALSE,
|
||||
source_depth,
|
||||
width, height);
|
||||
|
||||
gsk_gpu_node_processor_init (&other,
|
||||
self->frame,
|
||||
source_desc,
|
||||
intermediate,
|
||||
&(cairo_rectangle_int_t) { 0, 0, width, height },
|
||||
&intermediate_rect);
|
||||
|
||||
gsk_gpu_render_pass_begin_op (other.frame,
|
||||
intermediate,
|
||||
&(cairo_rectangle_int_t) { 0, 0, width, height },
|
||||
GSK_RENDER_PASS_OFFSCREEN);
|
||||
intermediate = gsk_gpu_node_processor_init_draw (&other,
|
||||
self->frame,
|
||||
source_depth,
|
||||
&self->scale,
|
||||
&intermediate_rect);
|
||||
|
||||
gsk_gpu_node_processor_sync_globals (&other, 0);
|
||||
|
||||
@ -1040,11 +1035,7 @@ gsk_gpu_node_processor_blur_op (GskGpuNodeProcessor *self,
|
||||
source_rect,
|
||||
&direction);
|
||||
|
||||
gsk_gpu_render_pass_end_op (other.frame,
|
||||
intermediate,
|
||||
GSK_RENDER_PASS_OFFSCREEN);
|
||||
|
||||
gsk_gpu_node_processor_finish (&other);
|
||||
gsk_gpu_node_processor_finish_draw (&other, intermediate);
|
||||
|
||||
real_offset = GRAPHENE_POINT_INIT (self->offset.x + shadow_offset->x,
|
||||
self->offset.y + shadow_offset->y);
|
||||
|
10
testsuite/gsk/compare/shadow-huge-offset.node
Normal file
10
testsuite/gsk/compare/shadow-huge-offset.node
Normal file
@ -0,0 +1,10 @@
|
||||
clip {
|
||||
clip: -20000 0 50 50;
|
||||
child: shadow {
|
||||
shadows: red -20000 0 0;
|
||||
child: color {
|
||||
bounds: 0 0 50 50;
|
||||
color: blue;
|
||||
}
|
||||
}
|
||||
}
|
BIN
testsuite/gsk/compare/shadow-huge-offset.png
Normal file
BIN
testsuite/gsk/compare/shadow-huge-offset.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 144 B |
50
testsuite/gsk/compare/shadow-offset-clip.node
Normal file
50
testsuite/gsk/compare/shadow-offset-clip.node
Normal file
@ -0,0 +1,50 @@
|
||||
clip {
|
||||
clip: 10 -10 40 20;
|
||||
child: shadow {
|
||||
shadows: red 60 0 1;
|
||||
child: color {
|
||||
bounds: -25 -25 50 50;
|
||||
color: blue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
clip {
|
||||
clip: -50 -10 40 20;
|
||||
child: shadow {
|
||||
shadows: red -60 0 1;
|
||||
child: color {
|
||||
bounds: -25 -25 50 50;
|
||||
color: blue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
clip {
|
||||
clip: -10 10 20 40;
|
||||
child: shadow {
|
||||
shadows: red 0 60 1;
|
||||
child: color {
|
||||
bounds: -25 -25 50 50;
|
||||
color: blue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
clip {
|
||||
clip: -10 -50 20 40;
|
||||
child: shadow {
|
||||
shadows: red 0 -60 1;
|
||||
child: color {
|
||||
bounds: -25 -25 50 50;
|
||||
color: blue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* cover the blur */
|
||||
border {
|
||||
outline: -37 -37 74 74;
|
||||
colors: black;
|
||||
widths: 4;
|
||||
}
|
BIN
testsuite/gsk/compare/shadow-offset-clip.png
Normal file
BIN
testsuite/gsk/compare/shadow-offset-clip.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 174 B |
@ -137,7 +137,9 @@ compare_render_tests = [
|
||||
'scale0-crash',
|
||||
'shadow-behind',
|
||||
'shadow-clip-contents',
|
||||
'shadow-huge-offset',
|
||||
'shadow-in-opacity',
|
||||
'shadow-offset-clip',
|
||||
'shadow-offset-to-outside-clip',
|
||||
'shadow-opacity',
|
||||
'shrink-rounded-border',
|
||||
|
Loading…
Reference in New Issue
Block a user