monitor-stream-src: Blit scanout when available

When there's a direct scanout set in the stage view, we
have to use it instead of the view's regular onscreen
framebuffer.

Use the new CoglScanout API to implement blitting to the
stream framebuffer.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1421
This commit is contained in:
Georges Basile Stavracas Neto 2020-08-28 23:01:11 -03:00
parent 098360f2c2
commit b1648e75a8

View File

@ -520,6 +520,7 @@ meta_screen_cast_monitor_stream_src_record_to_framebuffer (MetaScreenCastStreamS
{ {
ClutterStageView *view = CLUTTER_STAGE_VIEW (l->data); ClutterStageView *view = CLUTTER_STAGE_VIEW (l->data);
CoglFramebuffer *view_framebuffer; CoglFramebuffer *view_framebuffer;
CoglScanout *scanout;
MetaRectangle view_layout; MetaRectangle view_layout;
int x, y; int x, y;
@ -528,19 +529,30 @@ meta_screen_cast_monitor_stream_src_record_to_framebuffer (MetaScreenCastStreamS
if (!meta_rectangle_overlap (&logical_monitor_layout, &view_layout)) if (!meta_rectangle_overlap (&logical_monitor_layout, &view_layout))
continue; continue;
view_framebuffer = clutter_stage_view_get_framebuffer (view);
x = (int) roundf ((view_layout.x - logical_monitor_layout.x) * view_scale); x = (int) roundf ((view_layout.x - logical_monitor_layout.x) * view_scale);
y = (int) roundf ((view_layout.y - logical_monitor_layout.y) * view_scale); y = (int) roundf ((view_layout.y - logical_monitor_layout.y) * view_scale);
if (!cogl_blit_framebuffer (view_framebuffer, scanout = clutter_stage_view_peek_scanout (view);
framebuffer, if (scanout)
0, 0, {
x, y, if (!cogl_scanout_blit_to_framebuffer (scanout,
cogl_framebuffer_get_width (view_framebuffer), framebuffer,
cogl_framebuffer_get_height (view_framebuffer), x, y,
error)) error))
return FALSE; return FALSE;
}
else
{
view_framebuffer = clutter_stage_view_get_framebuffer (view);
if (!cogl_blit_framebuffer (view_framebuffer,
framebuffer,
0, 0,
x, y,
cogl_framebuffer_get_width (view_framebuffer),
cogl_framebuffer_get_height (view_framebuffer),
error))
return FALSE;
}
} }
cogl_framebuffer_finish (framebuffer); cogl_framebuffer_finish (framebuffer);