diff --git a/clutter/clutter/clutter-image.c b/clutter/clutter/clutter-image.c index 9d368e68d..6af4afc03 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 {