diff options
author | Neil Roberts <neil@linux.intel.com> | 2010-11-27 13:15:02 +0000 |
---|---|---|
committer | Neil Roberts <neil@linux.intel.com> | 2010-12-13 18:59:41 +0000 |
commit | 9aea72fab5a0b030c320dbc2efd905764b9af3ce (patch) | |
tree | c068010932acc417db1d9dd6cb405b50a3011195 /cogl/cogl-atlas-texture-private.h | |
parent | 0f0f763570b904591bdae10888a971a887e01f22 (diff) | |
download | cogl-9aea72fab5a0b030c320dbc2efd905764b9af3ce.tar.gz |
Allow multiple CoglAtlases for textures
Previously Cogl would only ever use one atlas for textures and if it
reached the maximum texture size then all other new textures would get
their own GL texture. This patch makes it so that we create as many
atlases as needed. This should avoid breaking up some batches and it
will be particularly good if we switch to always using multi-texturing
with a default shader that selects between multiple atlases using a
vertex attribute.
Whenever a new atlas is created it is stored in a GSList on the
context. A weak weference is taken on the atlas using
cogl_object_set_user_data so that it can be removed from the list when
the atlas is destroyed. The atlas textures themselves take a reference
to the atlas and this is the only thing that keeps the atlas
alive. This means that once the atlas becomes empty it will
automatically be destroyed.
All of the COGL_NOTEs pertaining to atlases are now prefixed with the
atlas pointer to make it clearer which atlas is changing.
Diffstat (limited to 'cogl/cogl-atlas-texture-private.h')
-rw-r--r-- | cogl/cogl-atlas-texture-private.h | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/cogl/cogl-atlas-texture-private.h b/cogl/cogl-atlas-texture-private.h index eaa6a84e..cdac7d38 100644 --- a/cogl/cogl-atlas-texture-private.h +++ b/cogl/cogl-atlas-texture-private.h @@ -46,9 +46,10 @@ struct _CoglAtlasTexture atlas. This includes the 1-pixel border */ CoglRectangleMapEntry rectangle; - /* The texture might need to be migrated out in which case this will - be set to TRUE and sub_texture will actually be a real texture */ - gboolean in_atlas; + /* The atlas that this texture is in. If the texture is no longer in + an atlas then this will be NULL. A reference is taken on the + atlas by the texture (but not vice versa so there is no cycle) */ + CoglAtlas *atlas; /* A CoglSubTexture representing the region for easy rendering */ CoglHandle sub_texture; @@ -62,7 +63,4 @@ _cogl_atlas_texture_new_from_bitmap (CoglBitmap *bmp, CoglTextureFlags flags, CoglPixelFormat internal_format); -CoglAtlas * -_cogl_atlas_texture_get_atlas (void); - #endif /* __COGL_ATLAS_TEXTURE_H */ |