clutter: Stop using get_default_backend helper

As it ends up using the global default context. So just call that
directly to easily spot the remaining usages of get_default_context.

Note that the helper will probably be removed later this cycle once the
remaining usages in meta & libst have been replaced with passing around
the context

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4077>
This commit is contained in:
Bilal Elmoussaoui 2024-10-16 09:05:10 +02:00
parent 696dfaa124
commit dabc13f7b8
8 changed files with 40 additions and 26 deletions

View File

@ -167,10 +167,11 @@ clutter_blur_effect_init (ClutterBlurEffect *self)
if (G_UNLIKELY (klass->base_pipeline == NULL))
{
CoglSnippet *snippet;
CoglContext *ctx =
clutter_backend_get_cogl_context (clutter_get_default_backend ());
ClutterContext *context = _clutter_context_get_default ();
ClutterBackend *backend = clutter_context_get_backend (context);
CoglContext *cogl_context = clutter_backend_get_cogl_context (backend);
klass->base_pipeline = cogl_pipeline_new (ctx);
klass->base_pipeline = cogl_pipeline_new (cogl_context);
cogl_pipeline_set_static_name (klass->base_pipeline,
"ClutterBlurEffect (base pipeline)");

View File

@ -370,10 +370,11 @@ clutter_brightness_contrast_effect_init (ClutterBrightnessContrastEffect *self)
if (G_UNLIKELY (klass->base_pipeline == NULL))
{
CoglSnippet *snippet;
CoglContext *ctx =
clutter_backend_get_cogl_context (clutter_get_default_backend ());
ClutterContext *context = _clutter_context_get_default ();
ClutterBackend *backend = clutter_context_get_backend (context);
CoglContext *cogl_context = clutter_backend_get_cogl_context (backend);
klass->base_pipeline = cogl_pipeline_new (ctx);
klass->base_pipeline = cogl_pipeline_new (cogl_context);
cogl_pipeline_set_static_name (klass->base_pipeline,
"ClutterBrightnessContrast");

View File

@ -210,10 +210,11 @@ clutter_colorize_effect_init (ClutterColorizeEffect *self)
if (G_UNLIKELY (klass->base_pipeline == NULL))
{
CoglSnippet *snippet;
CoglContext *ctx =
clutter_backend_get_cogl_context (clutter_get_default_backend ());
ClutterContext *context = _clutter_context_get_default ();
ClutterBackend *backend = clutter_context_get_backend (context);
CoglContext *cogl_context = clutter_backend_get_cogl_context (backend);
klass->base_pipeline = cogl_pipeline_new (ctx);
klass->base_pipeline = cogl_pipeline_new (cogl_context);
cogl_pipeline_set_static_name (klass->base_pipeline, "ClutterColorize");
snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_FRAGMENT,

View File

@ -373,8 +373,9 @@ clutter_deform_effect_init_arrays (ClutterDeformEffect *self)
gint x, y, direction, n_indices;
CoglAttribute *attributes[3];
guint16 *static_indices;
CoglContext *ctx =
clutter_backend_get_cogl_context (clutter_get_default_backend ());
ClutterContext *context = _clutter_context_get_default ();
ClutterBackend *backend = clutter_context_get_backend (context);
CoglContext *cogl_context = clutter_backend_get_cogl_context (backend);
CoglIndices *indices;
guint16 *idx;
int i;
@ -438,7 +439,7 @@ clutter_deform_effect_init_arrays (ClutterDeformEffect *self)
#undef MESH_INDEX
indices = cogl_indices_new (ctx,
indices = cogl_indices_new (cogl_context,
COGL_INDICES_TYPE_UNSIGNED_SHORT,
static_indices,
n_indices);
@ -448,7 +449,7 @@ clutter_deform_effect_init_arrays (ClutterDeformEffect *self)
priv->n_vertices = (priv->x_tiles + 1) * (priv->y_tiles + 1);
priv->buffer =
cogl_attribute_buffer_new (ctx,
cogl_attribute_buffer_new (cogl_context,
sizeof (ClutterVertexP3T2C4) *
priv->n_vertices,
NULL);

View File

@ -213,11 +213,12 @@ clutter_desaturate_effect_init (ClutterDesaturateEffect *self)
if (G_UNLIKELY (klass->base_pipeline == NULL))
{
CoglContext *ctx =
clutter_backend_get_cogl_context (clutter_get_default_backend ());
ClutterContext *context = _clutter_context_get_default ();
ClutterBackend *backend = clutter_context_get_backend (context);
CoglContext *cogl_context = clutter_backend_get_cogl_context (backend);
CoglSnippet *snippet;
klass->base_pipeline = cogl_pipeline_new (ctx);
klass->base_pipeline = cogl_pipeline_new (cogl_context);
cogl_pipeline_set_static_name (klass->base_pipeline, "ClutterDesaturate");
snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_FRAGMENT,

View File

@ -64,11 +64,12 @@ create_texture_from_data (unsigned int width,
const uint8_t *data,
GError **error)
{
CoglContext *ctx =
clutter_backend_get_cogl_context (clutter_get_default_backend ());
ClutterContext *context = _clutter_context_get_default ();
ClutterBackend *backend = clutter_context_get_backend (context);
CoglContext *cogl_context = clutter_backend_get_cogl_context (backend);
CoglTexture *texture_2d;
texture_2d = cogl_texture_2d_new_from_data (ctx,
texture_2d = cogl_texture_2d_new_from_data (cogl_context,
width,
height,
pixel_format,

View File

@ -243,10 +243,10 @@ clutter_input_method_put_im_event (ClutterInputMethod *im,
uint32_t len,
ClutterPreeditResetMode mode)
{
ClutterSeat *seat;
ClutterEvent *event;
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
ClutterContext *context = _clutter_context_get_default ();
ClutterBackend *backend = clutter_context_get_backend (context);
ClutterSeat *seat = clutter_backend_get_default_seat (backend);
event = clutter_event_im_new (event_type,
CLUTTER_EVENT_FLAG_INPUT_METHOD,
@ -476,6 +476,8 @@ clutter_input_method_forward_key (ClutterInputMethod *im,
ClutterInputDevice *keyboard;
ClutterSeat *seat;
ClutterEvent *event;
ClutterContext *context;
ClutterBackend *backend;
g_return_if_fail (CLUTTER_IS_INPUT_METHOD (im));
@ -483,7 +485,9 @@ clutter_input_method_forward_key (ClutterInputMethod *im,
if (!priv->focus)
return;
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
context = _clutter_context_get_default ();
backend = clutter_context_get_backend (context);
seat = clutter_backend_get_default_seat (backend);
keyboard = clutter_seat_get_keyboard (seat);
event = clutter_event_key_new (press ? CLUTTER_KEY_PRESS : CLUTTER_KEY_RELEASE,

View File

@ -1589,15 +1589,19 @@ clutter_blur_node_new (unsigned int width,
g_autoptr (GError) error = NULL;
ClutterLayerNode *layer_node;
ClutterBlurNode *blur_node;
CoglContext *context;
ClutterContext *context;
ClutterBackend *backend;
CoglContext *cogl_context;
CoglTexture *texture;
ClutterBlur *blur;
g_return_val_if_fail (radius >= 0.0, NULL);
context = _clutter_context_get_default ();
backend = clutter_context_get_backend (context);
cogl_context = clutter_backend_get_cogl_context (backend);
blur_node = _clutter_paint_node_create (CLUTTER_TYPE_BLUR_NODE);
context = clutter_backend_get_cogl_context (clutter_get_default_backend ());
texture = cogl_texture_2d_new_with_size (context, width, height);
texture = cogl_texture_2d_new_with_size (cogl_context, width, height);
cogl_texture_set_premultiplied (texture, TRUE);