diff --git a/src/compositor/cogl-utils.c b/src/compositor/cogl-utils.c index c752bd229..095c5340b 100644 --- a/src/compositor/cogl-utils.c +++ b/src/compositor/cogl-utils.c @@ -28,6 +28,7 @@ /** * meta_create_texture_pipeline: + * @cogl_context: A #CoglContext * @src_texture: (nullable): texture to use initially for the layer * * Creates a pipeline with a single layer. Using a common template @@ -37,7 +38,8 @@ * Return value: (transfer full): a newly created #CoglPipeline */ CoglPipeline * -meta_create_texture_pipeline (CoglTexture *src_texture) +meta_create_texture_pipeline (CoglContext *cogl_context, + CoglTexture *src_texture) { static CoglPipeline *texture_pipeline_template = NULL; CoglPipeline *pipeline; @@ -50,10 +52,7 @@ meta_create_texture_pipeline (CoglTexture *src_texture) pipeline ancestry instead of resorting to the shader cache. */ if (G_UNLIKELY (texture_pipeline_template == NULL)) { - CoglContext *ctx = - clutter_backend_get_cogl_context (clutter_get_default_backend ()); - - texture_pipeline_template = cogl_pipeline_new (ctx); + texture_pipeline_template = cogl_pipeline_new (cogl_context); cogl_pipeline_set_layer_null_texture (texture_pipeline_template, 0); } diff --git a/src/compositor/cogl-utils.h b/src/compositor/cogl-utils.h index 0ea4e5d6c..eec514960 100644 --- a/src/compositor/cogl-utils.h +++ b/src/compositor/cogl-utils.h @@ -22,7 +22,8 @@ #include "cogl/cogl.h" -CoglPipeline * meta_create_texture_pipeline (CoglTexture *texture); +CoglPipeline * meta_create_texture_pipeline (CoglContext *cogl_context, + CoglTexture *texture); typedef enum { diff --git a/src/compositor/meta-background-content.c b/src/compositor/meta-background-content.c index d88073a06..481765c8e 100644 --- a/src/compositor/meta-background-content.c +++ b/src/compositor/meta-background-content.c @@ -306,7 +306,8 @@ on_background_changed (MetaBackground *background, } static CoglPipeline * -make_pipeline (PipelineFlags pipeline_flags) +make_pipeline (CoglContext *cogl_context, + PipelineFlags pipeline_flags) { static CoglPipeline *templates[PIPELINE_ALL + 1]; CoglPipeline **templatep; @@ -320,7 +321,7 @@ make_pipeline (PipelineFlags pipeline_flags) * so we need to prevent identical pipelines from getting cached * separately, by reusing the same shader snippets. */ - *templatep = COGL_PIPELINE (meta_create_texture_pipeline (NULL)); + *templatep = COGL_PIPELINE (meta_create_texture_pipeline (cogl_context, NULL)); if ((pipeline_flags & PIPELINE_VIGNETTE) != 0) { @@ -393,6 +394,8 @@ setup_pipeline (MetaBackgroundContent *self, { MetaContext *context = meta_display_get_context (self->display); MetaBackend *backend = meta_context_get_backend (context); + ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend); + CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend); PipelineFlags pipeline_flags = 0; guint8 opacity; float color_component; @@ -416,7 +419,7 @@ setup_pipeline (MetaBackgroundContent *self, if (self->pipeline == NULL) { self->pipeline_flags = pipeline_flags; - self->pipeline = make_pipeline (pipeline_flags); + self->pipeline = make_pipeline (cogl_context, pipeline_flags); self->changed = CHANGED_ALL; } diff --git a/src/compositor/meta-background.c b/src/compositor/meta-background.c index 78b65a32b..ef7d783da 100644 --- a/src/compositor/meta-background.c +++ b/src/compositor/meta-background.c @@ -611,7 +611,8 @@ typedef enum } PipelineType; static CoglPipeline * -create_pipeline (PipelineType type) +create_pipeline (CoglContext *cogl_context, + PipelineType type) { const char * const blend_strings[3] = { [PIPELINE_REPLACE] = "RGBA = ADD (SRC_COLOR, 0)", @@ -622,7 +623,7 @@ create_pipeline (PipelineType type) if (templates[type] == NULL) { - templates[type] = meta_create_texture_pipeline (NULL); + templates[type] = meta_create_texture_pipeline (cogl_context, NULL); cogl_pipeline_set_blend (templates[type], blend_strings[type], NULL); } @@ -663,6 +664,8 @@ ensure_wallpaper_texture (MetaBackground *self, { int width = cogl_texture_get_width (texture); int height = cogl_texture_get_height (texture); + CoglContext *cogl_context = + cogl_texture_get_context (texture); CoglOffscreen *offscreen; CoglFramebuffer *fbo; GError *catch_error = NULL; @@ -692,7 +695,7 @@ ensure_wallpaper_texture (MetaBackground *self, cogl_framebuffer_orthographic (fbo, 0, 0, width, height, -1., 1.); - pipeline = create_pipeline (PIPELINE_REPLACE); + pipeline = create_pipeline (cogl_context, PIPELINE_REPLACE); cogl_pipeline_set_layer_texture (pipeline, 0, texture); cogl_framebuffer_draw_textured_rectangle (fbo, pipeline, 0, 0, width, height, 0., 0., 1., 1.); @@ -702,7 +705,7 @@ ensure_wallpaper_texture (MetaBackground *self, { ensure_color_texture (self); - pipeline = create_pipeline (PIPELINE_OVER_REVERSE); + pipeline = create_pipeline (cogl_context, PIPELINE_OVER_REVERSE); cogl_pipeline_set_layer_texture (pipeline, 0, self->color_texture); cogl_framebuffer_draw_rectangle (fbo, pipeline, 0, 0, width, height); g_object_unref (pipeline); @@ -762,6 +765,10 @@ meta_background_get_texture (MetaBackground *self, MtkRectangle monitor_area; CoglTexture *texture1, *texture2; float monitor_scale; + MetaContext *context = meta_display_get_context (self->display); + MetaBackend *backend = meta_context_get_backend (context); + ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend); + CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend); g_return_val_if_fail (META_IS_BACKGROUND (self), NULL); g_return_val_if_fail (monitor_index >= 0 && monitor_index < self->n_monitors, NULL); @@ -802,8 +809,6 @@ meta_background_get_texture (MetaBackground *self, if (monitor->dirty) { - MetaContext *context = meta_display_get_context (self->display); - MetaBackend *backend = meta_context_get_backend (context); GError *catch_error = NULL; gboolean bare_region_visible = FALSE; int texture_width, texture_height; @@ -860,7 +865,7 @@ meta_background_get_texture (MetaBackground *self, if (texture2 != NULL && self->blend_factor != 0.0f) { - CoglPipeline *pipeline = create_pipeline (PIPELINE_REPLACE); + CoglPipeline *pipeline = create_pipeline (cogl_context, PIPELINE_REPLACE); int mipmap_level; CoglColor color; @@ -892,7 +897,7 @@ meta_background_get_texture (MetaBackground *self, if (texture1 != NULL && self->blend_factor != 1.0) { - CoglPipeline *pipeline = create_pipeline (PIPELINE_ADD); + CoglPipeline *pipeline = create_pipeline (cogl_context, PIPELINE_ADD); int mipmap_level; CoglColor color; @@ -918,7 +923,7 @@ meta_background_get_texture (MetaBackground *self, if (bare_region_visible) { - CoglPipeline *pipeline = create_pipeline (PIPELINE_OVER_REVERSE); + CoglPipeline *pipeline = create_pipeline (cogl_context, PIPELINE_OVER_REVERSE); ensure_color_texture (self); cogl_pipeline_set_layer_texture (pipeline, 0, self->color_texture); diff --git a/src/x11/meta-shadow-factory.c b/src/x11/meta-shadow-factory.c index 8c7fe9a6c..7faebc1ab 100644 --- a/src/x11/meta-shadow-factory.c +++ b/src/x11/meta-shadow-factory.c @@ -931,7 +931,7 @@ make_shadow (MetaShadow *shadow, g_free (buffer); - shadow->pipeline = meta_create_texture_pipeline (shadow->texture); + shadow->pipeline = meta_create_texture_pipeline (ctx, shadow->texture); cogl_pipeline_set_static_name (shadow->pipeline, "MetaShadowFactory"); }