utils: Pass a CoglContext to meta_create_texture
Moves the global backend access from the function to the only place where we don't have a way to get CoglContext in background loading. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4201>
This commit is contained in:
parent
5a2ef3ca4b
commit
98e887df48
@ -68,7 +68,8 @@ meta_create_texture_pipeline (CoglContext *cogl_context,
|
||||
* meta_create_texture:
|
||||
* @width: width of the texture to create
|
||||
* @height: height of the texture to create
|
||||
* @components; components to store in the texture (color or alpha)
|
||||
* @ctx: A #CoglContext
|
||||
* @components: components to store in the texture (color or alpha)
|
||||
* @flags: flags that affect the allocation behavior
|
||||
*
|
||||
* Creates a texture of the given size with the specified components
|
||||
@ -84,11 +85,10 @@ meta_create_texture_pipeline (CoglContext *cogl_context,
|
||||
CoglTexture *
|
||||
meta_create_texture (int width,
|
||||
int height,
|
||||
CoglContext *ctx,
|
||||
CoglTextureComponents components,
|
||||
MetaTextureFlags flags)
|
||||
{
|
||||
ClutterBackend *backend = clutter_get_default_backend ();
|
||||
CoglContext *ctx = clutter_backend_get_cogl_context (backend);
|
||||
CoglTexture *texture;
|
||||
|
||||
texture = cogl_texture_2d_new_with_size (ctx, width, height);
|
||||
|
@ -33,6 +33,7 @@ typedef enum
|
||||
|
||||
CoglTexture * meta_create_texture (int width,
|
||||
int height,
|
||||
CoglContext *cogl_context,
|
||||
CoglTextureComponents components,
|
||||
MetaTextureFlags flags);
|
||||
|
||||
|
@ -157,6 +157,8 @@ file_loaded (GObject *source_object,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
ClutterBackend *backend = clutter_get_default_backend ();
|
||||
CoglContext *ctx = clutter_backend_get_cogl_context (backend);
|
||||
MetaBackgroundImage *image = META_BACKGROUND_IMAGE (source_object);
|
||||
g_autoptr (GError) error = NULL;
|
||||
g_autoptr (GError) local_error = NULL;
|
||||
@ -192,7 +194,7 @@ file_loaded (GObject *source_object,
|
||||
pixels = gdk_pixbuf_get_pixels (pixbuf);
|
||||
has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
|
||||
|
||||
texture = meta_create_texture (width, height,
|
||||
texture = meta_create_texture (width, height, ctx,
|
||||
has_alpha ? COGL_TEXTURE_COMPONENTS_RGBA : COGL_TEXTURE_COMPONENTS_RGB,
|
||||
META_TEXTURE_ALLOW_SLICING);
|
||||
|
||||
|
@ -671,7 +671,7 @@ ensure_wallpaper_texture (MetaBackground *self,
|
||||
GError *catch_error = NULL;
|
||||
CoglPipeline *pipeline;
|
||||
|
||||
self->wallpaper_texture = meta_create_texture (width, height,
|
||||
self->wallpaper_texture = meta_create_texture (width, height, cogl_context,
|
||||
COGL_TEXTURE_COMPONENTS_RGBA,
|
||||
META_TEXTURE_FLAGS_NONE);
|
||||
offscreen = cogl_offscreen_new_with_texture (self->wallpaper_texture);
|
||||
@ -830,6 +830,7 @@ meta_background_get_texture (MetaBackground *self,
|
||||
|
||||
monitor->texture = meta_create_texture (texture_width,
|
||||
texture_height,
|
||||
cogl_context,
|
||||
COGL_TEXTURE_COMPONENTS_RGBA,
|
||||
META_TEXTURE_FLAGS_NONE);
|
||||
offscreen = cogl_offscreen_new_with_texture (monitor->texture);
|
||||
|
Loading…
x
Reference in New Issue
Block a user