[cogl/wip/neil/master-next: 1/4] Add cogl_texture_get_type()
- From: Neil Roberts <nroberts src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl/wip/neil/master-next: 1/4] Add cogl_texture_get_type()
- Date: Thu, 9 Feb 2012 14:35:17 +0000 (UTC)
commit 8e0714ee8ff5bb1b5dcc00107cd7bf9554edd67b
Author: Neil Roberts <neil linux intel com>
Date: Thu Feb 9 11:19:04 2012 +0000
Add cogl_texture_get_type()
This adds a public 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.
cogl/cogl-atlas-texture.c | 7 ++++
cogl/cogl-sub-texture.c | 9 +++++
cogl/cogl-texture-2d-sliced.c | 7 ++++
cogl/cogl-texture-2d.c | 7 ++++
cogl/cogl-texture-3d.c | 7 ++++
cogl/cogl-texture-private.h | 2 +
cogl/cogl-texture-rectangle.c | 7 ++++
cogl/cogl-texture.c | 6 ++++
cogl/cogl-texture.h | 32 ++++++++++++++++++++
cogl/winsys/cogl-texture-pixmap-x11.c | 13 ++++++++
.../cogl-2.0-experimental-sections.txt | 1 +
11 files changed, 98 insertions(+), 0 deletions(-)
---
diff --git a/cogl/cogl-atlas-texture.c b/cogl/cogl-atlas-texture.c
index e3ecf80..06aed4a 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 3967ecd..5d060f0 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 03d3299..7220bf2 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 794f186..89bf63d 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 d6e36dd..f332b68 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 1048b21..a30bdbd 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);
};
diff --git a/cogl/cogl-texture-rectangle.c b/cogl/cogl-texture-rectangle.c
index c43779b..556b718 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 d957a94..b699361 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 6fedfb2..26bc6f2 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);
/**
@@ -335,6 +353,20 @@ cogl_texture_get_gl_texture (CoglTexture *texture,
GLenum *out_gl_target);
/**
+ * 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.
+ * Stability: unstable
+ * Since: 1.10
+ */
+CoglTextureType
+cogl_texture_get_type (CoglTexture *texture);
+
+/**
* cogl_texture_get_data:
* @texture a #CoglTexture pointer.
* @format: the #CoglPixelFormat to store the texture as.
diff --git a/cogl/winsys/cogl-texture-pixmap-x11.c b/cogl/winsys/cogl-texture-pixmap-x11.c
index 33d74ba..66360d8 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 36f4919..74924f6 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
+cogl_texture_get_type
<SUBSECTION Private>
COGL_TEXTURE_MAX_WASTE
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]