1
0
Fork 0

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, };
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;
if (CLUTTER_ACTOR_IS_TOPLEVEL (self))
{
g_warning ("Can't set the minimal width of a stage");
return;
}
info = _clutter_actor_get_layout_info (self);
@ -9492,14 +9489,11 @@ clutter_actor_set_min_height (ClutterActor *self,
ClutterActorBox old = { 0, };
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;
if (CLUTTER_ACTOR_IS_TOPLEVEL (self))
{
g_warning ("Can't set the minimal height of a stage");
return;
}
info = _clutter_actor_get_layout_info (self);
@ -9529,15 +9523,6 @@ clutter_actor_set_natural_width (ClutterActor *self,
ClutterActorBox old = { 0, };
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);
if (priv->natural_width_set && natural_width == info->natural.width)
@ -9566,15 +9551,6 @@ clutter_actor_set_natural_height (ClutterActor *self,
ClutterActorBox old = { 0, };
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);
if (priv->natural_height_set && natural_height == info->natural.height)

View file

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

View file

@ -365,25 +365,6 @@ clutter_backend_real_create_context (ClutterBackend *backend,
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
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->create_context = clutter_backend_real_create_context;
klass->get_features = clutter_backend_real_get_features;
}
static void
@ -515,46 +495,6 @@ _clutter_backend_create_context (ClutterBackend *backend,
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
_clutter_backend_get_units_per_em (ClutterBackend *backend,
PangoFontDescription *font_desc)

View file

@ -898,9 +898,7 @@ typedef enum /*< prefix=CLUTTER_SCROLL >*/
/**
* 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_STAGE_MULTIPLE: Set if multiple stages are supported.
*
* Runtime flags indicating specific features available via Clutter window
* system and graphics backend.
@ -909,9 +907,7 @@ typedef enum /*< prefix=CLUTTER_SCROLL >*/
*/
typedef enum
{
CLUTTER_FEATURE_STAGE_STATIC = (1 << 6),
CLUTTER_FEATURE_SHADERS_GLSL = (1 << 9),
CLUTTER_FEATURE_STAGE_MULTIPLE = (1 << 11),
} ClutterFeatureFlags;
/**

View file

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

View file

@ -28,14 +28,6 @@
* #ClutterStage is a top level 'window' on which child actors are placed
* 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
* (a #StageWindow) of the windowing system. It is possible to subclass
* #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 width, height;
cairo_rectangle_int_t window_size;
ClutterActorBox children_box;
ClutterLayoutManager *layout_manager = clutter_actor_get_layout_manager (self);
if (priv->impl == NULL)
@ -292,85 +285,52 @@ clutter_stage_allocate (ClutterActor *self,
/* the current Stage implementation 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))
children_box.x1 = children_box.y1 = 0.f;
children_box.x2 = box->x2 - box->x1;
children_box.y2 = box->y2 - box->y1;
CLUTTER_NOTE (LAYOUT,
"Following allocation to %.2fx%.2f",
width, height);
clutter_actor_set_allocation (self, box);
clutter_layout_manager_allocate (layout_manager,
CLUTTER_CONTAINER (self),
&children_box);
/* Ensure the window is sized correctly */
if (priv->min_size_changed)
{
ClutterActorBox children_box;
gfloat min_width, min_height;
gboolean min_width_set, min_height_set;
children_box.x1 = children_box.y1 = 0.f;
children_box.x2 = box->x2 - box->x1;
children_box.y2 = box->y2 - box->y1;
g_object_get (G_OBJECT (self),
"min-width", &min_width,
"min-width-set", &min_width_set,
"min-height", &min_height,
"min-height-set", &min_height_set,
NULL);
CLUTTER_NOTE (LAYOUT,
"Following allocation to %.2fx%.2f",
width, height);
if (!min_width_set)
min_width = 1;
if (!min_height_set)
min_height = 1;
clutter_actor_set_allocation (self, box);
if (width < min_width)
width = min_width;
if (height < min_height)
height = min_height;
clutter_layout_manager_allocate (layout_manager,
CLUTTER_CONTAINER (self),
&children_box);
/* Ensure the window is sized correctly */
if (priv->min_size_changed)
{
gfloat min_width, min_height;
gboolean min_width_set, min_height_set;
g_object_get (G_OBJECT (self),
"min-width", &min_width,
"min-width-set", &min_width_set,
"min-height", &min_height,
"min-height-set", &min_height_set,
NULL);
if (!min_width_set)
min_width = 1;
if (!min_height_set)
min_height = 1;
if (width < min_width)
width = min_width;
if (height < min_height)
height = min_height;
priv->min_size_changed = FALSE;
}
if (window_size.width != CLUTTER_NEARBYINT (width) ||
window_size.height != CLUTTER_NEARBYINT (height))
{
_clutter_stage_window_resize (priv->impl,
CLUTTER_NEARBYINT (width),
CLUTTER_NEARBYINT (height));
}
priv->min_size_changed = FALSE;
}
else
if (window_size.width != CLUTTER_NEARBYINT (width) ||
window_size.height != CLUTTER_NEARBYINT (height))
{
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);
_clutter_stage_window_resize (priv->impl,
CLUTTER_NEARBYINT (width),
CLUTTER_NEARBYINT (height));
}
/* set the viewport to the new allocation */
@ -1174,25 +1134,6 @@ clutter_stage_constructed (GObject *gobject)
/* this will take care to sinking the floating reference */
_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);
}

View file

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