diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c index 886f8471a..28067825d 100644 --- a/src/compositor/meta-shaped-texture.c +++ b/src/compositor/meta-shaped-texture.c @@ -175,6 +175,20 @@ meta_shaped_texture_get_property (GObject *object, } } +static void +meta_shaped_texture_constructed (GObject *object) +{ + MetaShapedTexture *stex = META_SHAPED_TEXTURE (object); + ClutterBackend *clutter_backend = + clutter_context_get_backend (stex->clutter_context); + CoglContext *cogl_context = + clutter_backend_get_cogl_context (clutter_backend); + + G_OBJECT_CLASS (meta_shaped_texture_parent_class)->constructed (object); + + stex->texture_mipmap = meta_texture_mipmap_new (cogl_context); +} + static void meta_shaped_texture_class_init (MetaShapedTextureClass *klass) { @@ -183,6 +197,7 @@ meta_shaped_texture_class_init (MetaShapedTextureClass *klass) object_class->dispose = meta_shaped_texture_dispose; object_class->set_property = meta_shaped_texture_set_property; object_class->get_property = meta_shaped_texture_get_property; + object_class->constructed = meta_shaped_texture_constructed; signals[SIZE_CHANGED] = g_signal_new ("size-changed", G_TYPE_FROM_CLASS (klass), @@ -215,7 +230,6 @@ invalidate_size (MetaShapedTexture *stex) static void meta_shaped_texture_init (MetaShapedTexture *stex) { - stex->texture_mipmap = meta_texture_mipmap_new (); stex->buffer_scale = 1; stex->texture = NULL; stex->mask_texture = NULL; diff --git a/src/compositor/meta-texture-mipmap.c b/src/compositor/meta-texture-mipmap.c index 54873ccb9..1c63ff617 100644 --- a/src/compositor/meta-texture-mipmap.c +++ b/src/compositor/meta-texture-mipmap.c @@ -36,6 +36,7 @@ struct _MetaTextureMipmap MetaMultiTexture *mipmap_texture; CoglPipeline *pipeline; CoglFramebuffer *fb; + CoglContext *cogl_context; gboolean invalid; }; @@ -48,11 +49,12 @@ struct _MetaTextureMipmap * Return value: the new texture mipmap handler. Free with meta_texture_mipmap_free() */ MetaTextureMipmap * -meta_texture_mipmap_new (void) +meta_texture_mipmap_new (CoglContext *cogl_context) { MetaTextureMipmap *mipmap; mipmap = g_new0 (MetaTextureMipmap, 1); + mipmap->cogl_context = cogl_context; return mipmap; } @@ -132,8 +134,6 @@ meta_texture_mipmap_clear (MetaTextureMipmap *mipmap) static void ensure_mipmap_texture (MetaTextureMipmap *mipmap) { - CoglContext *ctx = - clutter_backend_get_cogl_context (clutter_get_default_backend ()); int width, height; /* Let's avoid spending any texture memory copying the base level texture @@ -172,7 +172,7 @@ ensure_mipmap_texture (MetaTextureMipmap *mipmap) free_mipmaps (mipmap); - tex = cogl_texture_2d_new_with_size (ctx, width, height); + tex = cogl_texture_2d_new_with_size (mipmap->cogl_context, width, height); if (!tex) return; @@ -212,7 +212,7 @@ ensure_mipmap_texture (MetaTextureMipmap *mipmap) CoglSnippet *fragment_globals_snippet; CoglSnippet *fragment_snippet; - mipmap->pipeline = cogl_pipeline_new (ctx); + mipmap->pipeline = cogl_pipeline_new (mipmap->cogl_context); cogl_pipeline_set_blend (mipmap->pipeline, "RGBA = ADD (SRC_COLOR, 0)", NULL); diff --git a/src/compositor/meta-texture-mipmap.h b/src/compositor/meta-texture-mipmap.h index 4b91f83d3..582d76b29 100644 --- a/src/compositor/meta-texture-mipmap.h +++ b/src/compositor/meta-texture-mipmap.h @@ -37,7 +37,7 @@ G_BEGIN_DECLS typedef struct _MetaTextureMipmap MetaTextureMipmap; -MetaTextureMipmap *meta_texture_mipmap_new (void); +MetaTextureMipmap *meta_texture_mipmap_new (CoglContext *cogl_context); void meta_texture_mipmap_free (MetaTextureMipmap *mipmap);