mirror of
https://github.com/brl/mutter.git
synced 2025-02-17 21:54:10 +00:00
Add a strong CoglTexture type to replace CoglHandle
As part of the on going, incremental effort to purge the non type safe CoglHandle type from the Cogl API this patch tackles most of the CoglHandle uses relating to textures. We'd postponed making this change for quite a while because we wanted to have a clearer understanding of how we wanted to evolve the texture APIs towards Cogl 2.0 before exposing type safety here which would be difficult to change later since it would imply breaking APIs. The basic idea that we are steering towards now is that CoglTexture can be considered to be the most primitive interface we have for any object representing a texture. The texture interface would provide roughly these methods: cogl_texture_get_width cogl_texture_get_height cogl_texture_can_repeat cogl_texture_can_mipmap cogl_texture_generate_mipmap; cogl_texture_get_format cogl_texture_set_region cogl_texture_get_region Besides the texture interface we will then start to expose types corresponding to specific texture types: CoglTexture2D, CoglTexture3D, CoglTexture2DSliced, CoglSubTexture, CoglAtlasTexture and CoglTexturePixmapX11. We will then also expose an interface for the high-level texture types we have (such as CoglTexture2DSlice, CoglSubTexture and CoglAtlasTexture) called CoglMetaTexture. CoglMetaTexture is an additional interface that lets you iterate a virtual region of a meta texture and get mappings of primitive textures to sub-regions of that virtual region. Internally we already have this kind of abstraction for dealing with sliced texture, sub-textures and atlas textures in a consistent way, so this will just make that abstraction public. The aim here is to clarify that there is a difference between primitive textures (CoglTexture2D/3D) and some of the other high-level textures, and also enable developers to implement primitives that can support meta textures since they can only be used with the cogl_rectangle API currently. The thing that's not so clean-cut with this are the texture constructors we have currently; such as cogl_texture_new_from_file which no longer make sense when CoglTexture is considered to be an interface. These will basically just become convenient factory functions and it's just a bit unusual that they are within the cogl_texture namespace. It's worth noting here that all the texture type APIs will also have their own type specific constructors so these functions will only be used for the convenience of being able to create a texture without really wanting to know the details of what type of texture you need. Longer term for 2.0 we may come up with replacement names for these factory functions or the other thing we are considering is designing some asynchronous factory functions instead since it's so often detrimental to application performance to be blocked waiting for a texture to be uploaded to the GPU. Reviewed-by: Neil Roberts <neil@linux.intel.com>
This commit is contained in:
parent
dfb7c76567
commit
4c3dadd35e
@ -72,7 +72,7 @@ struct _CoglPangoDisplayListNode
|
|||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
/* The texture to render these coords from */
|
/* The texture to render these coords from */
|
||||||
CoglHandle texture;
|
CoglTexture *texture;
|
||||||
/* Array of rectangles in the format expected by
|
/* Array of rectangles in the format expected by
|
||||||
cogl_rectangles_with_texture_coords */
|
cogl_rectangles_with_texture_coords */
|
||||||
GArray *rectangles;
|
GArray *rectangles;
|
||||||
@ -134,7 +134,7 @@ _cogl_pango_display_list_remove_color_override (CoglPangoDisplayList *dl)
|
|||||||
|
|
||||||
void
|
void
|
||||||
_cogl_pango_display_list_add_texture (CoglPangoDisplayList *dl,
|
_cogl_pango_display_list_add_texture (CoglPangoDisplayList *dl,
|
||||||
CoglHandle texture,
|
CoglTexture *texture,
|
||||||
float x_1, float y_1,
|
float x_1, float y_1,
|
||||||
float x_2, float y_2,
|
float x_2, float y_2,
|
||||||
float tx_1, float ty_1,
|
float tx_1, float ty_1,
|
||||||
@ -168,7 +168,7 @@ _cogl_pango_display_list_add_texture (CoglPangoDisplayList *dl,
|
|||||||
node->color_override = dl->color_override;
|
node->color_override = dl->color_override;
|
||||||
node->color = dl->color;
|
node->color = dl->color;
|
||||||
node->pipeline = NULL;
|
node->pipeline = NULL;
|
||||||
node->d.texture.texture = cogl_handle_ref (texture);
|
node->d.texture.texture = cogl_object_ref (texture);
|
||||||
node->d.texture.rectangles
|
node->d.texture.rectangles
|
||||||
= g_array_new (FALSE, FALSE, sizeof (CoglPangoDisplayListRectangle));
|
= g_array_new (FALSE, FALSE, sizeof (CoglPangoDisplayListRectangle));
|
||||||
node->d.texture.primitive = NULL;
|
node->d.texture.primitive = NULL;
|
||||||
@ -465,8 +465,8 @@ _cogl_pango_display_list_node_free (CoglPangoDisplayListNode *node)
|
|||||||
if (node->type == COGL_PANGO_DISPLAY_LIST_TEXTURE)
|
if (node->type == COGL_PANGO_DISPLAY_LIST_TEXTURE)
|
||||||
{
|
{
|
||||||
g_array_free (node->d.texture.rectangles, TRUE);
|
g_array_free (node->d.texture.rectangles, TRUE);
|
||||||
if (node->d.texture.texture != COGL_INVALID_HANDLE)
|
if (node->d.texture.texture != NULL)
|
||||||
cogl_handle_unref (node->d.texture.texture);
|
cogl_object_unref (node->d.texture.texture);
|
||||||
if (node->d.texture.primitive != NULL)
|
if (node->d.texture.primitive != NULL)
|
||||||
cogl_object_unref (node->d.texture.primitive);
|
cogl_object_unref (node->d.texture.primitive);
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ void _cogl_pango_display_list_set_color_override (CoglPangoDisplayList *dl,
|
|||||||
void _cogl_pango_display_list_remove_color_override (CoglPangoDisplayList *dl);
|
void _cogl_pango_display_list_remove_color_override (CoglPangoDisplayList *dl);
|
||||||
|
|
||||||
void _cogl_pango_display_list_add_texture (CoglPangoDisplayList *dl,
|
void _cogl_pango_display_list_add_texture (CoglPangoDisplayList *dl,
|
||||||
CoglHandle texture,
|
CoglTexture *texture,
|
||||||
float x_1, float y_1,
|
float x_1, float y_1,
|
||||||
float x_2, float y_2,
|
float x_2, float y_2,
|
||||||
float tx_1, float ty_1,
|
float tx_1, float ty_1,
|
||||||
|
@ -71,7 +71,7 @@ static void
|
|||||||
cogl_pango_glyph_cache_value_free (CoglPangoGlyphCacheValue *value)
|
cogl_pango_glyph_cache_value_free (CoglPangoGlyphCacheValue *value)
|
||||||
{
|
{
|
||||||
if (value->texture)
|
if (value->texture)
|
||||||
cogl_handle_unref (value->texture);
|
cogl_object_unref (value->texture);
|
||||||
g_slice_free (CoglPangoGlyphCacheValue, value);
|
g_slice_free (CoglPangoGlyphCacheValue, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,8 +178,8 @@ cogl_pango_glyph_cache_update_position_cb (void *user_data,
|
|||||||
float tex_width, tex_height;
|
float tex_width, tex_height;
|
||||||
|
|
||||||
if (value->texture)
|
if (value->texture)
|
||||||
cogl_handle_unref (value->texture);
|
cogl_object_unref (value->texture);
|
||||||
value->texture = cogl_handle_ref (new_texture);
|
value->texture = cogl_object_ref (new_texture);
|
||||||
|
|
||||||
tex_width = cogl_texture_get_width (new_texture);
|
tex_width = cogl_texture_get_width (new_texture);
|
||||||
tex_height = cogl_texture_get_height (new_texture);
|
tex_height = cogl_texture_get_height (new_texture);
|
||||||
@ -202,7 +202,7 @@ cogl_pango_glyph_cache_add_to_global_atlas (CoglPangoGlyphCache *cache,
|
|||||||
PangoGlyph glyph,
|
PangoGlyph glyph,
|
||||||
CoglPangoGlyphCacheValue *value)
|
CoglPangoGlyphCacheValue *value)
|
||||||
{
|
{
|
||||||
CoglHandle texture;
|
CoglTexture *texture;
|
||||||
|
|
||||||
if (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_SHARED_ATLAS))
|
if (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_SHARED_ATLAS))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -217,7 +217,7 @@ cogl_pango_glyph_cache_add_to_global_atlas (CoglPangoGlyphCache *cache,
|
|||||||
COGL_TEXTURE_NONE,
|
COGL_TEXTURE_NONE,
|
||||||
COGL_PIXEL_FORMAT_RGBA_8888_PRE);
|
COGL_PIXEL_FORMAT_RGBA_8888_PRE);
|
||||||
|
|
||||||
if (texture == COGL_INVALID_HANDLE)
|
if (texture == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
value->texture = texture;
|
value->texture = texture;
|
||||||
@ -310,7 +310,7 @@ cogl_pango_glyph_cache_lookup (CoglPangoGlyphCache *cache,
|
|||||||
PangoRectangle ink_rect;
|
PangoRectangle ink_rect;
|
||||||
|
|
||||||
value = g_slice_new (CoglPangoGlyphCacheValue);
|
value = g_slice_new (CoglPangoGlyphCacheValue);
|
||||||
value->texture = COGL_INVALID_HANDLE;
|
value->texture = NULL;
|
||||||
|
|
||||||
pango_font_get_glyph_extents (font, glyph, &ink_rect, NULL);
|
pango_font_get_glyph_extents (font, glyph, &ink_rect, NULL);
|
||||||
pango_extents_to_pixels (&ink_rect, NULL);
|
pango_extents_to_pixels (&ink_rect, NULL);
|
||||||
|
@ -35,7 +35,7 @@ typedef struct _CoglPangoGlyphCacheValue CoglPangoGlyphCacheValue;
|
|||||||
|
|
||||||
struct _CoglPangoGlyphCacheValue
|
struct _CoglPangoGlyphCacheValue
|
||||||
{
|
{
|
||||||
CoglHandle texture;
|
CoglTexture *texture;
|
||||||
|
|
||||||
float tx1;
|
float tx1;
|
||||||
float ty1;
|
float ty1;
|
||||||
|
@ -49,7 +49,7 @@ struct _CoglPangoPipelineCacheEntry
|
|||||||
{
|
{
|
||||||
/* This will take a reference or it can be NULL to represent the
|
/* This will take a reference or it can be NULL to represent the
|
||||||
pipeline used to render colors */
|
pipeline used to render colors */
|
||||||
CoglHandle texture;
|
CoglTexture *texture;
|
||||||
|
|
||||||
/* This will only take a weak reference */
|
/* This will only take a weak reference */
|
||||||
CoglHandle pipeline;
|
CoglHandle pipeline;
|
||||||
@ -155,7 +155,7 @@ get_base_texture_alpha_pipeline (CoglPangoPipelineCache *cache)
|
|||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
CoglPangoPipelineCache *cache;
|
CoglPangoPipelineCache *cache;
|
||||||
CoglHandle texture;
|
CoglTexture *texture;
|
||||||
} PipelineDestroyNotifyData;
|
} PipelineDestroyNotifyData;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -188,7 +188,7 @@ _cogl_pango_pipeline_cache_get (CoglPangoPipelineCache *cache,
|
|||||||
{
|
{
|
||||||
CoglPipeline *base;
|
CoglPipeline *base;
|
||||||
|
|
||||||
entry->texture = cogl_handle_ref (texture);
|
entry->texture = cogl_object_ref (texture);
|
||||||
|
|
||||||
if (cogl_texture_get_format (entry->texture) == COGL_PIXEL_FORMAT_A_8)
|
if (cogl_texture_get_format (entry->texture) == COGL_PIXEL_FORMAT_A_8)
|
||||||
base = get_base_texture_alpha_pipeline (cache);
|
base = get_base_texture_alpha_pipeline (cache);
|
||||||
@ -216,7 +216,7 @@ _cogl_pango_pipeline_cache_get (CoglPangoPipelineCache *cache,
|
|||||||
pipeline_destroy_notify_cb);
|
pipeline_destroy_notify_cb);
|
||||||
|
|
||||||
g_hash_table_insert (cache->hash_table,
|
g_hash_table_insert (cache->hash_table,
|
||||||
texture ? cogl_handle_ref (texture) : NULL,
|
texture ? cogl_object_ref (texture) : NULL,
|
||||||
entry);
|
entry);
|
||||||
|
|
||||||
/* This doesn't take a reference on the pipeline so that it will use
|
/* This doesn't take a reference on the pipeline so that it will use
|
||||||
|
@ -94,7 +94,7 @@ typedef struct
|
|||||||
} CoglPangoRendererSliceCbData;
|
} CoglPangoRendererSliceCbData;
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_pango_renderer_slice_cb (CoglHandle handle,
|
cogl_pango_renderer_slice_cb (CoglTexture *texture,
|
||||||
const float *slice_coords,
|
const float *slice_coords,
|
||||||
const float *virtual_coords,
|
const float *virtual_coords,
|
||||||
void *user_data)
|
void *user_data)
|
||||||
@ -106,7 +106,7 @@ cogl_pango_renderer_slice_cb (CoglHandle handle,
|
|||||||
coordinates based on the virtual_coords */
|
coordinates based on the virtual_coords */
|
||||||
|
|
||||||
_cogl_pango_display_list_add_texture (data->display_list,
|
_cogl_pango_display_list_add_texture (data->display_list,
|
||||||
handle,
|
texture,
|
||||||
data->x1,
|
data->x1,
|
||||||
data->y1,
|
data->y1,
|
||||||
data->x2,
|
data->x2,
|
||||||
@ -486,7 +486,7 @@ cogl_pango_renderer_set_dirty_glyph (PangoFont *font,
|
|||||||
/* Glyphs that don't take up any space will end up without a
|
/* Glyphs that don't take up any space will end up without a
|
||||||
texture. These should never become dirty so they shouldn't end up
|
texture. These should never become dirty so they shouldn't end up
|
||||||
here */
|
here */
|
||||||
g_return_if_fail (value->texture != COGL_INVALID_HANDLE);
|
g_return_if_fail (value->texture != NULL);
|
||||||
|
|
||||||
if (cogl_texture_get_format (value->texture) == COGL_PIXEL_FORMAT_A_8)
|
if (cogl_texture_get_format (value->texture) == COGL_PIXEL_FORMAT_A_8)
|
||||||
{
|
{
|
||||||
|
@ -384,7 +384,7 @@ _cogl_atlas_texture_migrate_out_of_atlas (CoglAtlasTexture *atlas_tex)
|
|||||||
/* Notify cogl-pipeline.c that the texture's underlying GL texture
|
/* 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
|
* storage is changing so it knows it may need to bind a new texture
|
||||||
* if the CoglTexture is reused with the same texture unit. */
|
* if the CoglTexture is reused with the same texture unit. */
|
||||||
_cogl_pipeline_texture_storage_change_notify (atlas_tex);
|
_cogl_pipeline_texture_storage_change_notify (COGL_TEXTURE (atlas_tex));
|
||||||
|
|
||||||
/* We need to unref the sub texture after doing the copy because
|
/* We need to unref the sub texture after doing the copy because
|
||||||
the copy can involve rendering which might cause the texture
|
the copy can involve rendering which might cause the texture
|
||||||
|
@ -339,14 +339,14 @@ validate_layer_cb (CoglPipeline *pipeline,
|
|||||||
int layer_index,
|
int layer_index,
|
||||||
void *user_data)
|
void *user_data)
|
||||||
{
|
{
|
||||||
CoglHandle texture =
|
CoglTexture *texture =
|
||||||
_cogl_pipeline_get_layer_texture (pipeline, layer_index);
|
_cogl_pipeline_get_layer_texture (pipeline, layer_index);
|
||||||
ValidateLayerState *state = user_data;
|
ValidateLayerState *state = user_data;
|
||||||
gboolean status = TRUE;
|
gboolean status = TRUE;
|
||||||
|
|
||||||
/* invalid textures will be handled correctly in
|
/* invalid textures will be handled correctly in
|
||||||
* _cogl_pipeline_flush_layers_gl_state */
|
* _cogl_pipeline_flush_layers_gl_state */
|
||||||
if (texture == COGL_INVALID_HANDLE)
|
if (texture == NULL)
|
||||||
goto validated;
|
goto validated;
|
||||||
|
|
||||||
_cogl_texture_flush_journal_rendering (texture);
|
_cogl_texture_flush_journal_rendering (texture);
|
||||||
|
@ -243,8 +243,8 @@ cogl_context_new (CoglDisplay *display,
|
|||||||
|
|
||||||
context->legacy_state_set = 0;
|
context->legacy_state_set = 0;
|
||||||
|
|
||||||
context->default_gl_texture_2d_tex = COGL_INVALID_HANDLE;
|
context->default_gl_texture_2d_tex = NULL;
|
||||||
context->default_gl_texture_rect_tex = COGL_INVALID_HANDLE;
|
context->default_gl_texture_rect_tex = NULL;
|
||||||
|
|
||||||
context->framebuffers = NULL;
|
context->framebuffers = NULL;
|
||||||
|
|
||||||
@ -410,9 +410,9 @@ _cogl_context_free (CoglContext *context)
|
|||||||
cogl_handle_unref (context->current_path);
|
cogl_handle_unref (context->current_path);
|
||||||
|
|
||||||
if (context->default_gl_texture_2d_tex)
|
if (context->default_gl_texture_2d_tex)
|
||||||
cogl_handle_unref (context->default_gl_texture_2d_tex);
|
cogl_object_unref (context->default_gl_texture_2d_tex);
|
||||||
if (context->default_gl_texture_rect_tex)
|
if (context->default_gl_texture_rect_tex)
|
||||||
cogl_handle_unref (context->default_gl_texture_rect_tex);
|
cogl_object_unref (context->default_gl_texture_rect_tex);
|
||||||
|
|
||||||
if (context->opaque_color_pipeline)
|
if (context->opaque_color_pipeline)
|
||||||
cogl_handle_unref (context->opaque_color_pipeline);
|
cogl_handle_unref (context->opaque_color_pipeline);
|
||||||
|
@ -108,7 +108,7 @@ typedef struct _CoglOffscreen
|
|||||||
CoglFramebuffer _parent;
|
CoglFramebuffer _parent;
|
||||||
GLuint fbo_handle;
|
GLuint fbo_handle;
|
||||||
GSList *renderbuffers;
|
GSList *renderbuffers;
|
||||||
CoglHandle texture;
|
CoglTexture *texture;
|
||||||
} CoglOffscreen;
|
} CoglOffscreen;
|
||||||
|
|
||||||
/* Flags to pass to _cogl_offscreen_new_to_texture_full */
|
/* Flags to pass to _cogl_offscreen_new_to_texture_full */
|
||||||
@ -244,7 +244,7 @@ _cogl_free_framebuffer_stack (GSList *stack);
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* _cogl_offscreen_new_to_texture_full:
|
* _cogl_offscreen_new_to_texture_full:
|
||||||
* @texhandle: A handle to the texture to target
|
* @texture: A #CoglTexture pointer
|
||||||
* @create_flags: Flags specifying how to create the FBO
|
* @create_flags: Flags specifying how to create the FBO
|
||||||
* @level: The mipmap level within the texture to target
|
* @level: The mipmap level within the texture to target
|
||||||
*
|
*
|
||||||
@ -256,7 +256,7 @@ _cogl_free_framebuffer_stack (GSList *stack);
|
|||||||
* Return value: the new CoglOffscreen object.
|
* Return value: the new CoglOffscreen object.
|
||||||
*/
|
*/
|
||||||
CoglHandle
|
CoglHandle
|
||||||
_cogl_offscreen_new_to_texture_full (CoglHandle texhandle,
|
_cogl_offscreen_new_to_texture_full (CoglTexture *texture,
|
||||||
CoglOffscreenFlags create_flags,
|
CoglOffscreenFlags create_flags,
|
||||||
unsigned int level);
|
unsigned int level);
|
||||||
|
|
||||||
|
@ -682,7 +682,7 @@ _cogl_framebuffer_init_bits (CoglFramebuffer *framebuffer)
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
CoglHandle texture;
|
CoglTexture *texture;
|
||||||
unsigned int level;
|
unsigned int level;
|
||||||
unsigned int level_width;
|
unsigned int level_width;
|
||||||
unsigned int level_height;
|
unsigned int level_height;
|
||||||
@ -808,7 +808,7 @@ try_creating_fbo (CoglOffscreen *offscreen,
|
|||||||
}
|
}
|
||||||
|
|
||||||
CoglHandle
|
CoglHandle
|
||||||
_cogl_offscreen_new_to_texture_full (CoglHandle texhandle,
|
_cogl_offscreen_new_to_texture_full (CoglTexture *texture,
|
||||||
CoglOffscreenFlags create_flags,
|
CoglOffscreenFlags create_flags,
|
||||||
unsigned int level)
|
unsigned int level)
|
||||||
{
|
{
|
||||||
@ -824,21 +824,21 @@ _cogl_offscreen_new_to_texture_full (CoglHandle texhandle,
|
|||||||
if (!cogl_features_available (COGL_FEATURE_OFFSCREEN))
|
if (!cogl_features_available (COGL_FEATURE_OFFSCREEN))
|
||||||
return COGL_INVALID_HANDLE;
|
return COGL_INVALID_HANDLE;
|
||||||
|
|
||||||
/* Make texhandle is a valid texture object */
|
/* Make texture is a valid texture object */
|
||||||
if (!cogl_is_texture (texhandle))
|
if (!cogl_is_texture (texture))
|
||||||
return COGL_INVALID_HANDLE;
|
return COGL_INVALID_HANDLE;
|
||||||
|
|
||||||
/* The texture must not be sliced */
|
/* The texture must not be sliced */
|
||||||
if (cogl_texture_is_sliced (texhandle))
|
if (cogl_texture_is_sliced (texture))
|
||||||
return COGL_INVALID_HANDLE;
|
return COGL_INVALID_HANDLE;
|
||||||
|
|
||||||
data.texture = texhandle;
|
data.texture = texture;
|
||||||
data.level = level;
|
data.level = level;
|
||||||
|
|
||||||
/* Calculate the size of the texture at this mipmap level to ensure
|
/* Calculate the size of the texture at this mipmap level to ensure
|
||||||
that it's a valid level */
|
that it's a valid level */
|
||||||
data.level_width = cogl_texture_get_width (texhandle);
|
data.level_width = cogl_texture_get_width (texture);
|
||||||
data.level_height = cogl_texture_get_height (texhandle);
|
data.level_height = cogl_texture_get_height (texture);
|
||||||
|
|
||||||
for (i = 0; i < level; i++)
|
for (i = 0; i < level; i++)
|
||||||
{
|
{
|
||||||
@ -863,10 +863,10 @@ _cogl_offscreen_new_to_texture_full (CoglHandle texhandle,
|
|||||||
* the texture is actually used for rendering according to the filters set on
|
* the texture is actually used for rendering according to the filters set on
|
||||||
* the corresponding CoglPipeline.
|
* the corresponding CoglPipeline.
|
||||||
*/
|
*/
|
||||||
_cogl_texture_set_filters (texhandle, GL_NEAREST, GL_NEAREST);
|
_cogl_texture_set_filters (texture, GL_NEAREST, GL_NEAREST);
|
||||||
|
|
||||||
offscreen = g_new0 (CoglOffscreen, 1);
|
offscreen = g_new0 (CoglOffscreen, 1);
|
||||||
offscreen->texture = texhandle;
|
offscreen->texture = texture;
|
||||||
|
|
||||||
if ((create_flags & COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL))
|
if ((create_flags & COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL))
|
||||||
fbo_created = try_creating_fbo (offscreen, 0, &data);
|
fbo_created = try_creating_fbo (offscreen, 0, &data);
|
||||||
@ -903,15 +903,14 @@ _cogl_offscreen_new_to_texture_full (CoglHandle texhandle,
|
|||||||
_cogl_framebuffer_init (fb,
|
_cogl_framebuffer_init (fb,
|
||||||
ctx,
|
ctx,
|
||||||
COGL_FRAMEBUFFER_TYPE_OFFSCREEN,
|
COGL_FRAMEBUFFER_TYPE_OFFSCREEN,
|
||||||
cogl_texture_get_format (texhandle),
|
cogl_texture_get_format (texture),
|
||||||
data.level_width,
|
data.level_width,
|
||||||
data.level_height);
|
data.level_height);
|
||||||
|
|
||||||
/* take a reference on the texture */
|
cogl_object_ref (offscreen->texture);
|
||||||
cogl_handle_ref (offscreen->texture);
|
|
||||||
|
|
||||||
ret = _cogl_offscreen_object_new (offscreen);
|
ret = _cogl_offscreen_object_new (offscreen);
|
||||||
_cogl_texture_associate_framebuffer (texhandle, COGL_FRAMEBUFFER (ret));
|
_cogl_texture_associate_framebuffer (texture, COGL_FRAMEBUFFER (ret));
|
||||||
|
|
||||||
fb->allocated = TRUE;
|
fb->allocated = TRUE;
|
||||||
|
|
||||||
@ -928,9 +927,9 @@ _cogl_offscreen_new_to_texture_full (CoglHandle texhandle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
CoglHandle
|
CoglHandle
|
||||||
cogl_offscreen_new_to_texture (CoglHandle texhandle)
|
cogl_offscreen_new_to_texture (CoglTexture *texture)
|
||||||
{
|
{
|
||||||
return _cogl_offscreen_new_to_texture_full (texhandle, 0, 0);
|
return _cogl_offscreen_new_to_texture_full (texture, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -953,7 +952,7 @@ _cogl_offscreen_free (CoglOffscreen *offscreen)
|
|||||||
GE (ctx, glDeleteFramebuffers (1, &offscreen->fbo_handle));
|
GE (ctx, glDeleteFramebuffers (1, &offscreen->fbo_handle));
|
||||||
|
|
||||||
if (offscreen->texture != COGL_INVALID_HANDLE)
|
if (offscreen->texture != COGL_INVALID_HANDLE)
|
||||||
cogl_handle_unref (offscreen->texture);
|
cogl_object_unref (offscreen->texture);
|
||||||
|
|
||||||
g_free (offscreen);
|
g_free (offscreen);
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ _cogl_journal_log_quad (CoglJournal *journal,
|
|||||||
const float *position,
|
const float *position,
|
||||||
CoglPipeline *pipeline,
|
CoglPipeline *pipeline,
|
||||||
int n_layers,
|
int n_layers,
|
||||||
CoglHandle layer0_override_texture,
|
CoglTexture *layer0_override_texture,
|
||||||
const float *tex_coords,
|
const float *tex_coords,
|
||||||
unsigned int tex_coords_len);
|
unsigned int tex_coords_len);
|
||||||
|
|
||||||
|
@ -1449,7 +1449,7 @@ static gboolean
|
|||||||
add_framebuffer_deps_cb (CoglPipelineLayer *layer, void *user_data)
|
add_framebuffer_deps_cb (CoglPipelineLayer *layer, void *user_data)
|
||||||
{
|
{
|
||||||
CoglFramebuffer *framebuffer = user_data;
|
CoglFramebuffer *framebuffer = user_data;
|
||||||
CoglHandle texture = _cogl_pipeline_layer_get_texture_real (layer);
|
CoglTexture *texture = _cogl_pipeline_layer_get_texture_real (layer);
|
||||||
const GList *l;
|
const GList *l;
|
||||||
|
|
||||||
if (!texture)
|
if (!texture)
|
||||||
@ -1466,7 +1466,7 @@ _cogl_journal_log_quad (CoglJournal *journal,
|
|||||||
const float *position,
|
const float *position,
|
||||||
CoglPipeline *pipeline,
|
CoglPipeline *pipeline,
|
||||||
int n_layers,
|
int n_layers,
|
||||||
CoglHandle layer0_override_texture,
|
CoglTexture *layer0_override_texture,
|
||||||
const float *tex_coords,
|
const float *tex_coords,
|
||||||
unsigned int tex_coords_len)
|
unsigned int tex_coords_len)
|
||||||
{
|
{
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#define __COGL_OFFSCREEN_H__
|
#define __COGL_OFFSCREEN_H__
|
||||||
|
|
||||||
#include <cogl/cogl-types.h>
|
#include <cogl/cogl-types.h>
|
||||||
|
#include <cogl/cogl-texture.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
@ -44,14 +45,14 @@ G_BEGIN_DECLS
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* cogl_offscreen_new_to_texture:
|
* cogl_offscreen_new_to_texture:
|
||||||
* @handle: A CoglHandle for a Cogl texture
|
* @texture: A #CoglTexture pointer
|
||||||
*
|
*
|
||||||
* This creates an offscreen buffer object using the given texture as the
|
* This creates an offscreen buffer object using the given @texture as the
|
||||||
* primary color buffer. It doesn't just initialize the contents of the
|
* primary color buffer. It doesn't just initialize the contents of the
|
||||||
* offscreen buffer with the texture; they are tightly bound so that
|
* offscreen buffer with the @texture; they are tightly bound so that
|
||||||
* drawing to the offscreen buffer effectivly updates the contents of the
|
* drawing to the offscreen buffer effectivly updates the contents of the
|
||||||
* given texture. You don't need to destroy the offscreen buffer before
|
* given texture. You don't need to destroy the offscreen buffer before
|
||||||
* you can use the texture again.
|
* you can use the @texture again.
|
||||||
*
|
*
|
||||||
* Note: This does not work with sliced Cogl textures.
|
* Note: This does not work with sliced Cogl textures.
|
||||||
*
|
*
|
||||||
@ -59,7 +60,7 @@ G_BEGIN_DECLS
|
|||||||
* buffer or %COGL_INVALID_HANDLE if it wasn't possible to create the
|
* buffer or %COGL_INVALID_HANDLE if it wasn't possible to create the
|
||||||
* buffer.
|
* buffer.
|
||||||
*/
|
*/
|
||||||
CoglHandle cogl_offscreen_new_to_texture (CoglHandle handle);
|
CoglHandle cogl_offscreen_new_to_texture (CoglTexture *texture);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cogl_is_offscreen:
|
* cogl_is_offscreen:
|
||||||
|
@ -366,7 +366,7 @@ ensure_texture_lookup_generated (CoglPipelineShaderState *shader_state,
|
|||||||
|
|
||||||
texture = _cogl_pipeline_layer_get_texture (layer);
|
texture = _cogl_pipeline_layer_get_texture (layer);
|
||||||
|
|
||||||
if (texture == COGL_INVALID_HANDLE)
|
if (texture == NULL)
|
||||||
{
|
{
|
||||||
target_string = "2D";
|
target_string = "2D";
|
||||||
tex_coord_swizzle = "st";
|
tex_coord_swizzle = "st";
|
||||||
|
@ -108,7 +108,7 @@ _cogl_pipeline_set_layer_unit (CoglPipeline *required_owner,
|
|||||||
return layer;
|
return layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoglHandle
|
CoglTexture *
|
||||||
_cogl_pipeline_layer_get_texture_real (CoglPipelineLayer *layer)
|
_cogl_pipeline_layer_get_texture_real (CoglPipelineLayer *layer)
|
||||||
{
|
{
|
||||||
CoglPipelineLayer *authority =
|
CoglPipelineLayer *authority =
|
||||||
@ -118,7 +118,7 @@ _cogl_pipeline_layer_get_texture_real (CoglPipelineLayer *layer)
|
|||||||
return authority->texture;
|
return authority->texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoglHandle
|
CoglTexture *
|
||||||
_cogl_pipeline_get_layer_texture (CoglPipeline *pipeline,
|
_cogl_pipeline_get_layer_texture (CoglPipeline *pipeline,
|
||||||
int layer_index)
|
int layer_index)
|
||||||
{
|
{
|
||||||
@ -201,7 +201,7 @@ changed:
|
|||||||
static void
|
static void
|
||||||
_cogl_pipeline_set_layer_texture_data (CoglPipeline *pipeline,
|
_cogl_pipeline_set_layer_texture_data (CoglPipeline *pipeline,
|
||||||
int layer_index,
|
int layer_index,
|
||||||
CoglHandle texture)
|
CoglTexture *texture)
|
||||||
{
|
{
|
||||||
CoglPipelineLayerState change = COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA;
|
CoglPipelineLayerState change = COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA;
|
||||||
CoglPipelineLayer *layer;
|
CoglPipelineLayer *layer;
|
||||||
@ -282,7 +282,7 @@ changed:
|
|||||||
* with no associated CoglTexture will have a texture target of 0.
|
* with no associated CoglTexture will have a texture target of 0.
|
||||||
*/
|
*/
|
||||||
static GLenum
|
static GLenum
|
||||||
get_texture_target (CoglHandle texture)
|
get_texture_target (CoglTexture *texture)
|
||||||
{
|
{
|
||||||
GLuint ignore_handle;
|
GLuint ignore_handle;
|
||||||
GLenum gl_target;
|
GLenum gl_target;
|
||||||
@ -297,7 +297,7 @@ get_texture_target (CoglHandle texture)
|
|||||||
void
|
void
|
||||||
cogl_pipeline_set_layer_texture (CoglPipeline *pipeline,
|
cogl_pipeline_set_layer_texture (CoglPipeline *pipeline,
|
||||||
int layer_index,
|
int layer_index,
|
||||||
CoglHandle texture)
|
CoglTexture *texture)
|
||||||
{
|
{
|
||||||
/* For the convenience of fragend code we separate texture state
|
/* For the convenience of fragend code we separate texture state
|
||||||
* into the "target" and the "data", and setting a layer texture
|
* into the "target" and the "data", and setting a layer texture
|
||||||
@ -1305,7 +1305,7 @@ cogl_pipeline_set_layer_matrix (CoglPipeline *pipeline,
|
|||||||
|
|
||||||
/* FIXME: deprecate and replace with
|
/* FIXME: deprecate and replace with
|
||||||
* cogl_pipeline_get_layer_texture() instead. */
|
* cogl_pipeline_get_layer_texture() instead. */
|
||||||
CoglHandle
|
CoglTexture *
|
||||||
_cogl_pipeline_layer_get_texture (CoglPipelineLayer *layer)
|
_cogl_pipeline_layer_get_texture (CoglPipelineLayer *layer)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (_cogl_is_pipeline_layer (layer), NULL);
|
g_return_val_if_fail (_cogl_is_pipeline_layer (layer), NULL);
|
||||||
|
@ -121,7 +121,7 @@ typedef enum {
|
|||||||
* cogl_pipeline_set_layer:
|
* cogl_pipeline_set_layer:
|
||||||
* @pipeline: A #CoglPipeline object
|
* @pipeline: A #CoglPipeline object
|
||||||
* @layer_index: the index of the layer
|
* @layer_index: the index of the layer
|
||||||
* @texture: a #CoglHandle for the layer object
|
* @texture: a #CoglTexture for the layer object
|
||||||
*
|
*
|
||||||
* In addition to the standard OpenGL lighting model a Cogl pipeline may have
|
* In addition to the standard OpenGL lighting model a Cogl pipeline may have
|
||||||
* one or more layers comprised of textures that can be blended together in
|
* one or more layers comprised of textures that can be blended together in
|
||||||
@ -139,7 +139,7 @@ typedef enum {
|
|||||||
void
|
void
|
||||||
cogl_pipeline_set_layer_texture (CoglPipeline *pipeline,
|
cogl_pipeline_set_layer_texture (CoglPipeline *pipeline,
|
||||||
int layer_index,
|
int layer_index,
|
||||||
CoglHandle texture);
|
CoglTexture *texture);
|
||||||
|
|
||||||
#define cogl_pipeline_remove_layer cogl_pipeline_remove_layer_EXP
|
#define cogl_pipeline_remove_layer cogl_pipeline_remove_layer_EXP
|
||||||
/**
|
/**
|
||||||
|
@ -217,7 +217,7 @@ _cogl_delete_gl_texture (GLuint gl_texture)
|
|||||||
* if it is reused again with the same texture unit.
|
* if it is reused again with the same texture unit.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
_cogl_pipeline_texture_storage_change_notify (CoglHandle texture)
|
_cogl_pipeline_texture_storage_change_notify (CoglTexture *texture)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -781,11 +781,11 @@ flush_layers_common_gl_state_cb (CoglPipelineLayer *layer, void *user_data)
|
|||||||
unsigned long state = COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA;
|
unsigned long state = COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA;
|
||||||
CoglPipelineLayer *authority =
|
CoglPipelineLayer *authority =
|
||||||
_cogl_pipeline_layer_get_authority (layer, state);
|
_cogl_pipeline_layer_get_authority (layer, state);
|
||||||
CoglHandle texture;
|
CoglTexture *texture;
|
||||||
GLuint gl_texture;
|
GLuint gl_texture;
|
||||||
GLenum gl_target;
|
GLenum gl_target;
|
||||||
|
|
||||||
texture = (authority->texture == COGL_INVALID_HANDLE ?
|
texture = (authority->texture == NULL ?
|
||||||
ctx->default_gl_texture_2d_tex :
|
ctx->default_gl_texture_2d_tex :
|
||||||
authority->texture);
|
authority->texture);
|
||||||
|
|
||||||
@ -897,12 +897,12 @@ _cogl_pipeline_flush_common_gl_state (CoglPipeline *pipeline,
|
|||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
_cogl_pipeline_layer_forward_wrap_modes (CoglPipelineLayer *layer,
|
_cogl_pipeline_layer_forward_wrap_modes (CoglPipelineLayer *layer,
|
||||||
CoglHandle texture)
|
CoglTexture *texture)
|
||||||
{
|
{
|
||||||
CoglPipelineWrapModeInternal wrap_mode_s, wrap_mode_t, wrap_mode_p;
|
CoglPipelineWrapModeInternal wrap_mode_s, wrap_mode_t, wrap_mode_p;
|
||||||
GLenum gl_wrap_mode_s, gl_wrap_mode_t, gl_wrap_mode_p;
|
GLenum gl_wrap_mode_s, gl_wrap_mode_t, gl_wrap_mode_p;
|
||||||
|
|
||||||
if (texture == COGL_INVALID_HANDLE)
|
if (texture == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_cogl_pipeline_layer_get_wrap_modes (layer,
|
_cogl_pipeline_layer_get_wrap_modes (layer,
|
||||||
@ -964,9 +964,9 @@ foreach_texture_unit_update_filter_and_wrap_modes (void)
|
|||||||
|
|
||||||
if (unit->layer)
|
if (unit->layer)
|
||||||
{
|
{
|
||||||
CoglHandle texture = _cogl_pipeline_layer_get_texture (unit->layer);
|
CoglTexture *texture = _cogl_pipeline_layer_get_texture (unit->layer);
|
||||||
|
|
||||||
if (texture != COGL_INVALID_HANDLE)
|
if (texture != NULL)
|
||||||
{
|
{
|
||||||
CoglPipelineFilter min;
|
CoglPipelineFilter min;
|
||||||
CoglPipelineFilter mag;
|
CoglPipelineFilter mag;
|
||||||
|
@ -387,9 +387,9 @@ struct _CoglPipelineLayer
|
|||||||
/* Each layer is directly associated with a single texture unit */
|
/* Each layer is directly associated with a single texture unit */
|
||||||
int unit_index;
|
int unit_index;
|
||||||
|
|
||||||
/* The texture for this layer, or COGL_INVALID_HANDLE for an empty
|
/* The texture for this layer, or NULL for an empty
|
||||||
* layer */
|
* layer */
|
||||||
CoglHandle texture;
|
CoglTexture *texture;
|
||||||
GLenum target;
|
GLenum target;
|
||||||
|
|
||||||
CoglPipelineFilter mag_filter;
|
CoglPipelineFilter mag_filter;
|
||||||
@ -1006,7 +1006,7 @@ typedef struct _CoglPipelineFlushOptions
|
|||||||
|
|
||||||
guint32 fallback_layers;
|
guint32 fallback_layers;
|
||||||
guint32 disable_layers;
|
guint32 disable_layers;
|
||||||
CoglHandle layer0_override_texture;
|
CoglTexture *layer0_override_texture;
|
||||||
} CoglPipelineFlushOptions;
|
} CoglPipelineFlushOptions;
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1194,7 +1194,7 @@ _cogl_pipeline_get_layer_matrix (CoglPipeline *pipeline,
|
|||||||
int layer_index);
|
int layer_index);
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_pipeline_texture_storage_change_notify (CoglHandle texture);
|
_cogl_pipeline_texture_storage_change_notify (CoglTexture *texture);
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_pipeline_apply_legacy_state (CoglPipeline *pipeline);
|
_cogl_pipeline_apply_legacy_state (CoglPipeline *pipeline);
|
||||||
@ -1229,7 +1229,7 @@ _cogl_pipeline_find_equivalent_parent (CoglPipeline *pipeline,
|
|||||||
CoglPipelineState pipeline_state,
|
CoglPipelineState pipeline_state,
|
||||||
CoglPipelineLayerState layer_state);
|
CoglPipelineLayerState layer_state);
|
||||||
|
|
||||||
CoglHandle
|
CoglTexture *
|
||||||
_cogl_pipeline_get_layer_texture (CoglPipeline *pipeline,
|
_cogl_pipeline_get_layer_texture (CoglPipeline *pipeline,
|
||||||
int layer_index);
|
int layer_index);
|
||||||
|
|
||||||
@ -1273,10 +1273,10 @@ typedef enum {
|
|||||||
CoglPipelineLayerType
|
CoglPipelineLayerType
|
||||||
_cogl_pipeline_layer_get_type (CoglPipelineLayer *layer);
|
_cogl_pipeline_layer_get_type (CoglPipelineLayer *layer);
|
||||||
|
|
||||||
CoglHandle
|
CoglTexture *
|
||||||
_cogl_pipeline_layer_get_texture (CoglPipelineLayer *layer);
|
_cogl_pipeline_layer_get_texture (CoglPipelineLayer *layer);
|
||||||
|
|
||||||
CoglHandle
|
CoglTexture *
|
||||||
_cogl_pipeline_layer_get_texture_real (CoglPipelineLayer *layer);
|
_cogl_pipeline_layer_get_texture_real (CoglPipelineLayer *layer);
|
||||||
|
|
||||||
CoglPipelineFilter
|
CoglPipelineFilter
|
||||||
@ -1302,7 +1302,7 @@ CoglPipelineLayer *
|
|||||||
_cogl_pipeline_layer_get_authority (CoglPipelineLayer *layer,
|
_cogl_pipeline_layer_get_authority (CoglPipelineLayer *layer,
|
||||||
unsigned long difference);
|
unsigned long difference);
|
||||||
|
|
||||||
CoglHandle
|
CoglTexture *
|
||||||
_cogl_pipeline_layer_get_texture (CoglPipelineLayer *layer);
|
_cogl_pipeline_layer_get_texture (CoglPipelineLayer *layer);
|
||||||
|
|
||||||
typedef gboolean (*CoglPipelineInternalLayerCallback) (CoglPipelineLayer *layer,
|
typedef gboolean (*CoglPipelineInternalLayerCallback) (CoglPipelineLayer *layer,
|
||||||
|
@ -2149,7 +2149,7 @@ fallback_layer_cb (CoglPipelineLayer *layer, void *user_data)
|
|||||||
|
|
||||||
COGL_COUNTER_INC (_cogl_uprof_context, layer_fallback_counter);
|
COGL_COUNTER_INC (_cogl_uprof_context, layer_fallback_counter);
|
||||||
|
|
||||||
if (G_LIKELY (texture != COGL_INVALID_HANDLE))
|
if (G_LIKELY (texture != NULL))
|
||||||
cogl_texture_get_gl_texture (texture, NULL, &gl_target);
|
cogl_texture_get_gl_texture (texture, NULL, &gl_target);
|
||||||
else
|
else
|
||||||
gl_target = GL_TEXTURE_2D;
|
gl_target = GL_TEXTURE_2D;
|
||||||
@ -3161,7 +3161,7 @@ _cogl_pipeline_layer_pre_paint (CoglPipelineLayer *layer)
|
|||||||
_cogl_pipeline_layer_get_authority (layer,
|
_cogl_pipeline_layer_get_authority (layer,
|
||||||
COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA);
|
COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA);
|
||||||
|
|
||||||
if (texture_authority->texture != COGL_INVALID_HANDLE)
|
if (texture_authority->texture != NULL)
|
||||||
{
|
{
|
||||||
CoglTexturePrePaintFlags flags = 0;
|
CoglTexturePrePaintFlags flags = 0;
|
||||||
CoglPipelineFilter min_filter;
|
CoglPipelineFilter min_filter;
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
typedef struct _TextureSlicedQuadState
|
typedef struct _TextureSlicedQuadState
|
||||||
{
|
{
|
||||||
CoglPipeline *pipeline;
|
CoglPipeline *pipeline;
|
||||||
CoglHandle main_texture;
|
CoglTexture *main_texture;
|
||||||
float tex_virtual_origin_x;
|
float tex_virtual_origin_x;
|
||||||
float tex_virtual_origin_y;
|
float tex_virtual_origin_y;
|
||||||
float quad_origin_x;
|
float quad_origin_x;
|
||||||
@ -68,14 +68,14 @@ typedef struct _TextureSlicedPolygonState
|
|||||||
} TextureSlicedPolygonState;
|
} TextureSlicedPolygonState;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
log_quad_sub_textures_cb (CoglHandle texture_handle,
|
log_quad_sub_textures_cb (CoglTexture *texture,
|
||||||
const float *subtexture_coords,
|
const float *subtexture_coords,
|
||||||
const float *virtual_coords,
|
const float *virtual_coords,
|
||||||
void *user_data)
|
void *user_data)
|
||||||
{
|
{
|
||||||
TextureSlicedQuadState *state = user_data;
|
TextureSlicedQuadState *state = user_data;
|
||||||
CoglFramebuffer *framebuffer = cogl_get_draw_framebuffer ();
|
CoglFramebuffer *framebuffer = cogl_get_draw_framebuffer ();
|
||||||
CoglHandle texture_override;
|
CoglTexture *texture_override;
|
||||||
float quad_coords[4];
|
float quad_coords[4];
|
||||||
|
|
||||||
#define TEX_VIRTUAL_TO_QUAD(V, Q, AXIS) \
|
#define TEX_VIRTUAL_TO_QUAD(V, Q, AXIS) \
|
||||||
@ -112,10 +112,10 @@ log_quad_sub_textures_cb (CoglHandle texture_handle,
|
|||||||
|
|
||||||
/* We only need to override the texture if it's different from the
|
/* We only need to override the texture if it's different from the
|
||||||
main texture */
|
main texture */
|
||||||
if (texture_handle == state->main_texture)
|
if (texture == state->main_texture)
|
||||||
texture_override = COGL_INVALID_HANDLE;
|
texture_override = NULL;
|
||||||
else
|
else
|
||||||
texture_override = texture_handle;
|
texture_override = texture;
|
||||||
|
|
||||||
_cogl_journal_log_quad (framebuffer->journal,
|
_cogl_journal_log_quad (framebuffer->journal,
|
||||||
quad_coords,
|
quad_coords,
|
||||||
@ -180,7 +180,7 @@ validate_first_layer_cb (CoglPipeline *pipeline,
|
|||||||
*/
|
*/
|
||||||
/* TODO: support multitexturing */
|
/* TODO: support multitexturing */
|
||||||
static void
|
static void
|
||||||
_cogl_texture_quad_multiple_primitives (CoglHandle tex_handle,
|
_cogl_texture_quad_multiple_primitives (CoglTexture *texture,
|
||||||
CoglPipeline *pipeline,
|
CoglPipeline *pipeline,
|
||||||
gboolean clamp_s,
|
gboolean clamp_s,
|
||||||
gboolean clamp_t,
|
gboolean clamp_t,
|
||||||
@ -220,7 +220,7 @@ _cogl_texture_quad_multiple_primitives (CoglHandle tex_handle,
|
|||||||
(position[2] - position[0]) *
|
(position[2] - position[0]) *
|
||||||
(tx_1 - old_tx_1) / (old_tx_2 - old_tx_1)),
|
(tx_1 - old_tx_1) / (old_tx_2 - old_tx_1)),
|
||||||
position[3] };
|
position[3] };
|
||||||
_cogl_texture_quad_multiple_primitives (tex_handle, pipeline,
|
_cogl_texture_quad_multiple_primitives (texture, pipeline,
|
||||||
FALSE, clamp_t,
|
FALSE, clamp_t,
|
||||||
tmp_position,
|
tmp_position,
|
||||||
tx_1, ty_1, tx_1, ty_2);
|
tx_1, ty_1, tx_1, ty_2);
|
||||||
@ -235,7 +235,7 @@ _cogl_texture_quad_multiple_primitives (CoglHandle tex_handle,
|
|||||||
(position[2] - position[0]) *
|
(position[2] - position[0]) *
|
||||||
(tx_2 - old_tx_1) / (old_tx_2 - old_tx_1)),
|
(tx_2 - old_tx_1) / (old_tx_2 - old_tx_1)),
|
||||||
position[1], position[2], position[3] };
|
position[1], position[2], position[3] };
|
||||||
_cogl_texture_quad_multiple_primitives (tex_handle, pipeline,
|
_cogl_texture_quad_multiple_primitives (texture, pipeline,
|
||||||
FALSE, clamp_t,
|
FALSE, clamp_t,
|
||||||
tmp_position,
|
tmp_position,
|
||||||
tx_2, ty_1, tx_2, ty_2);
|
tx_2, ty_1, tx_2, ty_2);
|
||||||
@ -267,7 +267,7 @@ _cogl_texture_quad_multiple_primitives (CoglHandle tex_handle,
|
|||||||
(position[1] +
|
(position[1] +
|
||||||
(position[3] - position[1]) *
|
(position[3] - position[1]) *
|
||||||
(ty_1 - old_ty_1) / (old_ty_2 - old_ty_1)) };
|
(ty_1 - old_ty_1) / (old_ty_2 - old_ty_1)) };
|
||||||
_cogl_texture_quad_multiple_primitives (tex_handle, pipeline,
|
_cogl_texture_quad_multiple_primitives (texture, pipeline,
|
||||||
clamp_s, FALSE,
|
clamp_s, FALSE,
|
||||||
tmp_position,
|
tmp_position,
|
||||||
tx_1, ty_1, tx_2, ty_1);
|
tx_1, ty_1, tx_2, ty_1);
|
||||||
@ -283,7 +283,7 @@ _cogl_texture_quad_multiple_primitives (CoglHandle tex_handle,
|
|||||||
(position[3] - position[1]) *
|
(position[3] - position[1]) *
|
||||||
(ty_2 - old_ty_1) / (old_ty_2 - old_ty_1)),
|
(ty_2 - old_ty_1) / (old_ty_2 - old_ty_1)),
|
||||||
position[2], position[3] };
|
position[2], position[3] };
|
||||||
_cogl_texture_quad_multiple_primitives (tex_handle, pipeline,
|
_cogl_texture_quad_multiple_primitives (texture, pipeline,
|
||||||
clamp_s, FALSE,
|
clamp_s, FALSE,
|
||||||
tmp_position,
|
tmp_position,
|
||||||
tx_1, ty_2, tx_2, ty_2);
|
tx_1, ty_2, tx_2, ty_2);
|
||||||
@ -302,7 +302,7 @@ _cogl_texture_quad_multiple_primitives (CoglHandle tex_handle,
|
|||||||
validate_first_layer_cb,
|
validate_first_layer_cb,
|
||||||
&validate_first_layer_state);
|
&validate_first_layer_state);
|
||||||
|
|
||||||
state.main_texture = tex_handle;
|
state.main_texture = texture;
|
||||||
|
|
||||||
if (validate_first_layer_state.override_pipeline)
|
if (validate_first_layer_state.override_pipeline)
|
||||||
state.pipeline = validate_first_layer_state.override_pipeline;
|
state.pipeline = validate_first_layer_state.override_pipeline;
|
||||||
@ -350,7 +350,7 @@ _cogl_texture_quad_multiple_primitives (CoglHandle tex_handle,
|
|||||||
state.v_to_q_scale_x = fabs (state.quad_len_x / (tx_2 - tx_1));
|
state.v_to_q_scale_x = fabs (state.quad_len_x / (tx_2 - tx_1));
|
||||||
state.v_to_q_scale_y = fabs (state.quad_len_y / (ty_2 - ty_1));
|
state.v_to_q_scale_y = fabs (state.quad_len_y / (ty_2 - ty_1));
|
||||||
|
|
||||||
_cogl_texture_foreach_sub_texture_in_region (tex_handle,
|
_cogl_texture_foreach_sub_texture_in_region (texture,
|
||||||
tx_1, ty_1, tx_2, ty_2,
|
tx_1, ty_1, tx_2, ty_2,
|
||||||
log_quad_sub_textures_cb,
|
log_quad_sub_textures_cb,
|
||||||
&state);
|
&state);
|
||||||
@ -379,7 +379,7 @@ validate_tex_coords_cb (CoglPipeline *pipeline,
|
|||||||
void *user_data)
|
void *user_data)
|
||||||
{
|
{
|
||||||
ValidateTexCoordsState *state = user_data;
|
ValidateTexCoordsState *state = user_data;
|
||||||
CoglHandle texture;
|
CoglTexture *texture;
|
||||||
const float *in_tex_coords;
|
const float *in_tex_coords;
|
||||||
float *out_tex_coords;
|
float *out_tex_coords;
|
||||||
float default_tex_coords[4] = {0.0, 0.0, 1.0, 1.0};
|
float default_tex_coords[4] = {0.0, 0.0, 1.0, 1.0};
|
||||||
@ -457,7 +457,7 @@ validate_tex_coords_cb (CoglPipeline *pipeline,
|
|||||||
"supported with multi-texturing.", state->i);
|
"supported with multi-texturing.", state->i);
|
||||||
warning_seen = TRUE;
|
warning_seen = TRUE;
|
||||||
|
|
||||||
cogl_pipeline_set_layer_texture (texture, layer_index, NULL);
|
cogl_pipeline_set_layer_texture (pipeline, layer_index, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -543,7 +543,7 @@ _cogl_multitexture_quad_single_primitive (const float *position,
|
|||||||
position,
|
position,
|
||||||
pipeline,
|
pipeline,
|
||||||
n_layers,
|
n_layers,
|
||||||
COGL_INVALID_HANDLE, /* no texture override */
|
NULL, /* no texture override */
|
||||||
final_tex_coords,
|
final_tex_coords,
|
||||||
n_layers * 4);
|
n_layers * 4);
|
||||||
|
|
||||||
@ -567,7 +567,7 @@ _cogl_rectangles_validate_layer_cb (CoglPipeline *pipeline,
|
|||||||
void *user_data)
|
void *user_data)
|
||||||
{
|
{
|
||||||
ValidateLayerState *state = user_data;
|
ValidateLayerState *state = user_data;
|
||||||
CoglHandle texture;
|
CoglTexture *texture;
|
||||||
|
|
||||||
state->i++;
|
state->i++;
|
||||||
|
|
||||||
@ -615,9 +615,9 @@ _cogl_rectangles_validate_layer_cb (CoglPipeline *pipeline,
|
|||||||
|
|
||||||
texture = _cogl_pipeline_get_layer_texture (pipeline, layer_index);
|
texture = _cogl_pipeline_get_layer_texture (pipeline, layer_index);
|
||||||
|
|
||||||
/* COGL_INVALID_HANDLE textures are handled by
|
/* NULL textures are handled by
|
||||||
* _cogl_pipeline_flush_gl_state */
|
* _cogl_pipeline_flush_gl_state */
|
||||||
if (texture == COGL_INVALID_HANDLE)
|
if (texture == NULL)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
if (state->i == 0)
|
if (state->i == 0)
|
||||||
@ -753,7 +753,7 @@ _cogl_rectangles_with_multitexture_coords (
|
|||||||
|
|
||||||
for (i = 0; i < n_rects; i++)
|
for (i = 0; i < n_rects; i++)
|
||||||
{
|
{
|
||||||
CoglHandle texture;
|
CoglTexture *texture;
|
||||||
const float default_tex_coords[4] = {0.0, 0.0, 1.0, 1.0};
|
const float default_tex_coords[4] = {0.0, 0.0, 1.0, 1.0};
|
||||||
const float *tex_coords;
|
const float *tex_coords;
|
||||||
gboolean clamp_s, clamp_t;
|
gboolean clamp_s, clamp_t;
|
||||||
@ -981,19 +981,19 @@ append_tex_coord_attributes_cb (CoglPipeline *pipeline,
|
|||||||
void *user_data)
|
void *user_data)
|
||||||
{
|
{
|
||||||
AppendTexCoordsState *state = user_data;
|
AppendTexCoordsState *state = user_data;
|
||||||
CoglHandle tex_handle;
|
CoglTexture *texture;
|
||||||
float tx, ty;
|
float tx, ty;
|
||||||
float *t;
|
float *t;
|
||||||
|
|
||||||
tx = state->vertices_in[state->vertex].tx;
|
tx = state->vertices_in[state->vertex].tx;
|
||||||
ty = state->vertices_in[state->vertex].ty;
|
ty = state->vertices_in[state->vertex].ty;
|
||||||
|
|
||||||
/* COGL_INVALID_HANDLE textures will be handled in
|
/* NULL textures will be handled in
|
||||||
* _cogl_pipeline_flush_layers_gl_state but there is no need to worry
|
* _cogl_pipeline_flush_layers_gl_state but there is no need to worry
|
||||||
* about scaling texture coordinates in this case */
|
* about scaling texture coordinates in this case */
|
||||||
tex_handle = _cogl_pipeline_get_layer_texture (pipeline, layer_index);
|
texture = _cogl_pipeline_get_layer_texture (pipeline, layer_index);
|
||||||
if (tex_handle != COGL_INVALID_HANDLE)
|
if (texture != NULL)
|
||||||
_cogl_texture_transform_coords_to_gl (tex_handle, &tx, &ty);
|
_cogl_texture_transform_coords_to_gl (texture, &tx, &ty);
|
||||||
|
|
||||||
/* NB: [X,Y,Z,TX,TY...,R,G,B,A,...] */
|
/* NB: [X,Y,Z,TX,TY...,R,G,B,A,...] */
|
||||||
t = state->vertices_out + 3 + 2 * state->layer;
|
t = state->vertices_out + 3 + 2 * state->layer;
|
||||||
|
@ -155,7 +155,7 @@ typedef struct _CoglSubTextureForeachData
|
|||||||
} CoglSubTextureForeachData;
|
} CoglSubTextureForeachData;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cogl_sub_texture_foreach_cb (CoglHandle handle,
|
_cogl_sub_texture_foreach_cb (CoglTexture *texture,
|
||||||
const float *slice_coords,
|
const float *slice_coords,
|
||||||
const float *full_virtual_coords,
|
const float *full_virtual_coords,
|
||||||
void *user_data)
|
void *user_data)
|
||||||
@ -173,7 +173,7 @@ _cogl_sub_texture_foreach_cb (CoglHandle handle,
|
|||||||
&virtual_coords[2],
|
&virtual_coords[2],
|
||||||
&virtual_coords[3]);
|
&virtual_coords[3]);
|
||||||
|
|
||||||
data->callback (handle,
|
data->callback (texture,
|
||||||
slice_coords, virtual_coords,
|
slice_coords, virtual_coords,
|
||||||
data->user_data);
|
data->user_data);
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ typedef struct
|
|||||||
} ForeachData;
|
} ForeachData;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cogl_texture_2d_sliced_foreach_cb (CoglHandle handle,
|
_cogl_texture_2d_sliced_foreach_cb (CoglTexture *texture,
|
||||||
const float *slice_coords,
|
const float *slice_coords,
|
||||||
const float *virtual_coords_in,
|
const float *virtual_coords_in,
|
||||||
void *user_data)
|
void *user_data)
|
||||||
@ -86,7 +86,7 @@ _cogl_texture_2d_sliced_foreach_cb (CoglHandle handle,
|
|||||||
virtual_coords_out[3] = (virtual_coords_in[3] * data->y_span->size +
|
virtual_coords_out[3] = (virtual_coords_in[3] * data->y_span->size +
|
||||||
data->y_span->start) / data->tex->height;
|
data->y_span->start) / data->tex->height;
|
||||||
|
|
||||||
data->callback (handle,
|
data->callback (texture,
|
||||||
slice_coords,
|
slice_coords,
|
||||||
virtual_coords_out,
|
virtual_coords_out,
|
||||||
data->user_data);
|
data->user_data);
|
||||||
|
@ -28,12 +28,9 @@
|
|||||||
#include "cogl-handle.h"
|
#include "cogl-handle.h"
|
||||||
#include "cogl-pipeline-private.h"
|
#include "cogl-pipeline-private.h"
|
||||||
|
|
||||||
#define COGL_TEXTURE(tex) ((CoglTexture *)(tex))
|
|
||||||
|
|
||||||
typedef struct _CoglTexture CoglTexture;
|
|
||||||
typedef struct _CoglTextureVtable CoglTextureVtable;
|
typedef struct _CoglTextureVtable CoglTextureVtable;
|
||||||
|
|
||||||
typedef void (*CoglTextureSliceCallback) (CoglHandle handle,
|
typedef void (*CoglTextureSliceCallback) (CoglTexture *texture,
|
||||||
const float *slice_coords,
|
const float *slice_coords,
|
||||||
const float *virtual_coords,
|
const float *virtual_coords,
|
||||||
void *user_data);
|
void *user_data);
|
||||||
@ -136,7 +133,7 @@ struct _CoglTextureVtable
|
|||||||
|
|
||||||
struct _CoglTexture
|
struct _CoglTexture
|
||||||
{
|
{
|
||||||
CoglHandleObject _parent;
|
CoglObject _parent;
|
||||||
GList *framebuffers;
|
GList *framebuffers;
|
||||||
const CoglTextureVtable *vtable;
|
const CoglTextureVtable *vtable;
|
||||||
};
|
};
|
||||||
@ -193,7 +190,7 @@ _cogl_texture_register_texture_type (GQuark type);
|
|||||||
## type_name ## _get_type ()))
|
## type_name ## _get_type ()))
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_texture_foreach_sub_texture_in_region (CoglHandle handle,
|
_cogl_texture_foreach_sub_texture_in_region (CoglTexture *texture,
|
||||||
float virtual_tx_1,
|
float virtual_tx_1,
|
||||||
float virtual_ty_1,
|
float virtual_ty_1,
|
||||||
float virtual_tx_2,
|
float virtual_tx_2,
|
||||||
@ -202,36 +199,36 @@ _cogl_texture_foreach_sub_texture_in_region (CoglHandle handle,
|
|||||||
void *user_data);
|
void *user_data);
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
_cogl_texture_can_hardware_repeat (CoglHandle handle);
|
_cogl_texture_can_hardware_repeat (CoglTexture *texture);
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_texture_transform_coords_to_gl (CoglHandle handle,
|
_cogl_texture_transform_coords_to_gl (CoglTexture *texture,
|
||||||
float *s,
|
float *s,
|
||||||
float *t);
|
float *t);
|
||||||
CoglTransformResult
|
CoglTransformResult
|
||||||
_cogl_texture_transform_quad_coords_to_gl (CoglHandle handle,
|
_cogl_texture_transform_quad_coords_to_gl (CoglTexture *texture,
|
||||||
float *coords);
|
float *coords);
|
||||||
|
|
||||||
GLenum
|
GLenum
|
||||||
_cogl_texture_get_gl_format (CoglHandle handle);
|
_cogl_texture_get_gl_format (CoglTexture *texture);
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_texture_set_wrap_mode_parameters (CoglHandle handle,
|
_cogl_texture_set_wrap_mode_parameters (CoglTexture *texture,
|
||||||
GLenum wrap_mode_s,
|
GLenum wrap_mode_s,
|
||||||
GLenum wrap_mode_t,
|
GLenum wrap_mode_t,
|
||||||
GLenum wrap_mode_p);
|
GLenum wrap_mode_p);
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_texture_set_filters (CoglHandle handle,
|
_cogl_texture_set_filters (CoglTexture *texture,
|
||||||
GLenum min_filter,
|
GLenum min_filter,
|
||||||
GLenum mag_filter);
|
GLenum mag_filter);
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_texture_pre_paint (CoglHandle handle, CoglTexturePrePaintFlags flags);
|
_cogl_texture_pre_paint (CoglTexture *texture, CoglTexturePrePaintFlags flags);
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_texture_ensure_non_quad_rendering (CoglHandle handle);
|
_cogl_texture_ensure_non_quad_rendering (CoglTexture *texture);
|
||||||
|
|
||||||
/* Utility function to determine which pixel format to use when
|
/* Utility function to determine which pixel format to use when
|
||||||
dst_format is COGL_PIXEL_FORMAT_ANY. If dst_format is not ANY then
|
dst_format is COGL_PIXEL_FORMAT_ANY. If dst_format is not ANY then
|
||||||
@ -274,22 +271,22 @@ _cogl_texture_iterate_manual_repeats (CoglTextureManualRepeatCallback callback,
|
|||||||
texture via the framebuffer */
|
texture via the framebuffer */
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
_cogl_texture_draw_and_read (CoglHandle handle,
|
_cogl_texture_draw_and_read (CoglTexture *texture,
|
||||||
CoglBitmap *target_bmp,
|
CoglBitmap *target_bmp,
|
||||||
GLuint target_gl_format,
|
GLuint target_gl_format,
|
||||||
GLuint target_gl_type);
|
GLuint target_gl_type);
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
_cogl_texture_is_foreign (CoglHandle handle);
|
_cogl_texture_is_foreign (CoglTexture *texture);
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_texture_associate_framebuffer (CoglHandle handle,
|
_cogl_texture_associate_framebuffer (CoglTexture *texture,
|
||||||
CoglFramebuffer *framebuffer);
|
CoglFramebuffer *framebuffer);
|
||||||
|
|
||||||
const GList *
|
const GList *
|
||||||
_cogl_texture_get_associated_framebuffers (CoglHandle handle);
|
_cogl_texture_get_associated_framebuffers (CoglTexture *texture);
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_texture_flush_journal_rendering (CoglHandle handle);
|
_cogl_texture_flush_journal_rendering (CoglTexture *texture);
|
||||||
|
|
||||||
#endif /* __COGL_TEXTURE_PRIVATE_H */
|
#endif /* __COGL_TEXTURE_PRIVATE_H */
|
||||||
|
@ -79,14 +79,14 @@ _cogl_texture_register_texture_type (GQuark type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
cogl_is_texture (CoglHandle handle)
|
cogl_is_texture (void *object)
|
||||||
{
|
{
|
||||||
CoglHandleObject *obj = (CoglHandleObject *)handle;
|
CoglObject *obj = (CoglObject *)object;
|
||||||
GSList *l;
|
GSList *l;
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctxt, FALSE);
|
_COGL_GET_CONTEXT (ctxt, FALSE);
|
||||||
|
|
||||||
if (handle == COGL_INVALID_HANDLE)
|
if (object == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
for (l = ctxt->texture_types; l; l = l->next)
|
for (l = ctxt->texture_types; l; l = l->next)
|
||||||
@ -96,33 +96,33 @@ cogl_is_texture (CoglHandle handle)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoglHandle
|
void *
|
||||||
cogl_texture_ref (CoglHandle handle)
|
cogl_texture_ref (void *object)
|
||||||
{
|
{
|
||||||
if (!cogl_is_texture (handle))
|
if (!cogl_is_texture (object))
|
||||||
return COGL_INVALID_HANDLE;
|
return NULL;
|
||||||
|
|
||||||
_COGL_HANDLE_DEBUG_REF (CoglTexture, handle);
|
_COGL_OBJECT_DEBUG_REF (CoglTexture, object);
|
||||||
|
|
||||||
cogl_handle_ref (handle);
|
cogl_object_ref (object);
|
||||||
|
|
||||||
return handle;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_texture_unref (CoglHandle handle)
|
cogl_texture_unref (void *object)
|
||||||
{
|
{
|
||||||
if (!cogl_is_texture (handle))
|
if (!cogl_is_texture (object))
|
||||||
{
|
{
|
||||||
g_warning (G_STRINGIFY (cogl_texture_unref)
|
g_warning (G_STRINGIFY (cogl_texture_unref)
|
||||||
": Ignoring unref of Cogl handle "
|
": Ignoring unref of CoglObject "
|
||||||
"due to type mismatch");
|
"due to type mismatch");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_COGL_HANDLE_DEBUG_UNREF (CoglTexture, handle);
|
_COGL_OBJECT_DEBUG_UNREF (CoglTexture, object);
|
||||||
|
|
||||||
cogl_handle_unref (handle);
|
cogl_object_unref (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -281,14 +281,12 @@ _cogl_texture_prep_gl_alignment_for_pixels_download (int pixels_rowstride)
|
|||||||
|
|
||||||
/* FIXME: wrap modes should be set on pipelines not textures */
|
/* FIXME: wrap modes should be set on pipelines not textures */
|
||||||
void
|
void
|
||||||
_cogl_texture_set_wrap_mode_parameters (CoglHandle handle,
|
_cogl_texture_set_wrap_mode_parameters (CoglTexture *texture,
|
||||||
GLenum wrap_mode_s,
|
GLenum wrap_mode_s,
|
||||||
GLenum wrap_mode_t,
|
GLenum wrap_mode_t,
|
||||||
GLenum wrap_mode_p)
|
GLenum wrap_mode_p)
|
||||||
{
|
{
|
||||||
CoglTexture *tex = COGL_TEXTURE (handle);
|
texture->vtable->set_wrap_mode_parameters (texture,
|
||||||
|
|
||||||
tex->vtable->set_wrap_mode_parameters (tex,
|
|
||||||
wrap_mode_s,
|
wrap_mode_s,
|
||||||
wrap_mode_t,
|
wrap_mode_t,
|
||||||
wrap_mode_p);
|
wrap_mode_p);
|
||||||
@ -389,32 +387,33 @@ _cogl_texture_iterate_manual_repeats (CoglTextureManualRepeatCallback callback,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CoglHandle
|
CoglTexture *
|
||||||
cogl_texture_new_with_size (unsigned int width,
|
cogl_texture_new_with_size (unsigned int width,
|
||||||
unsigned int height,
|
unsigned int height,
|
||||||
CoglTextureFlags flags,
|
CoglTextureFlags flags,
|
||||||
CoglPixelFormat internal_format)
|
CoglPixelFormat internal_format)
|
||||||
{
|
{
|
||||||
CoglHandle tex;
|
CoglTexture *tex;
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
|
_COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
|
||||||
|
|
||||||
/* First try creating a fast-path non-sliced texture */
|
/* First try creating a fast-path non-sliced texture */
|
||||||
tex = cogl_texture_2d_new_with_size (ctx,
|
tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx,
|
||||||
width, height, internal_format,
|
width, height,
|
||||||
NULL);
|
internal_format,
|
||||||
|
NULL));
|
||||||
|
|
||||||
/* If it fails resort to sliced textures */
|
/* If it fails resort to sliced textures */
|
||||||
if (tex == COGL_INVALID_HANDLE)
|
if (tex == NULL)
|
||||||
tex = _cogl_texture_2d_sliced_new_with_size (width,
|
tex = COGL_TEXTURE (_cogl_texture_2d_sliced_new_with_size (width,
|
||||||
height,
|
height,
|
||||||
flags,
|
flags,
|
||||||
internal_format);
|
internal_format));
|
||||||
|
|
||||||
return tex;
|
return tex;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoglHandle
|
CoglTexture *
|
||||||
cogl_texture_new_from_data (unsigned int width,
|
cogl_texture_new_from_data (unsigned int width,
|
||||||
unsigned int height,
|
unsigned int height,
|
||||||
CoglTextureFlags flags,
|
CoglTextureFlags flags,
|
||||||
@ -424,13 +423,13 @@ cogl_texture_new_from_data (unsigned int width,
|
|||||||
const guint8 *data)
|
const guint8 *data)
|
||||||
{
|
{
|
||||||
CoglBitmap *bmp;
|
CoglBitmap *bmp;
|
||||||
CoglHandle tex;
|
CoglTexture *tex;
|
||||||
|
|
||||||
if (format == COGL_PIXEL_FORMAT_ANY)
|
if (format == COGL_PIXEL_FORMAT_ANY)
|
||||||
return COGL_INVALID_HANDLE;
|
return NULL;
|
||||||
|
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
return COGL_INVALID_HANDLE;
|
return NULL;
|
||||||
|
|
||||||
/* Rowstride from width if not given */
|
/* Rowstride from width if not given */
|
||||||
if (rowstride == 0)
|
if (rowstride == 0)
|
||||||
@ -451,47 +450,47 @@ cogl_texture_new_from_data (unsigned int width,
|
|||||||
return tex;
|
return tex;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoglHandle
|
CoglTexture *
|
||||||
cogl_texture_new_from_bitmap (CoglHandle bmp_handle,
|
cogl_texture_new_from_bitmap (CoglBitmap *bitmap,
|
||||||
CoglTextureFlags flags,
|
CoglTextureFlags flags,
|
||||||
CoglPixelFormat internal_format)
|
CoglPixelFormat internal_format)
|
||||||
{
|
{
|
||||||
CoglHandle tex;
|
CoglTexture *tex;
|
||||||
|
|
||||||
/* First try putting the texture in the atlas */
|
/* First try putting the texture in the atlas */
|
||||||
if ((tex = _cogl_atlas_texture_new_from_bitmap (bmp_handle,
|
if ((tex = _cogl_atlas_texture_new_from_bitmap (bitmap,
|
||||||
flags,
|
flags,
|
||||||
internal_format)))
|
internal_format)))
|
||||||
return tex;
|
return tex;
|
||||||
|
|
||||||
/* If that doesn't work try a fast path 2D texture */
|
/* If that doesn't work try a fast path 2D texture */
|
||||||
if ((tex = _cogl_texture_2d_new_from_bitmap (bmp_handle,
|
if ((tex = _cogl_texture_2d_new_from_bitmap (bitmap,
|
||||||
flags,
|
flags,
|
||||||
internal_format,
|
internal_format,
|
||||||
NULL)))
|
NULL)))
|
||||||
return tex;
|
return tex;
|
||||||
|
|
||||||
/* Otherwise create a sliced texture */
|
/* Otherwise create a sliced texture */
|
||||||
return _cogl_texture_2d_sliced_new_from_bitmap (bmp_handle,
|
return _cogl_texture_2d_sliced_new_from_bitmap (bitmap,
|
||||||
flags,
|
flags,
|
||||||
internal_format);
|
internal_format);
|
||||||
}
|
}
|
||||||
|
|
||||||
CoglHandle
|
CoglTexture *
|
||||||
cogl_texture_new_from_file (const char *filename,
|
cogl_texture_new_from_file (const char *filename,
|
||||||
CoglTextureFlags flags,
|
CoglTextureFlags flags,
|
||||||
CoglPixelFormat internal_format,
|
CoglPixelFormat internal_format,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
CoglBitmap *bmp;
|
CoglBitmap *bmp;
|
||||||
CoglHandle handle = COGL_INVALID_HANDLE;
|
CoglTexture *texture = NULL;
|
||||||
CoglPixelFormat src_format;
|
CoglPixelFormat src_format;
|
||||||
|
|
||||||
g_return_val_if_fail (error == NULL || *error == NULL, COGL_INVALID_HANDLE);
|
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||||
|
|
||||||
bmp = cogl_bitmap_new_from_file (filename, error);
|
bmp = cogl_bitmap_new_from_file (filename, error);
|
||||||
if (bmp == NULL)
|
if (bmp == NULL)
|
||||||
return COGL_INVALID_HANDLE;
|
return NULL;
|
||||||
|
|
||||||
src_format = _cogl_bitmap_get_format (bmp);
|
src_format = _cogl_bitmap_get_format (bmp);
|
||||||
|
|
||||||
@ -503,14 +502,14 @@ cogl_texture_new_from_file (const char *filename,
|
|||||||
_cogl_texture_determine_internal_format (src_format, internal_format);
|
_cogl_texture_determine_internal_format (src_format, internal_format);
|
||||||
if (!_cogl_texture_needs_premult_conversion (src_format, internal_format) ||
|
if (!_cogl_texture_needs_premult_conversion (src_format, internal_format) ||
|
||||||
_cogl_bitmap_convert_premult_status (bmp, src_format ^ COGL_PREMULT_BIT))
|
_cogl_bitmap_convert_premult_status (bmp, src_format ^ COGL_PREMULT_BIT))
|
||||||
handle = cogl_texture_new_from_bitmap (bmp, flags, internal_format);
|
texture = cogl_texture_new_from_bitmap (bmp, flags, internal_format);
|
||||||
|
|
||||||
cogl_object_unref (bmp);
|
cogl_object_unref (bmp);
|
||||||
|
|
||||||
return handle;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoglHandle
|
CoglTexture *
|
||||||
cogl_texture_new_from_foreign (GLuint gl_handle,
|
cogl_texture_new_from_foreign (GLuint gl_handle,
|
||||||
GLenum gl_target,
|
GLenum gl_target,
|
||||||
GLuint width,
|
GLuint width,
|
||||||
@ -549,32 +548,26 @@ cogl_texture_new_from_foreign (GLuint gl_handle,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
_COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
|
_COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
|
||||||
return cogl_texture_2d_new_from_foreign (ctx,
|
return COGL_TEXTURE (cogl_texture_2d_new_from_foreign (ctx,
|
||||||
gl_handle,
|
gl_handle,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
format,
|
format,
|
||||||
NULL);
|
NULL));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
_cogl_texture_is_foreign (CoglHandle handle)
|
_cogl_texture_is_foreign (CoglTexture *texture)
|
||||||
{
|
{
|
||||||
CoglTexture *tex;
|
if (texture->vtable->is_foreign)
|
||||||
|
return texture->vtable->is_foreign (texture);
|
||||||
g_return_val_if_fail (cogl_is_texture (handle), FALSE);
|
|
||||||
|
|
||||||
tex = COGL_TEXTURE (handle);
|
|
||||||
|
|
||||||
if (tex->vtable->is_foreign)
|
|
||||||
return tex->vtable->is_foreign (tex);
|
|
||||||
else
|
else
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoglHandle
|
CoglTexture *
|
||||||
cogl_texture_new_from_sub_texture (CoglHandle full_texture,
|
cogl_texture_new_from_sub_texture (CoglTexture *full_texture,
|
||||||
int sub_x,
|
int sub_x,
|
||||||
int sub_y,
|
int sub_y,
|
||||||
int sub_width,
|
int sub_width,
|
||||||
@ -584,8 +577,8 @@ cogl_texture_new_from_sub_texture (CoglHandle full_texture,
|
|||||||
sub_width, sub_height);
|
sub_width, sub_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
CoglHandle
|
CoglTexture *
|
||||||
cogl_texture_new_from_buffer_EXP (CoglHandle buffer,
|
cogl_texture_new_from_buffer_EXP (CoglPixelBuffer *buffer,
|
||||||
unsigned int width,
|
unsigned int width,
|
||||||
unsigned int height,
|
unsigned int height,
|
||||||
CoglTextureFlags flags,
|
CoglTextureFlags flags,
|
||||||
@ -594,15 +587,15 @@ cogl_texture_new_from_buffer_EXP (CoglHandle buffer,
|
|||||||
unsigned int rowstride,
|
unsigned int rowstride,
|
||||||
const unsigned int offset)
|
const unsigned int offset)
|
||||||
{
|
{
|
||||||
CoglHandle texture;
|
CoglTexture *texture;
|
||||||
CoglBuffer *cogl_buffer;
|
CoglBuffer *cogl_buffer;
|
||||||
CoglPixelBuffer *pixel_buffer;
|
CoglPixelBuffer *pixel_buffer;
|
||||||
CoglBitmap *bmp;
|
CoglBitmap *bmp;
|
||||||
|
|
||||||
g_return_val_if_fail (cogl_is_buffer (buffer), COGL_INVALID_HANDLE);
|
g_return_val_if_fail (cogl_is_buffer (buffer), NULL);
|
||||||
|
|
||||||
if (format == COGL_PIXEL_FORMAT_ANY)
|
if (format == COGL_PIXEL_FORMAT_ANY)
|
||||||
return COGL_INVALID_HANDLE;
|
return NULL;
|
||||||
|
|
||||||
cogl_buffer = COGL_BUFFER (buffer);
|
cogl_buffer = COGL_BUFFER (buffer);
|
||||||
pixel_buffer = COGL_PIXEL_BUFFER (buffer);
|
pixel_buffer = COGL_PIXEL_BUFFER (buffer);
|
||||||
@ -623,7 +616,7 @@ cogl_texture_new_from_buffer_EXP (CoglHandle buffer,
|
|||||||
/* no width or height specified, neither at creation time (because the
|
/* no width or height specified, neither at creation time (because the
|
||||||
* array was created by cogl_pixel_buffer_new()) nor when calling this
|
* array was created by cogl_pixel_buffer_new()) nor when calling this
|
||||||
* function */
|
* function */
|
||||||
return COGL_INVALID_HANDLE;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wrap the buffer into a bitmap */
|
/* Wrap the buffer into a bitmap */
|
||||||
@ -641,87 +634,45 @@ cogl_texture_new_from_buffer_EXP (CoglHandle buffer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
cogl_texture_get_width (CoglHandle handle)
|
cogl_texture_get_width (CoglTexture *texture)
|
||||||
{
|
{
|
||||||
CoglTexture *tex;
|
return texture->vtable->get_width (texture);
|
||||||
|
|
||||||
if (!cogl_is_texture (handle))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
tex = COGL_TEXTURE (handle);
|
|
||||||
|
|
||||||
return tex->vtable->get_width (tex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
cogl_texture_get_height (CoglHandle handle)
|
cogl_texture_get_height (CoglTexture *texture)
|
||||||
{
|
{
|
||||||
CoglTexture *tex;
|
return texture->vtable->get_height (texture);
|
||||||
|
|
||||||
if (!cogl_is_texture (handle))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
tex = COGL_TEXTURE (handle);
|
|
||||||
|
|
||||||
return tex->vtable->get_height (tex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CoglPixelFormat
|
CoglPixelFormat
|
||||||
cogl_texture_get_format (CoglHandle handle)
|
cogl_texture_get_format (CoglTexture *texture)
|
||||||
{
|
{
|
||||||
CoglTexture *tex;
|
return texture->vtable->get_format (texture);
|
||||||
|
|
||||||
if (!cogl_is_texture (handle))
|
|
||||||
return COGL_PIXEL_FORMAT_ANY;
|
|
||||||
|
|
||||||
tex = COGL_TEXTURE (handle);
|
|
||||||
|
|
||||||
return tex->vtable->get_format (tex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
cogl_texture_get_rowstride (CoglHandle handle)
|
cogl_texture_get_rowstride (CoglTexture *texture)
|
||||||
{
|
{
|
||||||
CoglTexture *tex;
|
|
||||||
|
|
||||||
if (!cogl_is_texture (handle))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* FIXME: This function should go away. It previously just returned
|
/* FIXME: This function should go away. It previously just returned
|
||||||
the rowstride that was used to upload the data as far as I can
|
the rowstride that was used to upload the data as far as I can
|
||||||
tell. This is not helpful */
|
tell. This is not helpful */
|
||||||
|
|
||||||
tex = COGL_TEXTURE (handle);
|
|
||||||
|
|
||||||
/* Just guess at a suitable rowstride */
|
/* Just guess at a suitable rowstride */
|
||||||
return (_cogl_get_format_bpp (cogl_texture_get_format (tex))
|
return (_cogl_get_format_bpp (cogl_texture_get_format (texture))
|
||||||
* cogl_texture_get_width (tex));
|
* cogl_texture_get_width (texture));
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
cogl_texture_get_max_waste (CoglHandle handle)
|
cogl_texture_get_max_waste (CoglTexture *texture)
|
||||||
{
|
{
|
||||||
CoglTexture *tex;
|
return texture->vtable->get_max_waste (texture);
|
||||||
|
|
||||||
if (!cogl_is_texture (handle))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
tex = COGL_TEXTURE (handle);
|
|
||||||
|
|
||||||
return tex->vtable->get_max_waste (tex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
cogl_texture_is_sliced (CoglHandle handle)
|
cogl_texture_is_sliced (CoglTexture *texture)
|
||||||
{
|
{
|
||||||
CoglTexture *tex;
|
return texture->vtable->is_sliced (texture);
|
||||||
|
|
||||||
if (!cogl_is_texture (handle))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
tex = COGL_TEXTURE (handle);
|
|
||||||
|
|
||||||
return tex->vtable->is_sliced (tex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Some CoglTextures, notably sliced textures or atlas textures when repeating
|
/* Some CoglTextures, notably sliced textures or atlas textures when repeating
|
||||||
@ -734,7 +685,7 @@ cogl_texture_is_sliced (CoglHandle handle)
|
|||||||
* region specified in texture coordinates.
|
* region specified in texture coordinates.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
_cogl_texture_foreach_sub_texture_in_region (CoglHandle handle,
|
_cogl_texture_foreach_sub_texture_in_region (CoglTexture *texture,
|
||||||
float virtual_tx_1,
|
float virtual_tx_1,
|
||||||
float virtual_ty_1,
|
float virtual_ty_1,
|
||||||
float virtual_tx_2,
|
float virtual_tx_2,
|
||||||
@ -742,9 +693,7 @@ _cogl_texture_foreach_sub_texture_in_region (CoglHandle handle,
|
|||||||
CoglTextureSliceCallback callback,
|
CoglTextureSliceCallback callback,
|
||||||
void *user_data)
|
void *user_data)
|
||||||
{
|
{
|
||||||
CoglTexture *tex = COGL_TEXTURE (handle);
|
texture->vtable->foreach_sub_texture_in_region (texture,
|
||||||
|
|
||||||
tex->vtable->foreach_sub_texture_in_region (tex,
|
|
||||||
virtual_tx_1,
|
virtual_tx_1,
|
||||||
virtual_ty_1,
|
virtual_ty_1,
|
||||||
virtual_tx_2,
|
virtual_tx_2,
|
||||||
@ -758,101 +707,66 @@ _cogl_texture_foreach_sub_texture_in_region (CoglHandle handle,
|
|||||||
* texture coordinates extend out of the range [0,1]
|
* texture coordinates extend out of the range [0,1]
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
_cogl_texture_can_hardware_repeat (CoglHandle handle)
|
_cogl_texture_can_hardware_repeat (CoglTexture *texture)
|
||||||
{
|
{
|
||||||
CoglTexture *tex = (CoglTexture *)handle;
|
return texture->vtable->can_hardware_repeat (texture);
|
||||||
|
|
||||||
return tex->vtable->can_hardware_repeat (tex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* NB: You can't use this with textures comprised of multiple sub textures (use
|
/* NB: You can't use this with textures comprised of multiple sub textures (use
|
||||||
* cogl_texture_is_sliced() to check) since coordinate transformation for such
|
* cogl_texture_is_sliced() to check) since coordinate transformation for such
|
||||||
* textures will be different for each slice. */
|
* textures will be different for each slice. */
|
||||||
void
|
void
|
||||||
_cogl_texture_transform_coords_to_gl (CoglHandle handle,
|
_cogl_texture_transform_coords_to_gl (CoglTexture *texture,
|
||||||
float *s,
|
float *s,
|
||||||
float *t)
|
float *t)
|
||||||
{
|
{
|
||||||
CoglTexture *tex = COGL_TEXTURE (handle);
|
texture->vtable->transform_coords_to_gl (texture, s, t);
|
||||||
|
|
||||||
tex->vtable->transform_coords_to_gl (tex, s, t);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CoglTransformResult
|
CoglTransformResult
|
||||||
_cogl_texture_transform_quad_coords_to_gl (CoglHandle handle,
|
_cogl_texture_transform_quad_coords_to_gl (CoglTexture *texture,
|
||||||
float *coords)
|
float *coords)
|
||||||
{
|
{
|
||||||
CoglTexture *tex = COGL_TEXTURE (handle);
|
return texture->vtable->transform_quad_coords_to_gl (texture, coords);
|
||||||
|
|
||||||
return tex->vtable->transform_quad_coords_to_gl (tex, coords);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLenum
|
GLenum
|
||||||
_cogl_texture_get_gl_format (CoglHandle handle)
|
_cogl_texture_get_gl_format (CoglTexture *texture)
|
||||||
{
|
{
|
||||||
CoglTexture *tex = COGL_TEXTURE (handle);
|
return texture->vtable->get_gl_format (texture);
|
||||||
|
|
||||||
return tex->vtable->get_gl_format (tex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
cogl_texture_get_gl_texture (CoglHandle handle,
|
cogl_texture_get_gl_texture (CoglTexture *texture,
|
||||||
GLuint *out_gl_handle,
|
GLuint *out_gl_handle,
|
||||||
GLenum *out_gl_target)
|
GLenum *out_gl_target)
|
||||||
{
|
{
|
||||||
CoglTexture *tex;
|
return texture->vtable->get_gl_texture (texture,
|
||||||
|
out_gl_handle, out_gl_target);
|
||||||
if (!cogl_is_texture (handle))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
tex = COGL_TEXTURE (handle);
|
|
||||||
|
|
||||||
return tex->vtable->get_gl_texture (tex, out_gl_handle, out_gl_target);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_texture_set_filters (CoglHandle handle,
|
_cogl_texture_set_filters (CoglTexture *texture,
|
||||||
GLenum min_filter,
|
GLenum min_filter,
|
||||||
GLenum mag_filter)
|
GLenum mag_filter)
|
||||||
{
|
{
|
||||||
CoglTexture *tex;
|
texture->vtable->set_filters (texture, min_filter, mag_filter);
|
||||||
|
|
||||||
if (!cogl_is_texture (handle))
|
|
||||||
return;
|
|
||||||
|
|
||||||
tex = COGL_TEXTURE (handle);
|
|
||||||
|
|
||||||
tex->vtable->set_filters (tex, min_filter, mag_filter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_texture_pre_paint (CoglHandle handle, CoglTexturePrePaintFlags flags)
|
_cogl_texture_pre_paint (CoglTexture *texture, CoglTexturePrePaintFlags flags)
|
||||||
{
|
{
|
||||||
CoglTexture *tex;
|
texture->vtable->pre_paint (texture, flags);
|
||||||
|
|
||||||
if (!cogl_is_texture (handle))
|
|
||||||
return;
|
|
||||||
|
|
||||||
tex = COGL_TEXTURE (handle);
|
|
||||||
|
|
||||||
tex->vtable->pre_paint (tex, flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_texture_ensure_non_quad_rendering (CoglHandle handle)
|
_cogl_texture_ensure_non_quad_rendering (CoglTexture *texture)
|
||||||
{
|
{
|
||||||
CoglTexture *tex;
|
texture->vtable->ensure_non_quad_rendering (texture);
|
||||||
|
|
||||||
if (!cogl_is_texture (handle))
|
|
||||||
return;
|
|
||||||
|
|
||||||
tex = COGL_TEXTURE (handle);
|
|
||||||
|
|
||||||
tex->vtable->ensure_non_quad_rendering (tex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
cogl_texture_set_region_from_bitmap (CoglHandle handle,
|
cogl_texture_set_region_from_bitmap (CoglTexture *texture,
|
||||||
int src_x,
|
int src_x,
|
||||||
int src_y,
|
int src_y,
|
||||||
int dst_x,
|
int dst_x,
|
||||||
@ -861,7 +775,6 @@ cogl_texture_set_region_from_bitmap (CoglHandle handle,
|
|||||||
unsigned int dst_height,
|
unsigned int dst_height,
|
||||||
CoglBitmap *bmp)
|
CoglBitmap *bmp)
|
||||||
{
|
{
|
||||||
CoglTexture *tex = COGL_TEXTURE (handle);
|
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
|
|
||||||
/* Shortcut out early if the image is empty */
|
/* Shortcut out early if the image is empty */
|
||||||
@ -875,7 +788,7 @@ cogl_texture_set_region_from_bitmap (CoglHandle handle,
|
|||||||
always stored in an RGBA texture even if the texture format is
|
always stored in an RGBA texture even if the texture format is
|
||||||
advertised as RGB. */
|
advertised as RGB. */
|
||||||
|
|
||||||
ret = tex->vtable->set_region (handle,
|
ret = texture->vtable->set_region (texture,
|
||||||
src_x, src_y,
|
src_x, src_y,
|
||||||
dst_x, dst_y,
|
dst_x, dst_y,
|
||||||
dst_width, dst_height,
|
dst_width, dst_height,
|
||||||
@ -885,7 +798,7 @@ cogl_texture_set_region_from_bitmap (CoglHandle handle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
cogl_texture_set_region (CoglHandle handle,
|
cogl_texture_set_region (CoglTexture *texture,
|
||||||
int src_x,
|
int src_x,
|
||||||
int src_y,
|
int src_y,
|
||||||
int dst_x,
|
int dst_x,
|
||||||
@ -918,7 +831,7 @@ cogl_texture_set_region (CoglHandle handle,
|
|||||||
NULL, /* destroy_fn */
|
NULL, /* destroy_fn */
|
||||||
NULL); /* destroy_fn_data */
|
NULL); /* destroy_fn_data */
|
||||||
|
|
||||||
ret = cogl_texture_set_region_from_bitmap (handle,
|
ret = cogl_texture_set_region_from_bitmap (texture,
|
||||||
src_x, src_y,
|
src_x, src_y,
|
||||||
dst_x, dst_y,
|
dst_x, dst_y,
|
||||||
dst_width, dst_height,
|
dst_width, dst_height,
|
||||||
@ -943,7 +856,7 @@ cogl_texture_set_region (CoglHandle handle,
|
|||||||
* glGetTexImage, but may be used as a fallback in some circumstances.
|
* glGetTexImage, but may be used as a fallback in some circumstances.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
do_texture_draw_and_read (CoglHandle handle,
|
do_texture_draw_and_read (CoglTexture *texture,
|
||||||
CoglBitmap *target_bmp,
|
CoglBitmap *target_bmp,
|
||||||
float *viewport)
|
float *viewport)
|
||||||
{
|
{
|
||||||
@ -958,8 +871,8 @@ do_texture_draw_and_read (CoglHandle handle,
|
|||||||
|
|
||||||
bpp = _cogl_get_format_bpp (COGL_PIXEL_FORMAT_RGBA_8888);
|
bpp = _cogl_get_format_bpp (COGL_PIXEL_FORMAT_RGBA_8888);
|
||||||
|
|
||||||
tex_width = cogl_texture_get_width (handle);
|
tex_width = cogl_texture_get_width (texture);
|
||||||
tex_height = cogl_texture_get_height (handle);
|
tex_height = cogl_texture_get_height (texture);
|
||||||
|
|
||||||
ry2 = 0;
|
ry2 = 0;
|
||||||
ty2 = 0;
|
ty2 = 0;
|
||||||
@ -1045,7 +958,7 @@ do_texture_draw_and_read (CoglHandle handle,
|
|||||||
* glGetTexImage, but may be used as a fallback in some circumstances.
|
* glGetTexImage, but may be used as a fallback in some circumstances.
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
_cogl_texture_draw_and_read (CoglHandle handle,
|
_cogl_texture_draw_and_read (CoglTexture *texture,
|
||||||
CoglBitmap *target_bmp,
|
CoglBitmap *target_bmp,
|
||||||
GLuint target_gl_format,
|
GLuint target_gl_format,
|
||||||
GLuint target_gl_type)
|
GLuint target_gl_type)
|
||||||
@ -1091,7 +1004,7 @@ _cogl_texture_draw_and_read (CoglHandle handle,
|
|||||||
|
|
||||||
/* Direct copy operation */
|
/* Direct copy operation */
|
||||||
|
|
||||||
if (ctx->texture_download_pipeline == COGL_INVALID_HANDLE)
|
if (ctx->texture_download_pipeline == NULL)
|
||||||
{
|
{
|
||||||
ctx->texture_download_pipeline = cogl_pipeline_new ();
|
ctx->texture_download_pipeline = cogl_pipeline_new ();
|
||||||
cogl_pipeline_set_blend (ctx->texture_download_pipeline,
|
cogl_pipeline_set_blend (ctx->texture_download_pipeline,
|
||||||
@ -1101,7 +1014,7 @@ _cogl_texture_draw_and_read (CoglHandle handle,
|
|||||||
|
|
||||||
_cogl_push_source (ctx->texture_download_pipeline, FALSE);
|
_cogl_push_source (ctx->texture_download_pipeline, FALSE);
|
||||||
|
|
||||||
cogl_pipeline_set_layer_texture (ctx->texture_download_pipeline, 0, handle);
|
cogl_pipeline_set_layer_texture (ctx->texture_download_pipeline, 0, texture);
|
||||||
|
|
||||||
cogl_pipeline_set_layer_combine (ctx->texture_download_pipeline,
|
cogl_pipeline_set_layer_combine (ctx->texture_download_pipeline,
|
||||||
0, /* layer */
|
0, /* layer */
|
||||||
@ -1112,7 +1025,7 @@ _cogl_texture_draw_and_read (CoglHandle handle,
|
|||||||
COGL_PIPELINE_FILTER_NEAREST,
|
COGL_PIPELINE_FILTER_NEAREST,
|
||||||
COGL_PIPELINE_FILTER_NEAREST);
|
COGL_PIPELINE_FILTER_NEAREST);
|
||||||
|
|
||||||
do_texture_draw_and_read (handle, target_bmp, viewport);
|
do_texture_draw_and_read (texture, target_bmp, viewport);
|
||||||
|
|
||||||
/* Check whether texture has alpha and framebuffer not */
|
/* Check whether texture has alpha and framebuffer not */
|
||||||
/* FIXME: For some reason even if ALPHA_BITS is 8, the framebuffer
|
/* FIXME: For some reason even if ALPHA_BITS is 8, the framebuffer
|
||||||
@ -1127,7 +1040,7 @@ _cogl_texture_draw_and_read (CoglHandle handle,
|
|||||||
printf ("G bits: %d\n", g_bits);
|
printf ("G bits: %d\n", g_bits);
|
||||||
printf ("B bits: %d\n", b_bits);
|
printf ("B bits: %d\n", b_bits);
|
||||||
printf ("A bits: %d\n", a_bits); */
|
printf ("A bits: %d\n", a_bits); */
|
||||||
if ((cogl_texture_get_format (handle) & COGL_A_BIT)/* && a_bits == 0*/)
|
if ((cogl_texture_get_format (texture) & COGL_A_BIT)/* && a_bits == 0*/)
|
||||||
{
|
{
|
||||||
guint8 *srcdata;
|
guint8 *srcdata;
|
||||||
guint8 *dstdata;
|
guint8 *dstdata;
|
||||||
@ -1157,7 +1070,7 @@ _cogl_texture_draw_and_read (CoglHandle handle,
|
|||||||
"RGBA = REPLACE (TEXTURE[A])",
|
"RGBA = REPLACE (TEXTURE[A])",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
do_texture_draw_and_read (handle, alpha_bmp, viewport);
|
do_texture_draw_and_read (texture, alpha_bmp, viewport);
|
||||||
|
|
||||||
/* Copy temp R to target A */
|
/* Copy temp R to target A */
|
||||||
|
|
||||||
@ -1189,7 +1102,7 @@ _cogl_texture_draw_and_read (CoglHandle handle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
get_texture_bits_via_offscreen (CoglHandle texture_handle,
|
get_texture_bits_via_offscreen (CoglTexture *texture,
|
||||||
int x,
|
int x,
|
||||||
int y,
|
int y,
|
||||||
int width,
|
int width,
|
||||||
@ -1206,7 +1119,7 @@ get_texture_bits_via_offscreen (CoglHandle texture_handle,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
framebuffer = _cogl_offscreen_new_to_texture_full
|
framebuffer = _cogl_offscreen_new_to_texture_full
|
||||||
(texture_handle,
|
(texture,
|
||||||
COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL,
|
COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
@ -1227,7 +1140,7 @@ get_texture_bits_via_offscreen (CoglHandle texture_handle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
get_texture_bits_via_copy (CoglHandle texture_handle,
|
get_texture_bits_via_copy (CoglTexture *texture,
|
||||||
int x,
|
int x,
|
||||||
int y,
|
int y,
|
||||||
int width,
|
int width,
|
||||||
@ -1236,22 +1149,21 @@ get_texture_bits_via_copy (CoglHandle texture_handle,
|
|||||||
unsigned int dst_rowstride,
|
unsigned int dst_rowstride,
|
||||||
CoglPixelFormat dst_format)
|
CoglPixelFormat dst_format)
|
||||||
{
|
{
|
||||||
CoglTexture *tex = COGL_TEXTURE (texture_handle);
|
|
||||||
unsigned int full_rowstride;
|
unsigned int full_rowstride;
|
||||||
guint8 *full_bits;
|
guint8 *full_bits;
|
||||||
gboolean ret = TRUE;
|
gboolean ret = TRUE;
|
||||||
int bpp;
|
int bpp;
|
||||||
int full_tex_width, full_tex_height;
|
int full_tex_width, full_tex_height;
|
||||||
|
|
||||||
full_tex_width = cogl_texture_get_width (texture_handle);
|
full_tex_width = cogl_texture_get_width (texture);
|
||||||
full_tex_height = cogl_texture_get_height (texture_handle);
|
full_tex_height = cogl_texture_get_height (texture);
|
||||||
|
|
||||||
bpp = _cogl_get_format_bpp (dst_format);
|
bpp = _cogl_get_format_bpp (dst_format);
|
||||||
|
|
||||||
full_rowstride = bpp * full_tex_width;
|
full_rowstride = bpp * full_tex_width;
|
||||||
full_bits = g_malloc (full_rowstride * full_tex_height);
|
full_bits = g_malloc (full_rowstride * full_tex_height);
|
||||||
|
|
||||||
if (tex->vtable->get_data (tex,
|
if (texture->vtable->get_data (texture,
|
||||||
dst_format,
|
dst_format,
|
||||||
full_rowstride,
|
full_rowstride,
|
||||||
full_bits))
|
full_bits))
|
||||||
@ -1285,18 +1197,17 @@ typedef struct
|
|||||||
} CoglTextureGetData;
|
} CoglTextureGetData;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
texture_get_cb (CoglHandle texture_handle,
|
texture_get_cb (CoglTexture *texture,
|
||||||
const float *subtexture_coords,
|
const float *subtexture_coords,
|
||||||
const float *virtual_coords,
|
const float *virtual_coords,
|
||||||
void *user_data)
|
void *user_data)
|
||||||
{
|
{
|
||||||
CoglTexture *tex = COGL_TEXTURE (texture_handle);
|
|
||||||
CoglTextureGetData *tg_data = user_data;
|
CoglTextureGetData *tg_data = user_data;
|
||||||
CoglPixelFormat format = _cogl_bitmap_get_format (tg_data->target_bmp);
|
CoglPixelFormat format = _cogl_bitmap_get_format (tg_data->target_bmp);
|
||||||
int bpp = _cogl_get_format_bpp (format);
|
int bpp = _cogl_get_format_bpp (format);
|
||||||
unsigned int rowstride = _cogl_bitmap_get_rowstride (tg_data->target_bmp);
|
unsigned int rowstride = _cogl_bitmap_get_rowstride (tg_data->target_bmp);
|
||||||
int subtexture_width = cogl_texture_get_width (texture_handle);
|
int subtexture_width = cogl_texture_get_width (texture);
|
||||||
int subtexture_height = cogl_texture_get_height (texture_handle);
|
int subtexture_height = cogl_texture_get_height (texture);
|
||||||
|
|
||||||
int x_in_subtexture = (int) (0.5 + subtexture_width * subtexture_coords[0]);
|
int x_in_subtexture = (int) (0.5 + subtexture_width * subtexture_coords[0]);
|
||||||
int y_in_subtexture = (int) (0.5 + subtexture_height * subtexture_coords[1]);
|
int y_in_subtexture = (int) (0.5 + subtexture_height * subtexture_coords[1]);
|
||||||
@ -1321,7 +1232,7 @@ texture_get_cb (CoglHandle texture_handle,
|
|||||||
if (x_in_subtexture == 0 && y_in_subtexture == 0 &&
|
if (x_in_subtexture == 0 && y_in_subtexture == 0 &&
|
||||||
width == subtexture_width && height == subtexture_height)
|
width == subtexture_width && height == subtexture_height)
|
||||||
{
|
{
|
||||||
if (tex->vtable->get_data (tex,
|
if (texture->vtable->get_data (texture,
|
||||||
format,
|
format,
|
||||||
rowstride,
|
rowstride,
|
||||||
dst_bits))
|
dst_bits))
|
||||||
@ -1329,7 +1240,7 @@ texture_get_cb (CoglHandle texture_handle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Next best option is a FBO and glReadPixels */
|
/* Next best option is a FBO and glReadPixels */
|
||||||
if (get_texture_bits_via_offscreen (texture_handle,
|
if (get_texture_bits_via_offscreen (texture,
|
||||||
x_in_subtexture, y_in_subtexture,
|
x_in_subtexture, y_in_subtexture,
|
||||||
width, height,
|
width, height,
|
||||||
dst_bits,
|
dst_bits,
|
||||||
@ -1338,7 +1249,7 @@ texture_get_cb (CoglHandle texture_handle,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* Getting ugly: read the entire texture, copy out the part we want */
|
/* Getting ugly: read the entire texture, copy out the part we want */
|
||||||
if (get_texture_bits_via_copy (texture_handle,
|
if (get_texture_bits_via_copy (texture,
|
||||||
x_in_subtexture, y_in_subtexture,
|
x_in_subtexture, y_in_subtexture,
|
||||||
width, height,
|
width, height,
|
||||||
dst_bits,
|
dst_bits,
|
||||||
@ -1352,12 +1263,11 @@ texture_get_cb (CoglHandle texture_handle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
cogl_texture_get_data (CoglHandle handle,
|
cogl_texture_get_data (CoglTexture *texture,
|
||||||
CoglPixelFormat format,
|
CoglPixelFormat format,
|
||||||
unsigned int rowstride,
|
unsigned int rowstride,
|
||||||
guint8 *data)
|
guint8 *data)
|
||||||
{
|
{
|
||||||
CoglTexture *tex;
|
|
||||||
int bpp;
|
int bpp;
|
||||||
int byte_size;
|
int byte_size;
|
||||||
CoglPixelFormat closest_format;
|
CoglPixelFormat closest_format;
|
||||||
@ -1376,17 +1286,12 @@ cogl_texture_get_data (CoglHandle handle,
|
|||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, 0);
|
_COGL_GET_CONTEXT (ctx, 0);
|
||||||
|
|
||||||
if (!cogl_is_texture (handle))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
tex = COGL_TEXTURE (handle);
|
|
||||||
|
|
||||||
/* Default to internal format if none specified */
|
/* Default to internal format if none specified */
|
||||||
if (format == COGL_PIXEL_FORMAT_ANY)
|
if (format == COGL_PIXEL_FORMAT_ANY)
|
||||||
format = cogl_texture_get_format (handle);
|
format = cogl_texture_get_format (texture);
|
||||||
|
|
||||||
tex_width = cogl_texture_get_width (handle);
|
tex_width = cogl_texture_get_width (texture);
|
||||||
tex_height = cogl_texture_get_height (handle);
|
tex_height = cogl_texture_get_height (texture);
|
||||||
|
|
||||||
/* Rowstride from texture width if none specified */
|
/* Rowstride from texture width if none specified */
|
||||||
bpp = _cogl_get_format_bpp (format);
|
bpp = _cogl_get_format_bpp (format);
|
||||||
@ -1442,7 +1347,7 @@ cogl_texture_get_data (CoglHandle handle,
|
|||||||
* the data for a sliced texture, and allows us to do the
|
* the data for a sliced texture, and allows us to do the
|
||||||
* read-from-framebuffer logic here in a simple fashion rather than
|
* read-from-framebuffer logic here in a simple fashion rather than
|
||||||
* passing offsets down through the code. */
|
* passing offsets down through the code. */
|
||||||
_cogl_texture_foreach_sub_texture_in_region (handle,
|
_cogl_texture_foreach_sub_texture_in_region (texture,
|
||||||
0, 0, 1, 1,
|
0, 0, 1, 1,
|
||||||
texture_get_cb,
|
texture_get_cb,
|
||||||
&tg_data);
|
&tg_data);
|
||||||
@ -1454,7 +1359,7 @@ cogl_texture_get_data (CoglHandle handle,
|
|||||||
* support glGetTexImage, so here we fallback to drawing the
|
* support glGetTexImage, so here we fallback to drawing the
|
||||||
* texture and reading the pixels from the framebuffer. */
|
* texture and reading the pixels from the framebuffer. */
|
||||||
if (!tg_data.success)
|
if (!tg_data.success)
|
||||||
_cogl_texture_draw_and_read (tex, target_bmp,
|
_cogl_texture_draw_and_read (texture, target_bmp,
|
||||||
closest_gl_format,
|
closest_gl_format,
|
||||||
closest_gl_type);
|
closest_gl_type);
|
||||||
|
|
||||||
@ -1512,40 +1417,37 @@ _cogl_texture_framebuffer_destroy_cb (void *user_data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_texture_associate_framebuffer (CoglHandle handle,
|
_cogl_texture_associate_framebuffer (CoglTexture *texture,
|
||||||
CoglFramebuffer *framebuffer)
|
CoglFramebuffer *framebuffer)
|
||||||
{
|
{
|
||||||
CoglTexture *tex = COGL_TEXTURE (handle);
|
|
||||||
static CoglUserDataKey framebuffer_destroy_notify_key;
|
static CoglUserDataKey framebuffer_destroy_notify_key;
|
||||||
|
|
||||||
/* Note: we don't take a reference on the framebuffer here because
|
/* Note: we don't take a reference on the framebuffer here because
|
||||||
* that would introduce a circular reference. */
|
* that would introduce a circular reference. */
|
||||||
tex->framebuffers = g_list_prepend (tex->framebuffers, framebuffer);
|
texture->framebuffers = g_list_prepend (texture->framebuffers, framebuffer);
|
||||||
|
|
||||||
/* Since we haven't taken a reference on the framebuffer we setup
|
/* Since we haven't taken a reference on the framebuffer we setup
|
||||||
* some private data so we will be notified if it is destroyed... */
|
* some private data so we will be notified if it is destroyed... */
|
||||||
_cogl_object_set_user_data (COGL_OBJECT (framebuffer),
|
_cogl_object_set_user_data (COGL_OBJECT (framebuffer),
|
||||||
&framebuffer_destroy_notify_key,
|
&framebuffer_destroy_notify_key,
|
||||||
tex,
|
texture,
|
||||||
_cogl_texture_framebuffer_destroy_cb);
|
_cogl_texture_framebuffer_destroy_cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
const GList *
|
const GList *
|
||||||
_cogl_texture_get_associated_framebuffers (CoglHandle handle)
|
_cogl_texture_get_associated_framebuffers (CoglTexture *texture)
|
||||||
{
|
{
|
||||||
CoglTexture *tex = COGL_TEXTURE (handle);
|
return texture->framebuffers;
|
||||||
return tex->framebuffers;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_texture_flush_journal_rendering (CoglHandle handle)
|
_cogl_texture_flush_journal_rendering (CoglTexture *texture)
|
||||||
{
|
{
|
||||||
CoglTexture *tex = COGL_TEXTURE (handle);
|
|
||||||
GList *l;
|
GList *l;
|
||||||
|
|
||||||
/* It could be that a referenced texture is part of a framebuffer
|
/* It could be that a referenced texture is part of a framebuffer
|
||||||
* which has an associated journal that must be flushed before it
|
* which has an associated journal that must be flushed before it
|
||||||
* can be sampled from by the current primitive... */
|
* can be sampled from by the current primitive... */
|
||||||
for (l = tex->framebuffers; l; l = l->next)
|
for (l = texture->framebuffers; l; l = l->next)
|
||||||
_cogl_framebuffer_flush_journal (l->data);
|
_cogl_framebuffer_flush_journal (l->data);
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,9 @@
|
|||||||
|
|
||||||
#include <cogl/cogl-types.h>
|
#include <cogl/cogl-types.h>
|
||||||
#include <cogl/cogl-defines.h>
|
#include <cogl/cogl-defines.h>
|
||||||
|
#if defined (COGL_ENABLE_EXPERIMENTAL_API)
|
||||||
|
#include <cogl/cogl-pixel-buffer.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
@ -37,11 +40,14 @@ G_BEGIN_DECLS
|
|||||||
* SECTION:cogl-texture
|
* SECTION:cogl-texture
|
||||||
* @short_description: Fuctions for creating and manipulating textures
|
* @short_description: Fuctions for creating and manipulating textures
|
||||||
*
|
*
|
||||||
* COGL allows creating and manipulating GL textures using a uniform
|
* Cogl allows creating and manipulating textures using a uniform
|
||||||
* API that tries to hide all the various complexities of creating,
|
* API that tries to hide all the various complexities of creating,
|
||||||
* loading and manipulating textures.
|
* loading and manipulating textures.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
typedef struct _CoglTexture CoglTexture;
|
||||||
|
#define COGL_TEXTURE(X) ((CoglTexture *)X)
|
||||||
|
|
||||||
#define COGL_TEXTURE_MAX_WASTE 127
|
#define COGL_TEXTURE_MAX_WASTE 127
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -80,14 +86,13 @@ GQuark cogl_texture_error_quark (void);
|
|||||||
* @internal_format: the #CoglPixelFormat to use for the GPU storage of the
|
* @internal_format: the #CoglPixelFormat to use for the GPU storage of the
|
||||||
* texture.
|
* texture.
|
||||||
*
|
*
|
||||||
* Creates a new COGL texture with the specified dimensions and pixel format.
|
* Creates a new #CoglTexture with the specified dimensions and pixel format.
|
||||||
*
|
*
|
||||||
* Return value: a #CoglHandle to the newly created texture or
|
* Return value: A newly created #CoglTexture or %NULL on failure
|
||||||
* %COGL_INVALID_HANDLE on failure
|
|
||||||
*
|
*
|
||||||
* Since: 0.8
|
* Since: 0.8
|
||||||
*/
|
*/
|
||||||
CoglHandle
|
CoglTexture *
|
||||||
cogl_texture_new_with_size (unsigned int width,
|
cogl_texture_new_with_size (unsigned int width,
|
||||||
unsigned int height,
|
unsigned int height,
|
||||||
CoglTextureFlags flags,
|
CoglTextureFlags flags,
|
||||||
@ -107,14 +112,13 @@ cogl_texture_new_with_size (unsigned int width,
|
|||||||
* other than straight blending.
|
* other than straight blending.
|
||||||
* @error: return location for a #GError or %NULL
|
* @error: return location for a #GError or %NULL
|
||||||
*
|
*
|
||||||
* Creates a COGL texture from an image file.
|
* Creates a #CoglTexture from an image file.
|
||||||
*
|
*
|
||||||
* Return value: a #CoglHandle to the newly created texture or
|
* Return value: A newly created #CoglTexture or %NULL on failure
|
||||||
* %COGL_INVALID_HANDLE on failure
|
|
||||||
*
|
*
|
||||||
* Since: 0.8
|
* Since: 0.8
|
||||||
*/
|
*/
|
||||||
CoglHandle
|
CoglTexture *
|
||||||
cogl_texture_new_from_file (const char *filename,
|
cogl_texture_new_from_file (const char *filename,
|
||||||
CoglTextureFlags flags,
|
CoglTextureFlags flags,
|
||||||
CoglPixelFormat internal_format,
|
CoglPixelFormat internal_format,
|
||||||
@ -138,14 +142,13 @@ cogl_texture_new_from_file (const char *filename,
|
|||||||
* scanlines in @data
|
* scanlines in @data
|
||||||
* @data: pointer the memory region where the source buffer resides
|
* @data: pointer the memory region where the source buffer resides
|
||||||
*
|
*
|
||||||
* Creates a new COGL texture based on data residing in memory.
|
* Creates a new #CoglTexture based on data residing in memory.
|
||||||
*
|
*
|
||||||
* Return value: a #CoglHandle to the newly created texture or
|
* Return value: A newly created #CoglTexture or %NULL on failure
|
||||||
* %COGL_INVALID_HANDLE on failure
|
|
||||||
*
|
*
|
||||||
* Since: 0.8
|
* Since: 0.8
|
||||||
*/
|
*/
|
||||||
CoglHandle
|
CoglTexture *
|
||||||
cogl_texture_new_from_data (unsigned int width,
|
cogl_texture_new_from_data (unsigned int width,
|
||||||
unsigned int height,
|
unsigned int height,
|
||||||
CoglTextureFlags flags,
|
CoglTextureFlags flags,
|
||||||
@ -164,7 +167,7 @@ cogl_texture_new_from_data (unsigned int width,
|
|||||||
* @y_pot_waste: vertical waste on the bottom edge of the texture.
|
* @y_pot_waste: vertical waste on the bottom edge of the texture.
|
||||||
* @format: format of the foreign texture.
|
* @format: format of the foreign texture.
|
||||||
*
|
*
|
||||||
* Creates a COGL texture based on an existing OpenGL texture; the
|
* Creates a #CoglTexture based on an existing OpenGL texture; the
|
||||||
* width, height and format are passed along since it is not always
|
* width, height and format are passed along since it is not always
|
||||||
* possible to query these from OpenGL.
|
* possible to query these from OpenGL.
|
||||||
*
|
*
|
||||||
@ -175,12 +178,11 @@ cogl_texture_new_from_data (unsigned int width,
|
|||||||
* the waste arguments to tell Cogl which region should be mapped to
|
* the waste arguments to tell Cogl which region should be mapped to
|
||||||
* the texture coordinate range [0:1].
|
* the texture coordinate range [0:1].
|
||||||
*
|
*
|
||||||
* Return value: a #CoglHandle to the newly created texture or
|
* Return value: A newly created #CoglTexture or %NULL on failure
|
||||||
* %COGL_INVALID_HANDLE on failure
|
|
||||||
*
|
*
|
||||||
* Since: 0.8
|
* Since: 0.8
|
||||||
*/
|
*/
|
||||||
CoglHandle
|
CoglTexture *
|
||||||
cogl_texture_new_from_foreign (GLuint gl_handle,
|
cogl_texture_new_from_foreign (GLuint gl_handle,
|
||||||
GLenum gl_target,
|
GLenum gl_target,
|
||||||
GLuint width,
|
GLuint width,
|
||||||
@ -191,83 +193,82 @@ cogl_texture_new_from_foreign (GLuint gl_handle,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* cogl_texture_new_from_bitmap:
|
* cogl_texture_new_from_bitmap:
|
||||||
* @bmp_handle: A CoglBitmap handle
|
* @bitmap: A #CoglBitmap pointer
|
||||||
* @flags: Optional flags for the texture, or %COGL_TEXTURE_NONE
|
* @flags: Optional flags for the texture, or %COGL_TEXTURE_NONE
|
||||||
* @internal_format: the #CoglPixelFormat to use for the GPU storage of the
|
* @internal_format: the #CoglPixelFormat to use for the GPU storage of the
|
||||||
* texture
|
* texture
|
||||||
*
|
*
|
||||||
* Creates a COGL texture from a CoglBitmap.
|
* Creates a #CoglTexture from a #CoglBitmap.
|
||||||
*
|
*
|
||||||
* Return value: a #CoglHandle to the newly created texture or
|
* Return value: A newly created #CoglTexture or %NULL on failure
|
||||||
* %COGL_INVALID_HANDLE on failure
|
|
||||||
*
|
*
|
||||||
* Since: 1.0
|
* Since: 1.0
|
||||||
*/
|
*/
|
||||||
CoglHandle
|
CoglTexture *
|
||||||
cogl_texture_new_from_bitmap (CoglHandle bmp_handle,
|
cogl_texture_new_from_bitmap (CoglBitmap *bitmap,
|
||||||
CoglTextureFlags flags,
|
CoglTextureFlags flags,
|
||||||
CoglPixelFormat internal_format);
|
CoglPixelFormat internal_format);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cogl_is_texture:
|
* cogl_is_texture:
|
||||||
* @handle: A CoglHandle
|
* @object: A #CoglObject pointer
|
||||||
*
|
*
|
||||||
* Gets whether the given handle references an existing texture object.
|
* Gets whether the given object references a texture object.
|
||||||
*
|
*
|
||||||
* Return value: %TRUE if the handle references a texture, and
|
* Return value: %TRUE if the handle references a texture, and
|
||||||
* %FALSE otherwise
|
* %FALSE otherwise
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
cogl_is_texture (CoglHandle handle);
|
cogl_is_texture (void *object);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cogl_texture_get_width:
|
* cogl_texture_get_width:
|
||||||
* @handle: a #CoglHandle for a texture.
|
* @texture a #CoglTexture pointer.
|
||||||
*
|
*
|
||||||
* Queries the width of a cogl texture.
|
* Queries the width of a cogl texture.
|
||||||
*
|
*
|
||||||
* Return value: the width of the GPU side texture in pixels
|
* Return value: the width of the GPU side texture in pixels
|
||||||
*/
|
*/
|
||||||
unsigned int
|
unsigned int
|
||||||
cogl_texture_get_width (CoglHandle handle);
|
cogl_texture_get_width (CoglTexture *texture);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cogl_texture_get_height:
|
* cogl_texture_get_height:
|
||||||
* @handle: a #CoglHandle for a texture.
|
* @texture a #CoglTexture pointer.
|
||||||
*
|
*
|
||||||
* Queries the height of a cogl texture.
|
* Queries the height of a cogl texture.
|
||||||
*
|
*
|
||||||
* Return value: the height of the GPU side texture in pixels
|
* Return value: the height of the GPU side texture in pixels
|
||||||
*/
|
*/
|
||||||
unsigned int
|
unsigned int
|
||||||
cogl_texture_get_height (CoglHandle handle);
|
cogl_texture_get_height (CoglTexture *texture);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cogl_texture_get_format:
|
* cogl_texture_get_format:
|
||||||
* @handle: a #CoglHandle for a texture.
|
* @texture a #CoglTexture pointer.
|
||||||
*
|
*
|
||||||
* Queries the #CoglPixelFormat of a cogl texture.
|
* Queries the #CoglPixelFormat of a cogl texture.
|
||||||
*
|
*
|
||||||
* Return value: the #CoglPixelFormat of the GPU side texture
|
* Return value: the #CoglPixelFormat of the GPU side texture
|
||||||
*/
|
*/
|
||||||
CoglPixelFormat
|
CoglPixelFormat
|
||||||
cogl_texture_get_format (CoglHandle handle);
|
cogl_texture_get_format (CoglTexture *texture);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cogl_texture_get_rowstride:
|
* cogl_texture_get_rowstride:
|
||||||
* @handle: a #CoglHandle for a texture.
|
* @texture a #CoglTexture pointer.
|
||||||
*
|
*
|
||||||
* Queries the rowstride of a cogl texture.
|
* Queries the rowstride of a cogl texture.
|
||||||
*
|
*
|
||||||
* Return value: the offset in bytes between each consequetive row of pixels
|
* Return value: the offset in bytes between each consequetive row of pixels
|
||||||
*/
|
*/
|
||||||
unsigned int
|
unsigned int
|
||||||
cogl_texture_get_rowstride (CoglHandle handle);
|
cogl_texture_get_rowstride (CoglTexture *texture);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cogl_texture_get_max_waste:
|
* cogl_texture_get_max_waste:
|
||||||
* @handle: a #CoglHandle for a texture.
|
* @texture a #CoglTexture pointer.
|
||||||
*
|
*
|
||||||
* Queries the maximum wasted (unused) pixels in one dimension of a GPU side
|
* Queries the maximum wasted (unused) pixels in one dimension of a GPU side
|
||||||
* texture.
|
* texture.
|
||||||
@ -275,11 +276,11 @@ cogl_texture_get_rowstride (CoglHandle handle);
|
|||||||
* Return value: the maximum waste
|
* Return value: the maximum waste
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
cogl_texture_get_max_waste (CoglHandle handle);
|
cogl_texture_get_max_waste (CoglTexture *texture);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cogl_texture_is_sliced:
|
* cogl_texture_is_sliced:
|
||||||
* @handle: a #CoglHandle for a texture.
|
* @texture a #CoglTexture pointer.
|
||||||
*
|
*
|
||||||
* Queries if a texture is sliced (stored as multiple GPU side tecture
|
* Queries if a texture is sliced (stored as multiple GPU side tecture
|
||||||
* objects).
|
* objects).
|
||||||
@ -288,17 +289,17 @@ cogl_texture_get_max_waste (CoglHandle handle);
|
|||||||
* is stored as a single GPU texture
|
* is stored as a single GPU texture
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
cogl_texture_is_sliced (CoglHandle handle);
|
cogl_texture_is_sliced (CoglTexture *texture);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cogl_texture_get_gl_texture:
|
* cogl_texture_get_gl_texture:
|
||||||
* @handle: a #CoglHandle for a texture.
|
* @texture a #CoglTexture pointer.
|
||||||
* @out_gl_handle: (out) (allow-none): pointer to return location for the
|
* @out_gl_handle: (out) (allow-none): pointer to return location for the
|
||||||
* textures GL handle, or %NULL.
|
* textures GL handle, or %NULL.
|
||||||
* @out_gl_target: (out) (allow-none): pointer to return location for the
|
* @out_gl_target: (out) (allow-none): pointer to return location for the
|
||||||
* GL target type, or %NULL.
|
* GL target type, or %NULL.
|
||||||
*
|
*
|
||||||
* Queries the GL handles for a GPU side texture through its #CoglHandle.
|
* Queries the GL handles for a GPU side texture through its #CoglTexture.
|
||||||
*
|
*
|
||||||
* If the texture is spliced the data for the first sub texture will be
|
* If the texture is spliced the data for the first sub texture will be
|
||||||
* queried.
|
* queried.
|
||||||
@ -307,13 +308,13 @@ cogl_texture_is_sliced (CoglHandle handle);
|
|||||||
* if the handle was invalid
|
* if the handle was invalid
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
cogl_texture_get_gl_texture (CoglHandle handle,
|
cogl_texture_get_gl_texture (CoglTexture *texture,
|
||||||
GLuint *out_gl_handle,
|
GLuint *out_gl_handle,
|
||||||
GLenum *out_gl_target);
|
GLenum *out_gl_target);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cogl_texture_get_data:
|
* cogl_texture_get_data:
|
||||||
* @handle: a #CoglHandle for a texture.
|
* @texture a #CoglTexture pointer.
|
||||||
* @format: the #CoglPixelFormat to store the texture as.
|
* @format: the #CoglPixelFormat to store the texture as.
|
||||||
* @rowstride: the rowstride of @data or retrieved from texture if none is
|
* @rowstride: the rowstride of @data or retrieved from texture if none is
|
||||||
* specified.
|
* specified.
|
||||||
@ -326,14 +327,14 @@ cogl_texture_get_gl_texture (CoglHandle handle,
|
|||||||
* is not valid
|
* is not valid
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
cogl_texture_get_data (CoglHandle handle,
|
cogl_texture_get_data (CoglTexture *texture,
|
||||||
CoglPixelFormat format,
|
CoglPixelFormat format,
|
||||||
unsigned int rowstride,
|
unsigned int rowstride,
|
||||||
guint8 *data);
|
guint8 *data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cogl_texture_set_region:
|
* cogl_texture_set_region:
|
||||||
* @handle: a #CoglHandle.
|
* @texture a #CoglTexture.
|
||||||
* @src_x: upper left coordinate to use from source data.
|
* @src_x: upper left coordinate to use from source data.
|
||||||
* @src_y: 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_x: upper left destination horizontal coordinate.
|
||||||
@ -354,7 +355,7 @@ cogl_texture_get_data (CoglHandle handle,
|
|||||||
* %FALSE otherwise
|
* %FALSE otherwise
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
cogl_texture_set_region (CoglHandle handle,
|
cogl_texture_set_region (CoglTexture *texture,
|
||||||
int src_x,
|
int src_x,
|
||||||
int src_y,
|
int src_y,
|
||||||
int dst_x,
|
int dst_x,
|
||||||
@ -373,7 +374,7 @@ cogl_texture_set_region (CoglHandle handle,
|
|||||||
cogl_texture_set_region_from_bitmap_EXP
|
cogl_texture_set_region_from_bitmap_EXP
|
||||||
/**
|
/**
|
||||||
* cogl_texture_set_region_from_bitmap:
|
* cogl_texture_set_region_from_bitmap:
|
||||||
* @handle: a #CoglHandle for a texture
|
* @texture a #CoglTexture pointer
|
||||||
* @src_x: upper left coordinate to use from the source bitmap.
|
* @src_x: upper left coordinate to use from the source bitmap.
|
||||||
* @src_y: 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_x: upper left destination horizontal coordinate.
|
||||||
@ -392,7 +393,7 @@ cogl_texture_set_region (CoglHandle handle,
|
|||||||
* Stability: unstable
|
* Stability: unstable
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
cogl_texture_set_region_from_bitmap (CoglHandle handle,
|
cogl_texture_set_region_from_bitmap (CoglTexture *texture,
|
||||||
int src_x,
|
int src_x,
|
||||||
int src_y,
|
int src_y,
|
||||||
int dst_x,
|
int dst_x,
|
||||||
@ -404,7 +405,7 @@ cogl_texture_set_region_from_bitmap (CoglHandle handle,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* cogl_texture_new_from_sub_texture:
|
* cogl_texture_new_from_sub_texture:
|
||||||
* @full_texture: a #CoglHandle to an existing texture
|
* @full_texture: a #CoglTexture pointer
|
||||||
* @sub_x: X coordinate of the top-left of the subregion
|
* @sub_x: X coordinate of the top-left of the subregion
|
||||||
* @sub_y: Y 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_width: Width in pixels of the subregion
|
||||||
@ -422,12 +423,11 @@ cogl_texture_set_region_from_bitmap (CoglHandle handle,
|
|||||||
* not need to keep one separately if you only want to use the sub
|
* not need to keep one separately if you only want to use the sub
|
||||||
* texture.
|
* texture.
|
||||||
*
|
*
|
||||||
* Return value: a #CoglHandle to the new texture.
|
* Return value: A newly created #CoglTexture or %NULL on failure
|
||||||
*
|
|
||||||
* Since: 1.2
|
* Since: 1.2
|
||||||
*/
|
*/
|
||||||
CoglHandle
|
CoglTexture *
|
||||||
cogl_texture_new_from_sub_texture (CoglHandle full_texture,
|
cogl_texture_new_from_sub_texture (CoglTexture *full_texture,
|
||||||
int sub_x,
|
int sub_x,
|
||||||
int sub_y,
|
int sub_y,
|
||||||
int sub_width,
|
int sub_width,
|
||||||
@ -435,9 +435,10 @@ cogl_texture_new_from_sub_texture (CoglHandle full_texture,
|
|||||||
|
|
||||||
#if defined (COGL_ENABLE_EXPERIMENTAL_API)
|
#if defined (COGL_ENABLE_EXPERIMENTAL_API)
|
||||||
|
|
||||||
|
#define cogl_texture_new_from_buffer cogl_texture_new_from_buffer_EXP
|
||||||
/**
|
/**
|
||||||
* cogl_texture_new_from_buffer:
|
* cogl_texture_new_from_buffer:
|
||||||
* @buffer: the #CoglHandle of a pixel buffer
|
* @buffer: A #CoglPixelBuffer pointer
|
||||||
* @width: width of texture in pixels or 0
|
* @width: width of texture in pixels or 0
|
||||||
* @height: height of texture in pixels or 0
|
* @height: height of texture in pixels or 0
|
||||||
* @flags: optional flags for the texture, or %COGL_TEXTURE_NONE
|
* @flags: optional flags for the texture, or %COGL_TEXTURE_NONE
|
||||||
@ -459,14 +460,13 @@ cogl_texture_new_from_sub_texture (CoglHandle full_texture,
|
|||||||
* has been created using cogl_pixel_buffer_new_for_size() it's possible to omit
|
* has been created using cogl_pixel_buffer_new_for_size() it's possible to omit
|
||||||
* the height and width values already specified at creation time.
|
* the height and width values already specified at creation time.
|
||||||
*
|
*
|
||||||
* Return value: a #CoglHandle to the new texture or %COGL_INVALID_HANDLE on
|
* Return value: A newly created #CoglTexture or %NULL on failure
|
||||||
* failure
|
|
||||||
*
|
*
|
||||||
* Since: 1.2
|
* Since: 1.2
|
||||||
* Stability: Unstable
|
* Stability: Unstable
|
||||||
*/
|
*/
|
||||||
CoglHandle
|
CoglTexture *
|
||||||
cogl_texture_new_from_buffer (CoglHandle buffer,
|
cogl_texture_new_from_buffer (CoglPixelBuffer *buffer,
|
||||||
unsigned int width,
|
unsigned int width,
|
||||||
unsigned int height,
|
unsigned int height,
|
||||||
CoglTextureFlags flags,
|
CoglTextureFlags flags,
|
||||||
@ -474,51 +474,33 @@ cogl_texture_new_from_buffer (CoglHandle buffer,
|
|||||||
CoglPixelFormat internal_format,
|
CoglPixelFormat internal_format,
|
||||||
unsigned int rowstride,
|
unsigned int rowstride,
|
||||||
unsigned int offset);
|
unsigned int offset);
|
||||||
|
|
||||||
/* the function above is experimental, the actual symbol is suffixed by _EXP so
|
|
||||||
* we can ensure ABI compatibility and leave the cogl_buffer namespace free for
|
|
||||||
* future use. A bunch of defines translates the symbols documented above into
|
|
||||||
* the real symbols */
|
|
||||||
|
|
||||||
CoglHandle
|
|
||||||
cogl_texture_new_from_buffer_EXP (CoglHandle buffer,
|
|
||||||
unsigned int width,
|
|
||||||
unsigned int height,
|
|
||||||
CoglTextureFlags flags,
|
|
||||||
CoglPixelFormat format,
|
|
||||||
CoglPixelFormat internal_format,
|
|
||||||
unsigned int rowstride,
|
|
||||||
unsigned int offset);
|
|
||||||
|
|
||||||
#define cogl_texture_new_from_buffer cogl_texture_new_from_buffer_EXP
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef COGL_DISABLE_DEPRECATED
|
#ifndef COGL_DISABLE_DEPRECATED
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cogl_texture_ref:
|
* cogl_texture_ref:
|
||||||
* @handle: a @CoglHandle.
|
* @texture: a #CoglTexture.
|
||||||
*
|
*
|
||||||
* Increment the reference count for a cogl texture.
|
* Increment the reference count for a cogl texture.
|
||||||
*
|
*
|
||||||
* Deprecated: 1.2: Use cogl_handle_ref() instead
|
* Deprecated: 1.2: Use cogl_object_ref() instead
|
||||||
*
|
*
|
||||||
* Return value: the @handle.
|
* Return value: the @texture pointer.
|
||||||
*/
|
*/
|
||||||
CoglHandle
|
void *
|
||||||
cogl_texture_ref (CoglHandle handle) G_GNUC_DEPRECATED;
|
cogl_texture_ref (void *texture) G_GNUC_DEPRECATED;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cogl_texture_unref:
|
* cogl_texture_unref:
|
||||||
* @handle: a @CoglHandle.
|
* @texture: a #CoglTexture.
|
||||||
*
|
*
|
||||||
* Decrement the reference count for a cogl texture.
|
* Decrement the reference count for a cogl texture.
|
||||||
*
|
*
|
||||||
* Deprecated: 1.2: Use cogl_handle_unref() instead
|
* Deprecated: 1.2: Use cogl_object_unref() instead
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
cogl_texture_unref (CoglHandle handle) G_GNUC_DEPRECATED;
|
cogl_texture_unref (void *texture) G_GNUC_DEPRECATED;
|
||||||
|
|
||||||
#endif /* COGL_DISABLE_DEPRECATED */
|
#endif /* COGL_DISABLE_DEPRECATED */
|
||||||
|
|
||||||
|
@ -1004,13 +1004,13 @@ cogl_set_source (void *material_or_pipeline)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_set_source_texture (CoglHandle texture_handle)
|
cogl_set_source_texture (CoglTexture *texture)
|
||||||
{
|
{
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
g_return_if_fail (texture_handle != NULL);
|
g_return_if_fail (texture != NULL);
|
||||||
|
|
||||||
cogl_pipeline_set_layer_texture (ctx->texture_pipeline, 0, texture_handle);
|
cogl_pipeline_set_layer_texture (ctx->texture_pipeline, 0, texture);
|
||||||
cogl_set_source (ctx->texture_pipeline);
|
cogl_set_source (ctx->texture_pipeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -693,10 +693,10 @@ cogl_set_source_color4f (float red,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* cogl_set_source_texture:
|
* cogl_set_source_texture:
|
||||||
* @texture_handle: The Cogl texture you want as your source
|
* @texture: The #CoglTexture you want as your source
|
||||||
*
|
*
|
||||||
* This is a convenience function for creating a material with the first
|
* This is a convenience function for creating a material with the first
|
||||||
* layer set to #texture_handle and setting that material as the source with
|
* layer set to @texture and setting that material as the source with
|
||||||
* cogl_set_source.
|
* cogl_set_source.
|
||||||
*
|
*
|
||||||
* Note: There is no interaction between calls to cogl_set_source_color
|
* Note: There is no interaction between calls to cogl_set_source_color
|
||||||
@ -712,7 +712,7 @@ cogl_set_source_color4f (float red,
|
|||||||
* Since: 1.0
|
* Since: 1.0
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
cogl_set_source_texture (CoglHandle texture_handle);
|
cogl_set_source_texture (CoglTexture *texture);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SECTION:cogl-clipping
|
* SECTION:cogl-clipping
|
||||||
|
@ -307,9 +307,9 @@ _cogl_path_fill_nodes (CoglPath *path)
|
|||||||
for (l = _cogl_pipeline_get_layers (cogl_get_source ()); l; l = l->next)
|
for (l = _cogl_pipeline_get_layers (cogl_get_source ()); l; l = l->next)
|
||||||
{
|
{
|
||||||
CoglHandle layer = l->data;
|
CoglHandle layer = l->data;
|
||||||
CoglHandle texture = _cogl_pipeline_layer_get_texture (layer);
|
CoglTexture *texture = _cogl_pipeline_layer_get_texture (layer);
|
||||||
|
|
||||||
if (texture != COGL_INVALID_HANDLE &&
|
if (texture != NULL &&
|
||||||
(cogl_texture_is_sliced (texture) ||
|
(cogl_texture_is_sliced (texture) ||
|
||||||
!_cogl_texture_can_hardware_repeat (texture)))
|
!_cogl_texture_can_hardware_repeat (texture)))
|
||||||
{
|
{
|
||||||
|
@ -637,7 +637,7 @@ _cogl_texture_pixmap_x11_set_use_winsys_texture (CoglTexturePixmapX11 *tex_pixma
|
|||||||
/* Notify cogl-pipeline.c that the texture's underlying GL texture
|
/* 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
|
* storage is changing so it knows it may need to bind a new texture
|
||||||
* if the CoglTexture is reused with the same texture unit. */
|
* if the CoglTexture is reused with the same texture unit. */
|
||||||
_cogl_pipeline_texture_storage_change_notify (tex_pixmap);
|
_cogl_pipeline_texture_storage_change_notify (COGL_TEXTURE (tex_pixmap));
|
||||||
|
|
||||||
tex_pixmap->use_winsys_texture = new_value;
|
tex_pixmap->use_winsys_texture = new_value;
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ typedef struct _CoglOnscreenEGL
|
|||||||
typedef struct _CoglTexturePixmapEGL
|
typedef struct _CoglTexturePixmapEGL
|
||||||
{
|
{
|
||||||
EGLImageKHR image;
|
EGLImageKHR image;
|
||||||
CoglHandle texture;
|
CoglTexture *texture;
|
||||||
} CoglTexturePixmapEGL;
|
} CoglTexturePixmapEGL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1667,13 +1667,13 @@ _cogl_winsys_texture_pixmap_x11_create (CoglTexturePixmapX11 *tex_pixmap)
|
|||||||
COGL_PIXEL_FORMAT_RGBA_8888_PRE :
|
COGL_PIXEL_FORMAT_RGBA_8888_PRE :
|
||||||
COGL_PIXEL_FORMAT_RGB_888);
|
COGL_PIXEL_FORMAT_RGB_888);
|
||||||
|
|
||||||
egl_tex_pixmap->texture =
|
egl_tex_pixmap->texture = COGL_TEXTURE (
|
||||||
_cogl_egl_texture_2d_new_from_image (ctx,
|
_cogl_egl_texture_2d_new_from_image (ctx,
|
||||||
tex_pixmap->width,
|
tex_pixmap->width,
|
||||||
tex_pixmap->height,
|
tex_pixmap->height,
|
||||||
texture_format,
|
texture_format,
|
||||||
egl_tex_pixmap->image,
|
egl_tex_pixmap->image,
|
||||||
NULL);
|
NULL));
|
||||||
|
|
||||||
tex_pixmap->winsys = egl_tex_pixmap;
|
tex_pixmap->winsys = egl_tex_pixmap;
|
||||||
|
|
||||||
@ -1695,7 +1695,7 @@ _cogl_winsys_texture_pixmap_x11_free (CoglTexturePixmapX11 *tex_pixmap)
|
|||||||
egl_tex_pixmap = tex_pixmap->winsys;
|
egl_tex_pixmap = tex_pixmap->winsys;
|
||||||
|
|
||||||
if (egl_tex_pixmap->texture)
|
if (egl_tex_pixmap->texture)
|
||||||
cogl_handle_unref (egl_tex_pixmap->texture);
|
cogl_object_unref (egl_tex_pixmap->texture);
|
||||||
|
|
||||||
if (egl_tex_pixmap->image != EGL_NO_IMAGE_KHR)
|
if (egl_tex_pixmap->image != EGL_NO_IMAGE_KHR)
|
||||||
_cogl_egl_destroy_image (ctx, egl_tex_pixmap->image);
|
_cogl_egl_destroy_image (ctx, egl_tex_pixmap->image);
|
||||||
|
@ -10,7 +10,7 @@ typedef struct _Data
|
|||||||
CoglMatrix view;
|
CoglMatrix view;
|
||||||
|
|
||||||
CoglPrimitive *prim;
|
CoglPrimitive *prim;
|
||||||
CoglHandle texture;
|
CoglTexture *texture;
|
||||||
CoglPipeline *crate_pipeline;
|
CoglPipeline *crate_pipeline;
|
||||||
|
|
||||||
/* The cube continually rotates around each axis. */
|
/* The cube continually rotates around each axis. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user