Merge branch 'offscreen-fixes' into 'master'

Offscreen fixes

See merge request GNOME/gtk!3379
This commit is contained in:
Matthias Clasen 2021-03-31 21:27:18 +00:00
commit 94747d53eb
4 changed files with 57 additions and 12 deletions

View File

@ -163,18 +163,29 @@ struct _GskNglRenderJob
typedef struct _GskNglRenderOffscreen
{
/* The bounds to render */
const graphene_rect_t *bounds;
/* Return location for texture coordinates */
struct {
float x;
float y;
float x2;
float y2;
} area;
/* Return location for texture ID */
guint texture_id;
/* Whether to force creating a new texture, even if the
* input already is a texture
*/
guint force_offscreen : 1;
guint reset_clip : 1;
guint do_not_cache : 1;
guint linear_filter : 1;
/* Return location for whether we created a texture */
guint was_offscreen : 1;
} GskNglRenderOffscreen;
@ -1594,6 +1605,7 @@ gsk_ngl_render_job_visit_rounded_clip_node (GskNglRenderJob *job,
offscreen.bounds = &node->bounds;
offscreen.force_offscreen = TRUE;
offscreen.reset_clip = FALSE;
gsk_ngl_render_job_push_clip (job, &transformed_clip);
if (!gsk_ngl_render_job_visit_node_with_offscreen (job, child, &offscreen))
@ -3554,8 +3566,8 @@ gsk_ngl_render_job_visit_node_with_offscreen (GskNglRenderJob *job,
float scaled_width;
float scaled_height;
float scale_x = job->scale_x;
float scale_y = job->scale_y;
float downscale_x = 1;
float downscale_y = 1;
g_assert (job->command_queue->max_texture_size > 0);
@ -3566,17 +3578,17 @@ gsk_ngl_render_job_visit_node_with_offscreen (GskNglRenderJob *job,
{
int max_texture_size = job->command_queue->max_texture_size;
scaled_width = ceilf (offscreen->bounds->size.width * scale_x);
scaled_width = ceilf (offscreen->bounds->size.width * job->scale_x);
if (scaled_width > max_texture_size)
{
scale_x *= (float)max_texture_size / scaled_width;
downscale_x = (float)max_texture_size / scaled_width;
scaled_width = max_texture_size;
}
scaled_height = ceilf (offscreen->bounds->size.height * scale_y);
scaled_height = ceilf (offscreen->bounds->size.height * job->scale_y);
if (scaled_height > max_texture_size)
{
scale_y *= (float)max_texture_size / scaled_height;
downscale_y = (float)max_texture_size / scaled_height;
scaled_height = max_texture_size;
}
}
@ -3620,10 +3632,9 @@ gsk_ngl_render_job_visit_node_with_offscreen (GskNglRenderJob *job,
gsk_ngl_render_job_set_viewport (job, &viewport, &prev_viewport);
gsk_ngl_render_job_set_projection_from_rect (job, &job->viewport, &prev_projection);
gsk_ngl_render_job_set_modelview (job, gsk_transform_scale (NULL, scale_x, scale_y));
if (downscale_x != 1 || downscale_y != 1)
gsk_ngl_render_job_push_modelview (job, gsk_transform_scale (NULL, downscale_x, downscale_y));
prev_alpha = gsk_ngl_render_job_set_alpha (job, 1.0f);
job->offset_x = offset_x;
job->offset_y = offset_y;
prev_fbo = gsk_ngl_command_queue_bind_framebuffer (job->command_queue, render_target->framebuffer_id);
gsk_ngl_command_queue_clear (job->command_queue, 0, &job->viewport);
@ -3636,7 +3647,8 @@ gsk_ngl_render_job_visit_node_with_offscreen (GskNglRenderJob *job,
if (offscreen->reset_clip)
gsk_ngl_render_job_pop_clip (job);
gsk_ngl_render_job_pop_modelview (job);
if (downscale_x != 1 || downscale_y != 1)
gsk_ngl_render_job_pop_modelview (job);
gsk_ngl_render_job_set_viewport (job, &prev_viewport, NULL);
gsk_ngl_render_job_set_projection (job, &prev_projection);
gsk_ngl_render_job_set_alpha (job, prev_alpha);

View File

@ -0,0 +1,32 @@
transform {
child: transform {
child: rounded-clip {
child: container {
repeat {
bounds: 0 0 159 34;
child: container {
color {
bounds: 0 0 10 10;
color: rgb(168,168,168);
}
color {
bounds: 10 0 10 10;
color: rgb(84,84,84);
}
color {
bounds: 0 10 10 10;
color: rgb(84,84,84);
}
color {
bounds: 10 10 10 10;
color: rgb(168,168,168);
}
}
}
}
clip: 0 0 159 34 / 6;
}
transform: scale(4, 4);
}
transform: translate(6, 20);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -76,6 +76,7 @@ compare_render_tests = [
'clip-in-rounded-clip2',
'clip-in-rounded-clip3',
'rounded-clip-in-clip-3d', # not really 3d, but cairo fails it
'clipped-repeat-3d-ngl',
'issue-3615'
]
@ -89,8 +90,8 @@ informative_render_tests = [
renderers = [
# name exclude term
[ 'opengl', '' ],
[ 'next', '' ],
[ 'gl', '-ngl' ],
[ 'ngl', '' ],
[ 'broadway', '-3d' ],
[ 'cairo', '-3d' ],
]