clutter/feature: Remove static vs multiple stage feature

This feature was configured depending on whether the Cogl backend
reported COGL_WINSYS_FEATURE_MULTIPLE_ONSCREEN or not. All cogl backends
do report this, so any code handled the 'static' case were never used.

While we only ever use one stage, it's arguable more correct to
consilidate on the single stage case, but multiple stages is something
that might be desirable for e.g. a remote lock screen, so lets keep this
logic intact.

This has the side effect of completely removing backend features, as
this was the only left-over feature detection that they handled.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2002>
This commit is contained in:
Jonas Ådahl 2021-09-17 11:41:16 +02:00 committed by Marge Bot
parent 57964becb6
commit b73bbecaad
7 changed files with 56 additions and 210 deletions

View File

@ -9454,14 +9454,11 @@ clutter_actor_set_min_width (ClutterActor *self,
ClutterActorBox old = { 0, }; ClutterActorBox old = { 0, };
ClutterLayoutInfo *info; ClutterLayoutInfo *info;
/* if we are setting the size on a top-level actor and the if (CLUTTER_ACTOR_IS_TOPLEVEL (self))
* backend only supports static top-levels (e.g. framebuffers) {
* then we ignore the passed value and we override it with g_warning ("Can't set the minimal width of a stage");
* the stage implementation's preferred size.
*/
if (CLUTTER_ACTOR_IS_TOPLEVEL (self) &&
clutter_feature_available (CLUTTER_FEATURE_STAGE_STATIC))
return; return;
}
info = _clutter_actor_get_layout_info (self); info = _clutter_actor_get_layout_info (self);
@ -9492,14 +9489,11 @@ clutter_actor_set_min_height (ClutterActor *self,
ClutterActorBox old = { 0, }; ClutterActorBox old = { 0, };
ClutterLayoutInfo *info; ClutterLayoutInfo *info;
/* if we are setting the size on a top-level actor and the if (CLUTTER_ACTOR_IS_TOPLEVEL (self))
* backend only supports static top-levels (e.g. framebuffers) {
* then we ignore the passed value and we override it with g_warning ("Can't set the minimal height of a stage");
* the stage implementation's preferred size.
*/
if (CLUTTER_ACTOR_IS_TOPLEVEL (self) &&
clutter_feature_available (CLUTTER_FEATURE_STAGE_STATIC))
return; return;
}
info = _clutter_actor_get_layout_info (self); info = _clutter_actor_get_layout_info (self);
@ -9529,15 +9523,6 @@ clutter_actor_set_natural_width (ClutterActor *self,
ClutterActorBox old = { 0, }; ClutterActorBox old = { 0, };
ClutterLayoutInfo *info; ClutterLayoutInfo *info;
/* if we are setting the size on a top-level actor and the
* backend only supports static top-levels (e.g. framebuffers)
* then we ignore the passed value and we override it with
* the stage implementation's preferred size.
*/
if (CLUTTER_ACTOR_IS_TOPLEVEL (self) &&
clutter_feature_available (CLUTTER_FEATURE_STAGE_STATIC))
return;
info = _clutter_actor_get_layout_info (self); info = _clutter_actor_get_layout_info (self);
if (priv->natural_width_set && natural_width == info->natural.width) if (priv->natural_width_set && natural_width == info->natural.width)
@ -9566,15 +9551,6 @@ clutter_actor_set_natural_height (ClutterActor *self,
ClutterActorBox old = { 0, }; ClutterActorBox old = { 0, };
ClutterLayoutInfo *info; ClutterLayoutInfo *info;
/* if we are setting the size on a top-level actor and the
* backend only supports static top-levels (e.g. framebuffers)
* then we ignore the passed value and we override it with
* the stage implementation's preferred size.
*/
if (CLUTTER_ACTOR_IS_TOPLEVEL (self) &&
clutter_feature_available (CLUTTER_FEATURE_STAGE_STATIC))
return;
info = _clutter_actor_get_layout_info (self); info = _clutter_actor_get_layout_info (self);
if (priv->natural_height_set && natural_height == info->natural.height) if (priv->natural_height_set && natural_height == info->natural.height)

View File

@ -72,7 +72,6 @@ struct _ClutterBackendClass
ClutterStage *wrapper, ClutterStage *wrapper,
GError **error); GError **error);
void (* init_features) (ClutterBackend *backend); void (* init_features) (ClutterBackend *backend);
ClutterFeatureFlags (* get_features) (ClutterBackend *backend);
CoglRenderer * (* get_renderer) (ClutterBackend *backend, CoglRenderer * (* get_renderer) (ClutterBackend *backend,
GError **error); GError **error);
CoglDisplay * (* get_display) (ClutterBackend *backend, CoglDisplay * (* get_display) (ClutterBackend *backend,
@ -110,8 +109,6 @@ gboolean _clutter_backend_translate_event (Clutter
gpointer native, gpointer native,
ClutterEvent *event); ClutterEvent *event);
ClutterFeatureFlags _clutter_backend_get_features (ClutterBackend *backend);
gfloat _clutter_backend_get_units_per_em (ClutterBackend *backend, gfloat _clutter_backend_get_units_per_em (ClutterBackend *backend,
PangoFontDescription *font_desc); PangoFontDescription *font_desc);
gint32 _clutter_backend_get_units_serial (ClutterBackend *backend); gint32 _clutter_backend_get_units_serial (ClutterBackend *backend);

View File

@ -365,25 +365,6 @@ clutter_backend_real_create_context (ClutterBackend *backend,
return TRUE; return TRUE;
} }
static ClutterFeatureFlags
clutter_backend_real_get_features (ClutterBackend *backend)
{
ClutterFeatureFlags flags = 0;
if (cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_MULTIPLE_ONSCREEN))
{
CLUTTER_NOTE (BACKEND, "Cogl supports multiple onscreen framebuffers");
flags |= CLUTTER_FEATURE_STAGE_MULTIPLE;
}
else
{
CLUTTER_NOTE (BACKEND, "Cogl only supports one onscreen framebuffer");
flags |= CLUTTER_FEATURE_STAGE_STATIC;
}
return flags;
}
static void static void
clutter_backend_class_init (ClutterBackendClass *klass) clutter_backend_class_init (ClutterBackendClass *klass)
{ {
@ -446,7 +427,6 @@ clutter_backend_class_init (ClutterBackendClass *klass)
klass->font_changed = clutter_backend_real_font_changed; klass->font_changed = clutter_backend_real_font_changed;
klass->create_context = clutter_backend_real_create_context; klass->create_context = clutter_backend_real_create_context;
klass->get_features = clutter_backend_real_get_features;
} }
static void static void
@ -515,46 +495,6 @@ _clutter_backend_create_context (ClutterBackend *backend,
return klass->create_context (backend, error); return klass->create_context (backend, error);
} }
ClutterFeatureFlags
_clutter_backend_get_features (ClutterBackend *backend)
{
ClutterBackendClass *klass;
GError *error;
g_assert (CLUTTER_IS_BACKEND (backend));
klass = CLUTTER_BACKEND_GET_CLASS (backend);
/* we need to have a context here; so we create the
* GL context first and the ask for features. if the
* context already exists this should be a no-op
*/
error = NULL;
if (klass->create_context != NULL)
{
gboolean res;
res = klass->create_context (backend, &error);
if (!res)
{
if (error)
{
g_critical ("Unable to create a context: %s", error->message);
g_error_free (error);
}
else
g_critical ("Unable to create a context: unknown error");
return 0;
}
}
if (klass->get_features)
return klass->get_features (backend);
return 0;
}
gfloat gfloat
_clutter_backend_get_units_per_em (ClutterBackend *backend, _clutter_backend_get_units_per_em (ClutterBackend *backend,
PangoFontDescription *font_desc) PangoFontDescription *font_desc)

View File

@ -898,9 +898,7 @@ typedef enum /*< prefix=CLUTTER_SCROLL >*/
/** /**
* ClutterFeatureFlags: * ClutterFeatureFlags:
* @CLUTTER_FEATURE_STAGE_STATIC: Set if stage size if fixed (i.e framebuffer)
* @CLUTTER_FEATURE_SHADERS_GLSL: Set if the backend supports GLSL shaders. * @CLUTTER_FEATURE_SHADERS_GLSL: Set if the backend supports GLSL shaders.
* @CLUTTER_FEATURE_STAGE_MULTIPLE: Set if multiple stages are supported.
* *
* Runtime flags indicating specific features available via Clutter window * Runtime flags indicating specific features available via Clutter window
* system and graphics backend. * system and graphics backend.
@ -909,9 +907,7 @@ typedef enum /*< prefix=CLUTTER_SCROLL >*/
*/ */
typedef enum typedef enum
{ {
CLUTTER_FEATURE_STAGE_STATIC = (1 << 6),
CLUTTER_FEATURE_SHADERS_GLSL = (1 << 9), CLUTTER_FEATURE_SHADERS_GLSL = (1 << 9),
CLUTTER_FEATURE_STAGE_MULTIPLE = (1 << 11),
} ClutterFeatureFlags; } ClutterFeatureFlags;
/** /**

View File

@ -87,8 +87,7 @@ clutter_feature_init (ClutterMainContext *context,
if (!_clutter_backend_create_context (context->backend, error)) if (!_clutter_backend_create_context (context->backend, error))
return FALSE; return FALSE;
__features->flags = (clutter_features_from_cogl () __features->flags = clutter_features_from_cogl ();
| _clutter_backend_get_features (context->backend));
__features->features_set = TRUE; __features->features_set = TRUE;

View File

@ -28,14 +28,6 @@
* #ClutterStage is a top level 'window' on which child actors are placed * #ClutterStage is a top level 'window' on which child actors are placed
* and manipulated. * and manipulated.
* *
* Backends might provide support for multiple stages. The support for this
* feature can be checked at run-time using the clutter_feature_available()
* function and the %CLUTTER_FEATURE_STAGE_MULTIPLE flag. If the backend used
* supports multiple stages, new #ClutterStage instances can be created
* using clutter_stage_new(). These stages must be managed by the developer
* using clutter_actor_destroy(), which will take care of destroying all the
* actors contained inside them.
*
* #ClutterStage is a proxy actor, wrapping the backend-specific implementation * #ClutterStage is a proxy actor, wrapping the backend-specific implementation
* (a #StageWindow) of the windowing system. It is possible to subclass * (a #StageWindow) of the windowing system. It is possible to subclass
* #ClutterStage, as long as every overridden virtual function chains up to the * #ClutterStage, as long as every overridden virtual function chains up to the
@ -281,6 +273,7 @@ clutter_stage_allocate (ClutterActor *self,
float new_width, new_height; float new_width, new_height;
float width, height; float width, height;
cairo_rectangle_int_t window_size; cairo_rectangle_int_t window_size;
ClutterActorBox children_box;
ClutterLayoutManager *layout_manager = clutter_actor_get_layout_manager (self); ClutterLayoutManager *layout_manager = clutter_actor_get_layout_manager (self);
if (priv->impl == NULL) if (priv->impl == NULL)
@ -292,15 +285,6 @@ clutter_stage_allocate (ClutterActor *self,
/* the current Stage implementation size */ /* the current Stage implementation size */
_clutter_stage_window_get_geometry (priv->impl, &window_size); _clutter_stage_window_get_geometry (priv->impl, &window_size);
/* if the stage is fixed size (for instance, it's using a EGL framebuffer)
* then we simply ignore any allocation request and override the
* allocation chain - because we cannot forcibly change the size of the
* stage window.
*/
if (!clutter_feature_available (CLUTTER_FEATURE_STAGE_STATIC))
{
ClutterActorBox children_box;
children_box.x1 = children_box.y1 = 0.f; children_box.x1 = children_box.y1 = 0.f;
children_box.x2 = box->x2 - box->x1; children_box.x2 = box->x2 - box->x1;
children_box.y2 = box->y2 - box->y1; children_box.y2 = box->y2 - box->y1;
@ -348,30 +332,6 @@ clutter_stage_allocate (ClutterActor *self,
CLUTTER_NEARBYINT (width), CLUTTER_NEARBYINT (width),
CLUTTER_NEARBYINT (height)); CLUTTER_NEARBYINT (height));
} }
}
else
{
ClutterActorBox override = { 0, };
/* override the passed allocation */
override.x1 = 0;
override.y1 = 0;
override.x2 = window_size.width;
override.y2 = window_size.height;
CLUTTER_NOTE (LAYOUT,
"Overriding original allocation of %.2fx%.2f "
"with %.2fx%.2f",
width, height,
override.x2, override.y2);
/* and store the overridden allocation */
clutter_actor_set_allocation (self, &override);
clutter_layout_manager_allocate (layout_manager,
CLUTTER_CONTAINER (self),
&override);
}
/* set the viewport to the new allocation */ /* set the viewport to the new allocation */
clutter_actor_get_allocation_box (self, &alloc); clutter_actor_get_allocation_box (self, &alloc);
@ -1174,25 +1134,6 @@ clutter_stage_constructed (GObject *gobject)
/* this will take care to sinking the floating reference */ /* this will take care to sinking the floating reference */
_clutter_stage_manager_add_stage (stage_manager, self); _clutter_stage_manager_add_stage (stage_manager, self);
/* if this stage has been created on a backend that does not
* support multiple stages then it becomes the default stage
* as well; any other attempt at creating a ClutterStage will
* fail.
*/
if (!clutter_feature_available (CLUTTER_FEATURE_STAGE_MULTIPLE))
{
if (G_UNLIKELY (clutter_stage_manager_get_default_stage (stage_manager) != NULL))
{
g_error ("Unable to create another stage: the backend of "
"type '%s' does not support multiple stages. Use "
"clutter_stage_manager_get_default_stage() instead "
"to access the stage singleton.",
G_OBJECT_TYPE_NAME (clutter_get_default_backend ()));
}
_clutter_stage_manager_set_default_stage (stage_manager, self);
}
G_OBJECT_CLASS (clutter_stage_parent_class)->constructed (gobject); G_OBJECT_CLASS (clutter_stage_parent_class)->constructed (gobject);
} }

View File

@ -178,15 +178,12 @@ main (int argc, char *argv[])
clutter_actor_show (stage_main); clutter_actor_show (stage_main);
if (clutter_feature_available (CLUTTER_FEATURE_STAGE_MULTIPLE))
{
stage = clutter_test_get_stage (); stage = clutter_test_get_stage ();
clutter_stage_set_title (CLUTTER_STAGE (stage), "Cally - AtkEvents/2"); clutter_stage_set_title (CLUTTER_STAGE (stage), "Cally - AtkEvents/2");
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL);
make_ui (stage); make_ui (stage);
clutter_actor_show (stage); clutter_actor_show (stage);
}
clutter_test_main (); clutter_test_main ();