diff options
author | Neil Roberts <neil@linux.intel.com> | 2012-02-09 11:19:04 +0000 |
---|---|---|
committer | Neil Roberts <neil@linux.intel.com> | 2012-02-13 17:02:46 +0000 |
commit | 8012eee31f01011d4b6572d924d7a979470c4afe (patch) | |
tree | 32ff8c37bdea9052d5c31aa9a96fdde0a12cac1e | |
parent | 9b87e8602cdac839edd82c3a0c0974ebf20bc7fe (diff) | |
download | cogl-8012eee31f01011d4b6572d924d7a979470c4afe.tar.gz |
Add _cogl_texture_get_type()
This adds an internal function to get the type of the underlying
hardware texture for any CoglTexture. It can return one of three
values to represent 2D textures, 3D textures or rectangle textures.
The idea is that this can be used as a replacement for
cogl_texture_get_gl_texture when only the target is required to make
it a bit less GL-centric. The implementation adds a new virtual
function which all of the texture backends now implement.
The enum is in a public header because a later patch will want to use
it from the CoglPipeline API. We may want to consider making the
function public too later.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
-rw-r--r-- | cogl/cogl-atlas-texture.c | 7 | ||||
-rw-r--r-- | cogl/cogl-sub-texture.c | 9 | ||||
-rw-r--r-- | cogl/cogl-texture-2d-sliced.c | 7 | ||||
-rw-r--r-- | cogl/cogl-texture-2d.c | 7 | ||||
-rw-r--r-- | cogl/cogl-texture-3d.c | 7 | ||||
-rw-r--r-- | cogl/cogl-texture-private.h | 14 | ||||
-rw-r--r-- | cogl/cogl-texture-rectangle.c | 7 | ||||
-rw-r--r-- | cogl/cogl-texture.c | 6 | ||||
-rw-r--r-- | cogl/cogl-texture.h | 18 | ||||
-rw-r--r-- | cogl/winsys/cogl-texture-pixmap-x11.c | 13 | ||||
-rw-r--r-- | doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt | 1 |
11 files changed, 96 insertions, 0 deletions
diff --git a/cogl/cogl-atlas-texture.c b/cogl/cogl-atlas-texture.c index e3ecf80a..06aed4af 100644 --- a/cogl/cogl-atlas-texture.c +++ b/cogl/cogl-atlas-texture.c @@ -809,6 +809,12 @@ _cogl_atlas_texture_remove_reorganize_callback (GHookFunc callback, g_hook_destroy_link (&ctx->atlas_reorganize_callbacks, hook); } +static CoglTextureType +_cogl_atlas_texture_get_type (CoglTexture *tex) +{ + return COGL_TEXTURE_TYPE_2D; +} + static const CoglTextureVtable cogl_atlas_texture_vtable = { @@ -829,5 +835,6 @@ cogl_atlas_texture_vtable = _cogl_atlas_texture_get_gl_format, _cogl_atlas_texture_get_width, _cogl_atlas_texture_get_height, + _cogl_atlas_texture_get_type, NULL /* is_foreign */ }; diff --git a/cogl/cogl-sub-texture.c b/cogl/cogl-sub-texture.c index 3967ecd6..99ecfcc5 100644 --- a/cogl/cogl-sub-texture.c +++ b/cogl/cogl-sub-texture.c @@ -416,6 +416,14 @@ _cogl_sub_texture_get_height (CoglTexture *tex) return sub_tex->sub_height; } +static CoglTextureType +_cogl_sub_texture_get_type (CoglTexture *tex) +{ + CoglSubTexture *sub_tex = COGL_SUB_TEXTURE (tex); + + return _cogl_texture_get_type (sub_tex->full_texture); +} + static const CoglTextureVtable cogl_sub_texture_vtable = { @@ -436,5 +444,6 @@ cogl_sub_texture_vtable = _cogl_sub_texture_get_gl_format, _cogl_sub_texture_get_width, _cogl_sub_texture_get_height, + _cogl_sub_texture_get_type, NULL /* is_foreign */ }; diff --git a/cogl/cogl-texture-2d-sliced.c b/cogl/cogl-texture-2d-sliced.c index 03d3299c..7220bf24 100644 --- a/cogl/cogl-texture-2d-sliced.c +++ b/cogl/cogl-texture-2d-sliced.c @@ -1293,6 +1293,12 @@ _cogl_texture_2d_sliced_get_height (CoglTexture *tex) return COGL_TEXTURE_2D_SLICED (tex)->height; } +static CoglTextureType +_cogl_texture_2d_sliced_get_type (CoglTexture *tex) +{ + return COGL_TEXTURE_TYPE_2D; +} + static const CoglTextureVtable cogl_texture_2d_sliced_vtable = { @@ -1313,5 +1319,6 @@ cogl_texture_2d_sliced_vtable = _cogl_texture_2d_sliced_get_gl_format, _cogl_texture_2d_sliced_get_width, _cogl_texture_2d_sliced_get_height, + _cogl_texture_2d_sliced_get_type, _cogl_texture_2d_sliced_is_foreign }; diff --git a/cogl/cogl-texture-2d.c b/cogl/cogl-texture-2d.c index 794f1864..89bf63da 100644 --- a/cogl/cogl-texture-2d.c +++ b/cogl/cogl-texture-2d.c @@ -859,6 +859,12 @@ _cogl_texture_2d_is_foreign (CoglTexture *tex) return COGL_TEXTURE_2D (tex)->is_foreign; } +static CoglTextureType +_cogl_texture_2d_get_type (CoglTexture *tex) +{ + return COGL_TEXTURE_TYPE_2D; +} + static const CoglTextureVtable cogl_texture_2d_vtable = { @@ -879,5 +885,6 @@ cogl_texture_2d_vtable = _cogl_texture_2d_get_gl_format, _cogl_texture_2d_get_width, _cogl_texture_2d_get_height, + _cogl_texture_2d_get_type, _cogl_texture_2d_is_foreign }; diff --git a/cogl/cogl-texture-3d.c b/cogl/cogl-texture-3d.c index d6e36dd4..f332b68f 100644 --- a/cogl/cogl-texture-3d.c +++ b/cogl/cogl-texture-3d.c @@ -592,6 +592,12 @@ _cogl_texture_3d_get_height (CoglTexture *tex) return COGL_TEXTURE_3D (tex)->height; } +static CoglTextureType +_cogl_texture_3d_get_type (CoglTexture *tex) +{ + return COGL_TEXTURE_TYPE_3D; +} + static const CoglTextureVtable cogl_texture_3d_vtable = { @@ -612,5 +618,6 @@ cogl_texture_3d_vtable = _cogl_texture_3d_get_gl_format, _cogl_texture_3d_get_width, _cogl_texture_3d_get_height, + _cogl_texture_3d_get_type, NULL /* is_foreign */ }; diff --git a/cogl/cogl-texture-private.h b/cogl/cogl-texture-private.h index 1048b210..2f7d9251 100644 --- a/cogl/cogl-texture-private.h +++ b/cogl/cogl-texture-private.h @@ -121,6 +121,8 @@ struct _CoglTextureVtable int (* get_width) (CoglTexture *tex); int (* get_height) (CoglTexture *tex); + CoglTextureType (* get_type) (CoglTexture *tex); + gboolean (* is_foreign) (CoglTexture *tex); }; @@ -274,4 +276,16 @@ _cogl_texture_spans_foreach_in_region (CoglSpan *x_spans, CoglMetaTextureCallback callback, void *user_data); +/* + * _cogl_texture_get_type: + * @texture: a #CoglTexture pointer + * + * Retrieves the texture type of the underlying hardware texture that + * this #CoglTexture will use. + * + * Return value: The type of the hardware texture. + */ +CoglTextureType +_cogl_texture_get_type (CoglTexture *texture); + #endif /* __COGL_TEXTURE_PRIVATE_H */ diff --git a/cogl/cogl-texture-rectangle.c b/cogl/cogl-texture-rectangle.c index c43779b2..556b718e 100644 --- a/cogl/cogl-texture-rectangle.c +++ b/cogl/cogl-texture-rectangle.c @@ -579,6 +579,12 @@ _cogl_texture_rectangle_is_foreign (CoglTexture *tex) return COGL_TEXTURE_RECTANGLE (tex)->is_foreign; } +static CoglTextureType +_cogl_texture_rectangle_get_type (CoglTexture *tex) +{ + return COGL_TEXTURE_TYPE_RECTANGLE; +} + static const CoglTextureVtable cogl_texture_rectangle_vtable = { @@ -599,5 +605,6 @@ cogl_texture_rectangle_vtable = _cogl_texture_rectangle_get_gl_format, _cogl_texture_rectangle_get_width, _cogl_texture_rectangle_get_height, + _cogl_texture_rectangle_get_type, _cogl_texture_rectangle_is_foreign }; diff --git a/cogl/cogl-texture.c b/cogl/cogl-texture.c index d957a944..6f6f9630 100644 --- a/cogl/cogl-texture.c +++ b/cogl/cogl-texture.c @@ -643,6 +643,12 @@ cogl_texture_get_gl_texture (CoglTexture *texture, out_gl_handle, out_gl_target); } +CoglTextureType +_cogl_texture_get_type (CoglTexture *texture) +{ + return texture->vtable->get_type (texture); +} + void _cogl_texture_set_filters (CoglTexture *texture, GLenum min_filter, diff --git a/cogl/cogl-texture.h b/cogl/cogl-texture.h index 6fedfb25..36fde2a2 100644 --- a/cogl/cogl-texture.h +++ b/cogl/cogl-texture.h @@ -78,6 +78,24 @@ typedef enum { COGL_TEXTURE_ERROR_TYPE } CoglTextureError; +/** + * CoglTextureType: + * @COGL_TEXTURE_TYPE_2D: A #CoglTexture2D + * @COGL_TEXTURE_TYPE_3D: A #CoglTexture3D + * @COGL_TEXTURE_TYPE_RECTANGLE: A #CoglTextureRectangle + * + * Constants representing the underlying hardware texture type of a + * #CoglTexture. + * + * Stability: unstable + * Since: 1.10 + */ +typedef enum { + COGL_TEXTURE_TYPE_2D, + COGL_TEXTURE_TYPE_3D, + COGL_TEXTURE_TYPE_RECTANGLE +} CoglTextureType; + GQuark cogl_texture_error_quark (void); /** diff --git a/cogl/winsys/cogl-texture-pixmap-x11.c b/cogl/winsys/cogl-texture-pixmap-x11.c index 33d74ba3..1b1a1b42 100644 --- a/cogl/winsys/cogl-texture-pixmap-x11.c +++ b/cogl/winsys/cogl-texture-pixmap-x11.c @@ -998,6 +998,18 @@ _cogl_texture_pixmap_x11_get_height (CoglTexture *tex) return tex_pixmap->height; } +static CoglTextureType +_cogl_texture_pixmap_x11_get_type (CoglTexture *tex) +{ + CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex); + CoglTexture *child_tex; + + child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap); + + /* Forward on to the child texture */ + return _cogl_texture_get_type (child_tex); +} + static void _cogl_texture_pixmap_x11_free (CoglTexturePixmapX11 *tex_pixmap) { @@ -1049,5 +1061,6 @@ cogl_texture_pixmap_x11_vtable = _cogl_texture_pixmap_x11_get_gl_format, _cogl_texture_pixmap_x11_get_width, _cogl_texture_pixmap_x11_get_height, + _cogl_texture_pixmap_x11_get_type, NULL /* is_foreign */ }; diff --git a/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt b/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt index 36f49193..2c2b561f 100644 --- a/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt +++ b/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt @@ -318,6 +318,7 @@ cogl_texture_get_format cogl_texture_is_sliced cogl_texture_get_data cogl_texture_set_region +CoglTextureType <SUBSECTION Private> COGL_TEXTURE_MAX_WASTE |