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)) if (G_UNLIKELY (klass->base_pipeline == NULL))
{ {
CoglSnippet *snippet; CoglSnippet *snippet;
CoglContext *ctx = ClutterContext *context = _clutter_context_get_default ();
clutter_backend_get_cogl_context (clutter_get_default_backend ()); 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, cogl_pipeline_set_static_name (klass->base_pipeline,
"ClutterBlurEffect (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)) if (G_UNLIKELY (klass->base_pipeline == NULL))
{ {
CoglSnippet *snippet; CoglSnippet *snippet;
CoglContext *ctx = ClutterContext *context = _clutter_context_get_default ();
clutter_backend_get_cogl_context (clutter_get_default_backend ()); 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, cogl_pipeline_set_static_name (klass->base_pipeline,
"ClutterBrightnessContrast"); "ClutterBrightnessContrast");

View File

@ -210,10 +210,11 @@ clutter_colorize_effect_init (ClutterColorizeEffect *self)
if (G_UNLIKELY (klass->base_pipeline == NULL)) if (G_UNLIKELY (klass->base_pipeline == NULL))
{ {
CoglSnippet *snippet; CoglSnippet *snippet;
CoglContext *ctx = ClutterContext *context = _clutter_context_get_default ();
clutter_backend_get_cogl_context (clutter_get_default_backend ()); 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"); cogl_pipeline_set_static_name (klass->base_pipeline, "ClutterColorize");
snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_FRAGMENT, 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; gint x, y, direction, n_indices;
CoglAttribute *attributes[3]; CoglAttribute *attributes[3];
guint16 *static_indices; guint16 *static_indices;
CoglContext *ctx = ClutterContext *context = _clutter_context_get_default ();
clutter_backend_get_cogl_context (clutter_get_default_backend ()); ClutterBackend *backend = clutter_context_get_backend (context);
CoglContext *cogl_context = clutter_backend_get_cogl_context (backend);
CoglIndices *indices; CoglIndices *indices;
guint16 *idx; guint16 *idx;
int i; int i;
@ -438,7 +439,7 @@ clutter_deform_effect_init_arrays (ClutterDeformEffect *self)
#undef MESH_INDEX #undef MESH_INDEX
indices = cogl_indices_new (ctx, indices = cogl_indices_new (cogl_context,
COGL_INDICES_TYPE_UNSIGNED_SHORT, COGL_INDICES_TYPE_UNSIGNED_SHORT,
static_indices, static_indices,
n_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->n_vertices = (priv->x_tiles + 1) * (priv->y_tiles + 1);
priv->buffer = priv->buffer =
cogl_attribute_buffer_new (ctx, cogl_attribute_buffer_new (cogl_context,
sizeof (ClutterVertexP3T2C4) * sizeof (ClutterVertexP3T2C4) *
priv->n_vertices, priv->n_vertices,
NULL); NULL);

View File

@ -213,11 +213,12 @@ clutter_desaturate_effect_init (ClutterDesaturateEffect *self)
if (G_UNLIKELY (klass->base_pipeline == NULL)) if (G_UNLIKELY (klass->base_pipeline == NULL))
{ {
CoglContext *ctx = ClutterContext *context = _clutter_context_get_default ();
clutter_backend_get_cogl_context (clutter_get_default_backend ()); ClutterBackend *backend = clutter_context_get_backend (context);
CoglContext *cogl_context = clutter_backend_get_cogl_context (backend);
CoglSnippet *snippet; 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"); cogl_pipeline_set_static_name (klass->base_pipeline, "ClutterDesaturate");
snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_FRAGMENT, 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, const uint8_t *data,
GError **error) GError **error)
{ {
CoglContext *ctx = ClutterContext *context = _clutter_context_get_default ();
clutter_backend_get_cogl_context (clutter_get_default_backend ()); ClutterBackend *backend = clutter_context_get_backend (context);
CoglContext *cogl_context = clutter_backend_get_cogl_context (backend);
CoglTexture *texture_2d; CoglTexture *texture_2d;
texture_2d = cogl_texture_2d_new_from_data (ctx, texture_2d = cogl_texture_2d_new_from_data (cogl_context,
width, width,
height, height,
pixel_format, pixel_format,

View File

@ -243,10 +243,10 @@ clutter_input_method_put_im_event (ClutterInputMethod *im,
uint32_t len, uint32_t len,
ClutterPreeditResetMode mode) ClutterPreeditResetMode mode)
{ {
ClutterSeat *seat;
ClutterEvent *event; ClutterEvent *event;
ClutterContext *context = _clutter_context_get_default ();
seat = clutter_backend_get_default_seat (clutter_get_default_backend ()); ClutterBackend *backend = clutter_context_get_backend (context);
ClutterSeat *seat = clutter_backend_get_default_seat (backend);
event = clutter_event_im_new (event_type, event = clutter_event_im_new (event_type,
CLUTTER_EVENT_FLAG_INPUT_METHOD, CLUTTER_EVENT_FLAG_INPUT_METHOD,
@ -476,6 +476,8 @@ clutter_input_method_forward_key (ClutterInputMethod *im,
ClutterInputDevice *keyboard; ClutterInputDevice *keyboard;
ClutterSeat *seat; ClutterSeat *seat;
ClutterEvent *event; ClutterEvent *event;
ClutterContext *context;
ClutterBackend *backend;
g_return_if_fail (CLUTTER_IS_INPUT_METHOD (im)); g_return_if_fail (CLUTTER_IS_INPUT_METHOD (im));
@ -483,7 +485,9 @@ clutter_input_method_forward_key (ClutterInputMethod *im,
if (!priv->focus) if (!priv->focus)
return; 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); keyboard = clutter_seat_get_keyboard (seat);
event = clutter_event_key_new (press ? CLUTTER_KEY_PRESS : CLUTTER_KEY_RELEASE, 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; g_autoptr (GError) error = NULL;
ClutterLayerNode *layer_node; ClutterLayerNode *layer_node;
ClutterBlurNode *blur_node; ClutterBlurNode *blur_node;
CoglContext *context; ClutterContext *context;
ClutterBackend *backend;
CoglContext *cogl_context;
CoglTexture *texture; CoglTexture *texture;
ClutterBlur *blur; ClutterBlur *blur;
g_return_val_if_fail (radius >= 0.0, NULL); 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); 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 (cogl_context, width, height);
texture = cogl_texture_2d_new_with_size (context, width, height);
cogl_texture_set_premultiplied (texture, TRUE); cogl_texture_set_premultiplied (texture, TRUE);