Skip to content

Commit bb88401

Browse files
committed
clutter/view: Make it possible to assign a temporary direct scanout
Make it possible to cause the next frame to scan out directly from the passed CoglScannout. This makes it possible to completely bypass compositing for the following frame. Original Mutter commit: https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/798/diffs?commit_id=753066598ff83fa9bdbd1be23d1e22663ae59297
1 parent afca6d8 commit bb88401

File tree

5 files changed

+58
-2
lines changed

5 files changed

+58
-2
lines changed

clutter/clutter/clutter-muffin.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ void clutter_stage_thaw_updates (ClutterStage *stage);
7575
CLUTTER_EXPORT
7676
void clutter_stage_update_resource_scales (ClutterStage *stage);
7777

78+
CLUTTER_EXPORT
79+
void clutter_stage_view_assign_next_scanout (ClutterStageView *stage_view,
80+
CoglScanout *scanout);
81+
7882
CLUTTER_EXPORT
7983
gboolean clutter_actor_has_damage (ClutterActor *actor);
8084

clutter/clutter/clutter-stage-view-private.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,6 @@ const cairo_region_t * clutter_stage_view_peek_redraw_clip (ClutterStageView *vi
4343

4444
cairo_region_t * clutter_stage_view_take_redraw_clip (ClutterStageView *view);
4545

46+
CoglScanout * clutter_stage_view_take_scanout (ClutterStageView *view);
47+
4648
#endif /* __CLUTTER_STAGE_VIEW_PRIVATE_H__ */

clutter/clutter/clutter-stage-view.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include <math.h>
2525

2626
#include "clutter/clutter-private.h"
27+
#include "clutter/clutter-muffin.h"
28+
#include "cogl/cogl.h"
2729

2830
enum
2931
{
@@ -52,6 +54,8 @@ typedef struct _ClutterStageViewPrivate
5254
CoglOffscreen *shadowfb;
5355
CoglPipeline *shadowfb_pipeline;
5456

57+
CoglScanout *next_scanout;
58+
5559
gboolean has_redraw_clip;
5660
cairo_region_t *redraw_clip;
5761

@@ -407,6 +411,26 @@ clutter_stage_default_get_offscreen_transformation_matrix (ClutterStageView *vie
407411
cogl_matrix_init_identity (matrix);
408412
}
409413

414+
void
415+
clutter_stage_view_assign_next_scanout (ClutterStageView *view,
416+
CoglScanout *scanout)
417+
{
418+
ClutterStageViewPrivate *priv =
419+
clutter_stage_view_get_instance_private (view);
420+
421+
g_clear_object (&priv->next_scanout);
422+
priv->next_scanout = scanout;
423+
}
424+
425+
CoglScanout *
426+
clutter_stage_view_take_scanout (ClutterStageView *view)
427+
{
428+
ClutterStageViewPrivate *priv =
429+
clutter_stage_view_get_instance_private (view);
430+
431+
return g_steal_pointer (&priv->next_scanout);
432+
}
433+
410434
static void
411435
clutter_stage_view_get_property (GObject *object,
412436
guint prop_id,

clutter/clutter/cogl/clutter-stage-cogl.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,20 @@ clutter_stage_cogl_redraw_view (ClutterStageWindow *stage_window,
989989
}
990990
}
991991

992+
static void
993+
clutter_stage_cogl_scanout_view (ClutterStageCogl *stage_cogl,
994+
ClutterStageView *view,
995+
CoglScanout *scanout)
996+
{
997+
CoglFramebuffer *framebuffer = clutter_stage_view_get_framebuffer (view);
998+
CoglOnscreen *onscreen;
999+
1000+
g_return_if_fail (cogl_is_onscreen (framebuffer));
1001+
1002+
onscreen = COGL_ONSCREEN (framebuffer);
1003+
cogl_onscreen_direct_scanout (onscreen, scanout);
1004+
}
1005+
9921006
static void
9931007
clutter_stage_cogl_redraw (ClutterStageWindow *stage_window)
9941008
{
@@ -1016,11 +1030,23 @@ clutter_stage_cogl_redraw (ClutterStageWindow *stage_window)
10161030
for (l = _clutter_stage_window_get_views (stage_window); l; l = l->next)
10171031
{
10181032
ClutterStageView *view = l->data;
1033+
g_autoptr (CoglScanout) scanout = NULL;
10191034

10201035
if (!clutter_stage_view_has_redraw_clip (view))
10211036
continue;
10221037

1023-
swap_event |= clutter_stage_cogl_redraw_view (stage_window, view);
1038+
scanout = clutter_stage_view_take_scanout (view);
1039+
if (scanout)
1040+
{
1041+
clutter_stage_cogl_scanout_view (stage_cogl,
1042+
view,
1043+
scanout);
1044+
swap_event = TRUE;
1045+
}
1046+
else
1047+
{
1048+
swap_event |= clutter_stage_cogl_redraw_view (stage_window, view);
1049+
}
10241050
}
10251051

10261052
if (has_redraw_clip)

cogl/cogl/cogl-onscreen.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ cogl_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen,
289289
/**
290290
* cogl_onscreen_direct_scanout: (skip)
291291
*/
292-
void
292+
COGL_EXPORT void
293293
cogl_onscreen_direct_scanout (CoglOnscreen *onscreen,
294294
CoglScanout *scanout);
295295

0 commit comments

Comments
 (0)