st/image-content: Take a CoglContext on set_bytes/set_data functions
This avoids retrieving it from the global clutter backend and instead pass things around. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3528>
This commit is contained in:
parent
76f2262d9c
commit
44b84e458a
@ -377,28 +377,6 @@ st_image_content_get_is_symbolic (StImageContent *content)
|
||||
return content->is_symbolic;
|
||||
}
|
||||
|
||||
static CoglTexture *
|
||||
create_texture_from_data (unsigned int width,
|
||||
unsigned int height,
|
||||
CoglPixelFormat pixel_format,
|
||||
unsigned int row_stride,
|
||||
const uint8_t *data,
|
||||
GError **error)
|
||||
{
|
||||
ClutterBackend *backend = clutter_get_default_backend ();
|
||||
CoglContext *cogl_context = clutter_backend_get_cogl_context (backend);
|
||||
CoglTexture *texture_2d;
|
||||
|
||||
texture_2d = cogl_texture_2d_new_from_data (cogl_context,
|
||||
width,
|
||||
height,
|
||||
pixel_format,
|
||||
row_stride,
|
||||
data,
|
||||
error);
|
||||
|
||||
return texture_2d;
|
||||
}
|
||||
|
||||
static void
|
||||
update_image_size (StImageContent *self)
|
||||
@ -424,6 +402,7 @@ update_image_size (StImageContent *self)
|
||||
/**
|
||||
* st_image_content_set_data:
|
||||
* @content: a #StImageContentImage
|
||||
* @cogl_context: The context to use
|
||||
* @data: (array): the image data, as an array of bytes
|
||||
* @pixel_format: the Cogl pixel format of the image data
|
||||
* @width: the width of the image data
|
||||
@ -467,6 +446,7 @@ update_image_size (StImageContent *self)
|
||||
*/
|
||||
gboolean
|
||||
st_image_content_set_data (StImageContent *content,
|
||||
CoglContext *cogl_context,
|
||||
const guint8 *data,
|
||||
CoglPixelFormat pixel_format,
|
||||
guint width,
|
||||
@ -480,7 +460,8 @@ st_image_content_set_data (StImageContent *content,
|
||||
if (content->texture != NULL)
|
||||
g_object_unref (content->texture);
|
||||
|
||||
content->texture = create_texture_from_data (width,
|
||||
content->texture = cogl_texture_2d_new_from_data (cogl_context,
|
||||
width,
|
||||
height,
|
||||
pixel_format,
|
||||
row_stride,
|
||||
@ -499,6 +480,7 @@ st_image_content_set_data (StImageContent *content,
|
||||
/**
|
||||
* st_image_content_set_bytes:
|
||||
* @content: a #StImageContent
|
||||
* @cogl_context: The context to use
|
||||
* @data: the image data, as a #GBytes
|
||||
* @pixel_format: the Cogl pixel format of the image data
|
||||
* @width: the width of the image data
|
||||
@ -521,6 +503,7 @@ st_image_content_set_data (StImageContent *content,
|
||||
*/
|
||||
gboolean
|
||||
st_image_content_set_bytes (StImageContent *content,
|
||||
CoglContext *cogl_context,
|
||||
GBytes *data,
|
||||
CoglPixelFormat pixel_format,
|
||||
guint width,
|
||||
@ -536,7 +519,8 @@ st_image_content_set_bytes (StImageContent *content,
|
||||
if (content->texture != NULL)
|
||||
g_object_unref (content->texture);
|
||||
|
||||
content->texture = create_texture_from_data (width,
|
||||
content->texture = cogl_texture_2d_new_from_data (cogl_context,
|
||||
width,
|
||||
height,
|
||||
pixel_format,
|
||||
row_stride,
|
||||
|
@ -30,6 +30,7 @@ ClutterContent *st_image_content_new_with_preferred_size (int width,
|
||||
int height);
|
||||
|
||||
gboolean st_image_content_set_data (StImageContent *content,
|
||||
CoglContext *cogl_context,
|
||||
const guint8 *data,
|
||||
CoglPixelFormat pixel_format,
|
||||
guint width,
|
||||
@ -38,6 +39,7 @@ gboolean st_image_content_set_data (StImageContent *content,
|
||||
GError **error);
|
||||
|
||||
gboolean st_image_content_set_bytes (StImageContent *content,
|
||||
CoglContext *cogl_context,
|
||||
GBytes *data,
|
||||
CoglPixelFormat pixel_format,
|
||||
guint width,
|
||||
|
@ -526,6 +526,7 @@ pixbuf_to_st_content_image (GdkPixbuf *pixbuf,
|
||||
|
||||
image = st_image_content_new_with_preferred_size (width, height);
|
||||
st_image_content_set_data (ST_IMAGE_CONTENT (image),
|
||||
context,
|
||||
gdk_pixbuf_get_pixels (pixbuf),
|
||||
gdk_pixbuf_get_has_alpha (pixbuf) ?
|
||||
COGL_PIXEL_FORMAT_RGBA_8888 : COGL_PIXEL_FORMAT_RGB_888,
|
||||
|
Loading…
x
Reference in New Issue
Block a user