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.
This commit is contained in:
Emmanuele Bassi 2014-12-03 12:12:43 +00:00
parent 54efcf0e90
commit 8afb499ce5

View File

@ -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,