[mutter] clutter/image: Port to cogl_texture_2d_new_from_data
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] clutter/image: Port to cogl_texture_2d_new_from_data
- Date: Wed, 1 Jun 2022 11:14:57 +0000 (UTC)
commit f1ac534cd23aaff0db092bb58d45bb23be8edd63
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Mar 31 12:48:37 2022 -0300
clutter/image: Port to cogl_texture_2d_new_from_data
Stop using cogl_texture_new_from_data() in favour of the undeprecated
cogl_texture_2d_new_from_data().
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2355>
clutter/clutter/clutter-image.c | 73 +++++++++++++++++++++++------------------
1 file changed, 41 insertions(+), 32 deletions(-)
---
diff --git a/clutter/clutter/clutter-image.c b/clutter/clutter/clutter-image.c
index 9d368e68d0..6af4afc038 100644
--- a/clutter/clutter/clutter-image.c
+++ b/clutter/clutter/clutter-image.c
@@ -68,6 +68,29 @@ clutter_image_error_quark (void)
return g_quark_from_static_string ("clutter-image-error-quark");
}
+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)
+{
+ CoglContext *ctx =
+ clutter_backend_get_cogl_context (clutter_get_default_backend ());
+ CoglTexture2D *texture_2d;
+
+ texture_2d = cogl_texture_2d_new_from_data (ctx,
+ width,
+ height,
+ pixel_format,
+ row_stride,
+ data,
+ error);
+
+ return texture_2d ? COGL_TEXTURE (texture_2d) : NULL;
+}
+
static void
update_image_size (ClutterImage *self)
{
@@ -231,7 +254,6 @@ clutter_image_set_data (ClutterImage *image,
GError **error)
{
ClutterImagePrivate *priv;
- CoglTextureFlags flags;
g_return_val_if_fail (CLUTTER_IS_IMAGE (image), FALSE);
g_return_val_if_fail (data != NULL, FALSE);
@@ -241,16 +263,13 @@ clutter_image_set_data (ClutterImage *image,
if (priv->texture != NULL)
cogl_object_unref (priv->texture);
- flags = COGL_TEXTURE_NONE;
- if (width >= 512 && height >= 512)
- flags |= COGL_TEXTURE_NO_ATLAS;
+ priv->texture = create_texture_from_data (width,
+ height,
+ pixel_format,
+ row_stride,
+ data,
+ NULL);
- priv->texture = cogl_texture_new_from_data (width, height,
- flags,
- pixel_format,
- COGL_PIXEL_FORMAT_ANY,
- row_stride,
- data);
if (priv->texture == NULL)
{
g_set_error_literal (error, CLUTTER_IMAGE_ERROR,
@@ -300,7 +319,6 @@ clutter_image_set_bytes (ClutterImage *image,
GError **error)
{
ClutterImagePrivate *priv;
- CoglTextureFlags flags;
g_return_val_if_fail (CLUTTER_IS_IMAGE (image), FALSE);
g_return_val_if_fail (data != NULL, FALSE);
@@ -310,16 +328,13 @@ clutter_image_set_bytes (ClutterImage *image,
if (priv->texture != NULL)
cogl_object_unref (priv->texture);
- flags = COGL_TEXTURE_NONE;
- if (width >= 512 && height >= 512)
- flags |= COGL_TEXTURE_NO_ATLAS;
+ priv->texture = create_texture_from_data (width,
+ height,
+ pixel_format,
+ row_stride,
+ g_bytes_get_data (data, NULL),
+ NULL);
- priv->texture = cogl_texture_new_from_data (width, height,
- flags,
- pixel_format,
- COGL_PIXEL_FORMAT_ANY,
- row_stride,
- g_bytes_get_data (data, NULL));
if (priv->texture == NULL)
{
g_set_error_literal (error, CLUTTER_IMAGE_ERROR,
@@ -381,18 +396,12 @@ clutter_image_set_area (ClutterImage *image,
if (priv->texture == NULL)
{
- CoglTextureFlags flags = COGL_TEXTURE_NONE;
-
- if (area->width >= 512 && area->height >= 512)
- flags |= COGL_TEXTURE_NO_ATLAS;
-
- priv->texture = cogl_texture_new_from_data (area->width,
- area->height,
- flags,
- pixel_format,
- COGL_PIXEL_FORMAT_ANY,
- row_stride,
- data);
+ priv->texture = create_texture_from_data (area->width,
+ area->height,
+ pixel_format,
+ row_stride,
+ data,
+ NULL);
}
else
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]