2009-12-04 08:06:32 -05:00
|
|
|
/*
|
|
|
|
* Cogl
|
|
|
|
*
|
2014-02-21 20:28:54 -05:00
|
|
|
* A Low Level GPU Graphics and Utilities API
|
2009-12-04 08:06:32 -05:00
|
|
|
*
|
2011-02-17 08:11:34 -05:00
|
|
|
* Copyright (C) 2009,2010,2011 Intel Corporation.
|
2009-12-04 08:06:32 -05:00
|
|
|
*
|
2014-02-21 20:28:54 -05:00
|
|
|
* Permission is hereby granted, free of charge, to any person
|
|
|
|
* obtaining a copy of this software and associated documentation
|
|
|
|
* files (the "Software"), to deal in the Software without
|
|
|
|
* restriction, including without limitation the rights to use, copy,
|
|
|
|
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
|
|
* of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
* included in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
2010-03-01 07:56:10 -05:00
|
|
|
*
|
|
|
|
*
|
2009-12-04 08:06:32 -05:00
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Neil Roberts <neil@linux.intel.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2010-07-25 16:36:41 -04:00
|
|
|
#include "cogl-debug.h"
|
2009-12-04 08:06:32 -05:00
|
|
|
#include "cogl-util.h"
|
|
|
|
#include "cogl-texture-private.h"
|
|
|
|
#include "cogl-atlas-texture-private.h"
|
|
|
|
#include "cogl-texture-2d-private.h"
|
2010-01-18 04:22:04 -05:00
|
|
|
#include "cogl-sub-texture-private.h"
|
2010-11-04 18:25:52 -04:00
|
|
|
#include "cogl-context-private.h"
|
2012-04-16 09:14:10 -04:00
|
|
|
#include "cogl-object-private.h"
|
2009-12-04 08:06:32 -05:00
|
|
|
#include "cogl-texture-driver.h"
|
2010-08-02 10:24:03 -04:00
|
|
|
#include "cogl-rectangle-map.h"
|
2010-02-12 10:33:56 -05:00
|
|
|
#include "cogl-journal-private.h"
|
2010-10-27 13:54:57 -04:00
|
|
|
#include "cogl-pipeline-opengl-private.h"
|
2010-08-02 11:29:10 -04:00
|
|
|
#include "cogl-atlas.h"
|
2012-02-17 16:46:39 -05:00
|
|
|
#include "cogl1-context.h"
|
2012-02-17 20:19:17 -05:00
|
|
|
#include "cogl-sub-texture.h"
|
2012-11-08 12:54:10 -05:00
|
|
|
#include "cogl-error-private.h"
|
2012-11-08 18:00:49 -05:00
|
|
|
#include "cogl-texture-gl-private.h"
|
2013-09-02 11:02:42 -04:00
|
|
|
#include "cogl-gtype-private.h"
|
2009-12-04 08:06:32 -05:00
|
|
|
|
2009-12-04 13:24:15 -05:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2009-12-04 08:06:32 -05:00
|
|
|
static void _cogl_atlas_texture_free (CoglAtlasTexture *sub_tex);
|
|
|
|
|
2013-09-06 13:18:52 -04:00
|
|
|
COGL_TEXTURE_DEFINE (AtlasTexture, atlas_texture);
|
2013-09-02 11:02:42 -04:00
|
|
|
COGL_GTYPE_DEFINE_CLASS (AtlasTexture, atlas_texture);
|
2009-12-04 08:06:32 -05:00
|
|
|
|
|
|
|
static const CoglTextureVtable cogl_atlas_texture_vtable;
|
|
|
|
|
2012-04-16 09:14:10 -04:00
|
|
|
static CoglSubTexture *
|
|
|
|
_cogl_atlas_texture_create_sub_texture (CoglTexture *full_texture,
|
2010-08-02 11:29:10 -04:00
|
|
|
const CoglRectangleMapEntry *rectangle)
|
2009-12-05 08:24:01 -05:00
|
|
|
{
|
2012-11-09 05:54:32 -05:00
|
|
|
CoglContext *ctx = full_texture->context;
|
2010-08-02 11:29:10 -04:00
|
|
|
/* Create a subtexture for the given rectangle not including the
|
|
|
|
1-pixel border */
|
2011-10-21 06:36:25 -04:00
|
|
|
return cogl_sub_texture_new (ctx,
|
|
|
|
full_texture,
|
|
|
|
rectangle->x + 1,
|
|
|
|
rectangle->y + 1,
|
|
|
|
rectangle->width - 2,
|
|
|
|
rectangle->height - 2);
|
2010-08-02 11:29:10 -04:00
|
|
|
}
|
2009-12-05 08:24:01 -05:00
|
|
|
|
2010-08-02 11:29:10 -04:00
|
|
|
static void
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
_cogl_atlas_texture_update_position_cb (void *user_data,
|
2012-04-16 09:14:10 -04:00
|
|
|
CoglTexture *new_texture,
|
2010-08-02 11:29:10 -04:00
|
|
|
const CoglRectangleMapEntry *rectangle)
|
|
|
|
{
|
|
|
|
CoglAtlasTexture *atlas_tex = user_data;
|
2009-12-05 08:24:01 -05:00
|
|
|
|
2010-08-02 11:29:10 -04:00
|
|
|
/* Update the sub texture */
|
|
|
|
if (atlas_tex->sub_texture)
|
2012-04-16 09:14:10 -04:00
|
|
|
cogl_object_unref (atlas_tex->sub_texture);
|
|
|
|
atlas_tex->sub_texture = COGL_TEXTURE (
|
|
|
|
_cogl_atlas_texture_create_sub_texture (new_texture, rectangle));
|
2009-12-05 08:24:01 -05:00
|
|
|
|
2010-08-02 11:29:10 -04:00
|
|
|
/* Update the position */
|
|
|
|
atlas_tex->rectangle = *rectangle;
|
|
|
|
}
|
2009-12-05 08:24:01 -05:00
|
|
|
|
|
|
|
static void
|
2011-02-17 08:11:34 -05:00
|
|
|
_cogl_atlas_texture_pre_reorganize_foreach_cb
|
|
|
|
(const CoglRectangleMapEntry *entry,
|
|
|
|
void *rectangle_data,
|
|
|
|
void *user_data)
|
2009-12-05 08:24:01 -05:00
|
|
|
{
|
2011-02-17 08:11:34 -05:00
|
|
|
CoglAtlasTexture *atlas_tex = rectangle_data;
|
|
|
|
|
|
|
|
/* Keep a reference to the texture because we don't want it to be
|
|
|
|
destroyed during the reorganization */
|
2012-04-16 09:14:10 -04:00
|
|
|
cogl_object_ref (atlas_tex);
|
2011-02-17 08:11:34 -05:00
|
|
|
|
2010-10-27 13:54:57 -04:00
|
|
|
/* Notify cogl-pipeline.c that the texture's underlying GL texture
|
2010-08-02 11:29:10 -04:00
|
|
|
* storage is changing so it knows it may need to bind a new texture
|
|
|
|
* if the CoglTexture is reused with the same texture unit. */
|
2011-02-17 08:11:34 -05:00
|
|
|
_cogl_pipeline_texture_storage_change_notify (COGL_TEXTURE (atlas_tex));
|
2009-12-05 08:24:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-02-17 08:11:34 -05:00
|
|
|
_cogl_atlas_texture_pre_reorganize_cb (void *data)
|
2009-12-05 08:24:01 -05:00
|
|
|
{
|
2010-11-27 08:15:02 -05:00
|
|
|
CoglAtlas *atlas = data;
|
|
|
|
|
2011-01-06 08:25:45 -05:00
|
|
|
/* We don't know if any journal entries currently depend on OpenGL
|
|
|
|
* texture coordinates that would be invalidated by reorganizing
|
|
|
|
* this atlas so we flush all journals before migrating.
|
2010-08-02 11:29:10 -04:00
|
|
|
*
|
|
|
|
* We are assuming that texture atlas migration never happens
|
|
|
|
* during a flush so we don't have to consider recursion here.
|
|
|
|
*/
|
2011-01-06 08:25:45 -05:00
|
|
|
cogl_flush ();
|
2010-08-02 11:29:10 -04:00
|
|
|
|
|
|
|
if (atlas->map)
|
|
|
|
_cogl_rectangle_map_foreach (atlas->map,
|
2011-02-17 08:11:34 -05:00
|
|
|
_cogl_atlas_texture_pre_reorganize_foreach_cb,
|
2010-08-02 11:29:10 -04:00
|
|
|
NULL);
|
2009-12-05 08:24:01 -05:00
|
|
|
}
|
|
|
|
|
2011-02-17 08:11:34 -05:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
CoglAtlasTexture **textures;
|
|
|
|
/* Number of textures found so far */
|
|
|
|
unsigned int n_textures;
|
|
|
|
} CoglAtlasTextureGetRectanglesData;
|
|
|
|
|
|
|
|
static void
|
|
|
|
_cogl_atlas_texture_get_rectangles_cb (const CoglRectangleMapEntry *entry,
|
|
|
|
void *rectangle_data,
|
|
|
|
void *user_data)
|
|
|
|
{
|
|
|
|
CoglAtlasTextureGetRectanglesData *data = user_data;
|
|
|
|
|
|
|
|
data->textures[data->n_textures++] = rectangle_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_cogl_atlas_texture_post_reorganize_cb (void *user_data)
|
|
|
|
{
|
|
|
|
CoglAtlas *atlas = user_data;
|
|
|
|
|
2011-03-30 07:53:50 -04:00
|
|
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
|
|
|
2011-02-17 08:11:34 -05:00
|
|
|
if (atlas->map)
|
|
|
|
{
|
|
|
|
CoglAtlasTextureGetRectanglesData data;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
data.textures = g_new (CoglAtlasTexture *,
|
|
|
|
_cogl_rectangle_map_get_n_rectangles (atlas->map));
|
|
|
|
data.n_textures = 0;
|
|
|
|
|
|
|
|
/* We need to remove all of the references that we took during
|
|
|
|
the preorganize callback. We have to get a separate array of
|
|
|
|
the textures because CoglRectangleMap doesn't support
|
|
|
|
removing rectangles during iteration */
|
|
|
|
_cogl_rectangle_map_foreach (atlas->map,
|
|
|
|
_cogl_atlas_texture_get_rectangles_cb,
|
|
|
|
&data);
|
|
|
|
|
|
|
|
for (i = 0; i < data.n_textures; i++)
|
|
|
|
{
|
|
|
|
/* Ignore textures that don't have an atlas yet. This will
|
|
|
|
happen when a new texture is added because we allocate
|
|
|
|
the structure for the texture so that it can get stored
|
|
|
|
in the atlas but it isn't a valid object yet */
|
|
|
|
if (data.textures[i]->atlas)
|
|
|
|
cogl_object_unref (data.textures[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (data.textures);
|
|
|
|
}
|
2011-03-30 07:53:50 -04:00
|
|
|
|
|
|
|
/* Notify any listeners that an atlas has changed */
|
|
|
|
g_hook_list_invoke (&ctx->atlas_reorganize_callbacks, FALSE);
|
2011-02-17 08:11:34 -05:00
|
|
|
}
|
|
|
|
|
2010-11-27 08:15:02 -05:00
|
|
|
static void
|
|
|
|
_cogl_atlas_texture_atlas_destroyed_cb (void *user_data)
|
2009-12-05 08:24:01 -05:00
|
|
|
{
|
2010-11-27 08:15:02 -05:00
|
|
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
|
|
|
|
|
|
/* Remove the atlas from the global list */
|
|
|
|
ctx->atlases = g_slist_remove (ctx->atlases, user_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static CoglAtlas *
|
2012-11-09 05:54:32 -05:00
|
|
|
_cogl_atlas_texture_create_atlas (CoglContext *ctx)
|
2010-11-27 08:15:02 -05:00
|
|
|
{
|
|
|
|
static CoglUserDataKey atlas_private_key;
|
|
|
|
|
2012-11-09 05:54:32 -05:00
|
|
|
CoglAtlas *atlas = _cogl_atlas_new (COGL_PIXEL_FORMAT_RGBA_8888,
|
|
|
|
0,
|
|
|
|
_cogl_atlas_texture_update_position_cb);
|
2010-08-02 11:29:10 -04:00
|
|
|
|
2010-11-27 08:15:02 -05:00
|
|
|
_cogl_atlas_add_reorganize_callback (atlas,
|
2011-02-17 08:11:34 -05:00
|
|
|
_cogl_atlas_texture_pre_reorganize_cb,
|
|
|
|
_cogl_atlas_texture_post_reorganize_cb,
|
2010-11-27 08:15:02 -05:00
|
|
|
atlas);
|
|
|
|
|
|
|
|
ctx->atlases = g_slist_prepend (ctx->atlases, atlas);
|
2010-08-02 11:29:10 -04:00
|
|
|
|
2010-11-27 08:15:02 -05:00
|
|
|
/* Set some data on the atlas so we can get notification when it is
|
|
|
|
destroyed in order to remove it from the list. ctx->atlases
|
|
|
|
effectively holds a weak reference. We don't need a strong
|
|
|
|
reference because the atlas textures take a reference on the
|
|
|
|
atlas so it will stay alive */
|
|
|
|
cogl_object_set_user_data (COGL_OBJECT (atlas), &atlas_private_key, atlas,
|
|
|
|
_cogl_atlas_texture_atlas_destroyed_cb);
|
|
|
|
|
|
|
|
return atlas;
|
2009-12-05 08:24:01 -05:00
|
|
|
}
|
|
|
|
|
2009-12-04 08:06:32 -05:00
|
|
|
static void
|
|
|
|
_cogl_atlas_texture_foreach_sub_texture_in_region (
|
|
|
|
CoglTexture *tex,
|
|
|
|
float virtual_tx_1,
|
|
|
|
float virtual_ty_1,
|
|
|
|
float virtual_tx_2,
|
|
|
|
float virtual_ty_2,
|
2011-10-08 09:13:03 -04:00
|
|
|
CoglMetaTextureCallback callback,
|
2009-12-04 08:06:32 -05:00
|
|
|
void *user_data)
|
|
|
|
{
|
|
|
|
CoglAtlasTexture *atlas_tex = COGL_ATLAS_TEXTURE (tex);
|
2012-04-16 09:14:10 -04:00
|
|
|
CoglMetaTexture *meta_texture = COGL_META_TEXTURE (atlas_tex->sub_texture);
|
2009-12-04 08:06:32 -05:00
|
|
|
|
|
|
|
/* Forward on to the sub texture */
|
2012-04-16 09:14:10 -04:00
|
|
|
cogl_meta_texture_foreach_in_region (meta_texture,
|
2011-10-08 09:13:03 -04:00
|
|
|
virtual_tx_1,
|
|
|
|
virtual_ty_1,
|
|
|
|
virtual_tx_2,
|
|
|
|
virtual_ty_2,
|
|
|
|
COGL_PIPELINE_WRAP_MODE_REPEAT,
|
|
|
|
COGL_PIPELINE_WRAP_MODE_REPEAT,
|
|
|
|
callback,
|
|
|
|
user_data);
|
2009-12-04 08:06:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-09-10 15:35:39 -04:00
|
|
|
_cogl_atlas_texture_gl_flush_legacy_texobj_wrap_modes (CoglTexture *tex,
|
|
|
|
GLenum wrap_mode_s,
|
|
|
|
GLenum wrap_mode_t,
|
|
|
|
GLenum wrap_mode_p)
|
2009-12-04 08:06:32 -05:00
|
|
|
{
|
|
|
|
CoglAtlasTexture *atlas_tex = COGL_ATLAS_TEXTURE (tex);
|
|
|
|
|
|
|
|
/* Forward on to the sub texture */
|
2012-09-10 15:35:39 -04:00
|
|
|
_cogl_texture_gl_flush_legacy_texobj_wrap_modes (atlas_tex->sub_texture,
|
|
|
|
wrap_mode_s,
|
|
|
|
wrap_mode_t,
|
|
|
|
wrap_mode_p);
|
2009-12-04 08:06:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-12-05 08:48:03 -05:00
|
|
|
_cogl_atlas_texture_remove_from_atlas (CoglAtlasTexture *atlas_tex)
|
2009-12-04 08:06:32 -05:00
|
|
|
{
|
2010-11-27 08:15:02 -05:00
|
|
|
if (atlas_tex->atlas)
|
2009-12-04 13:55:53 -05:00
|
|
|
{
|
2010-11-27 08:15:02 -05:00
|
|
|
_cogl_atlas_remove (atlas_tex->atlas,
|
2010-08-02 11:29:10 -04:00
|
|
|
&atlas_tex->rectangle);
|
2009-12-05 08:48:03 -05:00
|
|
|
|
2010-11-27 08:15:02 -05:00
|
|
|
cogl_object_unref (atlas_tex->atlas);
|
|
|
|
atlas_tex->atlas = NULL;
|
2009-12-04 13:55:53 -05:00
|
|
|
}
|
2009-12-05 08:48:03 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_cogl_atlas_texture_free (CoglAtlasTexture *atlas_tex)
|
|
|
|
{
|
|
|
|
_cogl_atlas_texture_remove_from_atlas (atlas_tex);
|
2009-12-04 08:06:32 -05:00
|
|
|
|
2013-06-11 10:57:38 -04:00
|
|
|
if (atlas_tex->sub_texture)
|
|
|
|
cogl_object_unref (atlas_tex->sub_texture);
|
2010-04-13 12:26:03 -04:00
|
|
|
|
2010-04-26 05:01:43 -04:00
|
|
|
/* Chain up */
|
|
|
|
_cogl_texture_free (COGL_TEXTURE (atlas_tex));
|
2009-12-04 08:06:32 -05:00
|
|
|
}
|
|
|
|
|
cogl: improves header and coding style consistency
We've had complaints that our Cogl code/headers are a bit "special" so
this is a first pass at tidying things up by giving them some
consistency. These changes are all consistent with how new code in Cogl
is being written, but the style isn't consistently applied across all
code yet.
There are two parts to this patch; but since each one required a large
amount of effort to maintain tidy indenting it made sense to combine the
changes to reduce the time spent re indenting the same lines.
The first change is to use a consistent style for declaring function
prototypes in headers. Cogl headers now consistently use this style for
prototypes:
return_type
cogl_function_name (CoglType arg0,
CoglType arg1);
Not everyone likes this style, but it seems that most of the currently
active Cogl developers agree on it.
The second change is to constrain the use of redundant glib data types
in Cogl. Uses of gint, guint, gfloat, glong, gulong and gchar have all
been replaced with int, unsigned int, float, long, unsigned long and char
respectively. When talking about pixel data; use of guchar has been
replaced with guint8, otherwise unsigned char can be used.
The glib types that we continue to use for portability are gboolean,
gint{8,16,32,64}, guint{8,16,32,64} and gsize.
The general intention is that Cogl should look palatable to the widest
range of C programmers including those outside the Gnome community so
- especially for the public API - we want to minimize the number of
foreign looking typedefs.
2010-02-09 20:57:32 -05:00
|
|
|
static int
|
2009-12-04 08:06:32 -05:00
|
|
|
_cogl_atlas_texture_get_max_waste (CoglTexture *tex)
|
|
|
|
{
|
|
|
|
CoglAtlasTexture *atlas_tex = COGL_ATLAS_TEXTURE (tex);
|
|
|
|
|
|
|
|
/* Forward on to the sub texture */
|
|
|
|
return cogl_texture_get_max_waste (atlas_tex->sub_texture);
|
|
|
|
}
|
|
|
|
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
static CoglBool
|
2009-12-04 08:06:32 -05:00
|
|
|
_cogl_atlas_texture_is_sliced (CoglTexture *tex)
|
|
|
|
{
|
|
|
|
CoglAtlasTexture *atlas_tex = COGL_ATLAS_TEXTURE (tex);
|
|
|
|
|
|
|
|
/* Forward on to the sub texture */
|
|
|
|
return cogl_texture_is_sliced (atlas_tex->sub_texture);
|
|
|
|
}
|
|
|
|
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
static CoglBool
|
2009-12-04 08:06:32 -05:00
|
|
|
_cogl_atlas_texture_can_hardware_repeat (CoglTexture *tex)
|
|
|
|
{
|
|
|
|
CoglAtlasTexture *atlas_tex = COGL_ATLAS_TEXTURE (tex);
|
|
|
|
|
|
|
|
/* Forward on to the sub texture */
|
|
|
|
return _cogl_texture_can_hardware_repeat (atlas_tex->sub_texture);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_cogl_atlas_texture_transform_coords_to_gl (CoglTexture *tex,
|
|
|
|
float *s,
|
|
|
|
float *t)
|
|
|
|
{
|
|
|
|
CoglAtlasTexture *atlas_tex = COGL_ATLAS_TEXTURE (tex);
|
|
|
|
|
|
|
|
/* Forward on to the sub texture */
|
|
|
|
_cogl_texture_transform_coords_to_gl (atlas_tex->sub_texture, s, t);
|
|
|
|
}
|
|
|
|
|
2010-03-01 16:49:04 -05:00
|
|
|
static CoglTransformResult
|
2010-01-18 04:22:04 -05:00
|
|
|
_cogl_atlas_texture_transform_quad_coords_to_gl (CoglTexture *tex,
|
|
|
|
float *coords)
|
|
|
|
{
|
|
|
|
CoglAtlasTexture *atlas_tex = COGL_ATLAS_TEXTURE (tex);
|
|
|
|
|
|
|
|
/* Forward on to the sub texture */
|
|
|
|
return _cogl_texture_transform_quad_coords_to_gl (atlas_tex->sub_texture,
|
|
|
|
coords);
|
|
|
|
}
|
|
|
|
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
static CoglBool
|
2009-12-04 08:06:32 -05:00
|
|
|
_cogl_atlas_texture_get_gl_texture (CoglTexture *tex,
|
|
|
|
GLuint *out_gl_handle,
|
|
|
|
GLenum *out_gl_target)
|
|
|
|
{
|
|
|
|
CoglAtlasTexture *atlas_tex = COGL_ATLAS_TEXTURE (tex);
|
|
|
|
|
|
|
|
/* Forward on to the sub texture */
|
|
|
|
return cogl_texture_get_gl_texture (atlas_tex->sub_texture,
|
|
|
|
out_gl_handle,
|
|
|
|
out_gl_target);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-09-10 15:35:39 -04:00
|
|
|
_cogl_atlas_texture_gl_flush_legacy_texobj_filters (CoglTexture *tex,
|
|
|
|
GLenum min_filter,
|
|
|
|
GLenum mag_filter)
|
2009-12-04 08:06:32 -05:00
|
|
|
{
|
|
|
|
CoglAtlasTexture *atlas_tex = COGL_ATLAS_TEXTURE (tex);
|
|
|
|
|
|
|
|
/* Forward on to the sub texture */
|
2012-09-10 15:35:39 -04:00
|
|
|
_cogl_texture_gl_flush_legacy_texobj_filters (atlas_tex->sub_texture,
|
|
|
|
min_filter, mag_filter);
|
2009-12-04 08:06:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-01-18 04:22:04 -05:00
|
|
|
_cogl_atlas_texture_migrate_out_of_atlas (CoglAtlasTexture *atlas_tex)
|
2009-12-04 08:06:32 -05:00
|
|
|
{
|
2012-11-09 05:54:32 -05:00
|
|
|
CoglTexture *standalone_tex;
|
|
|
|
|
2010-01-18 04:22:04 -05:00
|
|
|
/* Make sure this texture is not in the atlas */
|
2012-11-09 05:54:32 -05:00
|
|
|
if (!atlas_tex->atlas)
|
|
|
|
return;
|
|
|
|
|
|
|
|
COGL_NOTE (ATLAS, "Migrating texture out of the atlas");
|
|
|
|
|
|
|
|
/* We don't know if any journal entries currently depend on
|
|
|
|
* OpenGL texture coordinates that would be invalidated by
|
|
|
|
* migrating textures in this atlas so we flush all journals
|
|
|
|
* before migrating.
|
|
|
|
*
|
|
|
|
* We are assuming that texture atlas migration never happens
|
|
|
|
* during a flush so we don't have to consider recursion here.
|
|
|
|
*/
|
|
|
|
cogl_flush ();
|
|
|
|
|
|
|
|
standalone_tex =
|
|
|
|
_cogl_atlas_copy_rectangle (atlas_tex->atlas,
|
|
|
|
atlas_tex->rectangle.x + 1,
|
|
|
|
atlas_tex->rectangle.y + 1,
|
|
|
|
atlas_tex->rectangle.width - 2,
|
|
|
|
atlas_tex->rectangle.height - 2,
|
2013-06-23 11:18:18 -04:00
|
|
|
atlas_tex->internal_format);
|
2012-11-09 05:54:32 -05:00
|
|
|
/* Note: we simply silently ignore failures to migrate a texture
|
|
|
|
* out (most likely due to lack of memory) and hope for the
|
|
|
|
* best.
|
|
|
|
*
|
|
|
|
* Maybe we should find a way to report the problem back to the
|
|
|
|
* app.
|
|
|
|
*/
|
|
|
|
if (!standalone_tex)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Notify cogl-pipeline.c that the texture's underlying GL texture
|
|
|
|
* storage is changing so it knows it may need to bind a new texture
|
|
|
|
* if the CoglTexture is reused with the same texture unit. */
|
|
|
|
_cogl_pipeline_texture_storage_change_notify (COGL_TEXTURE (atlas_tex));
|
|
|
|
|
|
|
|
/* We need to unref the sub texture after doing the copy because
|
|
|
|
the copy can involve rendering which might cause the texture
|
|
|
|
to be used if it is used from a layer that is left in a
|
|
|
|
texture unit */
|
|
|
|
cogl_object_unref (atlas_tex->sub_texture);
|
|
|
|
atlas_tex->sub_texture = standalone_tex;
|
|
|
|
|
|
|
|
_cogl_atlas_texture_remove_from_atlas (atlas_tex);
|
2010-01-18 04:22:04 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-06-09 12:39:59 -04:00
|
|
|
_cogl_atlas_texture_pre_paint (CoglTexture *tex, CoglTexturePrePaintFlags flags)
|
2010-01-18 04:22:04 -05:00
|
|
|
{
|
|
|
|
CoglAtlasTexture *atlas_tex = COGL_ATLAS_TEXTURE (tex);
|
|
|
|
|
2010-06-09 12:39:59 -04:00
|
|
|
if ((flags & COGL_TEXTURE_NEEDS_MIPMAP))
|
|
|
|
/* Mipmaps do not work well with the current atlas so instead
|
|
|
|
we'll just migrate the texture out and use a regular texture */
|
|
|
|
_cogl_atlas_texture_migrate_out_of_atlas (atlas_tex);
|
2009-12-04 08:06:32 -05:00
|
|
|
|
|
|
|
/* Forward on to the sub texture */
|
2010-06-09 12:39:59 -04:00
|
|
|
_cogl_texture_pre_paint (atlas_tex->sub_texture, flags);
|
2009-12-04 08:06:32 -05:00
|
|
|
}
|
|
|
|
|
2010-01-18 04:22:04 -05:00
|
|
|
static void
|
|
|
|
_cogl_atlas_texture_ensure_non_quad_rendering (CoglTexture *tex)
|
|
|
|
{
|
|
|
|
CoglAtlasTexture *atlas_tex = COGL_ATLAS_TEXTURE (tex);
|
|
|
|
|
|
|
|
/* Sub textures can't support non-quad rendering so we'll just
|
|
|
|
migrate the texture out */
|
|
|
|
_cogl_atlas_texture_migrate_out_of_atlas (atlas_tex);
|
|
|
|
|
|
|
|
/* Forward on to the sub texture */
|
|
|
|
_cogl_texture_ensure_non_quad_rendering (atlas_tex->sub_texture);
|
|
|
|
}
|
|
|
|
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
static CoglBool
|
2010-01-18 05:53:00 -05:00
|
|
|
_cogl_atlas_texture_set_region_with_border (CoglAtlasTexture *atlas_tex,
|
2012-11-08 12:54:10 -05:00
|
|
|
int src_x,
|
|
|
|
int src_y,
|
|
|
|
int dst_x,
|
|
|
|
int dst_y,
|
|
|
|
int dst_width,
|
|
|
|
int dst_height,
|
|
|
|
CoglBitmap *bmp,
|
|
|
|
CoglError **error)
|
2010-01-18 05:53:00 -05:00
|
|
|
{
|
2010-11-27 08:15:02 -05:00
|
|
|
CoglAtlas *atlas = atlas_tex->atlas;
|
2010-01-18 05:53:00 -05:00
|
|
|
|
|
|
|
/* Copy the central data */
|
2012-11-08 12:54:10 -05:00
|
|
|
if (!_cogl_texture_set_region_from_bitmap (atlas->texture,
|
|
|
|
src_x, src_y,
|
|
|
|
dst_width,
|
|
|
|
dst_height,
|
|
|
|
bmp,
|
2012-11-09 12:55:54 -05:00
|
|
|
dst_x + atlas_tex->rectangle.x + 1,
|
|
|
|
dst_y + atlas_tex->rectangle.y + 1,
|
|
|
|
0, /* level 0 */
|
2012-11-08 12:54:10 -05:00
|
|
|
error))
|
2010-01-18 05:53:00 -05:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* Update the left edge pixels */
|
|
|
|
if (dst_x == 0 &&
|
2012-11-08 12:54:10 -05:00
|
|
|
!_cogl_texture_set_region_from_bitmap (atlas->texture,
|
|
|
|
src_x, src_y,
|
|
|
|
1, dst_height,
|
|
|
|
bmp,
|
2012-11-09 12:55:54 -05:00
|
|
|
atlas_tex->rectangle.x,
|
|
|
|
dst_y + atlas_tex->rectangle.y + 1,
|
|
|
|
0, /* level 0 */
|
2012-11-08 12:54:10 -05:00
|
|
|
error))
|
2010-01-18 05:53:00 -05:00
|
|
|
return FALSE;
|
|
|
|
/* Update the right edge pixels */
|
|
|
|
if (dst_x + dst_width == atlas_tex->rectangle.width - 2 &&
|
2012-11-08 12:54:10 -05:00
|
|
|
!_cogl_texture_set_region_from_bitmap (atlas->texture,
|
|
|
|
src_x + dst_width - 1, src_y,
|
2012-11-09 12:55:54 -05:00
|
|
|
1, dst_height,
|
|
|
|
bmp,
|
2012-11-08 12:54:10 -05:00
|
|
|
atlas_tex->rectangle.x +
|
|
|
|
atlas_tex->rectangle.width - 1,
|
|
|
|
dst_y + atlas_tex->rectangle.y + 1,
|
2012-11-09 12:55:54 -05:00
|
|
|
0, /* level 0 */
|
2012-11-08 12:54:10 -05:00
|
|
|
error))
|
2010-01-18 05:53:00 -05:00
|
|
|
return FALSE;
|
|
|
|
/* Update the top edge pixels */
|
|
|
|
if (dst_y == 0 &&
|
2012-11-08 12:54:10 -05:00
|
|
|
!_cogl_texture_set_region_from_bitmap (atlas->texture,
|
|
|
|
src_x, src_y,
|
|
|
|
dst_width, 1,
|
|
|
|
bmp,
|
2012-11-09 12:55:54 -05:00
|
|
|
dst_x + atlas_tex->rectangle.x + 1,
|
|
|
|
atlas_tex->rectangle.y,
|
|
|
|
0, /* level 0 */
|
2012-11-08 12:54:10 -05:00
|
|
|
error))
|
2010-01-18 05:53:00 -05:00
|
|
|
return FALSE;
|
|
|
|
/* Update the bottom edge pixels */
|
|
|
|
if (dst_y + dst_height == atlas_tex->rectangle.height - 2 &&
|
2012-11-08 12:54:10 -05:00
|
|
|
!_cogl_texture_set_region_from_bitmap (atlas->texture,
|
|
|
|
src_x, src_y + dst_height - 1,
|
2012-11-09 12:55:54 -05:00
|
|
|
dst_width, 1,
|
|
|
|
bmp,
|
2012-11-08 12:54:10 -05:00
|
|
|
dst_x + atlas_tex->rectangle.x + 1,
|
|
|
|
atlas_tex->rectangle.y +
|
|
|
|
atlas_tex->rectangle.height - 1,
|
2012-11-09 12:55:54 -05:00
|
|
|
0, /* level 0 */
|
2012-11-08 12:54:10 -05:00
|
|
|
error))
|
2010-01-18 05:53:00 -05:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-08-31 12:22:20 -04:00
|
|
|
static CoglBitmap *
|
2013-06-07 19:28:14 -04:00
|
|
|
_cogl_atlas_texture_convert_bitmap_for_upload (CoglAtlasTexture *atlas_tex,
|
|
|
|
CoglBitmap *bmp,
|
2013-06-23 11:18:18 -04:00
|
|
|
CoglPixelFormat internal_format,
|
2013-06-07 19:28:14 -04:00
|
|
|
CoglBool can_convert_in_place,
|
|
|
|
CoglError **error)
|
2011-08-31 12:22:20 -04:00
|
|
|
{
|
2013-06-07 19:28:14 -04:00
|
|
|
CoglBitmap *upload_bmp;
|
2011-08-31 12:22:20 -04:00
|
|
|
CoglBitmap *override_bmp;
|
|
|
|
|
|
|
|
/* We'll prepare to upload using the format of the actual texture of
|
|
|
|
the atlas texture instead of the format reported by
|
2013-06-27 13:33:04 -04:00
|
|
|
_cogl_texture_get_format which would be the original internal
|
2011-08-31 12:22:20 -04:00
|
|
|
format specified when the texture was created. However we'll
|
|
|
|
preserve the premult status of the internal format because the
|
|
|
|
images are all stored in the original premult format of the
|
|
|
|
orignal format so we do need to trigger the conversion */
|
|
|
|
|
|
|
|
internal_format = (COGL_PIXEL_FORMAT_RGBA_8888 |
|
2013-06-23 11:18:18 -04:00
|
|
|
(internal_format & COGL_PREMULT_BIT));
|
2011-08-31 12:22:20 -04:00
|
|
|
|
2013-06-07 19:28:14 -04:00
|
|
|
upload_bmp = _cogl_bitmap_convert_for_upload (bmp,
|
|
|
|
internal_format,
|
|
|
|
can_convert_in_place,
|
|
|
|
error);
|
|
|
|
if (upload_bmp == NULL)
|
2011-08-31 12:22:20 -04:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* We'll create another bitmap which uses the same data but
|
|
|
|
overrides the format to remove the premult flag so that uploads
|
|
|
|
to the atlas texture won't trigger the conversion again */
|
|
|
|
|
|
|
|
override_bmp =
|
2013-06-07 19:28:14 -04:00
|
|
|
_cogl_bitmap_new_shared (upload_bmp,
|
|
|
|
cogl_bitmap_get_format (upload_bmp) &
|
2011-08-31 12:22:20 -04:00
|
|
|
~COGL_PREMULT_BIT,
|
2013-06-07 19:28:14 -04:00
|
|
|
cogl_bitmap_get_width (upload_bmp),
|
|
|
|
cogl_bitmap_get_height (upload_bmp),
|
|
|
|
cogl_bitmap_get_rowstride (upload_bmp));
|
2011-08-31 12:22:20 -04:00
|
|
|
|
2013-06-07 19:28:14 -04:00
|
|
|
cogl_object_unref (upload_bmp);
|
2011-08-31 12:22:20 -04:00
|
|
|
|
|
|
|
return override_bmp;
|
|
|
|
}
|
|
|
|
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
static CoglBool
|
2012-11-08 12:54:10 -05:00
|
|
|
_cogl_atlas_texture_set_region (CoglTexture *tex,
|
|
|
|
int src_x,
|
|
|
|
int src_y,
|
|
|
|
int dst_x,
|
|
|
|
int dst_y,
|
|
|
|
int dst_width,
|
|
|
|
int dst_height,
|
2012-11-09 12:55:54 -05:00
|
|
|
int level,
|
2012-11-08 12:54:10 -05:00
|
|
|
CoglBitmap *bmp,
|
|
|
|
CoglError **error)
|
2009-12-04 08:06:32 -05:00
|
|
|
{
|
|
|
|
CoglAtlasTexture *atlas_tex = COGL_ATLAS_TEXTURE (tex);
|
|
|
|
|
2012-11-09 12:55:54 -05:00
|
|
|
if (level != 0 && atlas_tex->atlas)
|
|
|
|
_cogl_atlas_texture_migrate_out_of_atlas (atlas_tex);
|
|
|
|
|
2009-12-04 08:06:32 -05:00
|
|
|
/* If the texture is in the atlas then we need to copy the edge
|
|
|
|
pixels to the border */
|
2010-11-27 08:15:02 -05:00
|
|
|
if (atlas_tex->atlas)
|
2010-07-07 13:44:16 -04:00
|
|
|
{
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
CoglBool ret;
|
2013-06-07 19:28:14 -04:00
|
|
|
CoglBitmap *upload_bmp =
|
|
|
|
_cogl_atlas_texture_convert_bitmap_for_upload (atlas_tex,
|
|
|
|
bmp,
|
2013-06-23 11:18:18 -04:00
|
|
|
atlas_tex->internal_format,
|
2013-06-07 19:28:14 -04:00
|
|
|
FALSE, /* can't convert
|
|
|
|
in place */
|
|
|
|
error);
|
|
|
|
if (!upload_bmp)
|
2012-11-08 12:54:10 -05:00
|
|
|
return FALSE;
|
2010-07-07 13:44:16 -04:00
|
|
|
|
|
|
|
/* Upload the data ignoring the premult bit */
|
|
|
|
ret = _cogl_atlas_texture_set_region_with_border (atlas_tex,
|
|
|
|
src_x, src_y,
|
|
|
|
dst_x, dst_y,
|
|
|
|
dst_width, dst_height,
|
2013-06-07 19:28:14 -04:00
|
|
|
upload_bmp,
|
2012-11-08 12:54:10 -05:00
|
|
|
error);
|
2010-07-08 10:15:22 -04:00
|
|
|
|
2013-06-07 19:28:14 -04:00
|
|
|
cogl_object_unref (upload_bmp);
|
2010-07-07 13:44:16 -04:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2009-12-04 08:06:32 -05:00
|
|
|
else
|
|
|
|
/* Otherwise we can just forward on to the sub texture */
|
2012-11-08 12:54:10 -05:00
|
|
|
return _cogl_texture_set_region_from_bitmap (atlas_tex->sub_texture,
|
|
|
|
src_x, src_y,
|
|
|
|
dst_width, dst_height,
|
|
|
|
bmp,
|
2012-11-09 12:55:54 -05:00
|
|
|
dst_x, dst_y,
|
|
|
|
level,
|
2012-11-08 12:54:10 -05:00
|
|
|
error);
|
2009-12-04 08:06:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static CoglPixelFormat
|
|
|
|
_cogl_atlas_texture_get_format (CoglTexture *tex)
|
|
|
|
{
|
|
|
|
CoglAtlasTexture *atlas_tex = COGL_ATLAS_TEXTURE (tex);
|
|
|
|
|
|
|
|
/* We don't want to forward this on the sub-texture because it isn't
|
|
|
|
the necessarily the same format. This will happen if the texture
|
|
|
|
isn't pre-multiplied */
|
2013-06-23 11:18:18 -04:00
|
|
|
return atlas_tex->internal_format;
|
2009-12-04 08:06:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static GLenum
|
|
|
|
_cogl_atlas_texture_get_gl_format (CoglTexture *tex)
|
|
|
|
{
|
|
|
|
CoglAtlasTexture *atlas_tex = COGL_ATLAS_TEXTURE (tex);
|
|
|
|
|
|
|
|
/* Forward on to the sub texture */
|
2012-11-22 16:31:25 -05:00
|
|
|
return _cogl_texture_gl_get_format (atlas_tex->sub_texture);
|
2009-12-04 08:06:32 -05:00
|
|
|
}
|
|
|
|
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
static CoglBool
|
2010-05-05 11:45:21 -04:00
|
|
|
_cogl_atlas_texture_can_use_format (CoglPixelFormat format)
|
|
|
|
{
|
|
|
|
/* We don't care about the ordering or the premult status and we can
|
|
|
|
accept RGBA or RGB textures. Although we could also accept
|
|
|
|
luminance and alpha only textures or 16-bit formats it seems that
|
|
|
|
if the application is explicitly using these formats then they've
|
|
|
|
got a reason to want the lower memory requirements so putting
|
|
|
|
them in the atlas might not be a good idea */
|
|
|
|
format &= ~(COGL_PREMULT_BIT | COGL_BGR_BIT | COGL_AFIRST_BIT);
|
|
|
|
return (format == COGL_PIXEL_FORMAT_RGB_888 ||
|
|
|
|
format == COGL_PIXEL_FORMAT_RGBA_8888);
|
|
|
|
}
|
|
|
|
|
2013-06-23 11:18:18 -04:00
|
|
|
static CoglAtlasTexture *
|
|
|
|
_cogl_atlas_texture_create_base (CoglContext *ctx,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
CoglPixelFormat internal_format,
|
|
|
|
CoglTextureLoader *loader)
|
2009-12-04 08:06:32 -05:00
|
|
|
{
|
2010-02-01 07:11:58 -05:00
|
|
|
CoglAtlasTexture *atlas_tex;
|
2009-12-04 08:06:32 -05:00
|
|
|
|
2010-02-18 11:33:12 -05:00
|
|
|
COGL_NOTE (ATLAS, "Adding texture of size %ix%i", width, height);
|
2010-02-01 07:11:58 -05:00
|
|
|
|
2009-12-04 08:06:32 -05:00
|
|
|
/* We need to allocate the texture now because we need the pointer
|
|
|
|
to set as the data for the rectangle in the atlas */
|
2013-06-23 11:18:18 -04:00
|
|
|
atlas_tex = g_new0 (CoglAtlasTexture, 1);
|
2011-02-17 08:11:34 -05:00
|
|
|
/* Mark it as having no atlas so we don't try to unref it in
|
|
|
|
_cogl_atlas_texture_post_reorganize_cb */
|
|
|
|
atlas_tex->atlas = NULL;
|
2010-08-02 11:29:10 -04:00
|
|
|
|
2011-01-06 08:25:45 -05:00
|
|
|
_cogl_texture_init (COGL_TEXTURE (atlas_tex),
|
2012-09-07 10:26:34 -04:00
|
|
|
ctx,
|
2012-11-22 16:46:54 -05:00
|
|
|
width, height,
|
2013-06-23 11:18:18 -04:00
|
|
|
internal_format,
|
|
|
|
loader,
|
2011-01-06 08:25:45 -05:00
|
|
|
&cogl_atlas_texture_vtable);
|
|
|
|
|
2012-04-16 09:14:10 -04:00
|
|
|
atlas_tex->sub_texture = NULL;
|
2009-12-04 08:06:32 -05:00
|
|
|
|
2012-11-22 18:01:08 -05:00
|
|
|
atlas_tex->atlas = NULL;
|
|
|
|
|
|
|
|
return _cogl_atlas_texture_object_new (atlas_tex);
|
|
|
|
}
|
|
|
|
|
2013-06-23 11:18:18 -04:00
|
|
|
CoglAtlasTexture *
|
|
|
|
cogl_atlas_texture_new_with_size (CoglContext *ctx,
|
|
|
|
int width,
|
2013-07-01 20:48:54 -04:00
|
|
|
int height)
|
2013-06-23 11:18:18 -04:00
|
|
|
{
|
|
|
|
CoglTextureLoader *loader;
|
|
|
|
|
|
|
|
/* We can't atlas zero-sized textures because it breaks the atlas
|
|
|
|
* data structure */
|
|
|
|
_COGL_RETURN_VAL_IF_FAIL (width > 0 && height > 0, NULL);
|
|
|
|
|
|
|
|
loader = _cogl_texture_create_loader ();
|
|
|
|
loader->src_type = COGL_TEXTURE_SOURCE_TYPE_SIZED;
|
|
|
|
loader->src.sized.width = width;
|
|
|
|
loader->src.sized.height = height;
|
|
|
|
|
|
|
|
return _cogl_atlas_texture_create_base (ctx, width, height,
|
2013-07-01 20:48:54 -04:00
|
|
|
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
|
|
|
|
loader);
|
2013-06-23 11:18:18 -04:00
|
|
|
}
|
|
|
|
|
2012-11-22 18:01:08 -05:00
|
|
|
static CoglBool
|
2013-06-23 11:18:18 -04:00
|
|
|
allocate_space (CoglAtlasTexture *atlas_tex,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
CoglPixelFormat internal_format,
|
|
|
|
CoglError **error)
|
2012-11-22 18:01:08 -05:00
|
|
|
{
|
2013-06-23 11:18:18 -04:00
|
|
|
CoglTexture *tex = COGL_TEXTURE (atlas_tex);
|
2012-11-22 18:01:08 -05:00
|
|
|
CoglContext *ctx = tex->context;
|
|
|
|
CoglAtlas *atlas;
|
|
|
|
GSList *l;
|
|
|
|
|
2013-06-24 06:50:56 -04:00
|
|
|
/* If the texture is in a strange format then we won't use it */
|
2013-06-23 11:18:18 -04:00
|
|
|
if (!_cogl_atlas_texture_can_use_format (internal_format))
|
2013-06-24 06:50:56 -04:00
|
|
|
{
|
|
|
|
COGL_NOTE (ATLAS, "Texture can not be added because the "
|
|
|
|
"format is unsupported");
|
|
|
|
_cogl_set_error (error,
|
|
|
|
COGL_TEXTURE_ERROR,
|
|
|
|
COGL_TEXTURE_ERROR_FORMAT,
|
|
|
|
"Texture format unsuitable for atlasing");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If we can't use FBOs then it will be too slow to migrate textures
|
|
|
|
and we shouldn't use the atlas */
|
|
|
|
if (!cogl_has_feature (ctx, COGL_FEATURE_ID_OFFSCREEN))
|
|
|
|
{
|
|
|
|
_cogl_set_error (error,
|
|
|
|
COGL_SYSTEM_ERROR,
|
|
|
|
COGL_SYSTEM_ERROR_UNSUPPORTED,
|
|
|
|
"Atlasing disabled because migrations "
|
|
|
|
"would be too slow");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2010-11-27 08:15:02 -05:00
|
|
|
/* Look for an existing atlas that can hold the texture */
|
|
|
|
for (l = ctx->atlases; l; l = l->next)
|
2014-04-11 18:26:00 -04:00
|
|
|
{
|
|
|
|
/* We need to take a reference on the atlas before trying to
|
|
|
|
* reserve space because in some circumstances atlas migration
|
|
|
|
* can cause the atlas to be freed */
|
|
|
|
atlas = cogl_object_ref (l->data);
|
|
|
|
/* Try to make some space in the atlas for the texture */
|
|
|
|
if (_cogl_atlas_reserve_space (atlas,
|
|
|
|
/* Add two pixels for the border */
|
|
|
|
width + 2, height + 2,
|
|
|
|
atlas_tex))
|
|
|
|
{
|
|
|
|
/* keep the atlas reference */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cogl_object_unref (atlas);
|
|
|
|
}
|
|
|
|
}
|
2010-11-27 08:15:02 -05:00
|
|
|
|
|
|
|
/* If we couldn't find a suitable atlas then start another */
|
|
|
|
if (l == NULL)
|
2009-12-04 08:06:32 -05:00
|
|
|
{
|
2012-11-09 05:54:32 -05:00
|
|
|
atlas = _cogl_atlas_texture_create_atlas (ctx);
|
2010-11-27 08:15:02 -05:00
|
|
|
COGL_NOTE (ATLAS, "Created new atlas for textures: %p", atlas);
|
|
|
|
if (!_cogl_atlas_reserve_space (atlas,
|
|
|
|
/* Add two pixels for the border */
|
2013-06-23 11:18:18 -04:00
|
|
|
width + 2, height + 2,
|
2010-11-27 08:15:02 -05:00
|
|
|
atlas_tex))
|
|
|
|
{
|
|
|
|
/* Ok, this means we really can't add it to the atlas */
|
|
|
|
cogl_object_unref (atlas);
|
2012-11-22 18:01:08 -05:00
|
|
|
|
|
|
|
_cogl_set_error (error,
|
|
|
|
COGL_SYSTEM_ERROR,
|
|
|
|
COGL_SYSTEM_ERROR_NO_MEMORY,
|
|
|
|
"Not enough memory to atlas texture");
|
|
|
|
return FALSE;
|
2010-11-27 08:15:02 -05:00
|
|
|
}
|
2009-12-04 08:06:32 -05:00
|
|
|
}
|
|
|
|
|
2013-06-23 11:18:18 -04:00
|
|
|
atlas_tex->internal_format = internal_format;
|
|
|
|
|
2010-02-18 11:33:12 -05:00
|
|
|
atlas_tex->atlas = atlas;
|
|
|
|
|
2012-11-22 18:01:08 -05:00
|
|
|
return TRUE;
|
2010-02-18 11:33:12 -05:00
|
|
|
}
|
|
|
|
|
2013-06-23 11:18:18 -04:00
|
|
|
static CoglBool
|
|
|
|
allocate_with_size (CoglAtlasTexture *atlas_tex,
|
|
|
|
CoglTextureLoader *loader,
|
|
|
|
CoglError **error)
|
|
|
|
{
|
|
|
|
CoglTexture *tex = COGL_TEXTURE (atlas_tex);
|
|
|
|
CoglPixelFormat internal_format =
|
|
|
|
_cogl_texture_determine_internal_format (tex, COGL_PIXEL_FORMAT_ANY);
|
|
|
|
|
|
|
|
if (allocate_space (atlas_tex,
|
|
|
|
loader->src.sized.width,
|
|
|
|
loader->src.sized.height,
|
|
|
|
internal_format,
|
|
|
|
error))
|
|
|
|
{
|
|
|
|
_cogl_texture_set_allocated (COGL_TEXTURE (atlas_tex),
|
|
|
|
internal_format,
|
|
|
|
loader->src.sized.width,
|
|
|
|
loader->src.sized.height);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
2010-02-18 11:33:12 -05:00
|
|
|
|
2013-06-23 11:18:18 -04:00
|
|
|
static CoglBool
|
|
|
|
allocate_from_bitmap (CoglAtlasTexture *atlas_tex,
|
|
|
|
CoglTextureLoader *loader,
|
|
|
|
CoglError **error)
|
|
|
|
{
|
|
|
|
CoglTexture *tex = COGL_TEXTURE (atlas_tex);
|
|
|
|
CoglBitmap *bmp = loader->src.bitmap.bitmap;
|
|
|
|
CoglPixelFormat bmp_format = cogl_bitmap_get_format (bmp);
|
|
|
|
int width = cogl_bitmap_get_width (bmp);
|
|
|
|
int height = cogl_bitmap_get_height (bmp);
|
|
|
|
CoglBool can_convert_in_place = loader->src.bitmap.can_convert_in_place;
|
|
|
|
CoglPixelFormat internal_format;
|
|
|
|
CoglBitmap *upload_bmp;
|
2010-02-18 11:33:12 -05:00
|
|
|
|
2013-06-23 11:18:18 -04:00
|
|
|
_COGL_RETURN_VAL_IF_FAIL (atlas_tex->atlas == NULL, FALSE);
|
2010-02-18 11:33:12 -05:00
|
|
|
|
2013-06-23 11:18:18 -04:00
|
|
|
internal_format = _cogl_texture_determine_internal_format (tex, bmp_format);
|
2010-02-18 11:33:12 -05:00
|
|
|
|
2013-06-07 19:28:14 -04:00
|
|
|
upload_bmp =
|
|
|
|
_cogl_atlas_texture_convert_bitmap_for_upload (atlas_tex,
|
|
|
|
bmp,
|
2013-06-23 11:18:18 -04:00
|
|
|
internal_format,
|
2013-06-07 19:28:14 -04:00
|
|
|
can_convert_in_place,
|
|
|
|
error);
|
|
|
|
if (upload_bmp == NULL)
|
2013-06-23 11:18:18 -04:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!allocate_space (atlas_tex,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
internal_format,
|
|
|
|
error))
|
2009-12-04 08:06:32 -05:00
|
|
|
{
|
2013-06-23 11:18:18 -04:00
|
|
|
cogl_object_unref (upload_bmp);
|
|
|
|
return FALSE;
|
2009-12-04 08:06:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Defer to set_region so that we can share the code for copying the
|
2011-08-31 12:22:20 -04:00
|
|
|
edge pixels to the border. */
|
2012-11-08 12:54:10 -05:00
|
|
|
if (!_cogl_atlas_texture_set_region_with_border (atlas_tex,
|
|
|
|
0, /* src_x */
|
|
|
|
0, /* src_y */
|
|
|
|
0, /* dst_x */
|
|
|
|
0, /* dst_y */
|
2013-06-23 11:18:18 -04:00
|
|
|
width, /* dst_width */
|
|
|
|
height, /* dst_height */
|
2013-06-07 19:28:14 -04:00
|
|
|
upload_bmp,
|
2012-11-08 12:54:10 -05:00
|
|
|
error))
|
|
|
|
{
|
2013-06-23 11:18:18 -04:00
|
|
|
_cogl_atlas_texture_remove_from_atlas (atlas_tex);
|
2013-06-07 19:28:14 -04:00
|
|
|
cogl_object_unref (upload_bmp);
|
2013-06-23 11:18:18 -04:00
|
|
|
return FALSE;
|
2012-11-08 12:54:10 -05:00
|
|
|
}
|
2010-07-07 13:44:16 -04:00
|
|
|
|
2013-06-07 19:28:14 -04:00
|
|
|
cogl_object_unref (upload_bmp);
|
2009-12-04 08:06:32 -05:00
|
|
|
|
2013-06-23 11:18:18 -04:00
|
|
|
_cogl_texture_set_allocated (tex, internal_format, width, height);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static CoglBool
|
|
|
|
_cogl_atlas_texture_allocate (CoglTexture *tex,
|
|
|
|
CoglError **error)
|
|
|
|
{
|
|
|
|
CoglAtlasTexture *atlas_tex = COGL_ATLAS_TEXTURE (tex);
|
|
|
|
CoglTextureLoader *loader = tex->loader;
|
|
|
|
|
|
|
|
_COGL_RETURN_VAL_IF_FAIL (loader, FALSE);
|
|
|
|
|
|
|
|
switch (loader->src_type)
|
|
|
|
{
|
|
|
|
case COGL_TEXTURE_SOURCE_TYPE_SIZED:
|
|
|
|
return allocate_with_size (atlas_tex, loader, error);
|
|
|
|
case COGL_TEXTURE_SOURCE_TYPE_BITMAP:
|
|
|
|
return allocate_from_bitmap (atlas_tex, loader, error);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_return_val_if_reached (FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
CoglAtlasTexture *
|
|
|
|
_cogl_atlas_texture_new_from_bitmap (CoglBitmap *bmp,
|
2013-07-01 20:48:54 -04:00
|
|
|
CoglBool can_convert_in_place)
|
2013-06-23 11:18:18 -04:00
|
|
|
{
|
|
|
|
CoglTextureLoader *loader;
|
|
|
|
|
|
|
|
_COGL_RETURN_VAL_IF_FAIL (cogl_is_bitmap (bmp), NULL);
|
|
|
|
|
|
|
|
loader = _cogl_texture_create_loader ();
|
|
|
|
loader->src_type = COGL_TEXTURE_SOURCE_TYPE_BITMAP;
|
|
|
|
loader->src.bitmap.bitmap = cogl_object_ref (bmp);
|
|
|
|
loader->src.bitmap.can_convert_in_place = can_convert_in_place;
|
|
|
|
|
|
|
|
return _cogl_atlas_texture_create_base (_cogl_bitmap_get_context (bmp),
|
|
|
|
cogl_bitmap_get_width (bmp),
|
|
|
|
cogl_bitmap_get_height (bmp),
|
2013-07-01 20:48:54 -04:00
|
|
|
cogl_bitmap_get_format (bmp),
|
2013-06-23 11:18:18 -04:00
|
|
|
loader);
|
2009-12-04 08:06:32 -05:00
|
|
|
}
|
|
|
|
|
2013-06-07 20:58:05 -04:00
|
|
|
CoglAtlasTexture *
|
2013-07-01 20:48:54 -04:00
|
|
|
cogl_atlas_texture_new_from_bitmap (CoglBitmap *bmp)
|
2013-06-07 20:58:05 -04:00
|
|
|
{
|
2013-07-01 20:48:54 -04:00
|
|
|
return _cogl_atlas_texture_new_from_bitmap (bmp, FALSE);
|
2013-06-07 20:58:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
CoglAtlasTexture *
|
|
|
|
cogl_atlas_texture_new_from_data (CoglContext *ctx,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
CoglPixelFormat format,
|
|
|
|
int rowstride,
|
|
|
|
const uint8_t *data,
|
|
|
|
CoglError **error)
|
|
|
|
{
|
|
|
|
CoglBitmap *bmp;
|
|
|
|
CoglAtlasTexture *atlas_tex;
|
|
|
|
|
|
|
|
_COGL_RETURN_VAL_IF_FAIL (format != COGL_PIXEL_FORMAT_ANY, NULL);
|
|
|
|
_COGL_RETURN_VAL_IF_FAIL (data != NULL, NULL);
|
|
|
|
|
|
|
|
/* Rowstride from width if not given */
|
|
|
|
if (rowstride == 0)
|
|
|
|
rowstride = width * _cogl_pixel_format_get_bytes_per_pixel (format);
|
|
|
|
|
|
|
|
/* Wrap the data into a bitmap */
|
|
|
|
bmp = cogl_bitmap_new_for_data (ctx,
|
|
|
|
width, height,
|
|
|
|
format,
|
|
|
|
rowstride,
|
|
|
|
(uint8_t *) data);
|
|
|
|
|
2013-07-01 20:48:54 -04:00
|
|
|
atlas_tex = cogl_atlas_texture_new_from_bitmap (bmp);
|
2013-06-07 20:58:05 -04:00
|
|
|
|
|
|
|
cogl_object_unref (bmp);
|
|
|
|
|
2013-06-23 11:18:18 -04:00
|
|
|
if (atlas_tex &&
|
|
|
|
!cogl_texture_allocate (COGL_TEXTURE (atlas_tex), error))
|
|
|
|
{
|
|
|
|
cogl_object_unref (atlas_tex);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-06-07 20:58:05 -04:00
|
|
|
return atlas_tex;
|
|
|
|
}
|
|
|
|
|
|
|
|
CoglAtlasTexture *
|
|
|
|
cogl_atlas_texture_new_from_file (CoglContext *ctx,
|
|
|
|
const char *filename,
|
|
|
|
CoglError **error)
|
|
|
|
{
|
|
|
|
CoglBitmap *bmp;
|
|
|
|
CoglAtlasTexture *atlas_tex = NULL;
|
|
|
|
|
|
|
|
_COGL_RETURN_VAL_IF_FAIL (error == NULL || *error == NULL, NULL);
|
|
|
|
|
|
|
|
bmp = cogl_bitmap_new_from_file (filename, error);
|
|
|
|
if (bmp == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
atlas_tex = _cogl_atlas_texture_new_from_bitmap (bmp,
|
2013-07-01 20:48:54 -04:00
|
|
|
TRUE); /* convert in-place */
|
2013-06-07 20:58:05 -04:00
|
|
|
|
|
|
|
cogl_object_unref (bmp);
|
|
|
|
|
|
|
|
return atlas_tex;
|
|
|
|
}
|
|
|
|
|
2011-03-30 07:53:50 -04:00
|
|
|
void
|
2012-11-09 05:54:32 -05:00
|
|
|
_cogl_atlas_texture_add_reorganize_callback (CoglContext *ctx,
|
|
|
|
GHookFunc callback,
|
2011-03-30 07:53:50 -04:00
|
|
|
void *user_data)
|
|
|
|
{
|
2012-11-09 05:54:32 -05:00
|
|
|
GHook *hook = g_hook_alloc (&ctx->atlas_reorganize_callbacks);
|
2011-03-30 07:53:50 -04:00
|
|
|
hook->func = callback;
|
|
|
|
hook->data = user_data;
|
|
|
|
g_hook_prepend (&ctx->atlas_reorganize_callbacks, hook);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-11-09 05:54:32 -05:00
|
|
|
_cogl_atlas_texture_remove_reorganize_callback (CoglContext *ctx,
|
|
|
|
GHookFunc callback,
|
2011-03-30 07:53:50 -04:00
|
|
|
void *user_data)
|
|
|
|
{
|
2012-11-09 05:54:32 -05:00
|
|
|
GHook *hook = g_hook_find_func_data (&ctx->atlas_reorganize_callbacks,
|
|
|
|
FALSE,
|
|
|
|
callback,
|
|
|
|
user_data);
|
2011-03-30 07:53:50 -04:00
|
|
|
|
|
|
|
if (hook)
|
|
|
|
g_hook_destroy_link (&ctx->atlas_reorganize_callbacks, hook);
|
|
|
|
}
|
|
|
|
|
2012-02-09 06:19:04 -05:00
|
|
|
static CoglTextureType
|
|
|
|
_cogl_atlas_texture_get_type (CoglTexture *tex)
|
|
|
|
{
|
|
|
|
return COGL_TEXTURE_TYPE_2D;
|
|
|
|
}
|
|
|
|
|
2009-12-04 08:06:32 -05:00
|
|
|
static const CoglTextureVtable
|
|
|
|
cogl_atlas_texture_vtable =
|
|
|
|
{
|
2012-04-04 10:09:43 -04:00
|
|
|
FALSE, /* not primitive */
|
2012-11-22 18:01:08 -05:00
|
|
|
_cogl_atlas_texture_allocate,
|
2009-12-04 08:06:32 -05:00
|
|
|
_cogl_atlas_texture_set_region,
|
2010-11-12 11:02:13 -05:00
|
|
|
NULL, /* get_data */
|
2009-12-04 08:06:32 -05:00
|
|
|
_cogl_atlas_texture_foreach_sub_texture_in_region,
|
|
|
|
_cogl_atlas_texture_get_max_waste,
|
|
|
|
_cogl_atlas_texture_is_sliced,
|
|
|
|
_cogl_atlas_texture_can_hardware_repeat,
|
|
|
|
_cogl_atlas_texture_transform_coords_to_gl,
|
2010-01-18 04:22:04 -05:00
|
|
|
_cogl_atlas_texture_transform_quad_coords_to_gl,
|
2009-12-04 08:06:32 -05:00
|
|
|
_cogl_atlas_texture_get_gl_texture,
|
2012-09-10 15:35:39 -04:00
|
|
|
_cogl_atlas_texture_gl_flush_legacy_texobj_filters,
|
2010-06-09 12:39:59 -04:00
|
|
|
_cogl_atlas_texture_pre_paint,
|
2010-01-18 04:22:04 -05:00
|
|
|
_cogl_atlas_texture_ensure_non_quad_rendering,
|
2012-09-10 15:35:39 -04:00
|
|
|
_cogl_atlas_texture_gl_flush_legacy_texobj_wrap_modes,
|
2009-12-04 08:06:32 -05:00
|
|
|
_cogl_atlas_texture_get_format,
|
|
|
|
_cogl_atlas_texture_get_gl_format,
|
2012-02-09 06:19:04 -05:00
|
|
|
_cogl_atlas_texture_get_type,
|
2012-04-04 10:09:43 -04:00
|
|
|
NULL, /* is_foreign */
|
|
|
|
NULL /* set_auto_mipmap */
|
2009-12-04 08:06:32 -05:00
|
|
|
};
|