2009-04-27 10:48:12 -04:00
|
|
|
|
/*
|
|
|
|
|
* Cogl
|
2008-10-30 13:57:41 -04:00
|
|
|
|
*
|
2014-02-21 20:28:54 -05:00
|
|
|
|
* A Low Level GPU Graphics and Utilities API
|
2009-04-27 10:48:12 -04: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
|
|
|
|
* Copyright (C) 2007,2008,2009,2010 Intel Corporation.
|
2008-10-30 13:57:41 -04: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:
|
2008-10-30 13:57:41 -04:00
|
|
|
|
*
|
2014-02-21 20:28:54 -05:00
|
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
|
* included in all copies or substantial portions of the Software.
|
2008-10-30 13:57:41 -04:00
|
|
|
|
*
|
2014-02-21 20:28:54 -05:00
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
|
*
|
2008-10-30 13:57:41 -04:00
|
|
|
|
*/
|
|
|
|
|
|
2012-06-20 13:49:08 -04:00
|
|
|
|
#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION)
|
2008-10-30 13:25:00 -04:00
|
|
|
|
#error "Only <cogl/cogl.h> can be included directly."
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef __COGL_TEXTURE_H__
|
|
|
|
|
#define __COGL_TEXTURE_H__
|
|
|
|
|
|
2012-02-17 16:46:39 -05:00
|
|
|
|
/* We forward declare the CoglTexture type here to avoid some circular
|
|
|
|
|
* dependency issues with the following headers.
|
|
|
|
|
*/
|
2016-06-16 16:32:04 -04:00
|
|
|
|
#if defined(__COGL_H_INSIDE__) && !defined(COGL_ENABLE_MUTTER_API) && \
|
|
|
|
|
!defined(COGL_GIR_SCANNING)
|
2013-10-09 08:31:12 -04:00
|
|
|
|
/* For the public C api we typedef interface types as void to avoid needing
|
|
|
|
|
* lots of casting in code and instead we will rely on runtime type checking
|
|
|
|
|
* for these objects. */
|
|
|
|
|
typedef void CoglTexture;
|
|
|
|
|
#else
|
2012-02-17 16:46:39 -05:00
|
|
|
|
typedef struct _CoglTexture CoglTexture;
|
2013-10-09 08:31:12 -04:00
|
|
|
|
#define COGL_TEXTURE(X) ((CoglTexture *)X)
|
|
|
|
|
#endif
|
2012-02-17 16:46:39 -05:00
|
|
|
|
|
2008-10-30 13:25:00 -04:00
|
|
|
|
#include <cogl/cogl-types.h>
|
2013-09-23 13:21:16 -04:00
|
|
|
|
#include <cogl/cogl-macros.h>
|
2010-01-05 12:54:45 -05:00
|
|
|
|
#include <cogl/cogl-defines.h>
|
2011-08-24 16:30:34 -04:00
|
|
|
|
#include <cogl/cogl-pixel-buffer.h>
|
2019-04-04 05:02:47 -04:00
|
|
|
|
#include <cogl/cogl-pixel-format.h>
|
2011-09-08 19:40:06 -04:00
|
|
|
|
#include <cogl/cogl-bitmap.h>
|
2008-10-30 13:25:00 -04:00
|
|
|
|
|
2013-09-02 11:02:42 -04:00
|
|
|
|
#include <glib-object.h>
|
|
|
|
|
|
2018-11-23 02:42:05 -05:00
|
|
|
|
G_BEGIN_DECLS
|
2009-05-06 05:35:28 -04:00
|
|
|
|
|
2008-10-30 13:25:00 -04:00
|
|
|
|
/**
|
|
|
|
|
* SECTION:cogl-texture
|
2012-12-30 11:37:36 -05:00
|
|
|
|
* @short_description: Functions for creating and manipulating textures
|
2008-10-30 13:25:00 -04:00
|
|
|
|
*
|
2011-08-24 16:30:34 -04:00
|
|
|
|
* Cogl allows creating and manipulating textures using a uniform
|
2008-10-30 13:25:00 -04:00
|
|
|
|
* API that tries to hide all the various complexities of creating,
|
|
|
|
|
* loading and manipulating textures.
|
|
|
|
|
*/
|
|
|
|
|
|
[cogl] Remove max_waste argument from Texture ctors
The CoglTexture constructors expose the "max-waste" argument for
controlling the maximum amount of wasted areas for slicing or,
if set to -1, disables slicing.
Slicing is really relevant only for large images that are never
repeated, so it's a useful feature only in controlled use cases.
Specifying the amount of wasted area is, on the other hand, just
a way to mess up this feature; 99% the times, you either pull this
number out of thin air, hoping it's right, or you try to do the
right thing and you choose the wrong number anyway.
Instead, we can use the CoglTextureFlags to control whether the
texture should not be sliced (useful for Clutter-GST and for the
texture-from-pixmap actors) and provide a reasonable value for
enabling the slicing ourself. At some point, we might even
provide a way to change the default at compile time or at run time,
for particular platforms.
Since max_waste is gone, the :tile-waste property of ClutterTexture
becomes read-only, and it proxies the cogl_texture_get_max_waste()
function.
Inside Clutter, the only cases where the max_waste argument was
not set to -1 are in the Pango glyph cache (which is a POT texture
anyway) and inside the test cases where we want to force slicing;
for the latter we can create larger textures that will be bigger than
the threshold we set.
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
Signed-off-by: Robert Bragg <robert@linux.intel.com>
Signed-off-by: Neil Roberts <neil@linux.intel.com>
2009-05-23 14:18:18 -04:00
|
|
|
|
#define COGL_TEXTURE_MAX_WASTE 127
|
|
|
|
|
|
2013-09-02 11:02:42 -04:00
|
|
|
|
/**
|
|
|
|
|
* cogl_texture_get_gtype:
|
|
|
|
|
*
|
|
|
|
|
* Returns: a #GType that can be used with the GLib type system.
|
|
|
|
|
*/
|
2019-11-21 06:15:22 -05:00
|
|
|
|
COGL_EXPORT
|
2013-09-02 11:02:42 -04:00
|
|
|
|
GType cogl_texture_get_gtype (void);
|
|
|
|
|
|
2011-05-16 19:05:54 -04:00
|
|
|
|
/**
|
|
|
|
|
* COGL_TEXTURE_ERROR:
|
|
|
|
|
*
|
2019-06-18 02:02:10 -04:00
|
|
|
|
* #GError domain for texture errors.
|
2011-05-16 19:05:54 -04:00
|
|
|
|
*
|
2014-01-15 11:43:55 -05:00
|
|
|
|
* Since: 1.8
|
2011-05-16 19:05:54 -04:00
|
|
|
|
* Stability: Unstable
|
|
|
|
|
*/
|
|
|
|
|
#define COGL_TEXTURE_ERROR (cogl_texture_error_quark ())
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* CoglTextureError:
|
|
|
|
|
* @COGL_TEXTURE_ERROR_SIZE: Unsupported size
|
2014-01-15 11:43:55 -05:00
|
|
|
|
* @COGL_TEXTURE_ERROR_FORMAT: Unsupported format
|
|
|
|
|
* @COGL_TEXTURE_ERROR_TYPE: A primitive texture type that is
|
|
|
|
|
* unsupported by the driver was used
|
2011-05-16 19:05:54 -04:00
|
|
|
|
*
|
|
|
|
|
* Error codes that can be thrown when allocating textures.
|
|
|
|
|
*
|
2014-01-15 11:43:55 -05:00
|
|
|
|
* Since: 1.8
|
2011-05-16 19:05:54 -04:00
|
|
|
|
* Stability: Unstable
|
|
|
|
|
*/
|
2018-12-19 03:04:25 -05:00
|
|
|
|
typedef enum
|
|
|
|
|
{
|
2011-05-16 19:05:54 -04:00
|
|
|
|
COGL_TEXTURE_ERROR_SIZE,
|
2011-05-24 17:34:10 -04:00
|
|
|
|
COGL_TEXTURE_ERROR_FORMAT,
|
2011-10-14 04:25:12 -04:00
|
|
|
|
COGL_TEXTURE_ERROR_BAD_PARAMETER,
|
|
|
|
|
COGL_TEXTURE_ERROR_TYPE
|
2011-05-16 19:05:54 -04:00
|
|
|
|
} CoglTextureError;
|
|
|
|
|
|
2019-11-21 06:15:22 -05:00
|
|
|
|
COGL_EXPORT
|
2012-08-31 14:28:27 -04:00
|
|
|
|
uint32_t cogl_texture_error_quark (void);
|
2011-05-16 19:05:54 -04:00
|
|
|
|
|
2008-10-30 13:25:00 -04:00
|
|
|
|
/**
|
|
|
|
|
* cogl_is_texture:
|
2011-08-24 16:30:34 -04:00
|
|
|
|
* @object: A #CoglObject pointer
|
2008-10-30 13:25:00 -04:00
|
|
|
|
*
|
2011-08-24 16:30:34 -04:00
|
|
|
|
* Gets whether the given object references a texture object.
|
2008-10-30 13:25:00 -04:00
|
|
|
|
*
|
2012-04-16 09:14:10 -04:00
|
|
|
|
* Return value: %TRUE if the @object references a texture, and
|
2008-10-30 13:25:00 -04:00
|
|
|
|
* %FALSE otherwise
|
|
|
|
|
*/
|
2019-11-21 06:15:22 -05:00
|
|
|
|
COGL_EXPORT gboolean
|
2011-08-24 16:30:34 -04:00
|
|
|
|
cogl_is_texture (void *object);
|
2008-10-30 13:25:00 -04:00
|
|
|
|
|
2014-01-15 11:43:55 -05:00
|
|
|
|
/**
|
|
|
|
|
* CoglTextureComponents:
|
|
|
|
|
* @COGL_TEXTURE_COMPONENTS_A: Only the alpha component
|
2014-01-14 10:52:45 -05:00
|
|
|
|
* @COGL_TEXTURE_COMPONENTS_RG: Red and green components. Note that
|
|
|
|
|
* this can only be used if the %COGL_FEATURE_ID_TEXTURE_RG feature
|
|
|
|
|
* is advertised.
|
2014-01-15 11:43:55 -05:00
|
|
|
|
* @COGL_TEXTURE_COMPONENTS_RGB: Red, green and blue components
|
|
|
|
|
* @COGL_TEXTURE_COMPONENTS_RGBA: Red, green, blue and alpha components
|
|
|
|
|
* @COGL_TEXTURE_COMPONENTS_DEPTH: Only a depth component
|
|
|
|
|
*
|
|
|
|
|
* See cogl_texture_set_components().
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.18
|
|
|
|
|
*/
|
2013-06-23 11:18:18 -04:00
|
|
|
|
typedef enum _CoglTextureComponents
|
|
|
|
|
{
|
|
|
|
|
COGL_TEXTURE_COMPONENTS_A = 1,
|
2014-01-14 10:52:45 -05:00
|
|
|
|
COGL_TEXTURE_COMPONENTS_RG,
|
2013-06-23 11:18:18 -04:00
|
|
|
|
COGL_TEXTURE_COMPONENTS_RGB,
|
|
|
|
|
COGL_TEXTURE_COMPONENTS_RGBA,
|
|
|
|
|
COGL_TEXTURE_COMPONENTS_DEPTH
|
|
|
|
|
} CoglTextureComponents;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* cogl_texture_set_components:
|
|
|
|
|
* @texture: a #CoglTexture pointer.
|
|
|
|
|
*
|
2014-01-15 11:43:55 -05:00
|
|
|
|
* Affects the internal storage format for this texture by specifying
|
|
|
|
|
* what components will be required for sampling later.
|
2013-06-23 11:18:18 -04:00
|
|
|
|
*
|
|
|
|
|
* This api affects how data is uploaded to the GPU since unused
|
|
|
|
|
* components can potentially be discarded from source data.
|
|
|
|
|
*
|
2014-01-15 11:43:55 -05:00
|
|
|
|
* For textures created by the ‘_with_size’ constructors the default
|
|
|
|
|
* is %COGL_TEXTURE_COMPONENTS_RGBA. The other constructors which take
|
|
|
|
|
* a %CoglBitmap or a data pointer default to the same components as
|
|
|
|
|
* the pixel format of the data.
|
|
|
|
|
*
|
2014-01-14 10:52:45 -05:00
|
|
|
|
* Note that the %COGL_TEXTURE_COMPONENTS_RG format is not available
|
|
|
|
|
* on all drivers. The availability can be determined by checking for
|
|
|
|
|
* the %COGL_FEATURE_ID_TEXTURE_RG feature. If this format is used on
|
|
|
|
|
* a driver where it is not available then %COGL_TEXTURE_ERROR_FORMAT
|
|
|
|
|
* will be raised when the texture is allocated. Even if the feature
|
|
|
|
|
* is not available then %COGL_PIXEL_FORMAT_RG_88 can still be used as
|
|
|
|
|
* an image format as long as %COGL_TEXTURE_COMPONENTS_RG isn't used
|
|
|
|
|
* as the texture's components.
|
|
|
|
|
*
|
2014-01-15 11:43:55 -05:00
|
|
|
|
* Since: 1.18
|
2013-06-23 11:18:18 -04:00
|
|
|
|
*/
|
2019-11-21 06:15:22 -05:00
|
|
|
|
COGL_EXPORT void
|
2013-06-23 11:18:18 -04:00
|
|
|
|
cogl_texture_set_components (CoglTexture *texture,
|
|
|
|
|
CoglTextureComponents components);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* cogl_texture_get_components:
|
|
|
|
|
* @texture: a #CoglTexture pointer.
|
|
|
|
|
*
|
|
|
|
|
* Queries what components the given @texture stores internally as set
|
|
|
|
|
* via cogl_texture_set_components().
|
|
|
|
|
*
|
2014-01-15 11:43:55 -05:00
|
|
|
|
* For textures created by the ‘_with_size’ constructors the default
|
|
|
|
|
* is %COGL_TEXTURE_COMPONENTS_RGBA. The other constructors which take
|
|
|
|
|
* a %CoglBitmap or a data pointer default to the same components as
|
|
|
|
|
* the pixel format of the data.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.18
|
2013-06-23 11:18:18 -04:00
|
|
|
|
*/
|
2019-11-21 06:15:22 -05:00
|
|
|
|
COGL_EXPORT CoglTextureComponents
|
2013-06-23 11:18:18 -04:00
|
|
|
|
cogl_texture_get_components (CoglTexture *texture);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* cogl_texture_set_premultiplied:
|
|
|
|
|
* @texture: a #CoglTexture pointer.
|
|
|
|
|
* @premultiplied: Whether any internally stored red, green or blue
|
|
|
|
|
* components are pre-multiplied by an alpha
|
|
|
|
|
* component.
|
|
|
|
|
*
|
2014-01-15 11:43:55 -05:00
|
|
|
|
* Affects the internal storage format for this texture by specifying
|
2013-06-23 11:18:18 -04:00
|
|
|
|
* whether red, green and blue color components should be stored as
|
|
|
|
|
* pre-multiplied alpha values.
|
|
|
|
|
*
|
|
|
|
|
* This api affects how data is uploaded to the GPU since Cogl will
|
|
|
|
|
* convert source data to have premultiplied or unpremultiplied
|
|
|
|
|
* components according to this state.
|
|
|
|
|
*
|
|
|
|
|
* For example if you create a texture via
|
|
|
|
|
* cogl_texture_2d_new_with_size() and then upload data via
|
|
|
|
|
* cogl_texture_set_data() passing a source format of
|
|
|
|
|
* %COGL_PIXEL_FORMAT_RGBA_8888 then Cogl will internally multiply the
|
|
|
|
|
* red, green and blue components of the source data by the alpha
|
|
|
|
|
* component, for each pixel so that the internally stored data has
|
|
|
|
|
* pre-multiplied alpha components. If you instead upload data that
|
|
|
|
|
* already has pre-multiplied components by passing
|
|
|
|
|
* %COGL_PIXEL_FORMAT_RGBA_8888_PRE as the source format to
|
|
|
|
|
* cogl_texture_set_data() then the data can be uploaded without being
|
|
|
|
|
* converted.
|
|
|
|
|
*
|
|
|
|
|
* By default the @premultipled state is @TRUE.
|
2014-01-15 11:43:55 -05:00
|
|
|
|
*
|
|
|
|
|
* Since: 1.18
|
2013-06-23 11:18:18 -04:00
|
|
|
|
*/
|
2019-11-21 06:15:22 -05:00
|
|
|
|
COGL_EXPORT void
|
2013-06-23 11:18:18 -04:00
|
|
|
|
cogl_texture_set_premultiplied (CoglTexture *texture,
|
2018-11-24 07:04:47 -05:00
|
|
|
|
gboolean premultiplied);
|
2013-06-23 11:18:18 -04:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* cogl_texture_get_premultiplied:
|
|
|
|
|
* @texture: a #CoglTexture pointer.
|
|
|
|
|
*
|
|
|
|
|
* Queries the pre-multiplied alpha status for internally stored red,
|
|
|
|
|
* green and blue components for the given @texture as set by
|
|
|
|
|
* cogl_texture_set_premultiplied().
|
|
|
|
|
*
|
|
|
|
|
* By default the pre-multipled state is @TRUE.
|
|
|
|
|
*
|
|
|
|
|
* Return value: %TRUE if red, green and blue components are
|
|
|
|
|
* internally stored pre-multiplied by the alpha
|
|
|
|
|
* value or %FALSE if not.
|
2014-01-15 11:43:55 -05:00
|
|
|
|
* Since: 1.18
|
2013-06-23 11:18:18 -04:00
|
|
|
|
*/
|
2019-11-21 06:15:22 -05:00
|
|
|
|
COGL_EXPORT gboolean
|
2013-06-23 11:18:18 -04:00
|
|
|
|
cogl_texture_get_premultiplied (CoglTexture *texture);
|
|
|
|
|
|
2008-10-30 13:25:00 -04:00
|
|
|
|
/**
|
|
|
|
|
* cogl_texture_get_width:
|
2012-12-30 11:24:44 -05:00
|
|
|
|
* @texture: a #CoglTexture pointer.
|
2008-12-23 11:29:29 -05:00
|
|
|
|
*
|
2009-11-19 08:55:10 -05:00
|
|
|
|
* Queries the width of a cogl texture.
|
2008-10-30 13:25:00 -04:00
|
|
|
|
*
|
2009-11-19 08:55:10 -05:00
|
|
|
|
* Return value: the width of the GPU side texture in pixels
|
2008-10-30 13:25:00 -04:00
|
|
|
|
*/
|
2019-11-21 06:15:22 -05:00
|
|
|
|
COGL_EXPORT unsigned int
|
2011-08-24 16:30:34 -04:00
|
|
|
|
cogl_texture_get_width (CoglTexture *texture);
|
2008-10-30 13:25:00 -04:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* cogl_texture_get_height:
|
2012-12-30 11:24:44 -05:00
|
|
|
|
* @texture: a #CoglTexture pointer.
|
2008-12-23 11:29:29 -05:00
|
|
|
|
*
|
2009-11-19 08:55:10 -05:00
|
|
|
|
* Queries the height of a cogl texture.
|
2008-10-30 13:25:00 -04:00
|
|
|
|
*
|
2009-11-19 08:55:10 -05:00
|
|
|
|
* Return value: the height of the GPU side texture in pixels
|
2008-10-30 13:25:00 -04:00
|
|
|
|
*/
|
2019-11-21 06:15:22 -05:00
|
|
|
|
COGL_EXPORT unsigned int
|
2011-08-24 16:30:34 -04:00
|
|
|
|
cogl_texture_get_height (CoglTexture *texture);
|
2008-10-30 13:25:00 -04:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* cogl_texture_get_max_waste:
|
2012-12-30 11:24:44 -05:00
|
|
|
|
* @texture: a #CoglTexture pointer.
|
2008-12-23 11:29:29 -05:00
|
|
|
|
*
|
2009-11-19 08:55:10 -05:00
|
|
|
|
* Queries the maximum wasted (unused) pixels in one dimension of a GPU side
|
2008-10-30 13:25:00 -04:00
|
|
|
|
* texture.
|
|
|
|
|
*
|
2009-11-19 08:55:10 -05:00
|
|
|
|
* Return value: the maximum waste
|
2008-10-30 13:25:00 -04:00
|
|
|
|
*/
|
2019-11-21 06:15:22 -05:00
|
|
|
|
COGL_EXPORT int
|
2011-08-24 16:30:34 -04:00
|
|
|
|
cogl_texture_get_max_waste (CoglTexture *texture);
|
2008-10-30 13:25:00 -04:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* cogl_texture_is_sliced:
|
2012-12-30 11:24:44 -05:00
|
|
|
|
* @texture: a #CoglTexture pointer.
|
2008-12-23 11:29:29 -05:00
|
|
|
|
*
|
2009-11-19 08:55:10 -05:00
|
|
|
|
* Queries if a texture is sliced (stored as multiple GPU side tecture
|
2008-10-30 13:25:00 -04:00
|
|
|
|
* objects).
|
|
|
|
|
*
|
2009-11-19 08:55:10 -05:00
|
|
|
|
* Return value: %TRUE if the texture is sliced, %FALSE if the texture
|
|
|
|
|
* is stored as a single GPU texture
|
2008-10-30 13:25:00 -04:00
|
|
|
|
*/
|
2019-11-21 06:15:22 -05:00
|
|
|
|
COGL_EXPORT gboolean
|
2011-08-24 16:30:34 -04:00
|
|
|
|
cogl_texture_is_sliced (CoglTexture *texture);
|
2008-10-30 13:25:00 -04:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* cogl_texture_get_gl_texture:
|
2012-12-30 11:24:44 -05:00
|
|
|
|
* @texture: a #CoglTexture pointer.
|
2009-09-07 06:44:44 -04:00
|
|
|
|
* @out_gl_handle: (out) (allow-none): pointer to return location for the
|
|
|
|
|
* textures GL handle, or %NULL.
|
|
|
|
|
* @out_gl_target: (out) (allow-none): pointer to return location for the
|
|
|
|
|
* GL target type, or %NULL.
|
2008-12-23 11:29:29 -05:00
|
|
|
|
*
|
2011-08-24 16:30:34 -04:00
|
|
|
|
* Queries the GL handles for a GPU side texture through its #CoglTexture.
|
2009-11-19 08:55:10 -05:00
|
|
|
|
*
|
|
|
|
|
* If the texture is spliced the data for the first sub texture will be
|
2008-10-30 13:25:00 -04:00
|
|
|
|
* queried.
|
|
|
|
|
*
|
2009-11-19 08:55:10 -05:00
|
|
|
|
* Return value: %TRUE if the handle was successfully retrieved, %FALSE
|
|
|
|
|
* if the handle was invalid
|
2008-10-30 13:25:00 -04:00
|
|
|
|
*/
|
2019-11-21 06:15:22 -05:00
|
|
|
|
COGL_EXPORT gboolean
|
2011-08-24 16:30:34 -04:00
|
|
|
|
cogl_texture_get_gl_texture (CoglTexture *texture,
|
2012-03-23 14:05:46 -04:00
|
|
|
|
unsigned int *out_gl_handle,
|
|
|
|
|
unsigned int *out_gl_target);
|
2008-10-30 13:25:00 -04:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* cogl_texture_get_data:
|
2012-12-30 11:24:44 -05:00
|
|
|
|
* @texture: a #CoglTexture pointer.
|
2008-10-30 13:25:00 -04:00
|
|
|
|
* @format: the #CoglPixelFormat to store the texture as.
|
2011-11-01 15:05:32 -04:00
|
|
|
|
* @rowstride: the rowstride of @data in bytes or pass 0 to calculate
|
|
|
|
|
* from the bytes-per-pixel of @format multiplied by the
|
|
|
|
|
* @texture width.
|
2020-03-17 08:21:11 -04:00
|
|
|
|
* @data: (array) (nullable): memory location to write the @texture's contents,
|
|
|
|
|
* or %NULL to only query the data size through the return value.
|
2008-12-23 11:29:29 -05:00
|
|
|
|
*
|
2009-11-19 08:55:10 -05:00
|
|
|
|
* Copies the pixel data from a cogl texture to system memory.
|
2008-10-30 13:25:00 -04:00
|
|
|
|
*
|
2011-11-01 15:05:32 -04:00
|
|
|
|
* <note>Don't pass the value of cogl_texture_get_rowstride() as the
|
|
|
|
|
* @rowstride argument, the rowstride should be the rowstride you
|
|
|
|
|
* want for the destination @data buffer not the rowstride of the
|
|
|
|
|
* source texture</note>
|
|
|
|
|
*
|
|
|
|
|
* Return value: the size of the texture data in bytes
|
2008-10-30 13:25:00 -04:00
|
|
|
|
*/
|
2019-11-21 06:15:22 -05:00
|
|
|
|
COGL_EXPORT int
|
2011-08-24 16:30:34 -04:00
|
|
|
|
cogl_texture_get_data (CoglTexture *texture,
|
|
|
|
|
CoglPixelFormat format,
|
|
|
|
|
unsigned int rowstride,
|
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
|
|
|
|
uint8_t *data);
|
2008-10-30 13:25:00 -04:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* cogl_texture_set_region:
|
2012-12-30 11:24:44 -05:00
|
|
|
|
* @texture: a #CoglTexture.
|
2008-10-30 13:25:00 -04:00
|
|
|
|
* @src_x: upper left coordinate to use from source data.
|
|
|
|
|
* @src_y: upper left coordinate to use from source data.
|
|
|
|
|
* @dst_x: upper left destination horizontal coordinate.
|
|
|
|
|
* @dst_y: upper left destination vertical coordinate.
|
2011-11-22 07:06:40 -05:00
|
|
|
|
* @dst_width: width of destination region to write. (Must be less
|
|
|
|
|
* than or equal to @width)
|
|
|
|
|
* @dst_height: height of destination region to write. (Must be less
|
|
|
|
|
* than or equal to @height)
|
2008-10-30 13:25:00 -04:00
|
|
|
|
* @width: width of source data buffer.
|
|
|
|
|
* @height: height of source data buffer.
|
|
|
|
|
* @format: the #CoglPixelFormat used in the source buffer.
|
|
|
|
|
* @rowstride: rowstride of source buffer (computed from width if none
|
|
|
|
|
* specified)
|
2020-03-17 08:21:11 -04:00
|
|
|
|
* @data: (array): the actual pixel data.
|
2008-10-30 13:25:00 -04:00
|
|
|
|
*
|
2011-11-22 07:06:40 -05:00
|
|
|
|
* Sets the pixels in a rectangular subregion of @texture from an in-memory
|
2008-12-23 11:29:29 -05:00
|
|
|
|
* buffer containing pixel data.
|
2008-10-30 13:25:00 -04:00
|
|
|
|
*
|
2011-11-22 07:06:40 -05:00
|
|
|
|
* <note>The region set can't be larger than the source @data</note>
|
|
|
|
|
*
|
2009-11-19 08:55:10 -05:00
|
|
|
|
* Return value: %TRUE if the subregion upload was successful, and
|
|
|
|
|
* %FALSE otherwise
|
2008-10-30 13:25:00 -04:00
|
|
|
|
*/
|
2019-11-21 06:15:22 -05:00
|
|
|
|
COGL_EXPORT gboolean
|
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_texture_set_region (CoglTexture *texture,
|
|
|
|
|
int src_x,
|
|
|
|
|
int src_y,
|
|
|
|
|
int dst_x,
|
|
|
|
|
int dst_y,
|
|
|
|
|
unsigned int dst_width,
|
|
|
|
|
unsigned int dst_height,
|
|
|
|
|
int width,
|
|
|
|
|
int height,
|
|
|
|
|
CoglPixelFormat format,
|
|
|
|
|
unsigned int rowstride,
|
|
|
|
|
const uint8_t *data);
|
2008-10-30 13:25:00 -04:00
|
|
|
|
|
2012-11-26 08:14:27 -05:00
|
|
|
|
/**
|
|
|
|
|
* cogl_texture_set_data:
|
|
|
|
|
* @texture a #CoglTexture.
|
|
|
|
|
* @format: the #CoglPixelFormat used in the source @data buffer.
|
|
|
|
|
* @rowstride: rowstride of the source @data buffer (computed from
|
|
|
|
|
* the texture width and @format if it equals 0)
|
2020-03-17 08:21:11 -04:00
|
|
|
|
* @data: (array): the source data, pointing to the first top-left pixel to set
|
2012-11-26 08:14:27 -05:00
|
|
|
|
* @level: The mipmap level to update (Normally 0 for the largest,
|
|
|
|
|
* base texture)
|
2019-06-18 02:02:10 -04:00
|
|
|
|
* @error: A #GError to return exceptional errors
|
2012-11-26 08:14:27 -05:00
|
|
|
|
*
|
|
|
|
|
* Sets all the pixels for a given mipmap @level by copying the pixel
|
|
|
|
|
* data pointed to by the @data argument into the given @texture.
|
|
|
|
|
*
|
|
|
|
|
* @data should point to the first pixel to copy corresponding
|
|
|
|
|
* to the top left of the mipmap @level being set.
|
|
|
|
|
*
|
|
|
|
|
* If @rowstride equals 0 then it will be automatically calculated
|
|
|
|
|
* from the width of the mipmap level and the bytes-per-pixel for the
|
|
|
|
|
* given @format.
|
|
|
|
|
*
|
|
|
|
|
* A mipmap @level of 0 corresponds to the largest, base image of a
|
|
|
|
|
* texture and @level 1 is half the width and height of level 0. If
|
|
|
|
|
* dividing any dimension of the previous level by two results in a
|
|
|
|
|
* fraction then round the number down (floor()), but clamp to 1
|
|
|
|
|
* something like this:
|
|
|
|
|
*
|
|
|
|
|
* |[
|
|
|
|
|
* next_width = MAX (1, floor (prev_width));
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* You can determine the number of mipmap levels for a given texture
|
|
|
|
|
* like this:
|
|
|
|
|
*
|
|
|
|
|
* |[
|
|
|
|
|
* n_levels = 1 + floor (log2 (max_dimension));
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* Where %max_dimension is the larger of cogl_texture_get_width() and
|
|
|
|
|
* cogl_texture_get_height().
|
|
|
|
|
*
|
|
|
|
|
* It is an error to pass a @level number >= the number of levels that
|
|
|
|
|
* @texture can have according to the above calculation.
|
|
|
|
|
*
|
|
|
|
|
* <note>Since the storage for a #CoglTexture is allocated lazily then
|
|
|
|
|
* if the given @texture has not previously been allocated then this
|
|
|
|
|
* api can return %FALSE and throw an exceptional @error if there is
|
|
|
|
|
* not enough memory to allocate storage for @texture.</note>
|
|
|
|
|
*
|
|
|
|
|
* Return value: %TRUE if the data upload was successful, and
|
|
|
|
|
* %FALSE otherwise
|
|
|
|
|
*/
|
2019-11-21 06:15:22 -05:00
|
|
|
|
COGL_EXPORT gboolean
|
2012-11-26 08:14:27 -05:00
|
|
|
|
cogl_texture_set_data (CoglTexture *texture,
|
|
|
|
|
CoglPixelFormat format,
|
|
|
|
|
int rowstride,
|
|
|
|
|
const uint8_t *data,
|
|
|
|
|
int level,
|
2019-06-18 02:02:10 -04:00
|
|
|
|
GError **error);
|
2012-11-26 08:14:27 -05:00
|
|
|
|
|
2011-07-25 17:14:08 -04:00
|
|
|
|
/**
|
|
|
|
|
* cogl_texture_set_region_from_bitmap:
|
2012-12-30 11:24:44 -05:00
|
|
|
|
* @texture: a #CoglTexture pointer
|
2011-07-25 17:14:08 -04:00
|
|
|
|
* @src_x: upper left coordinate to use from the source bitmap.
|
|
|
|
|
* @src_y: upper left coordinate to use from the source bitmap
|
|
|
|
|
* @dst_x: upper left destination horizontal coordinate.
|
|
|
|
|
* @dst_y: upper left destination vertical coordinate.
|
2011-11-22 07:06:40 -05:00
|
|
|
|
* @dst_width: width of destination region to write. (Must be less
|
|
|
|
|
* than or equal to the bitmap width)
|
|
|
|
|
* @dst_height: height of destination region to write. (Must be less
|
|
|
|
|
* than or equal to the bitmap height)
|
2011-07-25 17:14:08 -04:00
|
|
|
|
* @bitmap: The source bitmap to read from
|
|
|
|
|
*
|
|
|
|
|
* Copies a specified source region from @bitmap to the position
|
|
|
|
|
* (@src_x, @src_y) of the given destination texture @handle.
|
|
|
|
|
*
|
2011-11-22 07:06:40 -05:00
|
|
|
|
* <note>The region updated can't be larger than the source
|
|
|
|
|
* bitmap</note>
|
|
|
|
|
*
|
2011-07-25 17:14:08 -04:00
|
|
|
|
* Return value: %TRUE if the subregion upload was successful, and
|
|
|
|
|
* %FALSE otherwise
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.8
|
|
|
|
|
* Stability: unstable
|
|
|
|
|
*/
|
2019-11-21 06:15:22 -05:00
|
|
|
|
COGL_EXPORT gboolean
|
2011-08-24 16:30:34 -04:00
|
|
|
|
cogl_texture_set_region_from_bitmap (CoglTexture *texture,
|
2011-07-25 17:14:08 -04:00
|
|
|
|
int src_x,
|
|
|
|
|
int src_y,
|
|
|
|
|
int dst_x,
|
|
|
|
|
int dst_y,
|
|
|
|
|
unsigned int dst_width,
|
|
|
|
|
unsigned int dst_height,
|
|
|
|
|
CoglBitmap *bitmap);
|
|
|
|
|
|
2012-11-22 18:01:08 -05:00
|
|
|
|
/**
|
|
|
|
|
* cogl_texture_allocate:
|
|
|
|
|
* @texture: A #CoglTexture
|
2019-06-18 02:02:10 -04:00
|
|
|
|
* @error: A #GError to return exceptional errors or %NULL
|
2012-11-22 18:01:08 -05:00
|
|
|
|
*
|
|
|
|
|
* Explicitly allocates the storage for the given @texture which
|
|
|
|
|
* allows you to be sure that there is enough memory for the
|
|
|
|
|
* texture and if not then the error can be handled gracefully.
|
|
|
|
|
*
|
|
|
|
|
* <note>Normally applications don't need to use this api directly
|
|
|
|
|
* since the texture will be implicitly allocated when data is set on
|
|
|
|
|
* the texture, or if the texture is attached to a #CoglOffscreen
|
|
|
|
|
* framebuffer and rendered too.</note>
|
|
|
|
|
*
|
|
|
|
|
* Return value: %TRUE if the texture was successfully allocated,
|
|
|
|
|
* otherwise %FALSE and @error will be updated if it
|
|
|
|
|
* wasn't %NULL.
|
|
|
|
|
*/
|
2019-11-21 06:15:22 -05:00
|
|
|
|
COGL_EXPORT gboolean
|
2012-11-22 18:01:08 -05:00
|
|
|
|
cogl_texture_allocate (CoglTexture *texture,
|
2019-06-18 02:02:10 -04:00
|
|
|
|
GError **error);
|
2012-11-22 18:01:08 -05:00
|
|
|
|
|
2018-12-19 05:46:45 -05:00
|
|
|
|
/**
|
|
|
|
|
* cogl_texture_is_get_data_supported: (skip)
|
|
|
|
|
*/
|
2019-11-21 06:15:22 -05:00
|
|
|
|
COGL_EXPORT gboolean
|
2018-12-19 05:46:45 -05:00
|
|
|
|
cogl_texture_is_get_data_supported (CoglTexture *texture);
|
|
|
|
|
|
2018-11-23 02:42:05 -05:00
|
|
|
|
G_END_DECLS
|
2008-10-30 13:25:00 -04:00
|
|
|
|
|
|
|
|
|
#endif /* __COGL_TEXTURE_H__ */
|