[Cogl] [PATCH] auto-texture: Adds cogl-auto-texture.h header

Robert Bragg robert at sixbynine.org
Thu Jan 2 07:09:24 PST 2014


From: Robert Bragg <robert at linux.intel.com>

This moves all of the automagic texture constructor prototypes from
cogl-texture.h into a new deprecated/cogl-auto-texture.h file. This also
moves cogl_texture_new_from_sub_texture() into
deprecated/cogl-auto-texture.c
---
 cogl/Makefile.am                    |   1 +
 cogl/cogl-texture.c                 |  13 ---
 cogl/cogl-texture.h                 | 166 ----------------------------
 cogl/cogl.h                         |   2 +
 cogl/deprecated/cogl-auto-texture.c |  19 +++-
 cogl/deprecated/cogl-auto-texture.h | 215 ++++++++++++++++++++++++++++++++++++
 6 files changed, 234 insertions(+), 182 deletions(-)
 create mode 100644 cogl/deprecated/cogl-auto-texture.h

diff --git a/cogl/Makefile.am b/cogl/Makefile.am
index b9f63c3..dffec07 100644
--- a/cogl/Makefile.am
+++ b/cogl/Makefile.am
@@ -78,6 +78,7 @@ cogl_deprecated_h = \
 	$(srcdir)/deprecated/cogl-type-casts.h       	\
 	$(srcdir)/deprecated/cogl-framebuffer-deprecated.h \
 	$(srcdir)/deprecated/cogl-texture-deprecated.h	\
+	$(srcdir)/deprecated/cogl-auto-texture.h	\
 	$(NULL)
 
 # public 1.x api headers
diff --git a/cogl/cogl-texture.c b/cogl/cogl-texture.c
index 2aa62aa..eabe8ce 100644
--- a/cogl/cogl-texture.c
+++ b/cogl/cogl-texture.c
@@ -194,19 +194,6 @@ _cogl_texture_is_foreign (CoglTexture *texture)
     return FALSE;
 }
 
-CoglTexture *
-cogl_texture_new_from_sub_texture (CoglTexture *full_texture,
-                                   int sub_x,
-                                   int sub_y,
-                                   int sub_width,
-                                   int sub_height)
-{
-  _COGL_GET_CONTEXT (ctx, NULL);
-  return COGL_TEXTURE (cogl_sub_texture_new (ctx,
-                                             full_texture, sub_x, sub_y,
-                                             sub_width, sub_height));
-}
-
 unsigned int
 cogl_texture_get_width (CoglTexture *texture)
 {
diff --git a/cogl/cogl-texture.h b/cogl/cogl-texture.h
index 55b3be9..49ba745 100644
--- a/cogl/cogl-texture.h
+++ b/cogl/cogl-texture.h
@@ -110,141 +110,6 @@ typedef enum {
 uint32_t cogl_texture_error_quark (void);
 
 /**
- * cogl_texture_new_with_size:
- * @width: width of texture in pixels.
- * @height: height of texture in pixels.
- * @flags: Optional flags for the texture, or %COGL_TEXTURE_NONE
- * @internal_format: the #CoglPixelFormat to use for the GPU storage of the
- *    texture.
- *
- * Creates a new #CoglTexture with the specified dimensions and pixel format.
- *
- * Return value: (transfer full): A newly created #CoglTexture or %NULL on failure
- *
- * Since: 0.8
- */
-CoglTexture *
-cogl_texture_new_with_size (unsigned int width,
-                            unsigned int height,
-                            CoglTextureFlags flags,
-                            CoglPixelFormat internal_format);
-
-/**
- * cogl_texture_new_from_file:
- * @filename: the file to load
- * @flags: Optional flags for the texture, or %COGL_TEXTURE_NONE
- * @internal_format: the #CoglPixelFormat to use for the GPU storage of the
- *    texture. If %COGL_PIXEL_FORMAT_ANY is given then a premultiplied
- *    format similar to the format of the source data will be used. The
- *    default blending equations of Cogl expect premultiplied color data;
- *    the main use of passing a non-premultiplied format here is if you
- *    have non-premultiplied source data and are going to adjust the blend
- *    mode (see cogl_material_set_blend()) or use the data for something
- *    other than straight blending.
- * @error: return location for a #CoglError or %NULL
- *
- * Creates a #CoglTexture from an image file.
- *
- * Return value: (transfer full): A newly created #CoglTexture or
- *               %NULL on failure
- *
- * Since: 0.8
- */
-CoglTexture *
-cogl_texture_new_from_file (const char       *filename,
-                            CoglTextureFlags   flags,
-                            CoglPixelFormat    internal_format,
-                            CoglError           **error);
-
-/**
- * cogl_texture_new_from_data:
- * @width: width of texture in pixels
- * @height: height of texture in pixels
- * @flags: Optional flags for the texture, or %COGL_TEXTURE_NONE
- * @format: the #CoglPixelFormat the buffer is stored in in RAM
- * @internal_format: the #CoglPixelFormat that will be used for storing
- *    the buffer on the GPU. If COGL_PIXEL_FORMAT_ANY is given then a
- *    premultiplied format similar to the format of the source data will
- *    be used. The default blending equations of Cogl expect premultiplied
- *    color data; the main use of passing a non-premultiplied format here
- *    is if you have non-premultiplied source data and are going to adjust
- *    the blend mode (see cogl_material_set_blend()) or use the data for
- *    something other than straight blending.
- * @rowstride: the memory offset in bytes between the starts of
- *    scanlines in @data
- * @data: pointer the memory region where the source buffer resides
- *
- * Creates a new #CoglTexture based on data residing in memory.
- *
- * Return value: (transfer full): A newly created #CoglTexture or
- *               %NULL on failure
- *
- * Since: 0.8
- */
-CoglTexture *
-cogl_texture_new_from_data (int width,
-                            int height,
-                            CoglTextureFlags flags,
-                            CoglPixelFormat format,
-                            CoglPixelFormat internal_format,
-                            int rowstride,
-                            const uint8_t *data);
-
-/**
- * cogl_texture_new_from_foreign:
- * @gl_handle: opengl handle of foreign texture.
- * @gl_target: opengl target type of foreign texture
- * @width: width of foreign texture
- * @height: height of foreign texture.
- * @x_pot_waste: horizontal waste on the right hand edge of the texture.
- * @y_pot_waste: vertical waste on the bottom edge of the texture.
- * @format: format of the foreign texture.
- *
- * Creates a #CoglTexture based on an existing OpenGL texture; the
- * width, height and format are passed along since it is not always
- * possible to query these from OpenGL.
- *
- * The waste arguments allow you to create a Cogl texture that maps to
- * a region smaller than the real OpenGL texture. For instance if your
- * hardware only supports power-of-two textures you may load a
- * non-power-of-two image into a larger power-of-two texture and use
- * the waste arguments to tell Cogl which region should be mapped to
- * the texture coordinate range [0:1].
- *
- * Return value: (transfer full): A newly created #CoglTexture or
- *               %NULL on failure
- *
- * Since: 0.8
- */
-CoglTexture *
-cogl_texture_new_from_foreign (unsigned int gl_handle,
-                               unsigned int gl_target,
-                               unsigned int width,
-                               unsigned int height,
-                               unsigned int x_pot_waste,
-                               unsigned int y_pot_waste,
-                               CoglPixelFormat format);
-
-/**
- * cogl_texture_new_from_bitmap:
- * @bitmap: A #CoglBitmap pointer
- * @flags: Optional flags for the texture, or %COGL_TEXTURE_NONE
- * @internal_format: the #CoglPixelFormat to use for the GPU storage of the
- * texture
- *
- * Creates a #CoglTexture from a #CoglBitmap.
- *
- * Return value: (transfer full): A newly created #CoglTexture or
- *               %NULL on failure
- *
- * Since: 1.0
- */
-CoglTexture *
-cogl_texture_new_from_bitmap (CoglBitmap *bitmap,
-                              CoglTextureFlags flags,
-                              CoglPixelFormat internal_format);
-
-/**
  * cogl_is_texture:
  * @object: A #CoglObject pointer
  *
@@ -578,37 +443,6 @@ cogl_texture_set_region_from_bitmap (CoglTexture *texture,
 #endif
 
 /**
- * cogl_texture_new_from_sub_texture:
- * @full_texture: a #CoglTexture pointer
- * @sub_x: X coordinate of the top-left of the subregion
- * @sub_y: Y coordinate of the top-left of the subregion
- * @sub_width: Width in pixels of the subregion
- * @sub_height: Height in pixels of the subregion
- *
- * Creates a new texture which represents a subregion of another
- * texture. The GL resources will be shared so that no new texture
- * data is actually allocated.
- *
- * Sub textures have undefined behaviour texture coordinates outside
- * of the range [0,1] are used. They also do not work with
- * CoglVertexBuffers.
- *
- * The sub texture will keep a reference to the full texture so you do
- * not need to keep one separately if you only want to use the sub
- * texture.
- *
- * Return value: (transfer full): A newly created #CoglTexture or
- *               %NULL on failure
- * Since: 1.2
- */
-CoglTexture *
-cogl_texture_new_from_sub_texture (CoglTexture *full_texture,
-                                   int sub_x,
-                                   int sub_y,
-                                   int sub_width,
-                                   int sub_height);
-
-/**
  * cogl_texture_allocate:
  * @texture: A #CoglTexture
  * @error: A #CoglError to return exceptional errors or %NULL
diff --git a/cogl/cogl.h b/cogl/cogl.h
index 56fd6c3..e3ab0a0 100644
--- a/cogl/cogl.h
+++ b/cogl/cogl.h
@@ -88,6 +88,8 @@
  * they enable the experimental api... */
 #include <cogl/deprecated/cogl-type-casts.h>
 
+#include <cogl/deprecated/cogl-auto-texture.h>
+
 /*
  * 2.0 api that's compatible with the 1.x api...
  */
diff --git a/cogl/deprecated/cogl-auto-texture.c b/cogl/deprecated/cogl-auto-texture.c
index 172d1f0..96c5101 100644
--- a/cogl/deprecated/cogl-auto-texture.c
+++ b/cogl/deprecated/cogl-auto-texture.c
@@ -27,9 +27,7 @@
  *  Robert Bragg   <robert at linux.intel.com>
  */
 
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
+#include <config.h>
 
 #include "cogl-context-private.h"
 #include "cogl-texture.h"
@@ -47,6 +45,8 @@
 #include "cogl-sub-texture.h"
 #include "cogl-texture-2d-gl.h"
 
+#include "deprecated/cogl-auto-texture.h"
+
 static CoglTexture *
 _cogl_texture_new_from_bitmap (CoglBitmap *bitmap,
                                CoglTextureFlags flags,
@@ -397,3 +397,16 @@ cogl_texture_new_from_foreign (GLuint           gl_handle,
       return tex;
     }
 }
+
+CoglTexture *
+cogl_texture_new_from_sub_texture (CoglTexture *full_texture,
+                                   int sub_x,
+                                   int sub_y,
+                                   int sub_width,
+                                   int sub_height)
+{
+  _COGL_GET_CONTEXT (ctx, NULL);
+  return COGL_TEXTURE (cogl_sub_texture_new (ctx,
+                                             full_texture, sub_x, sub_y,
+                                             sub_width, sub_height));
+}
diff --git a/cogl/deprecated/cogl-auto-texture.h b/cogl/deprecated/cogl-auto-texture.h
new file mode 100644
index 0000000..e4eb6ca
--- /dev/null
+++ b/cogl/deprecated/cogl-auto-texture.h
@@ -0,0 +1,215 @@
+/*
+ * Cogl
+ *
+ * An object oriented GL/GLES Abstraction/Utility Layer
+ *
+ * Copyright (C) 2014 Intel Corporation.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ *
+ */
+
+#ifndef __COGL_AUTO_TEXTURE_H__
+#define __COGL_AUTO_TEXTURE_H__
+
+COGL_BEGIN_DECLS
+
+/**
+ * cogl_texture_new_with_size:
+ * @width: width of texture in pixels.
+ * @height: height of texture in pixels.
+ * @flags: Optional flags for the texture, or %COGL_TEXTURE_NONE
+ * @internal_format: the #CoglPixelFormat to use for the GPU storage of the
+ *    texture.
+ *
+ * Creates a new #CoglTexture with the specified dimensions and pixel format.
+ *
+ * Return value: (transfer full): A newly created #CoglTexture or %NULL on failure
+ *
+ * Since: 0.8
+ * Deprecated: 1.18: Use specific constructors such as
+ *                   cogl_texture_2d_new_with_size()
+ */
+COGL_DEPRECATED_IN_1_18_FOR(cogl_texture_2d_new_with_size__OR__cogl_texture_2d_sliced_new_with_size)
+CoglTexture *
+cogl_texture_new_with_size (unsigned int width,
+                            unsigned int height,
+                            CoglTextureFlags flags,
+                            CoglPixelFormat internal_format);
+
+/**
+ * cogl_texture_new_from_file:
+ * @filename: the file to load
+ * @flags: Optional flags for the texture, or %COGL_TEXTURE_NONE
+ * @internal_format: the #CoglPixelFormat to use for the GPU storage of the
+ *    texture. If %COGL_PIXEL_FORMAT_ANY is given then a premultiplied
+ *    format similar to the format of the source data will be used. The
+ *    default blending equations of Cogl expect premultiplied color data;
+ *    the main use of passing a non-premultiplied format here is if you
+ *    have non-premultiplied source data and are going to adjust the blend
+ *    mode (see cogl_material_set_blend()) or use the data for something
+ *    other than straight blending.
+ * @error: return location for a #CoglError or %NULL
+ *
+ * Creates a #CoglTexture from an image file.
+ *
+ * Return value: (transfer full): A newly created #CoglTexture or
+ *               %NULL on failure
+ *
+ * Since: 0.8
+ * Deprecated: 1.18: Use specific constructors such as
+ *                   cogl_texture_2d_new_from_file()
+ */
+COGL_DEPRECATED_IN_1_18_FOR(cogl_texture_2d_new_from_file__OR__cogl_texture_2d_sliced_new_from_file)
+CoglTexture *
+cogl_texture_new_from_file (const char       *filename,
+                            CoglTextureFlags   flags,
+                            CoglPixelFormat    internal_format,
+                            CoglError           **error);
+
+/**
+ * cogl_texture_new_from_data:
+ * @width: width of texture in pixels
+ * @height: height of texture in pixels
+ * @flags: Optional flags for the texture, or %COGL_TEXTURE_NONE
+ * @format: the #CoglPixelFormat the buffer is stored in in RAM
+ * @internal_format: the #CoglPixelFormat that will be used for storing
+ *    the buffer on the GPU. If COGL_PIXEL_FORMAT_ANY is given then a
+ *    premultiplied format similar to the format of the source data will
+ *    be used. The default blending equations of Cogl expect premultiplied
+ *    color data; the main use of passing a non-premultiplied format here
+ *    is if you have non-premultiplied source data and are going to adjust
+ *    the blend mode (see cogl_material_set_blend()) or use the data for
+ *    something other than straight blending.
+ * @rowstride: the memory offset in bytes between the starts of
+ *    scanlines in @data
+ * @data: pointer the memory region where the source buffer resides
+ *
+ * Creates a new #CoglTexture based on data residing in memory.
+ *
+ * Return value: (transfer full): A newly created #CoglTexture or
+ *               %NULL on failure
+ *
+ * Since: 0.8
+ * Deprecated: 1.18: Use specific constructors such as
+ *                   cogl_texture_2d_new_from_data()
+ */
+COGL_DEPRECATED_IN_1_18_FOR(cogl_texture_2d_new_from_data__OR__cogl_texture_2d_sliced_new_from_data)
+CoglTexture *
+cogl_texture_new_from_data (int width,
+                            int height,
+                            CoglTextureFlags flags,
+                            CoglPixelFormat format,
+                            CoglPixelFormat internal_format,
+                            int rowstride,
+                            const uint8_t *data);
+
+/**
+ * cogl_texture_new_from_foreign:
+ * @gl_handle: opengl handle of foreign texture.
+ * @gl_target: opengl target type of foreign texture
+ * @width: width of foreign texture
+ * @height: height of foreign texture.
+ * @x_pot_waste: horizontal waste on the right hand edge of the texture.
+ * @y_pot_waste: vertical waste on the bottom edge of the texture.
+ * @format: format of the foreign texture.
+ *
+ * Creates a #CoglTexture based on an existing OpenGL texture; the
+ * width, height and format are passed along since it is not always
+ * possible to query these from OpenGL.
+ *
+ * The waste arguments allow you to create a Cogl texture that maps to
+ * a region smaller than the real OpenGL texture. For instance if your
+ * hardware only supports power-of-two textures you may load a
+ * non-power-of-two image into a larger power-of-two texture and use
+ * the waste arguments to tell Cogl which region should be mapped to
+ * the texture coordinate range [0:1].
+ *
+ * Return value: (transfer full): A newly created #CoglTexture or
+ *               %NULL on failure
+ *
+ * Since: 0.8
+ * Deprecated: 1.18: Use specific constructors such as
+ *                   cogl_texture_2d_new_from_foreign()
+ */
+COGL_DEPRECATED_IN_1_18_FOR(cogl_texture_2d_new_from_foreign)
+CoglTexture *
+cogl_texture_new_from_foreign (unsigned int gl_handle,
+                               unsigned int gl_target,
+                               unsigned int width,
+                               unsigned int height,
+                               unsigned int x_pot_waste,
+                               unsigned int y_pot_waste,
+                               CoglPixelFormat format);
+
+/**
+ * cogl_texture_new_from_bitmap:
+ * @bitmap: A #CoglBitmap pointer
+ * @flags: Optional flags for the texture, or %COGL_TEXTURE_NONE
+ * @internal_format: the #CoglPixelFormat to use for the GPU storage of the
+ * texture
+ *
+ * Creates a #CoglTexture from a #CoglBitmap.
+ *
+ * Return value: (transfer full): A newly created #CoglTexture or
+ *               %NULL on failure
+ *
+ * Since: 1.0
+ * Deprecated: 1.18: Use specific constructors such as
+ *                   cogl_texture_2d_new_from_bitmap()
+ */
+COGL_DEPRECATED_IN_1_18_FOR(cogl_texture_2d_new_from_bitmap__OR__cogl_texture_2d_sliced_new_from_bitmap)
+CoglTexture *
+cogl_texture_new_from_bitmap (CoglBitmap *bitmap,
+                              CoglTextureFlags flags,
+                              CoglPixelFormat internal_format);
+
+/**
+ * cogl_texture_new_from_sub_texture:
+ * @full_texture: a #CoglTexture pointer
+ * @sub_x: X coordinate of the top-left of the subregion
+ * @sub_y: Y coordinate of the top-left of the subregion
+ * @sub_width: Width in pixels of the subregion
+ * @sub_height: Height in pixels of the subregion
+ *
+ * Creates a new texture which represents a subregion of another
+ * texture. The GL resources will be shared so that no new texture
+ * data is actually allocated.
+ *
+ * Sub textures have undefined behaviour texture coordinates outside
+ * of the range [0,1] are used. They also do not work with
+ * CoglVertexBuffers.
+ *
+ * The sub texture will keep a reference to the full texture so you do
+ * not need to keep one separately if you only want to use the sub
+ * texture.
+ *
+ * Return value: (transfer full): A newly created #CoglTexture or
+ *               %NULL on failure
+ * Since: 1.2
+ * Deprecated: 1.18: Use cogl_sub_texture_new()
+ */
+COGL_DEPRECATED_IN_1_18_FOR(cogl_sub_texture_new)
+CoglTexture *
+cogl_texture_new_from_sub_texture (CoglTexture *full_texture,
+                                   int sub_x,
+                                   int sub_y,
+                                   int sub_width,
+                                   int sub_height);
+
+COGL_END_DECLS
+
+#endif /* __COGL_AUTO_TEXTURE_H__ */
-- 
1.8.5.2



More information about the Cogl mailing list