summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2014-12-03 12:12:43 +0000
committerEmmanuele Bassi <ebassi@gnome.org>2014-12-03 12:12:43 +0000
commit8afb499ce506b68716b4262bc16eb3d2a031bce1 (patch)
tree68f203c07e588a45b2249d7363bd2dfc81581a81
parent54efcf0e903e50ce927d3b22aa1edfa7dfa1744a (diff)
downloadclutter-8afb499ce506b68716b4262bc16eb3d2a031bce1.tar.gz
image: Do not put large textures in the atlas
Atlasing is fine for smaller textures, but once they get too large its downsides outweight the benefits. At worst, the larger texture will end up inside its own atlas, but at worst it will require copying and/or resizing of an existing atlas. The cut-off at 512x512 pixels is a bit arbitrary, and we can change it at any point; it would be nice if we could get the texture limit from Cogl, and then use a fraction of that size as the cut-off limit. Sadly, that's not portable, and it's not guaranteed to work either.
-rw-r--r--clutter/clutter-image.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/clutter/clutter-image.c b/clutter/clutter-image.c
index 067b799fa..880b7344e 100644
--- a/clutter/clutter-image.c
+++ b/clutter/clutter-image.c
@@ -246,6 +246,7 @@ 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);
@@ -255,8 +256,12 @@ 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 = cogl_texture_new_from_data (width, height,
- COGL_TEXTURE_NONE,
+ flags,
pixel_format,
COGL_PIXEL_FORMAT_ANY,
row_stride,
@@ -309,6 +314,7 @@ 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);
@@ -318,8 +324,12 @@ 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 = cogl_texture_new_from_data (width, height,
- COGL_TEXTURE_NONE,
+ flags,
pixel_format,
COGL_PIXEL_FORMAT_ANY,
row_stride,
@@ -384,9 +394,14 @@ 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,
- COGL_TEXTURE_NONE,
+ flags,
pixel_format,
COGL_PIXEL_FORMAT_ANY,
row_stride,