cogl-atlas: Make the cogl_atlas_* API internal
This just adds an underscore to every entry point for the CoglAtlas API so that it's not exported.
This commit is contained in:
parent
145cc9d3df
commit
5063f4669c
@ -244,18 +244,18 @@ _cogl_atlas_texture_remove_from_atlas (CoglAtlasTexture *atlas_tex)
|
||||
{
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
cogl_atlas_remove_rectangle (ctx->atlas, &atlas_tex->rectangle);
|
||||
_cogl_atlas_remove_rectangle (ctx->atlas, &atlas_tex->rectangle);
|
||||
|
||||
COGL_NOTE (ATLAS, "Removed rectangle sized %ix%i",
|
||||
atlas_tex->rectangle.width,
|
||||
atlas_tex->rectangle.height);
|
||||
COGL_NOTE (ATLAS, "Atlas is %ix%i, has %i textures and is %i%% waste",
|
||||
cogl_atlas_get_width (ctx->atlas),
|
||||
cogl_atlas_get_height (ctx->atlas),
|
||||
cogl_atlas_get_n_rectangles (ctx->atlas),
|
||||
cogl_atlas_get_remaining_space (ctx->atlas) * 100 /
|
||||
(cogl_atlas_get_width (ctx->atlas) *
|
||||
cogl_atlas_get_height (ctx->atlas)));
|
||||
_cogl_atlas_get_width (ctx->atlas),
|
||||
_cogl_atlas_get_height (ctx->atlas),
|
||||
_cogl_atlas_get_n_rectangles (ctx->atlas),
|
||||
_cogl_atlas_get_remaining_space (ctx->atlas) * 100 /
|
||||
(_cogl_atlas_get_width (ctx->atlas) *
|
||||
_cogl_atlas_get_height (ctx->atlas)));
|
||||
|
||||
atlas_tex->in_atlas = FALSE;
|
||||
}
|
||||
@ -730,12 +730,12 @@ _cogl_atlas_texture_create_atlas (guint atlas_width,
|
||||
the textures */
|
||||
while (atlas_width < max_texture_size && atlas_height < max_texture_size)
|
||||
{
|
||||
CoglAtlas *new_atlas = cogl_atlas_new (atlas_width, atlas_height, NULL);
|
||||
CoglAtlas *new_atlas = _cogl_atlas_new (atlas_width, atlas_height, NULL);
|
||||
guint i;
|
||||
|
||||
/* Add all of the textures and keep track of the new position */
|
||||
for (i = 0; i < n_textures; i++)
|
||||
if (!cogl_atlas_add_rectangle (new_atlas,
|
||||
if (!_cogl_atlas_add_rectangle (new_atlas,
|
||||
textures[i].texture->rectangle.width,
|
||||
textures[i].texture->rectangle.height,
|
||||
textures[i].texture,
|
||||
@ -747,7 +747,7 @@ _cogl_atlas_texture_create_atlas (guint atlas_width,
|
||||
if (i >= n_textures)
|
||||
return new_atlas;
|
||||
|
||||
cogl_atlas_free (new_atlas);
|
||||
_cogl_atlas_free (new_atlas);
|
||||
_cogl_atlas_texture_get_next_size (&atlas_width, &atlas_height);
|
||||
}
|
||||
|
||||
@ -785,17 +785,17 @@ _cogl_atlas_texture_reserve_space (CoglAtlasTexture *new_sub_tex,
|
||||
_COGL_GET_CONTEXT (ctx, FALSE);
|
||||
|
||||
/* Check if we can fit the rectangle into the existing atlas */
|
||||
if (ctx->atlas && cogl_atlas_add_rectangle (ctx->atlas, width, height,
|
||||
if (ctx->atlas && _cogl_atlas_add_rectangle (ctx->atlas, width, height,
|
||||
new_sub_tex,
|
||||
&new_sub_tex->rectangle))
|
||||
{
|
||||
COGL_NOTE (ATLAS, "Atlas is %ix%i, has %i textures and is %i%% waste",
|
||||
cogl_atlas_get_width (ctx->atlas),
|
||||
cogl_atlas_get_height (ctx->atlas),
|
||||
cogl_atlas_get_n_rectangles (ctx->atlas),
|
||||
cogl_atlas_get_remaining_space (ctx->atlas) * 100 /
|
||||
(cogl_atlas_get_width (ctx->atlas) *
|
||||
cogl_atlas_get_height (ctx->atlas)));
|
||||
_cogl_atlas_get_width (ctx->atlas),
|
||||
_cogl_atlas_get_height (ctx->atlas),
|
||||
_cogl_atlas_get_n_rectangles (ctx->atlas),
|
||||
_cogl_atlas_get_remaining_space (ctx->atlas) * 100 /
|
||||
(_cogl_atlas_get_width (ctx->atlas) *
|
||||
_cogl_atlas_get_height (ctx->atlas)));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -807,9 +807,10 @@ _cogl_atlas_texture_reserve_space (CoglAtlasTexture *new_sub_tex,
|
||||
data.textures = g_malloc (sizeof (CoglAtlasTextureRepositionData));
|
||||
else
|
||||
{
|
||||
data.textures = g_malloc (sizeof (CoglAtlasTextureRepositionData) *
|
||||
(cogl_atlas_get_n_rectangles (ctx->atlas) + 1));
|
||||
cogl_atlas_foreach (ctx->atlas, _cogl_atlas_texture_get_rectangles_cb,
|
||||
data.textures =
|
||||
g_malloc (sizeof (CoglAtlasTextureRepositionData) *
|
||||
(_cogl_atlas_get_n_rectangles (ctx->atlas) + 1));
|
||||
_cogl_atlas_foreach (ctx->atlas, _cogl_atlas_texture_get_rectangles_cb,
|
||||
&data);
|
||||
}
|
||||
|
||||
@ -827,13 +828,13 @@ _cogl_atlas_texture_reserve_space (CoglAtlasTexture *new_sub_tex,
|
||||
/* Try to create a new atlas that can contain all of the textures */
|
||||
if (ctx->atlas)
|
||||
{
|
||||
atlas_width = cogl_atlas_get_width (ctx->atlas);
|
||||
atlas_height = cogl_atlas_get_height (ctx->atlas);
|
||||
atlas_width = _cogl_atlas_get_width (ctx->atlas);
|
||||
atlas_height = _cogl_atlas_get_height (ctx->atlas);
|
||||
|
||||
/* If there is enough space in the existing for the new
|
||||
rectangle in the existing atlas we'll start with the same
|
||||
size, otherwise we'll immediately double it */
|
||||
if (cogl_atlas_get_remaining_space (ctx->atlas) < width * height)
|
||||
if (_cogl_atlas_get_remaining_space (ctx->atlas) < width * height)
|
||||
_cogl_atlas_texture_get_next_size (&atlas_width, &atlas_height);
|
||||
}
|
||||
else
|
||||
@ -856,21 +857,21 @@ _cogl_atlas_texture_reserve_space (CoglAtlasTexture *new_sub_tex,
|
||||
{
|
||||
/* We need to migrate the existing textures into a new texture */
|
||||
new_tex =
|
||||
_cogl_texture_2d_new_with_size (cogl_atlas_get_width (new_atlas),
|
||||
cogl_atlas_get_height (new_atlas),
|
||||
_cogl_texture_2d_new_with_size (_cogl_atlas_get_width (new_atlas),
|
||||
_cogl_atlas_get_height (new_atlas),
|
||||
COGL_TEXTURE_NONE,
|
||||
COGL_PIXEL_FORMAT_RGBA_8888);
|
||||
|
||||
COGL_NOTE (ATLAS,
|
||||
"Atlas %s with size %ix%i",
|
||||
ctx->atlas == NULL ||
|
||||
cogl_atlas_get_width (ctx->atlas) !=
|
||||
cogl_atlas_get_width (new_atlas) ||
|
||||
cogl_atlas_get_height (ctx->atlas) !=
|
||||
cogl_atlas_get_height (new_atlas) ?
|
||||
_cogl_atlas_get_width (ctx->atlas) !=
|
||||
_cogl_atlas_get_width (new_atlas) ||
|
||||
_cogl_atlas_get_height (ctx->atlas) !=
|
||||
_cogl_atlas_get_height (new_atlas) ?
|
||||
"resized" : "reorganized",
|
||||
cogl_atlas_get_width (new_atlas),
|
||||
cogl_atlas_get_height (new_atlas));
|
||||
_cogl_atlas_get_width (new_atlas),
|
||||
_cogl_atlas_get_height (new_atlas));
|
||||
|
||||
if (ctx->atlas)
|
||||
{
|
||||
@ -881,7 +882,7 @@ _cogl_atlas_texture_reserve_space (CoglAtlasTexture *new_sub_tex,
|
||||
ctx->atlas_texture,
|
||||
new_tex,
|
||||
new_sub_tex);
|
||||
cogl_atlas_free (ctx->atlas);
|
||||
_cogl_atlas_free (ctx->atlas);
|
||||
cogl_handle_unref (ctx->atlas_texture);
|
||||
}
|
||||
else
|
||||
@ -893,12 +894,12 @@ _cogl_atlas_texture_reserve_space (CoglAtlasTexture *new_sub_tex,
|
||||
ctx->atlas_texture = new_tex;
|
||||
|
||||
COGL_NOTE (ATLAS, "Atlas is %ix%i, has %i textures and is %i%% waste",
|
||||
cogl_atlas_get_width (ctx->atlas),
|
||||
cogl_atlas_get_height (ctx->atlas),
|
||||
cogl_atlas_get_n_rectangles (ctx->atlas),
|
||||
cogl_atlas_get_remaining_space (ctx->atlas) * 100 /
|
||||
(cogl_atlas_get_width (ctx->atlas) *
|
||||
cogl_atlas_get_height (ctx->atlas)));
|
||||
_cogl_atlas_get_width (ctx->atlas),
|
||||
_cogl_atlas_get_height (ctx->atlas),
|
||||
_cogl_atlas_get_n_rectangles (ctx->atlas),
|
||||
_cogl_atlas_get_remaining_space (ctx->atlas) * 100 /
|
||||
(_cogl_atlas_get_width (ctx->atlas) *
|
||||
_cogl_atlas_get_height (ctx->atlas)));
|
||||
|
||||
ret = TRUE;
|
||||
}
|
||||
@ -994,7 +995,7 @@ _cogl_atlas_texture_new_from_bitmap (CoglHandle bmp_handle,
|
||||
&gl_format,
|
||||
&gl_type))
|
||||
{
|
||||
cogl_atlas_remove_rectangle (ctx->atlas, &atlas_tex->rectangle);
|
||||
_cogl_atlas_remove_rectangle (ctx->atlas, &atlas_tex->rectangle);
|
||||
g_free (atlas_tex);
|
||||
return COGL_INVALID_HANDLE;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@
|
||||
the atlas */
|
||||
#include <cairo.h>
|
||||
|
||||
static void cogl_atlas_dump_image (CoglAtlas *atlas);
|
||||
static void _cogl_atlas_dump_image (CoglAtlas *atlas);
|
||||
|
||||
#endif /* COGL_ENABLE_DEBUG */
|
||||
|
||||
@ -107,23 +107,23 @@ struct _CoglAtlasStackEntry
|
||||
};
|
||||
|
||||
static CoglAtlasNode *
|
||||
cogl_atlas_node_new (void)
|
||||
_cogl_atlas_node_new (void)
|
||||
{
|
||||
return g_slice_new (CoglAtlasNode);
|
||||
}
|
||||
|
||||
static void
|
||||
cogl_atlas_node_free (CoglAtlasNode *node)
|
||||
_cogl_atlas_node_free (CoglAtlasNode *node)
|
||||
{
|
||||
g_slice_free (CoglAtlasNode, node);
|
||||
}
|
||||
|
||||
CoglAtlas *
|
||||
cogl_atlas_new (guint width, guint height,
|
||||
_cogl_atlas_new (guint width, guint height,
|
||||
GDestroyNotify value_destroy_func)
|
||||
{
|
||||
CoglAtlas *atlas = g_new (CoglAtlas, 1);
|
||||
CoglAtlasNode *root = cogl_atlas_node_new ();
|
||||
CoglAtlasNode *root = _cogl_atlas_node_new ();
|
||||
|
||||
root->type = COGL_ATLAS_EMPTY_LEAF;
|
||||
root->parent = NULL;
|
||||
@ -141,7 +141,7 @@ cogl_atlas_new (guint width, guint height,
|
||||
}
|
||||
|
||||
static CoglAtlasStackEntry *
|
||||
cogl_atlas_stack_push (CoglAtlasStackEntry *stack,
|
||||
_cogl_atlas_stack_push (CoglAtlasStackEntry *stack,
|
||||
CoglAtlasNode *node,
|
||||
gboolean next_index)
|
||||
{
|
||||
@ -155,7 +155,7 @@ cogl_atlas_stack_push (CoglAtlasStackEntry *stack,
|
||||
}
|
||||
|
||||
static CoglAtlasStackEntry *
|
||||
cogl_atlas_stack_pop (CoglAtlasStackEntry *stack)
|
||||
_cogl_atlas_stack_pop (CoglAtlasStackEntry *stack)
|
||||
{
|
||||
CoglAtlasStackEntry *next = stack->next;
|
||||
|
||||
@ -165,7 +165,7 @@ cogl_atlas_stack_pop (CoglAtlasStackEntry *stack)
|
||||
}
|
||||
|
||||
static CoglAtlasNode *
|
||||
cogl_atlas_node_split_horizontally (CoglAtlasNode *node,
|
||||
_cogl_atlas_node_split_horizontally (CoglAtlasNode *node,
|
||||
guint left_width)
|
||||
{
|
||||
/* Splits the node horizontally (according to emacs' definition, not
|
||||
@ -179,7 +179,7 @@ cogl_atlas_node_split_horizontally (CoglAtlasNode *node,
|
||||
if (node->rectangle.width == left_width)
|
||||
return node;
|
||||
|
||||
left_node = cogl_atlas_node_new ();
|
||||
left_node = _cogl_atlas_node_new ();
|
||||
left_node->type = COGL_ATLAS_EMPTY_LEAF;
|
||||
left_node->parent = node;
|
||||
left_node->rectangle.x = node->rectangle.x;
|
||||
@ -188,7 +188,7 @@ cogl_atlas_node_split_horizontally (CoglAtlasNode *node,
|
||||
left_node->rectangle.height = node->rectangle.height;
|
||||
node->d.branch.left = left_node;
|
||||
|
||||
right_node = cogl_atlas_node_new ();
|
||||
right_node = _cogl_atlas_node_new ();
|
||||
right_node->type = COGL_ATLAS_EMPTY_LEAF;
|
||||
right_node->parent = node;
|
||||
right_node->rectangle.x = node->rectangle.x + left_width;
|
||||
@ -203,7 +203,7 @@ cogl_atlas_node_split_horizontally (CoglAtlasNode *node,
|
||||
}
|
||||
|
||||
static CoglAtlasNode *
|
||||
cogl_atlas_node_split_vertically (CoglAtlasNode *node,
|
||||
_cogl_atlas_node_split_vertically (CoglAtlasNode *node,
|
||||
guint top_height)
|
||||
{
|
||||
/* Splits the node vertically (according to emacs' definition, not
|
||||
@ -217,7 +217,7 @@ cogl_atlas_node_split_vertically (CoglAtlasNode *node,
|
||||
if (node->rectangle.height == top_height)
|
||||
return node;
|
||||
|
||||
top_node = cogl_atlas_node_new ();
|
||||
top_node = _cogl_atlas_node_new ();
|
||||
top_node->type = COGL_ATLAS_EMPTY_LEAF;
|
||||
top_node->parent = node;
|
||||
top_node->rectangle.x = node->rectangle.x;
|
||||
@ -226,7 +226,7 @@ cogl_atlas_node_split_vertically (CoglAtlasNode *node,
|
||||
top_node->rectangle.height = top_height;
|
||||
node->d.branch.left = top_node;
|
||||
|
||||
bottom_node = cogl_atlas_node_new ();
|
||||
bottom_node = _cogl_atlas_node_new ();
|
||||
bottom_node->type = COGL_ATLAS_EMPTY_LEAF;
|
||||
bottom_node->parent = node;
|
||||
bottom_node->rectangle.x = node->rectangle.x;
|
||||
@ -241,7 +241,7 @@ cogl_atlas_node_split_vertically (CoglAtlasNode *node,
|
||||
}
|
||||
|
||||
gboolean
|
||||
cogl_atlas_add_rectangle (CoglAtlas *atlas,
|
||||
_cogl_atlas_add_rectangle (CoglAtlas *atlas,
|
||||
guint width, guint height,
|
||||
gpointer data,
|
||||
CoglAtlasRectangle *rectangle)
|
||||
@ -255,7 +255,7 @@ cogl_atlas_add_rectangle (CoglAtlas *atlas,
|
||||
g_return_val_if_fail (width > 0 && height > 0, FALSE);
|
||||
|
||||
/* Start with the root node */
|
||||
node_stack = cogl_atlas_stack_push (NULL, atlas->root, FALSE);
|
||||
node_stack = _cogl_atlas_stack_push (NULL, atlas->root, FALSE);
|
||||
|
||||
/* Depth-first search for an empty node that is big enough */
|
||||
while (node_stack)
|
||||
@ -263,7 +263,7 @@ cogl_atlas_add_rectangle (CoglAtlas *atlas,
|
||||
/* Pop an entry off the stack */
|
||||
CoglAtlasNode *node = node_stack->node;
|
||||
int next_index = node_stack->next_index;
|
||||
node_stack = cogl_atlas_stack_pop (node_stack);
|
||||
node_stack = _cogl_atlas_stack_pop (node_stack);
|
||||
|
||||
/* Regardless of the type of the node, there's no point
|
||||
descending any further if the new rectangle won't fit within
|
||||
@ -281,18 +281,18 @@ cogl_atlas_add_rectangle (CoglAtlas *atlas,
|
||||
{
|
||||
if (next_index)
|
||||
/* Try the right branch */
|
||||
node_stack = cogl_atlas_stack_push (node_stack,
|
||||
node_stack = _cogl_atlas_stack_push (node_stack,
|
||||
node->d.branch.right,
|
||||
0);
|
||||
else
|
||||
{
|
||||
/* Make sure we remember to try the right branch once
|
||||
we've finished descending the left branch */
|
||||
node_stack = cogl_atlas_stack_push (node_stack,
|
||||
node_stack = _cogl_atlas_stack_push (node_stack,
|
||||
node,
|
||||
1);
|
||||
/* Try the left branch */
|
||||
node_stack = cogl_atlas_stack_push (node_stack,
|
||||
node_stack = _cogl_atlas_stack_push (node_stack,
|
||||
node->d.branch.left,
|
||||
0);
|
||||
}
|
||||
@ -302,7 +302,7 @@ cogl_atlas_add_rectangle (CoglAtlas *atlas,
|
||||
|
||||
/* Free the stack */
|
||||
while (node_stack)
|
||||
node_stack = cogl_atlas_stack_pop (node_stack);
|
||||
node_stack = _cogl_atlas_stack_pop (node_stack);
|
||||
|
||||
if (found_node)
|
||||
{
|
||||
@ -311,13 +311,13 @@ cogl_atlas_add_rectangle (CoglAtlas *atlas,
|
||||
if (found_node->rectangle.width - width >
|
||||
found_node->rectangle.height - height)
|
||||
{
|
||||
found_node = cogl_atlas_node_split_horizontally (found_node, width);
|
||||
found_node = cogl_atlas_node_split_vertically (found_node, height);
|
||||
found_node = _cogl_atlas_node_split_horizontally (found_node, width);
|
||||
found_node = _cogl_atlas_node_split_vertically (found_node, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
found_node = cogl_atlas_node_split_vertically (found_node, height);
|
||||
found_node = cogl_atlas_node_split_horizontally (found_node, width);
|
||||
found_node = _cogl_atlas_node_split_vertically (found_node, height);
|
||||
found_node = _cogl_atlas_node_split_horizontally (found_node, width);
|
||||
}
|
||||
|
||||
found_node->type = COGL_ATLAS_FILLED_LEAF;
|
||||
@ -333,7 +333,7 @@ cogl_atlas_add_rectangle (CoglAtlas *atlas,
|
||||
|
||||
#ifdef COGL_ENABLE_DEBUG
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_DUMP_ATLAS_IMAGE))
|
||||
cogl_atlas_dump_image (atlas);
|
||||
_cogl_atlas_dump_image (atlas);
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
@ -343,7 +343,7 @@ cogl_atlas_add_rectangle (CoglAtlas *atlas,
|
||||
}
|
||||
|
||||
void
|
||||
cogl_atlas_remove_rectangle (CoglAtlas *atlas,
|
||||
_cogl_atlas_remove_rectangle (CoglAtlas *atlas,
|
||||
const CoglAtlasRectangle *rectangle)
|
||||
{
|
||||
CoglAtlasNode *node = atlas->root;
|
||||
@ -391,8 +391,8 @@ cogl_atlas_remove_rectangle (CoglAtlas *atlas,
|
||||
if (node->d.branch.left->type == COGL_ATLAS_EMPTY_LEAF &&
|
||||
node->d.branch.right->type == COGL_ATLAS_EMPTY_LEAF)
|
||||
{
|
||||
cogl_atlas_node_free (node->d.branch.left);
|
||||
cogl_atlas_node_free (node->d.branch.right);
|
||||
_cogl_atlas_node_free (node->d.branch.left);
|
||||
_cogl_atlas_node_free (node->d.branch.right);
|
||||
node->type = COGL_ATLAS_EMPTY_LEAF;
|
||||
}
|
||||
else
|
||||
@ -407,36 +407,36 @@ cogl_atlas_remove_rectangle (CoglAtlas *atlas,
|
||||
|
||||
#ifdef COGL_ENABLE_DEBUG
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_DUMP_ATLAS_IMAGE))
|
||||
cogl_atlas_dump_image (atlas);
|
||||
_cogl_atlas_dump_image (atlas);
|
||||
#endif
|
||||
}
|
||||
|
||||
guint
|
||||
cogl_atlas_get_width (CoglAtlas *atlas)
|
||||
_cogl_atlas_get_width (CoglAtlas *atlas)
|
||||
{
|
||||
return atlas->root->rectangle.width;
|
||||
}
|
||||
|
||||
guint
|
||||
cogl_atlas_get_height (CoglAtlas *atlas)
|
||||
_cogl_atlas_get_height (CoglAtlas *atlas)
|
||||
{
|
||||
return atlas->root->rectangle.height;
|
||||
}
|
||||
|
||||
guint
|
||||
cogl_atlas_get_remaining_space (CoglAtlas *atlas)
|
||||
_cogl_atlas_get_remaining_space (CoglAtlas *atlas)
|
||||
{
|
||||
return atlas->space_remaining;
|
||||
}
|
||||
|
||||
guint
|
||||
cogl_atlas_get_n_rectangles (CoglAtlas *atlas)
|
||||
_cogl_atlas_get_n_rectangles (CoglAtlas *atlas)
|
||||
{
|
||||
return atlas->n_rectangles;
|
||||
}
|
||||
|
||||
static void
|
||||
cogl_atlas_internal_foreach (CoglAtlas *atlas,
|
||||
_cogl_atlas_internal_foreach (CoglAtlas *atlas,
|
||||
CoglAtlasInternalForeachCb callback,
|
||||
gpointer data)
|
||||
{
|
||||
@ -444,7 +444,7 @@ cogl_atlas_internal_foreach (CoglAtlas *atlas,
|
||||
CoglAtlasStackEntry *node_stack;
|
||||
|
||||
/* Start with the root node */
|
||||
node_stack = cogl_atlas_stack_push (NULL, atlas->root, 0);
|
||||
node_stack = _cogl_atlas_stack_push (NULL, atlas->root, 0);
|
||||
|
||||
/* Iterate all nodes depth-first */
|
||||
while (node_stack)
|
||||
@ -460,7 +460,7 @@ cogl_atlas_internal_foreach (CoglAtlas *atlas,
|
||||
node_stack->next_index = 1;
|
||||
|
||||
/* Explore the left branch next */
|
||||
node_stack = cogl_atlas_stack_push (node_stack,
|
||||
node_stack = _cogl_atlas_stack_push (node_stack,
|
||||
node->d.branch.left,
|
||||
0);
|
||||
}
|
||||
@ -470,7 +470,7 @@ cogl_atlas_internal_foreach (CoglAtlas *atlas,
|
||||
node_stack->next_index = 2;
|
||||
|
||||
/* Explore the right branch next */
|
||||
node_stack = cogl_atlas_stack_push (node_stack,
|
||||
node_stack = _cogl_atlas_stack_push (node_stack,
|
||||
node->d.branch.right,
|
||||
0);
|
||||
}
|
||||
@ -478,14 +478,14 @@ cogl_atlas_internal_foreach (CoglAtlas *atlas,
|
||||
{
|
||||
/* We're finished with this node so we can call the callback */
|
||||
callback (node, data);
|
||||
node_stack = cogl_atlas_stack_pop (node_stack);
|
||||
node_stack = _cogl_atlas_stack_pop (node_stack);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Some sort of leaf node, just call the callback */
|
||||
callback (node, data);
|
||||
node_stack = cogl_atlas_stack_pop (node_stack);
|
||||
node_stack = _cogl_atlas_stack_pop (node_stack);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -501,7 +501,7 @@ typedef struct _CoglAtlasForeachClosure
|
||||
} CoglAtlasForeachClosure;
|
||||
|
||||
static void
|
||||
cogl_atlas_foreach_cb (CoglAtlasNode *node, gpointer data)
|
||||
_cogl_atlas_foreach_cb (CoglAtlasNode *node, gpointer data)
|
||||
{
|
||||
CoglAtlasForeachClosure *closure = data;
|
||||
|
||||
@ -510,7 +510,7 @@ cogl_atlas_foreach_cb (CoglAtlasNode *node, gpointer data)
|
||||
}
|
||||
|
||||
void
|
||||
cogl_atlas_foreach (CoglAtlas *atlas,
|
||||
_cogl_atlas_foreach (CoglAtlas *atlas,
|
||||
CoglAtlasCallback callback,
|
||||
gpointer data)
|
||||
{
|
||||
@ -519,31 +519,31 @@ cogl_atlas_foreach (CoglAtlas *atlas,
|
||||
closure.callback = callback;
|
||||
closure.data = data;
|
||||
|
||||
cogl_atlas_internal_foreach (atlas, cogl_atlas_foreach_cb, &closure);
|
||||
_cogl_atlas_internal_foreach (atlas, _cogl_atlas_foreach_cb, &closure);
|
||||
}
|
||||
|
||||
static void
|
||||
cogl_atlas_free_cb (CoglAtlasNode *node, gpointer data)
|
||||
_cogl_atlas_free_cb (CoglAtlasNode *node, gpointer data)
|
||||
{
|
||||
CoglAtlas *atlas = data;
|
||||
|
||||
if (node->type == COGL_ATLAS_FILLED_LEAF && atlas->value_destroy_func)
|
||||
atlas->value_destroy_func (node->d.data);
|
||||
|
||||
cogl_atlas_node_free (node);
|
||||
_cogl_atlas_node_free (node);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_atlas_free (CoglAtlas *atlas)
|
||||
_cogl_atlas_free (CoglAtlas *atlas)
|
||||
{
|
||||
cogl_atlas_internal_foreach (atlas, cogl_atlas_free_cb, atlas);
|
||||
_cogl_atlas_internal_foreach (atlas, _cogl_atlas_free_cb, atlas);
|
||||
g_free (atlas);
|
||||
}
|
||||
|
||||
#ifdef COGL_ENABLE_DEBUG
|
||||
|
||||
static void
|
||||
cogl_atlas_dump_image_cb (CoglAtlasNode *node, gpointer data)
|
||||
_cogl_atlas_dump_image_cb (CoglAtlasNode *node, gpointer data)
|
||||
{
|
||||
cairo_t *cr = data;
|
||||
|
||||
@ -572,7 +572,7 @@ cogl_atlas_dump_image_cb (CoglAtlasNode *node, gpointer data)
|
||||
}
|
||||
|
||||
static void
|
||||
cogl_atlas_dump_image (CoglAtlas *atlas)
|
||||
_cogl_atlas_dump_image (CoglAtlas *atlas)
|
||||
{
|
||||
/* This dumps a png to help visualize the atlas. Each leaf rectangle
|
||||
is drawn with a white outline. Unused leaves are filled in black
|
||||
@ -580,11 +580,11 @@ cogl_atlas_dump_image (CoglAtlas *atlas)
|
||||
|
||||
cairo_surface_t *surface =
|
||||
cairo_image_surface_create (CAIRO_FORMAT_RGB24,
|
||||
cogl_atlas_get_width (atlas),
|
||||
cogl_atlas_get_height (atlas));
|
||||
_cogl_atlas_get_width (atlas),
|
||||
_cogl_atlas_get_height (atlas));
|
||||
cairo_t *cr = cairo_create (surface);
|
||||
|
||||
cogl_atlas_internal_foreach (atlas, cogl_atlas_dump_image_cb, cr);
|
||||
_cogl_atlas_internal_foreach (atlas, _cogl_atlas_dump_image_cb, cr);
|
||||
|
||||
cairo_destroy (cr);
|
||||
|
||||
|
@ -40,37 +40,37 @@ struct _CoglAtlasRectangle
|
||||
};
|
||||
|
||||
CoglAtlas *
|
||||
cogl_atlas_new (guint width, guint height,
|
||||
_cogl_atlas_new (guint width, guint height,
|
||||
GDestroyNotify value_destroy_func);
|
||||
|
||||
gboolean
|
||||
cogl_atlas_add_rectangle (CoglAtlas *atlas,
|
||||
_cogl_atlas_add_rectangle (CoglAtlas *atlas,
|
||||
guint width, guint height,
|
||||
gpointer data,
|
||||
CoglAtlasRectangle *rectangle);
|
||||
|
||||
void
|
||||
cogl_atlas_remove_rectangle (CoglAtlas *atlas,
|
||||
_cogl_atlas_remove_rectangle (CoglAtlas *atlas,
|
||||
const CoglAtlasRectangle *rectangle);
|
||||
|
||||
guint
|
||||
cogl_atlas_get_width (CoglAtlas *atlas);
|
||||
_cogl_atlas_get_width (CoglAtlas *atlas);
|
||||
|
||||
guint
|
||||
cogl_atlas_get_height (CoglAtlas *atlas);
|
||||
_cogl_atlas_get_height (CoglAtlas *atlas);
|
||||
|
||||
guint
|
||||
cogl_atlas_get_remaining_space (CoglAtlas *atlas);
|
||||
_cogl_atlas_get_remaining_space (CoglAtlas *atlas);
|
||||
|
||||
guint
|
||||
cogl_atlas_get_n_rectangles (CoglAtlas *atlas);
|
||||
_cogl_atlas_get_n_rectangles (CoglAtlas *atlas);
|
||||
|
||||
void
|
||||
cogl_atlas_foreach (CoglAtlas *atlas,
|
||||
_cogl_atlas_foreach (CoglAtlas *atlas,
|
||||
CoglAtlasCallback callback,
|
||||
gpointer data);
|
||||
|
||||
void
|
||||
cogl_atlas_free (CoglAtlas *atlas);
|
||||
_cogl_atlas_free (CoglAtlas *atlas);
|
||||
|
||||
#endif /* __COGL_ATLAS_H */
|
||||
|
@ -192,7 +192,7 @@ _cogl_destroy_context ()
|
||||
cogl_handle_unref (_context->default_material);
|
||||
|
||||
if (_context->atlas)
|
||||
cogl_atlas_free (_context->atlas);
|
||||
_cogl_atlas_free (_context->atlas);
|
||||
if (_context->atlas_texture)
|
||||
cogl_handle_unref (_context->atlas_texture);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user