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>
This commit is contained in:
parent
f927e692c7
commit
f1ac534cd2
@ -68,6 +68,29 @@ clutter_image_error_quark (void)
|
|||||||
return g_quark_from_static_string ("clutter-image-error-quark");
|
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
|
static void
|
||||||
update_image_size (ClutterImage *self)
|
update_image_size (ClutterImage *self)
|
||||||
{
|
{
|
||||||
@ -231,7 +254,6 @@ clutter_image_set_data (ClutterImage *image,
|
|||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
ClutterImagePrivate *priv;
|
ClutterImagePrivate *priv;
|
||||||
CoglTextureFlags flags;
|
|
||||||
|
|
||||||
g_return_val_if_fail (CLUTTER_IS_IMAGE (image), FALSE);
|
g_return_val_if_fail (CLUTTER_IS_IMAGE (image), FALSE);
|
||||||
g_return_val_if_fail (data != NULL, FALSE);
|
g_return_val_if_fail (data != NULL, FALSE);
|
||||||
@ -241,16 +263,13 @@ clutter_image_set_data (ClutterImage *image,
|
|||||||
if (priv->texture != NULL)
|
if (priv->texture != NULL)
|
||||||
cogl_object_unref (priv->texture);
|
cogl_object_unref (priv->texture);
|
||||||
|
|
||||||
flags = COGL_TEXTURE_NONE;
|
priv->texture = create_texture_from_data (width,
|
||||||
if (width >= 512 && height >= 512)
|
height,
|
||||||
flags |= COGL_TEXTURE_NO_ATLAS;
|
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)
|
if (priv->texture == NULL)
|
||||||
{
|
{
|
||||||
g_set_error_literal (error, CLUTTER_IMAGE_ERROR,
|
g_set_error_literal (error, CLUTTER_IMAGE_ERROR,
|
||||||
@ -300,7 +319,6 @@ clutter_image_set_bytes (ClutterImage *image,
|
|||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
ClutterImagePrivate *priv;
|
ClutterImagePrivate *priv;
|
||||||
CoglTextureFlags flags;
|
|
||||||
|
|
||||||
g_return_val_if_fail (CLUTTER_IS_IMAGE (image), FALSE);
|
g_return_val_if_fail (CLUTTER_IS_IMAGE (image), FALSE);
|
||||||
g_return_val_if_fail (data != NULL, FALSE);
|
g_return_val_if_fail (data != NULL, FALSE);
|
||||||
@ -310,16 +328,13 @@ clutter_image_set_bytes (ClutterImage *image,
|
|||||||
if (priv->texture != NULL)
|
if (priv->texture != NULL)
|
||||||
cogl_object_unref (priv->texture);
|
cogl_object_unref (priv->texture);
|
||||||
|
|
||||||
flags = COGL_TEXTURE_NONE;
|
priv->texture = create_texture_from_data (width,
|
||||||
if (width >= 512 && height >= 512)
|
height,
|
||||||
flags |= COGL_TEXTURE_NO_ATLAS;
|
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)
|
if (priv->texture == NULL)
|
||||||
{
|
{
|
||||||
g_set_error_literal (error, CLUTTER_IMAGE_ERROR,
|
g_set_error_literal (error, CLUTTER_IMAGE_ERROR,
|
||||||
@ -381,18 +396,12 @@ clutter_image_set_area (ClutterImage *image,
|
|||||||
|
|
||||||
if (priv->texture == NULL)
|
if (priv->texture == NULL)
|
||||||
{
|
{
|
||||||
CoglTextureFlags flags = COGL_TEXTURE_NONE;
|
priv->texture = create_texture_from_data (area->width,
|
||||||
|
area->height,
|
||||||
if (area->width >= 512 && area->height >= 512)
|
pixel_format,
|
||||||
flags |= COGL_TEXTURE_NO_ATLAS;
|
row_stride,
|
||||||
|
data,
|
||||||
priv->texture = cogl_texture_new_from_data (area->width,
|
NULL);
|
||||||
area->height,
|
|
||||||
flags,
|
|
||||||
pixel_format,
|
|
||||||
COGL_PIXEL_FORMAT_ANY,
|
|
||||||
row_stride,
|
|
||||||
data);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user