compositor: Require a context when creating a texture mipmap
avoids going through globals Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3989>
This commit is contained in:

committed by
Jonas Ådahl

parent
0c7019a092
commit
ea902ac928
@ -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
|
static void
|
||||||
meta_shaped_texture_class_init (MetaShapedTextureClass *klass)
|
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->dispose = meta_shaped_texture_dispose;
|
||||||
object_class->set_property = meta_shaped_texture_set_property;
|
object_class->set_property = meta_shaped_texture_set_property;
|
||||||
object_class->get_property = meta_shaped_texture_get_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",
|
signals[SIZE_CHANGED] = g_signal_new ("size-changed",
|
||||||
G_TYPE_FROM_CLASS (klass),
|
G_TYPE_FROM_CLASS (klass),
|
||||||
@ -215,7 +230,6 @@ invalidate_size (MetaShapedTexture *stex)
|
|||||||
static void
|
static void
|
||||||
meta_shaped_texture_init (MetaShapedTexture *stex)
|
meta_shaped_texture_init (MetaShapedTexture *stex)
|
||||||
{
|
{
|
||||||
stex->texture_mipmap = meta_texture_mipmap_new ();
|
|
||||||
stex->buffer_scale = 1;
|
stex->buffer_scale = 1;
|
||||||
stex->texture = NULL;
|
stex->texture = NULL;
|
||||||
stex->mask_texture = NULL;
|
stex->mask_texture = NULL;
|
||||||
|
@ -36,6 +36,7 @@ struct _MetaTextureMipmap
|
|||||||
MetaMultiTexture *mipmap_texture;
|
MetaMultiTexture *mipmap_texture;
|
||||||
CoglPipeline *pipeline;
|
CoglPipeline *pipeline;
|
||||||
CoglFramebuffer *fb;
|
CoglFramebuffer *fb;
|
||||||
|
CoglContext *cogl_context;
|
||||||
gboolean invalid;
|
gboolean invalid;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -48,11 +49,12 @@ struct _MetaTextureMipmap
|
|||||||
* Return value: the new texture mipmap handler. Free with meta_texture_mipmap_free()
|
* Return value: the new texture mipmap handler. Free with meta_texture_mipmap_free()
|
||||||
*/
|
*/
|
||||||
MetaTextureMipmap *
|
MetaTextureMipmap *
|
||||||
meta_texture_mipmap_new (void)
|
meta_texture_mipmap_new (CoglContext *cogl_context)
|
||||||
{
|
{
|
||||||
MetaTextureMipmap *mipmap;
|
MetaTextureMipmap *mipmap;
|
||||||
|
|
||||||
mipmap = g_new0 (MetaTextureMipmap, 1);
|
mipmap = g_new0 (MetaTextureMipmap, 1);
|
||||||
|
mipmap->cogl_context = cogl_context;
|
||||||
|
|
||||||
return mipmap;
|
return mipmap;
|
||||||
}
|
}
|
||||||
@ -132,8 +134,6 @@ meta_texture_mipmap_clear (MetaTextureMipmap *mipmap)
|
|||||||
static void
|
static void
|
||||||
ensure_mipmap_texture (MetaTextureMipmap *mipmap)
|
ensure_mipmap_texture (MetaTextureMipmap *mipmap)
|
||||||
{
|
{
|
||||||
CoglContext *ctx =
|
|
||||||
clutter_backend_get_cogl_context (clutter_get_default_backend ());
|
|
||||||
int width, height;
|
int width, height;
|
||||||
|
|
||||||
/* Let's avoid spending any texture memory copying the base level texture
|
/* Let's avoid spending any texture memory copying the base level texture
|
||||||
@ -172,7 +172,7 @@ ensure_mipmap_texture (MetaTextureMipmap *mipmap)
|
|||||||
|
|
||||||
free_mipmaps (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)
|
if (!tex)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -212,7 +212,7 @@ ensure_mipmap_texture (MetaTextureMipmap *mipmap)
|
|||||||
CoglSnippet *fragment_globals_snippet;
|
CoglSnippet *fragment_globals_snippet;
|
||||||
CoglSnippet *fragment_snippet;
|
CoglSnippet *fragment_snippet;
|
||||||
|
|
||||||
mipmap->pipeline = cogl_pipeline_new (ctx);
|
mipmap->pipeline = cogl_pipeline_new (mipmap->cogl_context);
|
||||||
cogl_pipeline_set_blend (mipmap->pipeline,
|
cogl_pipeline_set_blend (mipmap->pipeline,
|
||||||
"RGBA = ADD (SRC_COLOR, 0)",
|
"RGBA = ADD (SRC_COLOR, 0)",
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -37,7 +37,7 @@ G_BEGIN_DECLS
|
|||||||
|
|
||||||
typedef struct _MetaTextureMipmap MetaTextureMipmap;
|
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);
|
void meta_texture_mipmap_free (MetaTextureMipmap *mipmap);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user