diff options
author | Robert Bragg <robert@linux.intel.com> | 2012-04-16 14:14:10 +0100 |
---|---|---|
committer | Robert Bragg <robert@linux.intel.com> | 2012-04-18 14:24:02 +0100 |
commit | 6ed3aaf4be21d605a1ed3176b3ea825933f85cf0 (patch) | |
tree | 58c0e51fc084ee5d7c163fd8e3cc36e49b5e0c42 | |
parent | 465b39a764f2720e77678cafa56acb0e69007ffd (diff) | |
download | cogl-6ed3aaf4be21d605a1ed3176b3ea825933f85cf0.tar.gz |
Removes all remaining use of CoglHandle
Removing CoglHandle has been an on going goal for quite a long time now
and finally this patch removes the last remaining uses of the CoglHandle
type and the cogl_handle_ apis.
Since the big remaining users of CoglHandle were the cogl_program_ and
cogl_shader_ apis which have replaced with the CoglSnippets api this
patch removes both of these apis.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
84 files changed, 596 insertions, 2805 deletions
diff --git a/cogl-pango/cogl-pango-glyph-cache.c b/cogl-pango/cogl-pango-glyph-cache.c index 5ddb4acd..b7fb5b04 100644 --- a/cogl-pango/cogl-pango-glyph-cache.c +++ b/cogl-pango/cogl-pango-glyph-cache.c @@ -173,7 +173,7 @@ cogl_pango_glyph_cache_free (CoglPangoGlyphCache *cache) static void cogl_pango_glyph_cache_update_position_cb (void *user_data, - CoglHandle new_texture, + CoglTexture *new_texture, const CoglRectangleMapEntry *rect) { CoglPangoGlyphCacheValue *value = user_data; @@ -204,7 +204,7 @@ cogl_pango_glyph_cache_add_to_global_atlas (CoglPangoGlyphCache *cache, PangoGlyph glyph, CoglPangoGlyphCacheValue *value) { - CoglTexture *texture; + CoglAtlasTexture *texture; if (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_SHARED_ATLAS)) return FALSE; @@ -222,7 +222,7 @@ cogl_pango_glyph_cache_add_to_global_atlas (CoglPangoGlyphCache *cache, if (texture == NULL) return FALSE; - value->texture = texture; + value->texture = COGL_TEXTURE (texture); value->tx1 = 0; value->ty1 = 0; value->tx2 = 1; diff --git a/cogl-pango/cogl-pango-pipeline-cache.c b/cogl-pango/cogl-pango-pipeline-cache.c index 5a2e2ecd..e07d6468 100644 --- a/cogl-pango/cogl-pango-pipeline-cache.c +++ b/cogl-pango/cogl-pango-pipeline-cache.c @@ -54,7 +54,7 @@ struct _CoglPangoPipelineCacheEntry CoglTexture *texture; /* This will only take a weak reference */ - CoglHandle pipeline; + CoglPipeline *pipeline; }; static void @@ -173,7 +173,7 @@ pipeline_destroy_notify_cb (void *user_data) CoglPipeline * _cogl_pango_pipeline_cache_get (CoglPangoPipelineCache *cache, - CoglHandle texture) + CoglTexture *texture) { CoglPangoPipelineCacheEntry *entry; PipelineDestroyNotifyData *destroy_data; @@ -216,7 +216,7 @@ _cogl_pango_pipeline_cache_get (CoglPangoPipelineCache *cache, destroy_data = g_slice_new (PipelineDestroyNotifyData); destroy_data->cache = cache; destroy_data->texture = texture; - cogl_object_set_user_data (entry->pipeline, + cogl_object_set_user_data (COGL_OBJECT (entry->pipeline), &pipeline_destroy_notify_key, destroy_data, pipeline_destroy_notify_cb); diff --git a/cogl-pango/cogl-pango-pipeline-cache.h b/cogl-pango/cogl-pango-pipeline-cache.h index d095c584..1ebfb67a 100644 --- a/cogl-pango/cogl-pango-pipeline-cache.h +++ b/cogl-pango/cogl-pango-pipeline-cache.h @@ -43,7 +43,7 @@ _cogl_pango_pipeline_cache_new (gboolean use_mipmapping); to unref it */ CoglPipeline * _cogl_pango_pipeline_cache_get (CoglPangoPipelineCache *cache, - CoglHandle texture); + CoglTexture *texture); void _cogl_pango_pipeline_cache_free (CoglPangoPipelineCache *cache); diff --git a/cogl/Makefile.am b/cogl/Makefile.am index 74d532de..82f5857a 100644 --- a/cogl/Makefile.am +++ b/cogl/Makefile.am @@ -54,7 +54,6 @@ cogl_1_public_h = \ $(srcdir)/cogl-matrix.h \ $(srcdir)/cogl-offscreen.h \ $(srcdir)/cogl-primitives.h \ - $(srcdir)/cogl-shader.h \ $(srcdir)/cogl-texture.h \ $(srcdir)/cogl-types.h \ $(srcdir)/cogl-clutter.h \ @@ -245,6 +244,9 @@ cogl_sources_c = \ $(srcdir)/cogl-pipeline-debug.c \ $(srcdir)/cogl-pipeline-opengl.c \ $(srcdir)/cogl-pipeline-opengl-private.h \ + $(srcdir)/cogl-glsl-shader.c \ + $(srcdir)/cogl-glsl-shader-private.h \ + $(srcdir)/cogl-glsl-shader-boilerplate.h \ $(srcdir)/cogl-pipeline-fragend-glsl.c \ $(srcdir)/cogl-pipeline-fragend-glsl-private.h \ $(srcdir)/cogl-pipeline-fragend-arbfp.c \ @@ -263,8 +265,6 @@ cogl_sources_c = \ $(srcdir)/cogl-pipeline-snippet.c \ $(srcdir)/cogl-pipeline-cache.h \ $(srcdir)/cogl-pipeline-cache.c \ - $(srcdir)/cogl-program.c \ - $(srcdir)/cogl-program-private.h \ $(srcdir)/cogl-sampler-cache.c \ $(srcdir)/cogl-sampler-cache-private.h \ $(srcdir)/cogl-blend-string.c \ @@ -306,9 +306,6 @@ cogl_sources_c = \ $(srcdir)/cogl-flags.h \ $(srcdir)/cogl-bitmask.h \ $(srcdir)/cogl-bitmask.c \ - $(srcdir)/cogl-shader-boilerplate.h \ - $(srcdir)/cogl-shader-private.h \ - $(srcdir)/cogl-shader.c \ $(srcdir)/cogl-gtype-private.h \ $(srcdir)/cogl-point-in-poly-private.h \ $(srcdir)/cogl-point-in-poly.c \ diff --git a/cogl/cogl-atlas-texture-private.h b/cogl/cogl-atlas-texture-private.h index 4387affe..43bc2fbf 100644 --- a/cogl/cogl-atlas-texture-private.h +++ b/cogl/cogl-atlas-texture-private.h @@ -24,7 +24,7 @@ #ifndef __COGL_ATLAS_TEXTURE_H #define __COGL_ATLAS_TEXTURE_H -#include "cogl-handle.h" +#include "cogl-object-private.h" #include "cogl-texture-private.h" #include "cogl-rectangle-map.h" #include "cogl-atlas.h" @@ -51,16 +51,18 @@ struct _CoglAtlasTexture atlas by the texture (but not vice versa so there is no cycle) */ CoglAtlas *atlas; - /* A CoglSubTexture representing the region for easy rendering */ - CoglHandle sub_texture; + /* Either a CoglSubTexture representing the atlas region for easy + * rendering or if the texture has been migrated out of the atlas it + * may be some other texture type such as CoglTexture2D */ + CoglTexture *sub_texture; }; -CoglHandle +CoglAtlasTexture * _cogl_atlas_texture_new_from_bitmap (CoglBitmap *bmp, CoglTextureFlags flags, CoglPixelFormat internal_format); -CoglHandle +CoglAtlasTexture * _cogl_atlas_texture_new_with_size (unsigned int width, unsigned int height, CoglTextureFlags flags, diff --git a/cogl/cogl-atlas-texture.c b/cogl/cogl-atlas-texture.c index 53435d33..fa27e681 100644 --- a/cogl/cogl-atlas-texture.c +++ b/cogl/cogl-atlas-texture.c @@ -36,7 +36,7 @@ #include "cogl-texture-2d-private.h" #include "cogl-sub-texture-private.h" #include "cogl-context-private.h" -#include "cogl-handle.h" +#include "cogl-object-private.h" #include "cogl-texture-driver.h" #include "cogl-rectangle-map.h" #include "cogl-journal-private.h" @@ -53,8 +53,8 @@ COGL_TEXTURE_INTERNAL_DEFINE (AtlasTexture, atlas_texture); static const CoglTextureVtable cogl_atlas_texture_vtable; -static CoglHandle -_cogl_atlas_texture_create_sub_texture (CoglHandle full_texture, +static CoglSubTexture * +_cogl_atlas_texture_create_sub_texture (CoglTexture *full_texture, const CoglRectangleMapEntry *rectangle) { /* Create a subtexture for the given rectangle not including the @@ -70,16 +70,16 @@ _cogl_atlas_texture_create_sub_texture (CoglHandle full_texture, static void _cogl_atlas_texture_update_position_cb (gpointer user_data, - CoglHandle new_texture, + CoglTexture *new_texture, const CoglRectangleMapEntry *rectangle) { CoglAtlasTexture *atlas_tex = user_data; /* Update the sub texture */ if (atlas_tex->sub_texture) - cogl_handle_unref (atlas_tex->sub_texture); - atlas_tex->sub_texture = - _cogl_atlas_texture_create_sub_texture (new_texture, rectangle); + cogl_object_unref (atlas_tex->sub_texture); + atlas_tex->sub_texture = COGL_TEXTURE ( + _cogl_atlas_texture_create_sub_texture (new_texture, rectangle)); /* Update the position */ atlas_tex->rectangle = *rectangle; @@ -95,7 +95,7 @@ _cogl_atlas_texture_pre_reorganize_foreach_cb /* Keep a reference to the texture because we don't want it to be destroyed during the reorganization */ - cogl_handle_ref (atlas_tex); + cogl_object_ref (atlas_tex); /* 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 @@ -197,7 +197,7 @@ _cogl_atlas_texture_create_atlas (void) CoglAtlas *atlas; - _COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE); + _COGL_GET_CONTEXT (ctx, NULL); atlas = _cogl_atlas_new (COGL_PIXEL_FORMAT_RGBA_8888, 0, @@ -232,9 +232,10 @@ _cogl_atlas_texture_foreach_sub_texture_in_region ( void *user_data) { CoglAtlasTexture *atlas_tex = COGL_ATLAS_TEXTURE (tex); + CoglMetaTexture *meta_texture = COGL_META_TEXTURE (atlas_tex->sub_texture); /* Forward on to the sub texture */ - cogl_meta_texture_foreach_in_region (atlas_tex->sub_texture, + cogl_meta_texture_foreach_in_region (meta_texture, virtual_tx_1, virtual_ty_1, virtual_tx_2, @@ -278,7 +279,7 @@ _cogl_atlas_texture_free (CoglAtlasTexture *atlas_tex) { _cogl_atlas_texture_remove_from_atlas (atlas_tex); - cogl_handle_unref (atlas_tex->sub_texture); + cogl_object_unref (atlas_tex->sub_texture); /* Chain up */ _cogl_texture_free (COGL_TEXTURE (atlas_tex)); @@ -363,7 +364,7 @@ _cogl_atlas_texture_migrate_out_of_atlas (CoglAtlasTexture *atlas_tex) /* Make sure this texture is not in the atlas */ if (atlas_tex->atlas) { - CoglHandle sub_texture; + CoglTexture *standalone_tex; COGL_NOTE (ATLAS, "Migrating texture out of the atlas"); @@ -377,7 +378,7 @@ _cogl_atlas_texture_migrate_out_of_atlas (CoglAtlasTexture *atlas_tex) */ cogl_flush (); - sub_texture = + standalone_tex = _cogl_atlas_copy_rectangle (atlas_tex->atlas, atlas_tex->rectangle.x + 1, atlas_tex->rectangle.y + 1, @@ -395,8 +396,8 @@ _cogl_atlas_texture_migrate_out_of_atlas (CoglAtlasTexture *atlas_tex) the copy can involve rendering which might cause the texture to be used if it is used from a layer that is left in a texture unit */ - cogl_handle_unref (atlas_tex->sub_texture); - atlas_tex->sub_texture = sub_texture; + cogl_object_unref (atlas_tex->sub_texture); + atlas_tex->sub_texture = standalone_tex; _cogl_atlas_texture_remove_from_atlas (atlas_tex); } @@ -632,7 +633,7 @@ _cogl_atlas_texture_can_use_format (CoglPixelFormat format) format == COGL_PIXEL_FORMAT_RGBA_8888); } -CoglHandle +CoglAtlasTexture * _cogl_atlas_texture_new_with_size (unsigned int width, unsigned int height, CoglTextureFlags flags, @@ -642,28 +643,28 @@ _cogl_atlas_texture_new_with_size (unsigned int width, CoglAtlas *atlas; GSList *l; - _COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE); + _COGL_GET_CONTEXT (ctx, NULL); /* Don't put textures in the atlas if the user has explicitly requested to disable it */ if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_ATLAS))) - return COGL_INVALID_HANDLE; + return NULL; /* We can't put the texture in the atlas if there are any special flags. This precludes textures with COGL_TEXTURE_NO_ATLAS and COGL_TEXTURE_NO_SLICING from being atlased */ if (flags) - return COGL_INVALID_HANDLE; + return NULL; /* We can't atlas zero-sized textures because it breaks the atlas data structure */ if (width < 1 || height < 1) - return COGL_INVALID_HANDLE; + return NULL; /* If we can't use FBOs then it will be too slow to migrate textures and we shouldn't use the atlas */ if (!cogl_has_feature (ctx, COGL_FEATURE_ID_OFFSCREEN)) - return COGL_INVALID_HANDLE; + return NULL; COGL_NOTE (ATLAS, "Adding texture of size %ix%i", width, height); @@ -673,7 +674,7 @@ _cogl_atlas_texture_new_with_size (unsigned int width, COGL_NOTE (ATLAS, "Texture can not be added because the " "format is unsupported"); - return COGL_INVALID_HANDLE; + return NULL; } /* We need to allocate the texture now because we need the pointer @@ -686,7 +687,7 @@ _cogl_atlas_texture_new_with_size (unsigned int width, _cogl_texture_init (COGL_TEXTURE (atlas_tex), &cogl_atlas_texture_vtable); - atlas_tex->sub_texture = COGL_INVALID_HANDLE; + atlas_tex->sub_texture = NULL; /* Look for an existing atlas that can hold the texture */ for (l = ctx->atlases; l; l = l->next) @@ -713,29 +714,28 @@ _cogl_atlas_texture_new_with_size (unsigned int width, /* Ok, this means we really can't add it to the atlas */ cogl_object_unref (atlas); g_free (atlas_tex); - return COGL_INVALID_HANDLE; + return NULL; } } atlas_tex->format = internal_format; atlas_tex->atlas = atlas; - return _cogl_atlas_texture_handle_new (atlas_tex); + return _cogl_atlas_texture_object_new (atlas_tex); } -CoglHandle +CoglAtlasTexture * _cogl_atlas_texture_new_from_bitmap (CoglBitmap *bmp, CoglTextureFlags flags, CoglPixelFormat internal_format) { - CoglHandle atlas_tex_handle; CoglAtlasTexture *atlas_tex; CoglBitmap *dst_bmp; int bmp_width; int bmp_height; CoglPixelFormat bmp_format; - _COGL_RETURN_VAL_IF_FAIL (cogl_is_bitmap (bmp), COGL_INVALID_HANDLE); + _COGL_RETURN_VAL_IF_FAIL (cogl_is_bitmap (bmp), NULL); bmp_width = cogl_bitmap_get_width (bmp); bmp_height = cogl_bitmap_get_height (bmp); @@ -744,21 +744,19 @@ _cogl_atlas_texture_new_from_bitmap (CoglBitmap *bmp, internal_format = _cogl_texture_determine_internal_format (bmp_format, internal_format); - atlas_tex_handle = _cogl_atlas_texture_new_with_size (bmp_width, bmp_height, - flags, internal_format); + atlas_tex = _cogl_atlas_texture_new_with_size (bmp_width, bmp_height, + flags, internal_format); - if (atlas_tex_handle == COGL_INVALID_HANDLE) - return COGL_INVALID_HANDLE; - - atlas_tex = atlas_tex_handle; + if (atlas_tex == NULL) + return NULL; dst_bmp = _cogl_atlas_texture_prepare_for_upload (atlas_tex, bmp); if (dst_bmp == NULL) { - cogl_handle_unref (atlas_tex_handle); - return COGL_INVALID_HANDLE; + cogl_object_unref (atlas_tex); + return NULL; } /* Defer to set_region so that we can share the code for copying the @@ -774,7 +772,7 @@ _cogl_atlas_texture_new_from_bitmap (CoglBitmap *bmp, cogl_object_unref (dst_bmp); - return atlas_tex_handle; + return atlas_tex; } void diff --git a/cogl/cogl-atlas.c b/cogl/cogl-atlas.c index 7dd1cdc5..03eee309 100644 --- a/cogl/cogl-atlas.c +++ b/cogl/cogl-atlas.c @@ -70,7 +70,7 @@ _cogl_atlas_free (CoglAtlas *atlas) COGL_NOTE (ATLAS, "%p: Atlas destroyed", atlas); if (atlas->texture) - cogl_handle_unref (atlas->texture); + cogl_object_unref (atlas->texture); if (atlas->map) _cogl_rectangle_map_free (atlas->map); @@ -93,8 +93,8 @@ static void _cogl_atlas_migrate (CoglAtlas *atlas, unsigned int n_textures, CoglAtlasRepositionData *textures, - CoglHandle old_texture, - CoglHandle new_texture, + CoglTexture *old_texture, + CoglTexture *new_texture, void *skip_user_data) { unsigned int i; @@ -269,14 +269,14 @@ _cogl_atlas_create_map (CoglPixelFormat format, return NULL; } -static CoglHandle +static CoglTexture2D * _cogl_atlas_create_texture (CoglAtlas *atlas, int width, int height) { - CoglHandle tex; + CoglTexture2D *tex; - _COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE); + _COGL_GET_CONTEXT (ctx, NULL); if ((atlas->flags & COGL_ATLAS_CLEAR_TEXTURE)) { @@ -345,7 +345,7 @@ _cogl_atlas_reserve_space (CoglAtlas *atlas, { CoglAtlasGetRectanglesData data; CoglRectangleMap *new_map; - CoglHandle new_tex; + CoglTexture2D *new_tex; unsigned int map_width, map_height; gboolean ret; CoglRectangleMapEntry new_position; @@ -442,7 +442,7 @@ _cogl_atlas_reserve_space (CoglAtlas *atlas, else if ((new_tex = _cogl_atlas_create_texture (atlas, _cogl_rectangle_map_get_width (new_map), - _cogl_rectangle_map_get_height (new_map))) == COGL_INVALID_HANDLE) + _cogl_rectangle_map_get_height (new_map))) == NULL) { COGL_NOTE (ATLAS, "%p: Could not create a CoglTexture2D", atlas); _cogl_rectangle_map_free (new_map); @@ -472,20 +472,20 @@ _cogl_atlas_reserve_space (CoglAtlas *atlas, data.n_textures, data.textures, atlas->texture, - new_tex, + COGL_TEXTURE (new_tex), user_data); _cogl_rectangle_map_free (atlas->map); - cogl_handle_unref (atlas->texture); + cogl_object_unref (atlas->texture); } else /* We know there's only one texture so we can just directly update the rectangle from its new position */ atlas->update_position_cb (data.textures[0].user_data, - new_tex, + COGL_TEXTURE (new_tex), &data.textures[0].new_position); atlas->map = new_map; - atlas->texture = new_tex; + atlas->texture = COGL_TEXTURE (new_tex); waste = (_cogl_rectangle_map_get_remaining_space (atlas->map) * 100 / (_cogl_rectangle_map_get_width (atlas->map) * @@ -528,7 +528,7 @@ _cogl_atlas_remove (CoglAtlas *atlas, _cogl_rectangle_map_get_height (atlas->map))); }; -CoglHandle +CoglTexture * _cogl_atlas_copy_rectangle (CoglAtlas *atlas, unsigned int x, unsigned int y, @@ -537,7 +537,7 @@ _cogl_atlas_copy_rectangle (CoglAtlas *atlas, CoglTextureFlags flags, CoglPixelFormat format) { - CoglHandle tex; + CoglTexture *tex; CoglBlitData blit_data; /* Create a new texture at the right size */ diff --git a/cogl/cogl-atlas.h b/cogl/cogl-atlas.h index 95c4c11d..2b7bb8e1 100644 --- a/cogl/cogl-atlas.h +++ b/cogl/cogl-atlas.h @@ -26,10 +26,11 @@ #include "cogl-rectangle-map.h" #include "cogl-object-private.h" +#include "cogl-texture.h" typedef void (* CoglAtlasUpdatePositionCallback) (void *user_data, - CoglHandle new_texture, + CoglTexture *new_texture, const CoglRectangleMapEntry *rect); typedef enum @@ -48,7 +49,7 @@ struct _CoglAtlas CoglRectangleMap *map; - CoglHandle texture; + CoglTexture *texture; CoglPixelFormat texture_format; CoglAtlasFlags flags; @@ -73,7 +74,7 @@ void _cogl_atlas_remove (CoglAtlas *atlas, const CoglRectangleMapEntry *rectangle); -CoglHandle +CoglTexture * _cogl_atlas_copy_rectangle (CoglAtlas *atlas, unsigned int x, unsigned int y, diff --git a/cogl/cogl-attribute-buffer.h b/cogl/cogl-attribute-buffer.h index 492ba210..707cee18 100644 --- a/cogl/cogl-attribute-buffer.h +++ b/cogl/cogl-attribute-buffer.h @@ -77,7 +77,7 @@ cogl_attribute_buffer_new (CoglContext *context, * * Gets whether the given object references a #CoglAttributeBuffer. * - * Returns: %TRUE if the handle references a #CoglAttributeBuffer, + * Returns: %TRUE if @object references a #CoglAttributeBuffer, * %FALSE otherwise * * Since: 1.4 diff --git a/cogl/cogl-attribute.h b/cogl/cogl-attribute.h index b59402cb..a85b2de4 100644 --- a/cogl/cogl-attribute.h +++ b/cogl/cogl-attribute.h @@ -210,7 +210,7 @@ cogl_attribute_set_buffer (CoglAttribute *attribute, * * Gets whether the given object references a #CoglAttribute. * - * Return value: %TRUE if the handle references a #CoglAttribute, + * Return value: %TRUE if the @object references a #CoglAttribute, * %FALSE otherwise */ gboolean diff --git a/cogl/cogl-bitmap-private.h b/cogl/cogl-bitmap-private.h index b46ba734..b67c4f2e 100644 --- a/cogl/cogl-bitmap-private.h +++ b/cogl/cogl-bitmap-private.h @@ -28,7 +28,7 @@ #include <glib.h> -#include "cogl-handle.h" +#include "cogl-object-private.h" #include "cogl-buffer.h" #include "cogl-bitmap.h" diff --git a/cogl/cogl-bitmap.c b/cogl/cogl-bitmap.c index b81c6811..8952608f 100644 --- a/cogl/cogl-bitmap.c +++ b/cogl/cogl-bitmap.c @@ -37,7 +37,7 @@ struct _CoglBitmap { - CoglHandleObject _parent; + CoglObject _parent; /* Pointer back to the context that this bitmap was created with */ CoglContext *context; @@ -256,7 +256,7 @@ CoglBitmap * cogl_bitmap_new_from_file (const char *filename, GError **error) { - _COGL_RETURN_VAL_IF_FAIL (error == NULL || *error == NULL, COGL_INVALID_HANDLE); + _COGL_RETURN_VAL_IF_FAIL (error == NULL || *error == NULL, NULL); return _cogl_bitmap_from_file (filename, error); } diff --git a/cogl/cogl-bitmap.h b/cogl/cogl-bitmap.h index e2e2962c..e13d2c82 100644 --- a/cogl/cogl-bitmap.h +++ b/cogl/cogl-bitmap.h @@ -239,17 +239,17 @@ cogl_bitmap_get_size_from_file (const char *filename, /** * cogl_is_bitmap: - * @handle: a #CoglHandle for a bitmap + * @object: a #CoglObject pointer * - * Checks whether @handle is a #CoglHandle for a bitmap + * Checks whether @object is a #CoglBitmap * - * Return value: %TRUE if the passed handle represents a bitmap, + * Return value: %TRUE if the passed @object represents a bitmap, * and %FALSE otherwise * * Since: 1.0 */ gboolean -cogl_is_bitmap (CoglHandle handle); +cogl_is_bitmap (void *object); /** * COGL_BITMAP_ERROR: diff --git a/cogl/cogl-blit.c b/cogl/cogl-blit.c index 56c0c141..493fc753 100644 --- a/cogl/cogl-blit.c +++ b/cogl/cogl-blit.c @@ -43,38 +43,37 @@ static const CoglBlitMode *_cogl_blit_default_mode = NULL; static gboolean _cogl_blit_texture_render_begin (CoglBlitData *data) { - CoglHandle fbo; + CoglOffscreen *offscreen; + CoglFramebuffer *fb; CoglPipeline *pipeline; unsigned int dst_width, dst_height; _COGL_GET_CONTEXT (ctx, FALSE); - fbo = _cogl_offscreen_new_to_texture_full + offscreen = _cogl_offscreen_new_to_texture_full (data->dst_tex, COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL, 0 /* level */); - if (fbo == COGL_INVALID_HANDLE) + if (offscreen == NULL) return FALSE; - if (!cogl_framebuffer_allocate (fbo, NULL)) + fb = COGL_FRAMEBUFFER (offscreen); + if (!cogl_framebuffer_allocate (fb, NULL)) { - cogl_handle_unref (fbo); + cogl_object_unref (fb); return FALSE; } - cogl_push_framebuffer (fbo); - cogl_handle_unref (fbo); + cogl_push_framebuffer (fb); + cogl_object_unref (fb); dst_width = cogl_texture_get_width (data->dst_tex); dst_height = cogl_texture_get_height (data->dst_tex); /* Set up an orthographic projection so we can use pixel coordinates to render to the texture */ - cogl_ortho (0, /* left */ - dst_width, /* right */ - dst_height, /* bottom */ - 0, /* top */ - -1, /* near */ - 1 /* far */); + cogl_framebuffer_orthographic (fb, + 0, 0, dst_width, dst_height, + -1 /* near */, 1 /* far */); /* We cache a pipeline used for migrating on to the context so that it doesn't have to continuously regenerate a shader @@ -146,8 +145,8 @@ _cogl_blit_texture_render_end (CoglBlitData *data) static gboolean _cogl_blit_framebuffer_begin (CoglBlitData *data) { - CoglHandle dst_fbo, src_fbo; - gboolean ret; + CoglOffscreen *dst_offscreen = NULL, *src_offscreen = NULL; + CoglFramebuffer *dst_fb, *src_fb; _COGL_GET_CONTEXT (ctx, FALSE); @@ -158,39 +157,39 @@ _cogl_blit_framebuffer_begin (CoglBlitData *data) !(ctx->private_feature_flags & COGL_PRIVATE_FEATURE_OFFSCREEN_BLIT)) return FALSE; - dst_fbo = _cogl_offscreen_new_to_texture_full + dst_offscreen = _cogl_offscreen_new_to_texture_full (data->dst_tex, COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL, 0 /* level */); + if (dst_offscreen == NULL) + return FALSE; - if (dst_fbo == COGL_INVALID_HANDLE) - ret = FALSE; - else - { - if (!cogl_framebuffer_allocate (dst_fbo, NULL)) - ret = FALSE; - else - { - src_fbo = _cogl_offscreen_new_to_texture_full - (data->src_tex, - COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL, - 0 /* level */); - - if (src_fbo == COGL_INVALID_HANDLE) - ret = FALSE; - else - { - if (!cogl_framebuffer_allocate (src_fbo, NULL)) - ret = FALSE; - else - _cogl_push_framebuffers (dst_fbo, src_fbo); + dst_fb = COGL_FRAMEBUFFER (dst_offscreen); + if (!cogl_framebuffer_allocate (dst_fb, NULL)) + goto ERROR; - cogl_handle_unref (src_fbo); - } - } + src_offscreen= _cogl_offscreen_new_to_texture_full + (data->src_tex, + COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL, + 0 /* level */); - cogl_handle_unref (dst_fbo); - } + if (src_offscreen == NULL) + goto ERROR; + + src_fb = COGL_FRAMEBUFFER (src_offscreen); + if (!cogl_framebuffer_allocate (src_fb, NULL)) + goto ERROR; + + _cogl_push_framebuffers (dst_fb, src_fb); + + return TRUE; + +ERROR: + + if (dst_offscreen) + cogl_object_unref (dst_offscreen); + if (src_offscreen) + cogl_object_unref (src_offscreen); - return ret; + return FALSE; } static void @@ -216,7 +215,8 @@ _cogl_blit_framebuffer_end (CoglBlitData *data) static gboolean _cogl_blit_copy_tex_sub_image_begin (CoglBlitData *data) { - CoglHandle fbo; + CoglOffscreen *offscreen; + CoglFramebuffer *fb; _COGL_GET_CONTEXT (ctx, FALSE); @@ -224,20 +224,21 @@ _cogl_blit_copy_tex_sub_image_begin (CoglBlitData *data) if (!cogl_is_texture_2d (data->dst_tex)) return FALSE; - fbo = _cogl_offscreen_new_to_texture_full + offscreen = _cogl_offscreen_new_to_texture_full (data->src_tex, COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL, 0 /* level */); - if (fbo == COGL_INVALID_HANDLE) + if (offscreen == NULL) return FALSE; - if (!cogl_framebuffer_allocate (fbo, NULL)) + fb = COGL_FRAMEBUFFER (offscreen); + if (!cogl_framebuffer_allocate (fb, NULL)) { - cogl_handle_unref (fbo); + cogl_object_unref (fb); return FALSE; } - cogl_push_framebuffer (fbo); - cogl_handle_unref (fbo); + cogl_push_framebuffer (fb); + cogl_object_unref (fb); return TRUE; } @@ -251,7 +252,7 @@ _cogl_blit_copy_tex_sub_image_blit (CoglBlitData *data, unsigned int width, unsigned int height) { - _cogl_texture_2d_copy_from_framebuffer (data->dst_tex, + _cogl_texture_2d_copy_from_framebuffer (COGL_TEXTURE_2D (data->dst_tex), dst_x, dst_y, src_x, src_y, width, height); @@ -334,8 +335,8 @@ _cogl_blit_modes[] = void _cogl_blit_begin (CoglBlitData *data, - CoglHandle dst_tex, - CoglHandle src_tex) + CoglTexture *dst_tex, + CoglTexture *src_tex) { int i; diff --git a/cogl/cogl-blit.h b/cogl/cogl-blit.h index 95e708ea..738b82f5 100644 --- a/cogl/cogl-blit.h +++ b/cogl/cogl-blit.h @@ -25,7 +25,8 @@ #define __COGL_BLIT_H #include <glib.h> -#include "cogl-handle.h" +#include "cogl-object-private.h" +#include "cogl-texture.h" /* This structures and functions are used when a series of blits needs to be performed between two textures. In this case there are @@ -55,7 +56,7 @@ typedef struct struct _CoglBlitData { - CoglHandle src_tex, dst_tex; + CoglTexture *src_tex, *dst_tex; unsigned int src_width; unsigned int src_height; @@ -71,8 +72,8 @@ struct _CoglBlitData void _cogl_blit_begin (CoglBlitData *data, - CoglHandle dst_tex, - CoglHandle src_tex); + CoglTexture *dst_tex, + CoglTexture *src_tex); void _cogl_blit (CoglBlitData *data, diff --git a/cogl/cogl-buffer.c b/cogl/cogl-buffer.c index f5a0fc54..8dd4f6d8 100644 --- a/cogl/cogl-buffer.c +++ b/cogl/cogl-buffer.c @@ -41,7 +41,7 @@ #include "cogl-internal.h" #include "cogl-util.h" #include "cogl-context-private.h" -#include "cogl-handle.h" +#include "cogl-object-private.h" #include "cogl-pixel-buffer-private.h" /* @@ -71,7 +71,7 @@ #endif /* XXX: - * The CoglHandle macros don't support any form of inheritance, so for + * The CoglObject macros don't support any form of inheritance, so for * now we implement the CoglObject support for the CoglBuffer * abstract class manually. */ @@ -87,7 +87,7 @@ _cogl_buffer_register_buffer_type (const CoglObjectClass *klass) gboolean cogl_is_buffer (void *object) { - const CoglHandleObject *obj = object; + const CoglObject *obj = object; GSList *l; if (object == NULL) diff --git a/cogl/cogl-clip-state.c b/cogl/cogl-clip-state.c index 97f8ce68..0ab9c5f5 100644 --- a/cogl/cogl-clip-state.c +++ b/cogl/cogl-clip-state.c @@ -173,7 +173,7 @@ _cogl_clip_state_save_clip_stack (CoglClipState *clip_state) void _cogl_clip_state_restore_clip_stack (CoglClipState *clip_state) { - CoglHandle stack; + CoglClipStack *stack; _COGL_RETURN_IF_FAIL (clip_state->stacks != NULL); diff --git a/cogl/cogl-context-private.h b/cogl/cogl-context-private.h index 174944f5..9b18ffed 100644 --- a/cogl/cogl-context-private.h +++ b/cogl/cogl-context-private.h @@ -171,7 +171,7 @@ struct _CoglContext /* Framebuffers */ GSList *framebuffer_stack; - CoglHandle window_buffer; + CoglFramebuffer *window_buffer; unsigned long current_draw_buffer_state_flushed; unsigned long current_draw_buffer_changes; CoglFramebuffer *current_draw_buffer; @@ -182,9 +182,9 @@ struct _CoglContext /* Pre-generated VBOs containing indices to generate GL_TRIANGLES out of a vertex array of quads */ - CoglHandle quad_buffer_indices_byte; + CoglIndices *quad_buffer_indices_byte; unsigned int quad_buffer_indices_len; - CoglHandle quad_buffer_indices; + CoglIndices *quad_buffer_indices; CoglIndices *rectangle_byte_indices; CoglIndices *rectangle_short_indices; @@ -210,9 +210,6 @@ struct _CoglContext GLint max_texture_image_units; GLint max_activateable_texture_units; - /* Fragment processing programs */ - CoglHandle current_program; - CoglPipelineProgramType current_fragment_program_type; CoglPipelineProgramType current_vertex_program_type; GLuint current_gl_program; diff --git a/cogl/cogl-context.c b/cogl/cogl-context.c index 6a01fcc9..aa612212 100644 --- a/cogl/cogl-context.c +++ b/cogl/cogl-context.c @@ -332,8 +332,6 @@ cogl_context_new (CoglDisplay *display, context->max_texture_units = -1; context->max_activateable_texture_units = -1; - context->current_program = COGL_INVALID_HANDLE; - context->current_fragment_program_type = COGL_PIPELINE_PROGRAM_TYPE_FIXED; context->current_vertex_program_type = COGL_PIPELINE_PROGRAM_TYPE_FIXED; context->current_gl_program = 0; @@ -374,16 +372,16 @@ cogl_context_new (CoglDisplay *display, context->in_begin_gl_block = FALSE; - context->quad_buffer_indices_byte = COGL_INVALID_HANDLE; - context->quad_buffer_indices = COGL_INVALID_HANDLE; + context->quad_buffer_indices_byte = NULL; + context->quad_buffer_indices = NULL; context->quad_buffer_indices_len = 0; context->rectangle_byte_indices = NULL; context->rectangle_short_indices = NULL; context->rectangle_short_indices_len = 0; - context->texture_download_pipeline = COGL_INVALID_HANDLE; - context->blit_texture_pipeline = COGL_INVALID_HANDLE; + context->texture_download_pipeline = NULL; + context->blit_texture_pipeline = NULL; #if defined (HAVE_COGL_GL) || defined (HAVE_COGL_GLES) if (context->driver != COGL_DRIVER_GLES2) @@ -469,14 +467,14 @@ _cogl_context_free (CoglContext *context) cogl_object_unref (context->default_gl_texture_rect_tex); if (context->opaque_color_pipeline) - cogl_handle_unref (context->opaque_color_pipeline); + cogl_object_unref (context->opaque_color_pipeline); if (context->blended_color_pipeline) - cogl_handle_unref (context->blended_color_pipeline); + cogl_object_unref (context->blended_color_pipeline); if (context->texture_pipeline) - cogl_handle_unref (context->texture_pipeline); + cogl_object_unref (context->texture_pipeline); if (context->blit_texture_pipeline) - cogl_handle_unref (context->blit_texture_pipeline); + cogl_object_unref (context->blit_texture_pipeline); if (context->journal_flush_attributes_array) g_array_free (context->journal_flush_attributes_array, TRUE); @@ -487,9 +485,9 @@ _cogl_context_free (CoglContext *context) g_array_free (context->polygon_vertices, TRUE); if (context->quad_buffer_indices_byte) - cogl_handle_unref (context->quad_buffer_indices_byte); + cogl_object_unref (context->quad_buffer_indices_byte); if (context->quad_buffer_indices) - cogl_handle_unref (context->quad_buffer_indices); + cogl_object_unref (context->quad_buffer_indices); if (context->rectangle_byte_indices) cogl_object_unref (context->rectangle_byte_indices); @@ -497,14 +495,14 @@ _cogl_context_free (CoglContext *context) cogl_object_unref (context->rectangle_short_indices); if (context->default_pipeline) - cogl_handle_unref (context->default_pipeline); + cogl_object_unref (context->default_pipeline); if (context->dummy_layer_dependant) - cogl_handle_unref (context->dummy_layer_dependant); + cogl_object_unref (context->dummy_layer_dependant); if (context->default_layer_n) - cogl_handle_unref (context->default_layer_n); + cogl_object_unref (context->default_layer_n); if (context->default_layer_0) - cogl_handle_unref (context->default_layer_0); + cogl_object_unref (context->default_layer_0); if (context->current_clip_stack_valid) _cogl_clip_stack_unref (context->current_clip_stack); diff --git a/cogl/cogl-context.h b/cogl/cogl-context.h index e2120d73..ed5bcf1f 100644 --- a/cogl/cogl-context.h +++ b/cogl/cogl-context.h @@ -147,7 +147,7 @@ cogl_android_set_native_window (ANativeWindow *window); * * Gets whether the given object references an existing context object. * - * Return value: %TRUE if the handle references a #CoglContext, + * Return value: %TRUE if the @object references a #CoglContext, * %FALSE otherwise * * Since: 1.10 diff --git a/cogl/cogl-debug-options.h b/cogl/cogl-debug-options.h index c5d486d7..4b177aed 100644 --- a/cogl/cogl-debug-options.h +++ b/cogl/cogl-debug-options.h @@ -21,7 +21,7 @@ * */ -OPT (HANDLE, +OPT (OBJECT, N_("Cogl Tracing"), "ref-counts", N_("CoglObject references"), diff --git a/cogl/cogl-debug.c b/cogl/cogl-debug.c index d838caeb..7f0143d8 100644 --- a/cogl/cogl-debug.c +++ b/cogl/cogl-debug.c @@ -41,7 +41,7 @@ * used since they don't affect the behaviour of Cogl they * simply print out verbose information */ static const GDebugKey cogl_log_debug_keys[] = { - { "handle", COGL_DEBUG_HANDLE }, + { "object", COGL_DEBUG_OBJECT }, { "slicing", COGL_DEBUG_SLICING }, { "atlas", COGL_DEBUG_ATLAS }, { "blend-strings", COGL_DEBUG_BLEND_STRINGS }, diff --git a/cogl/cogl-debug.h b/cogl/cogl-debug.h index 83534c84..bf8fa581 100644 --- a/cogl/cogl-debug.h +++ b/cogl/cogl-debug.h @@ -38,7 +38,7 @@ typedef enum { COGL_DEBUG_DRAW, COGL_DEBUG_PANGO, COGL_DEBUG_RECTANGLES, - COGL_DEBUG_HANDLE, + COGL_DEBUG_OBJECT, COGL_DEBUG_BLEND_STRINGS, COGL_DEBUG_DISABLE_BATCHING, COGL_DEBUG_DISABLE_VBOS, diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c index bc6bad80..14916fe5 100644 --- a/cogl/cogl-framebuffer.c +++ b/cogl/cogl-framebuffer.c @@ -132,7 +132,6 @@ static void _cogl_offscreen_free (CoglOffscreen *offscreen); COGL_OBJECT_DEFINE_WITH_CODE (Offscreen, offscreen, _cogl_offscreen_class.virt_unref = _cogl_framebuffer_unref); -COGL_OBJECT_DEFINE_DEPRECATED_REF_COUNTING (offscreen); /* XXX: * The CoglObject macros don't support any form of inheritance, so for @@ -726,20 +725,20 @@ _cogl_offscreen_new_to_texture_full (CoglTexture *texture, int level_width; int level_height; int i; - CoglHandle ret; + CoglOffscreen *ret; - _COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE); + _COGL_GET_CONTEXT (ctx, NULL); if (!cogl_has_feature (ctx, COGL_FEATURE_ID_OFFSCREEN)) - return COGL_INVALID_HANDLE; + return NULL; /* Make texture is a valid texture object */ if (!cogl_is_texture (texture)) - return COGL_INVALID_HANDLE; + return NULL; /* The texture must not be sliced */ if (cogl_texture_is_sliced (texture)) - return COGL_INVALID_HANDLE; + return NULL; /* Calculate the size of the texture at this mipmap level to ensure that it's a valid level */ @@ -754,7 +753,7 @@ _cogl_offscreen_new_to_texture_full (CoglTexture *texture, { g_warning ("Invalid texture level passed to " "_cogl_offscreen_new_to_texture_full"); - return COGL_INVALID_HANDLE; + return NULL; } if (level_width > 1) @@ -811,7 +810,7 @@ _cogl_offscreen_free (CoglOffscreen *offscreen) GE (ctx, glDeleteFramebuffers (1, &offscreen->fbo_handle)); - if (offscreen->texture != COGL_INVALID_HANDLE) + if (offscreen->texture != NULL) cogl_object_unref (offscreen->texture); g_free (offscreen); @@ -1096,7 +1095,7 @@ _cogl_create_framebuffer_stack (void) CoglFramebufferStackEntry *entry; GSList *stack = NULL; - entry = create_stack_entry (COGL_INVALID_HANDLE, COGL_INVALID_HANDLE); + entry = create_stack_entry (NULL, NULL); return g_slist_prepend (stack, entry); } @@ -1199,21 +1198,6 @@ cogl_set_framebuffer (CoglFramebuffer *framebuffer) _cogl_set_framebuffers (framebuffer, framebuffer); } -/* XXX: deprecated API */ -void -cogl_set_draw_buffer (CoglBufferTarget target, CoglHandle handle) -{ - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - - if (target == COGL_WINDOW_BUFFER) - handle = ctx->window_buffer; - - /* This is deprecated public API. The public API doesn't currently - really expose the concept of separate draw and read buffers so - for the time being this actually just sets both buffers */ - cogl_set_framebuffer (handle); -} - CoglFramebuffer * cogl_get_draw_framebuffer (void) { diff --git a/cogl/cogl-shader-boilerplate.h b/cogl/cogl-glsl-shader-boilerplate.h index e5a86d87..e5a86d87 100644 --- a/cogl/cogl-shader-boilerplate.h +++ b/cogl/cogl-glsl-shader-boilerplate.h diff --git a/cogl/cogl-handle.h b/cogl/cogl-glsl-shader-private.h index f69e97e5..9d506506 100644 --- a/cogl/cogl-handle.h +++ b/cogl/cogl-glsl-shader-private.h @@ -3,7 +3,7 @@ * * An object oriented GL/GLES Abstraction/Utility Layer * - * Copyright (C) 2010 Intel Corporation. + * Copyright (C) 2012 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -18,18 +18,18 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see * <http://www.gnu.org/licenses/>. - * - * */ -/* This file is just kept for compatability while we eradicate - * CoglHandle - */ - -#ifndef __COGL_HANDLE_H -#define __COGL_HANDLE_H - -#include "cogl-object-private.h" +#ifndef _COGL_GLSL_SHADER_PRIVATE_H_ +#define _COGL_GLSL_SHADER_PRIVATE_H_ -#endif /* __COGL_HANDLE_H */ +void +_cogl_glsl_shader_set_source_with_boilerplate (CoglContext *ctx, + GLuint shader_gl_handle, + GLenum shader_gl_type, + int n_tex_coord_attribs, + GLsizei count_in, + const char **strings_in, + const GLint *lengths_in); +#endif /* _COGL_GLSL_SHADER_PRIVATE_H_ */ diff --git a/cogl/cogl-glsl-shader.c b/cogl/cogl-glsl-shader.c new file mode 100644 index 00000000..ae979423 --- /dev/null +++ b/cogl/cogl-glsl-shader.c @@ -0,0 +1,154 @@ +/* + * Cogl + * + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2012 Intel Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * <http://www.gnu.org/licenses/>. + * + * + * + * Authors: + * Robert Bragg <robert@linux.intel.com> + * Neil Roberts <neil@linux.intel.com> + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "cogl-context-private.h" +#include "cogl-glsl-shader-private.h" +#include "cogl-glsl-shader-boilerplate.h" +#include "cogl-internal.h" + +#include <string.h> + +#include <glib.h> + +void +_cogl_glsl_shader_set_source_with_boilerplate (CoglContext *ctx, + GLuint shader_gl_handle, + GLenum shader_gl_type, + int n_tex_coord_attribs, + GLsizei count_in, + const char **strings_in, + const GLint *lengths_in) +{ + const char *vertex_boilerplate; + const char *fragment_boilerplate; + + const char **strings = g_alloca (sizeof (char *) * (count_in + 3)); + GLint *lengths = g_alloca (sizeof (GLint) * (count_in + 3)); + int count = 0; + char *tex_coord_declarations = NULL; + + if (ctx->driver == COGL_DRIVER_GLES2) + { + vertex_boilerplate = _COGL_VERTEX_SHADER_BOILERPLATE_GLES2; + fragment_boilerplate = _COGL_FRAGMENT_SHADER_BOILERPLATE_GLES2; + } + else + { + vertex_boilerplate = _COGL_VERTEX_SHADER_BOILERPLATE_GL; + fragment_boilerplate = _COGL_FRAGMENT_SHADER_BOILERPLATE_GL; + } + + if (ctx->driver == COGL_DRIVER_GLES2 && + cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_3D)) + { + static const char texture_3d_extension[] = + "#extension GL_OES_texture_3D : enable\n"; + strings[count] = texture_3d_extension; + lengths[count++] = sizeof (texture_3d_extension) - 1; + } + + if (shader_gl_type == GL_VERTEX_SHADER) + { + strings[count] = vertex_boilerplate; + lengths[count++] = strlen (vertex_boilerplate); + } + else if (shader_gl_type == GL_FRAGMENT_SHADER) + { + strings[count] = fragment_boilerplate; + lengths[count++] = strlen (fragment_boilerplate); + } + + if (ctx->driver == COGL_DRIVER_GLES2 && + n_tex_coord_attribs) + { + GString *declarations = g_string_new (NULL); + + g_string_append_printf (declarations, + "varying vec4 _cogl_tex_coord[%d];\n", + n_tex_coord_attribs); + + if (shader_gl_type == GL_VERTEX_SHADER) + { + int i; + + g_string_append_printf (declarations, + "uniform mat4 cogl_texture_matrix[%d];\n", + n_tex_coord_attribs); + + for (i = 0; i < n_tex_coord_attribs; i++) + g_string_append_printf (declarations, + "attribute vec4 cogl_tex_coord%d_in;\n", + i); + } + + tex_coord_declarations = g_string_free (declarations, FALSE); + strings[count] = tex_coord_declarations; + lengths[count++] = -1; /* null terminated */ + } + + memcpy (strings + count, strings_in, sizeof (char *) * count_in); + if (lengths_in) + memcpy (lengths + count, lengths_in, sizeof (GLint) * count_in); + else + { + int i; + + for (i = 0; i < count_in; i++) + lengths[count + i] = -1; /* null terminated */ + } + count += count_in; + + if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_SHOW_SOURCE))) + { + GString *buf = g_string_new (NULL); + int i; + + g_string_append_printf (buf, + "%s shader:\n", + shader_gl_type == GL_VERTEX_SHADER ? + "vertex" : "fragment"); + for (i = 0; i < count; i++) + if (lengths[i] != -1) + g_string_append_len (buf, strings[i], lengths[i]); + else + g_string_append (buf, strings[i]); + + g_message ("%s", buf->str); + + g_string_free (buf, TRUE); + } + + GE( ctx, glShaderSource (shader_gl_handle, count, + (const char **) strings, lengths) ); + + g_free (tex_coord_declarations); +} diff --git a/cogl/cogl-index-buffer.h b/cogl/cogl-index-buffer.h index 2e64ab35..0c0f477b 100644 --- a/cogl/cogl-index-buffer.h +++ b/cogl/cogl-index-buffer.h @@ -70,7 +70,7 @@ cogl_index_buffer_new (CoglContext *context, * * Gets whether the given object references a #CoglIndexBuffer. * - * Returns: %TRUE if the handle references a #CoglIndexBuffer, + * Returns: %TRUE if the @object references a #CoglIndexBuffer, * %FALSE otherwise * * Since: 1.4 diff --git a/cogl/cogl-journal-private.h b/cogl/cogl-journal-private.h index 90363cd8..650f093c 100644 --- a/cogl/cogl-journal-private.h +++ b/cogl/cogl-journal-private.h @@ -25,7 +25,7 @@ #define __COGL_JOURNAL_PRIVATE_H #include "cogl-texture.h" -#include "cogl-handle.h" +#include "cogl-object-private.h" #include "cogl-clip-stack.h" #define COGL_JOURNAL_VBO_POOL_SIZE 8 diff --git a/cogl/cogl-journal.c b/cogl/cogl-journal.c index 8aeee59f..d68d921a 100644 --- a/cogl/cogl-journal.c +++ b/cogl/cogl-journal.c @@ -31,6 +31,7 @@ #include "cogl-journal-private.h" #include "cogl-texture-private.h" #include "cogl-pipeline-private.h" +#include "cogl-pipeline-state-private.h" #include "cogl-pipeline-opengl-private.h" #include "cogl-framebuffer-private.h" #include "cogl-profile.h" @@ -853,7 +854,6 @@ can_software_clip_entry (CoglJournalEntry *journal_entry, { CoglPipeline *pipeline = journal_entry->pipeline; CoglClipStack *clip_entry; - int layer_num; clip_bounds_out->x_1 = -G_MAXFLOAT; clip_bounds_out->y_1 = -G_MAXFLOAT; @@ -864,18 +864,11 @@ can_software_clip_entry (CoglJournalEntry *journal_entry, entries using the same pipeline as the previous entry */ if (prev_journal_entry == NULL || pipeline != prev_journal_entry->pipeline) { - /* If the pipeline has a user program then we can't reliably modify - the texture coordinates */ - if (cogl_pipeline_get_user_program (pipeline)) + /* If there is a custom texture transform; either due to custom shader + * snippets or a custom texture matrix then we can't reliably modify the + * texture coordinates. */ + if (_cogl_pipeline_maybe_has_custom_texture_transform (pipeline)) return FALSE; - - /* If any of the pipeline layers have a texture matrix then we can't - reliably modify the texture coordinates */ - for (layer_num = cogl_pipeline_get_n_layers (pipeline) - 1; - layer_num >= 0; - layer_num--) - if (_cogl_pipeline_layer_has_user_matrix (pipeline, layer_num)) - return FALSE; } /* Now we need to verify that each clip entry's matrix is just a @@ -1596,7 +1589,7 @@ _cogl_journal_log_quad (CoglJournal *journal, entry->clip_stack = _cogl_clip_stack_ref (clip_stack); if (G_UNLIKELY (final_pipeline != pipeline)) - cogl_handle_unref (final_pipeline); + cogl_object_unref (final_pipeline); cogl_framebuffer_get_modelview_matrix (framebuffer, &entry->model_view); diff --git a/cogl/cogl-object-private.h b/cogl/cogl-object-private.h index be1e709d..2dc9728a 100644 --- a/cogl/cogl-object-private.h +++ b/cogl/cogl-object-private.h @@ -32,10 +32,6 @@ #include "cogl-object.h" #include "cogl-debug.h" -/* For compatability until all components have been converted */ -typedef struct _CoglObjectClass CoglHandleClass; -typedef struct _CoglObject CoglHandleObject; - /* XXX: sadly we didn't fully consider when we copied the cairo API * for _set_user_data that the callback doesn't get a pointer to the * instance which is desired in most cases. This means you tend to end @@ -90,23 +86,23 @@ struct _CoglObject #ifdef COGL_OBJECT_DEBUG #define _COGL_OBJECT_DEBUG_NEW(type_name, obj) \ - COGL_NOTE (HANDLE, "COGL " G_STRINGIFY (type_name) " NEW %p %i", \ + COGL_NOTE (OBJECT, "COGL " G_STRINGIFY (type_name) " NEW %p %i", \ (obj), (obj)->ref_count) #define _COGL_OBJECT_DEBUG_REF(type_name, object) G_STMT_START { \ CoglObject *__obj = (CoglObject *)object; \ - COGL_NOTE (HANDLE, "COGL %s REF %p %i", \ + COGL_NOTE (OBJECT, "COGL %s REF %p %i", \ (__obj)->klass->name, \ (__obj), (__obj)->ref_count); } G_STMT_END #define _COGL_OBJECT_DEBUG_UNREF(type_name, object) G_STMT_START { \ CoglObject *__obj = (CoglObject *)object; \ - COGL_NOTE (HANDLE, "COGL %s UNREF %p %i", \ + COGL_NOTE (OBJECT, "COGL %s UNREF %p %i", \ (__obj)->klass->name, \ (__obj), (__obj)->ref_count - 1); } G_STMT_END #define COGL_OBJECT_DEBUG_FREE(obj) \ - COGL_NOTE (HANDLE, "COGL %s FREE %p", \ + COGL_NOTE (OBJECT, "COGL %s FREE %p", \ (obj)->klass->name, (obj)) #else /* !COGL_OBJECT_DEBUG */ @@ -118,12 +114,6 @@ struct _CoglObject #endif /* COGL_OBJECT_DEBUG */ -/* For temporary compatability */ -#define _COGL_HANDLE_DEBUG_NEW _COGL_OBJECT_DEBUG_NEW -#define _COGL_HANDLE_DEBUG_REF _COGL_OBJECT_DEBUG_REF -#define _COGL_HANDLE_DEBUG_UNREF _COGL_OBJECT_DEBUG_UNREF -#define COGL_HANDLE_DEBUG_FREE COGL_OBJECT_DEBUG_FREE - #define COGL_OBJECT_COMMON_DEFINE_WITH_CODE(TypeName, type_name, code) \ \ CoglObjectClass _cogl_##type_name##_class; \ @@ -214,70 +204,12 @@ _cogl_is_##type_name (void *object) \ return obj->klass == &_cogl_##type_name##_class; \ } -#define COGL_OBJECT_DEFINE_DEPRECATED_REF_COUNTING(type_name) \ - \ -void * G_GNUC_DEPRECATED \ -cogl_##type_name##_ref (void *object) \ -{ \ - if (!cogl_is_##type_name (object)) \ - return NULL; \ - \ - _COGL_OBJECT_DEBUG_REF (TypeName, object); \ - \ - cogl_handle_ref (object); \ - \ - return object; \ -} \ - \ -void G_GNUC_DEPRECATED \ -cogl_##type_name##_unref (void *object) \ -{ \ - if (!cogl_is_##type_name (object)) \ - { \ - g_warning (G_STRINGIFY (cogl_##type_name##_unref) \ - ": Ignoring unref of Cogl handle " \ - "due to type mismatch"); \ - return; \ - } \ - \ - _COGL_OBJECT_DEBUG_UNREF (TypeName, object); \ - \ - cogl_handle_unref (object); \ -} - #define COGL_OBJECT_DEFINE(TypeName, type_name) \ COGL_OBJECT_DEFINE_WITH_CODE (TypeName, type_name, (void) 0) #define COGL_OBJECT_INTERNAL_DEFINE(TypeName, type_name) \ COGL_OBJECT_INTERNAL_DEFINE_WITH_CODE (TypeName, type_name, (void) 0) -/* For temporary compatability */ -#define COGL_HANDLE_INTERNAL_DEFINE_WITH_CODE(TypeName, type_name, code) \ - \ -COGL_OBJECT_INTERNAL_DEFINE_WITH_CODE (TypeName, type_name, code) \ - \ -static Cogl##TypeName * \ -_cogl_##type_name##_handle_new (CoglHandle handle) \ -{ \ - return _cogl_##type_name##_object_new (handle); \ -} - -#define COGL_HANDLE_DEFINE_WITH_CODE(TypeName, type_name, code) \ - \ -COGL_OBJECT_DEFINE_WITH_CODE (TypeName, type_name, code) \ - \ -static Cogl##TypeName * \ -_cogl_##type_name##_handle_new (CoglHandle handle) \ -{ \ - return _cogl_##type_name##_object_new (handle); \ -} - -#define COGL_HANDLE_INTERNAL_DEFINE(TypeName, type_name) \ - COGL_HANDLE_INTERNAL_DEFINE_WITH_CODE (TypeName, type_name, (void) 0) - -#define COGL_HANDLE_DEFINE(TypeName, type_name) \ - COGL_HANDLE_DEFINE_WITH_CODE (TypeName, type_name, (void) 0) - void _cogl_object_set_user_data (CoglObject *object, CoglUserDataKey *key, diff --git a/cogl/cogl-object.c b/cogl/cogl-object.c index 9ae29f75..1ec2e8d3 100644 --- a/cogl/cogl-object.c +++ b/cogl/cogl-object.c @@ -45,12 +45,6 @@ cogl_object_ref (void *object) return object; } -CoglHandle -cogl_handle_ref (CoglHandle handle) -{ - return cogl_object_ref (handle); -} - void _cogl_object_default_unref (void *object) { @@ -104,27 +98,6 @@ cogl_object_unref (void *obj) unref_func (obj); } -void -cogl_handle_unref (CoglHandle handle) -{ - cogl_object_unref (handle); -} - -GType -cogl_handle_get_type (void) -{ - static GType our_type = 0; - - /* XXX: We are keeping the "CoglHandle" name for now incase it would - * break bindings to change to "CoglObject" */ - if (G_UNLIKELY (our_type == 0)) - our_type = g_boxed_type_register_static (g_intern_static_string ("CoglHandle"), - (GBoxedCopyFunc) cogl_object_ref, - (GBoxedFreeFunc) cogl_object_unref); - - return our_type; -} - /* XXX: Unlike for cogl_object_get_user_data this code will return * an empty entry if available and no entry for the given key can be * found. */ diff --git a/cogl/cogl-onscreen.c b/cogl/cogl-onscreen.c index 9a1d5836..142639ac 100644 --- a/cogl/cogl-onscreen.c +++ b/cogl/cogl-onscreen.c @@ -114,7 +114,7 @@ _cogl_onscreen_free (CoglOnscreen *onscreen) CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen); const CoglWinsysVtable *winsys = _cogl_framebuffer_get_winsys (framebuffer); - if (framebuffer->context->window_buffer == onscreen) + if (framebuffer->context->window_buffer == COGL_FRAMEBUFFER (onscreen)) framebuffer->context->window_buffer = NULL; winsys->onscreen_deinit (onscreen); diff --git a/cogl/cogl-pipeline-fragend-arbfp.c b/cogl/cogl-pipeline-fragend-arbfp.c index 2b580638..d4cf5801 100644 --- a/cogl/cogl-pipeline-fragend-arbfp.c +++ b/cogl/cogl-pipeline-fragend-arbfp.c @@ -39,14 +39,13 @@ #include "cogl-internal.h" #include "cogl-context-private.h" -#include "cogl-handle.h" +#include "cogl-object-private.h" #include "cogl-texture-private.h" #include "cogl-blend-string.h" #include "cogl-journal-private.h" #include "cogl-color-private.h" #include "cogl-profile.h" -#include "cogl-program-private.h" #include <glib.h> #include <glib/gprintf.h> @@ -72,17 +71,12 @@ typedef struct { int ref_count; - CoglHandle user_program; /* XXX: only valid during codegen */ GString *source; GLuint gl_program; UnitState *unit_state; int next_constant_id; - /* Age of the program the last time the uniforms were flushed. This - is used to detect when we need to flush all of the uniforms */ - unsigned int user_program_age; - /* We need to track the last pipeline that an ARBfp program was used * with so know if we need to update any program.local parameters. */ CoglPipeline *last_used_for_pipeline; @@ -164,7 +158,6 @@ _cogl_pipeline_fragend_arbfp_start (CoglPipeline *pipeline, CoglPipelineShaderState *shader_state; CoglPipeline *authority; CoglPipeline *template_pipeline = NULL; - CoglHandle user_program; _COGL_GET_CONTEXT (ctx, FALSE); @@ -182,21 +175,6 @@ _cogl_pipeline_fragend_arbfp_start (CoglPipeline *pipeline, if (_cogl_pipeline_has_fragment_snippets (pipeline)) return FALSE; - user_program = cogl_pipeline_get_user_program (pipeline); - if (user_program != COGL_INVALID_HANDLE) - { - /* If the program doesn't have a fragment shader then some other - vertend will handle the vertex shader state and we still need - to generate a fragment program */ - if (!_cogl_program_has_fragment_shader (user_program)) - user_program = COGL_INVALID_HANDLE; - /* If the user program does have a fragment shader then we can - only handle it if it's in ARBfp */ - else if (_cogl_program_get_language (user_program) != - COGL_SHADER_LANGUAGE_ARBFP) - return FALSE; - } - /* Now lookup our ARBfp backend private state */ shader_state = get_shader_state (pipeline); @@ -250,21 +228,17 @@ _cogl_pipeline_fragend_arbfp_start (CoglPipeline *pipeline, { shader_state = shader_state_new (n_layers); - shader_state->user_program = user_program; - if (user_program == COGL_INVALID_HANDLE) - { - /* We reuse a single grow-only GString for code-gen */ - g_string_set_size (ctx->codegen_source_buffer, 0); - shader_state->source = ctx->codegen_source_buffer; - g_string_append (shader_state->source, - "!!ARBfp1.0\n" - "TEMP output;\n" - "TEMP tmp0, tmp1, tmp2, tmp3, tmp4;\n" - "PARAM half = {.5, .5, .5, .5};\n" - "PARAM one = {1, 1, 1, 1};\n" - "PARAM two = {2, 2, 2, 2};\n" - "PARAM minus_one = {-1, -1, -1, -1};\n"); - } + /* We reuse a single grow-only GString for code-gen */ + g_string_set_size (ctx->codegen_source_buffer, 0); + shader_state->source = ctx->codegen_source_buffer; + g_string_append (shader_state->source, + "!!ARBfp1.0\n" + "TEMP output;\n" + "TEMP tmp0, tmp1, tmp2, tmp3, tmp4;\n" + "PARAM half = {.5, .5, .5, .5};\n" + "PARAM one = {1, 1, 1, 1};\n" + "PARAM two = {2, 2, 2, 2};\n" + "PARAM minus_one = {-1, -1, -1, -1};\n"); } set_shader_state (pipeline, shader_state); @@ -844,6 +818,7 @@ _cogl_pipeline_fragend_arbfp_end (CoglPipeline *pipeline, { CoglPipelineShaderState *shader_state = get_shader_state (pipeline); GLuint gl_program; + UpdateConstantsState state; _COGL_GET_CONTEXT (ctx, FALSE); @@ -886,47 +861,20 @@ _cogl_pipeline_fragend_arbfp_end (CoglPipeline *pipeline, shader_state->source = NULL; } - if (shader_state->user_program != COGL_INVALID_HANDLE) - { - /* An arbfp program should contain exactly one shader which we - can use directly */ - CoglProgram *program = shader_state->user_program; - CoglShader *shader = program->attached_shaders->data; - - gl_program = shader->gl_handle; - } - else - gl_program = shader_state->gl_program; + gl_program = shader_state->gl_program; GE (ctx, glBindProgram (GL_FRAGMENT_PROGRAM_ARB, gl_program)); _cogl_use_fragment_program (0, COGL_PIPELINE_PROGRAM_TYPE_ARBFP); - if (shader_state->user_program == COGL_INVALID_HANDLE) - { - UpdateConstantsState state; - state.unit = 0; - state.shader_state = shader_state; - /* If this arbfp program was last used with a different pipeline - * then we need to ensure we update all program.local params */ - state.update_all = - pipeline != shader_state->last_used_for_pipeline; - cogl_pipeline_foreach_layer (pipeline, - update_constants_cb, - &state); - } - else - { - CoglProgram *program = shader_state->user_program; - gboolean program_changed; - - /* If the shader has changed since it was last flushed then we - need to update all uniforms */ - program_changed = program->age != shader_state->user_program_age; - - _cogl_program_flush_uniforms (program, gl_program, program_changed); - - shader_state->user_program_age = program->age; - } + state.unit = 0; + state.shader_state = shader_state; + /* If this arbfp program was last used with a different pipeline + * then we need to ensure we update all program.local params */ + state.update_all = + pipeline != shader_state->last_used_for_pipeline; + cogl_pipeline_foreach_layer (pipeline, + update_constants_cb, + &state); /* We need to track what pipeline used this arbfp program last since * we will need to update program.local params when switching diff --git a/cogl/cogl-pipeline-fragend-fixed.c b/cogl/cogl-pipeline-fragend-fixed.c index c8e8e2c6..c11c1d2f 100644 --- a/cogl/cogl-pipeline-fragend-fixed.c +++ b/cogl/cogl-pipeline-fragend-fixed.c @@ -38,12 +38,11 @@ #include "cogl-internal.h" #include "cogl-context-private.h" -#include "cogl-handle.h" +#include "cogl-object-private.h" #include "cogl-texture-private.h" #include "cogl-blend-string.h" #include "cogl-profile.h" -#include "cogl-program-private.h" #include <glib.h> #include <glib/gprintf.h> @@ -95,8 +94,6 @@ _cogl_pipeline_fragend_fixed_start (CoglPipeline *pipeline, unsigned long pipelines_difference, int n_tex_coord_attribs) { - CoglHandle user_program; - _COGL_GET_CONTEXT (ctx, FALSE); if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_FIXED))) @@ -109,15 +106,6 @@ _cogl_pipeline_fragend_fixed_start (CoglPipeline *pipeline, if (_cogl_pipeline_has_fragment_snippets (pipeline)) return FALSE; - /* If there is a user program with a fragment shader then the - appropriate backend for that language should handle it. We can - still use the fixed fragment backend if the program only contains - a vertex shader */ - user_program = cogl_pipeline_get_user_program (pipeline); - if (user_program != COGL_INVALID_HANDLE && - _cogl_program_has_fragment_shader (user_program)) - return FALSE; - _cogl_use_fragment_program (0, COGL_PIPELINE_PROGRAM_TYPE_FIXED); return TRUE; } diff --git a/cogl/cogl-pipeline-fragend-glsl.c b/cogl/cogl-pipeline-fragend-glsl.c index 1f447221..055e0cae 100644 --- a/cogl/cogl-pipeline-fragend-glsl.c +++ b/cogl/cogl-pipeline-fragend-glsl.c @@ -35,7 +35,6 @@ #include "cogl-context-private.h" #include "cogl-pipeline-private.h" #include "cogl-pipeline-layer-private.h" -#include "cogl-shader-private.h" #include "cogl-blend-string.h" #include "cogl-snippet-private.h" @@ -43,11 +42,10 @@ #include "cogl-internal.h" #include "cogl-context-private.h" -#include "cogl-handle.h" -#include "cogl-shader-private.h" -#include "cogl-program-private.h" +#include "cogl-object-private.h" #include "cogl-pipeline-cache.h" #include "cogl-pipeline-fragend-glsl-private.h" +#include "cogl-glsl-shader-private.h" #include <glib.h> @@ -99,12 +97,6 @@ typedef struct again */ LayerDataList layers; - /* Age of the user program that was current when the shader was - generated. We need to keep track of this because if the user - program changes then we may need to redecide whether to generate - a shader at all */ - unsigned int user_program_age; - /* The number of tex coord attributes that the shader was generated for. If this changes on GLES2 then we need to regenerate the shader */ @@ -223,7 +215,6 @@ _cogl_pipeline_fragend_glsl_start (CoglPipeline *pipeline, CoglPipelineShaderState *shader_state; CoglPipeline *authority; CoglPipeline *template_pipeline = NULL; - CoglProgram *user_program; int i; _COGL_GET_CONTEXT (ctx, FALSE); @@ -231,15 +222,6 @@ _cogl_pipeline_fragend_glsl_start (CoglPipeline *pipeline, if (!cogl_has_feature (ctx, COGL_FEATURE_ID_GLSL)) return FALSE; - user_program = cogl_pipeline_get_user_program (pipeline); - - /* If the user fragment shader isn't GLSL then we should let - another backend handle it */ - if (user_program && - _cogl_program_has_fragment_shader (user_program) && - _cogl_program_get_language (user_program) != COGL_SHADER_LANGUAGE_GLSL) - return FALSE; - /* Now lookup our glsl backend private state */ shader_state = get_shader_state (pipeline); @@ -305,15 +287,11 @@ _cogl_pipeline_fragend_glsl_start (CoglPipeline *pipeline, if (shader_state->gl_shader) { /* If we already have a valid GLSL shader then we don't need to - generate a new one. However if there's a user program and it - has changed since the last link then we do need a new - shader. If the number of tex coord attribs changes on GLES2 - then we need to regenerate the shader with a different boiler - plate */ - if ((user_program == NULL || - shader_state->user_program_age == user_program->age) - && (ctx->driver != COGL_DRIVER_GLES2 || - shader_state->n_tex_coord_attribs == n_tex_coord_attribs)) + generate a new one. However if the number of tex coord + attribs changes on GLES2 then we need to regenerate the + shader with a different boiler plate */ + if ((ctx->driver != COGL_DRIVER_GLES2 || + shader_state->n_tex_coord_attribs == n_tex_coord_attribs)) return TRUE; /* We need to recreate the shader so destroy the existing one */ @@ -322,20 +300,11 @@ _cogl_pipeline_fragend_glsl_start (CoglPipeline *pipeline, } /* If we make it here then we have a glsl_shader_state struct - without a gl_shader either because this is the first time we've - encountered it or because the user program has changed */ - - if (user_program) - shader_state->user_program_age = user_program->age; + without a gl_shader because this is the first time we've + encountered it. */ shader_state->n_tex_coord_attribs = n_tex_coord_attribs; - /* If the user program contains a fragment shader then we don't need - to generate one */ - if (user_program && - _cogl_program_has_fragment_shader (user_program)) - return TRUE; - /* We reuse two grow-only GStrings for code-gen. One string contains the uniform and attribute declarations while the other contains the main function. We need two strings @@ -1089,11 +1058,12 @@ _cogl_pipeline_fragend_glsl_end (CoglPipeline *pipeline, lengths[1] = shader_state->source->len; source_strings[1] = shader_state->source->str; - _cogl_shader_set_source_with_boilerplate (shader, GL_FRAGMENT_SHADER, - shader_state - ->n_tex_coord_attribs, - 2, /* count */ - source_strings, lengths); + _cogl_glsl_shader_set_source_with_boilerplate (ctx, + shader, GL_FRAGMENT_SHADER, + shader_state + ->n_tex_coord_attribs, + 2, /* count */ + source_strings, lengths); GE( ctx, glCompileShader (shader) ); GE( ctx, glGetShaderiv (shader, GL_COMPILE_STATUS, &compile_status) ); diff --git a/cogl/cogl-pipeline-layer-state.h b/cogl/cogl-pipeline-layer-state.h index 90dbc6a9..58c0c1ee 100644 --- a/cogl/cogl-pipeline-layer-state.h +++ b/cogl/cogl-pipeline-layer-state.h @@ -413,7 +413,7 @@ cogl_pipeline_get_layer_mag_filter (CoglPipeline *pipeline, /** * cogl_pipeline_set_layer_point_sprite_coords_enabled: - * @pipeline: a #CoglHandle to a pipeline. + * @pipeline: A #CoglPipeline object * @layer_index: the layer number to change. * @enable: whether to enable point sprite coord generation. * @error: A return location for a GError, or NULL to ignore errors. @@ -441,7 +441,7 @@ cogl_pipeline_set_layer_point_sprite_coords_enabled (CoglPipeline *pipeline, /** * cogl_pipeline_get_layer_point_sprite_coords_enabled: - * @pipeline: a #CoglHandle to a pipeline. + * @pipeline: A #CoglPipeline object * @layer_index: the layer number to check. * * Gets whether point sprite coordinate generation is enabled for this diff --git a/cogl/cogl-pipeline-opengl-private.h b/cogl/cogl-pipeline-opengl-private.h index be7b6d0a..882d4fb7 100644 --- a/cogl/cogl-pipeline-opengl-private.h +++ b/cogl/cogl-pipeline-opengl-private.h @@ -142,9 +142,6 @@ void _cogl_delete_gl_texture (GLuint gl_texture); void -_cogl_gl_use_program_wrapper (CoglHandle program); - -void _cogl_pipeline_flush_gl_state (CoglPipeline *pipeline, gboolean skip_gl_state, int n_tex_coord_attribs); diff --git a/cogl/cogl-pipeline-opengl.c b/cogl/cogl-pipeline-opengl.c index fc331d0f..d7e74342 100644 --- a/cogl/cogl-pipeline-opengl.c +++ b/cogl/cogl-pipeline-opengl.c @@ -872,9 +872,9 @@ flush_layers_common_gl_state_cb (CoglPipelineLayer *layer, void *user_data) } #endif - cogl_handle_ref (layer); - if (unit->layer != COGL_INVALID_HANDLE) - cogl_handle_unref (unit->layer); + cogl_object_ref (layer); + if (unit->layer != NULL) + cogl_object_unref (unit->layer); unit->layer = layer; unit->layer_changes_since_flush = 0; diff --git a/cogl/cogl-pipeline-private.h b/cogl/cogl-pipeline-private.h index b88e4017..b22d1962 100644 --- a/cogl/cogl-pipeline-private.h +++ b/cogl/cogl-pipeline-private.h @@ -175,7 +175,6 @@ typedef enum COGL_PIPELINE_STATE_ALPHA_FUNC_INDEX, COGL_PIPELINE_STATE_ALPHA_FUNC_REFERENCE_INDEX, COGL_PIPELINE_STATE_BLEND_INDEX, - COGL_PIPELINE_STATE_USER_SHADER_INDEX, COGL_PIPELINE_STATE_DEPTH_INDEX, COGL_PIPELINE_STATE_FOG_INDEX, COGL_PIPELINE_STATE_POINT_SIZE_INDEX, @@ -220,8 +219,6 @@ typedef enum _CoglPipelineState 1L<<COGL_PIPELINE_STATE_ALPHA_FUNC_REFERENCE_INDEX, COGL_PIPELINE_STATE_BLEND = 1L<<COGL_PIPELINE_STATE_BLEND_INDEX, - COGL_PIPELINE_STATE_USER_SHADER = - 1L<<COGL_PIPELINE_STATE_USER_SHADER_INDEX, COGL_PIPELINE_STATE_DEPTH = 1L<<COGL_PIPELINE_STATE_DEPTH_INDEX, COGL_PIPELINE_STATE_FOG = @@ -261,7 +258,6 @@ typedef enum _CoglPipelineState COGL_PIPELINE_STATE_LAYERS | \ COGL_PIPELINE_STATE_LIGHTING | \ COGL_PIPELINE_STATE_BLEND | \ - COGL_PIPELINE_STATE_USER_SHADER | \ COGL_PIPELINE_STATE_VERTEX_SNIPPETS | \ COGL_PIPELINE_STATE_FRAGMENT_SNIPPETS) @@ -270,7 +266,6 @@ typedef enum _CoglPipelineState COGL_PIPELINE_STATE_ALPHA_FUNC | \ COGL_PIPELINE_STATE_ALPHA_FUNC_REFERENCE | \ COGL_PIPELINE_STATE_BLEND | \ - COGL_PIPELINE_STATE_USER_SHADER | \ COGL_PIPELINE_STATE_DEPTH | \ COGL_PIPELINE_STATE_FOG | \ COGL_PIPELINE_STATE_POINT_SIZE | \ @@ -294,7 +289,6 @@ typedef enum _CoglPipelineState #define COGL_PIPELINE_STATE_AFFECTS_VERTEX_CODEGEN \ (COGL_PIPELINE_STATE_LAYERS | \ - COGL_PIPELINE_STATE_USER_SHADER | \ COGL_PIPELINE_STATE_VERTEX_SNIPPETS) typedef enum @@ -386,7 +380,6 @@ typedef struct CoglPipelineLightingState lighting_state; CoglPipelineAlphaFuncState alpha_state; CoglPipelineBlendState blend_state; - CoglHandle user_program; CoglDepthState depth_state; CoglPipelineFogState fog_state; float point_size; diff --git a/cogl/cogl-pipeline-progend-glsl.c b/cogl/cogl-pipeline-progend-glsl.c index 6d7cf430..fac72c9e 100644 --- a/cogl/cogl-pipeline-progend-glsl.c +++ b/cogl/cogl-pipeline-progend-glsl.c @@ -41,8 +41,7 @@ #include "cogl-internal.h" #include "cogl-context-private.h" -#include "cogl-handle.h" -#include "cogl-program-private.h" +#include "cogl-object-private.h" #include "cogl-pipeline-fragend-glsl-private.h" #include "cogl-pipeline-vertend-glsl-private.h" #include "cogl-pipeline-cache.h" @@ -100,10 +99,6 @@ typedef struct { unsigned int ref_count; - /* Age that the user program had last time we generated a GL - program. If it's different then we need to relink the program */ - unsigned int user_program_age; - GLuint program; /* To allow writing shaders that are portable between GLES 2 and @@ -654,7 +649,6 @@ _cogl_pipeline_progend_glsl_end (CoglPipeline *pipeline, GLuint gl_program; gboolean program_changed = FALSE; UpdateUniformsState state; - CoglProgram *user_program; CoglPipeline *template_pipeline = NULL; _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -667,8 +661,6 @@ _cogl_pipeline_progend_glsl_end (CoglPipeline *pipeline, program_state = get_program_state (pipeline); - user_program = cogl_pipeline_get_user_program (pipeline); - if (program_state == NULL) { CoglPipeline *authority; @@ -722,16 +714,11 @@ _cogl_pipeline_progend_glsl_end (CoglPipeline *pipeline, } } - /* If the program has changed since the last link then we do - * need to relink - * - * Also if the number of texture coordinate attributes in use has + /* If the number of texture coordinate attributes in use has * changed, then delete the program so we can prepend a new * _cogl_tex_coord[] varying array declaration. */ - if ((program_state->program && user_program && - user_program->age != program_state->user_program_age) || - (ctx->driver == COGL_DRIVER_GLES2 && - n_tex_coord_attribs != program_state->n_tex_coord_attribs)) + if (ctx->driver == COGL_DRIVER_GLES2 && + n_tex_coord_attribs != program_state->n_tex_coord_attribs) { GE( ctx, glDeleteProgram (program_state->program) ); program_state->program = 0; @@ -740,28 +727,9 @@ _cogl_pipeline_progend_glsl_end (CoglPipeline *pipeline, if (program_state->program == 0) { GLuint backend_shader; - GSList *l; GE_RET( program_state->program, ctx, glCreateProgram () ); - /* Attach all of the shader from the user program */ - if (user_program) - { - for (l = user_program->attached_shaders; l; l = l->next) - { - CoglShader *shader = l->data; - - _cogl_shader_compile_real (shader, n_tex_coord_attribs); - - g_assert (shader->language == COGL_SHADER_LANGUAGE_GLSL); - - GE( ctx, glAttachShader (program_state->program, - shader->gl_handle) ); - } - - program_state->user_program_age = user_program->age; - } - /* Attach any shaders from the GLSL backends */ if (pipeline->fragend == COGL_PIPELINE_FRAGEND_GLSL && (backend_shader = _cogl_pipeline_fragend_glsl_get_shader (pipeline))) @@ -847,11 +815,6 @@ _cogl_pipeline_progend_glsl_end (CoglPipeline *pipeline, gl_program, program_changed); - if (user_program) - _cogl_program_flush_uniforms (user_program, - gl_program, - program_changed); - /* We need to track the last pipeline that the program was used with * so know if we need to update all of the uniforms */ program_state->last_used_for_pipeline = pipeline; diff --git a/cogl/cogl-pipeline-state-private.h b/cogl/cogl-pipeline-state-private.h index 2bc162dc..d70451c4 100644 --- a/cogl/cogl-pipeline-state-private.h +++ b/cogl/cogl-pipeline-state-private.h @@ -28,8 +28,8 @@ #ifndef __COGL_PIPELINE_STATE_PRIVATE_H #define __COGL_PIPELINE_STATE_PRIVATE_H -CoglPipeline * -_cogl_pipeline_get_user_program (CoglPipeline *pipeline); +gboolean +_cogl_pipeline_maybe_has_custom_texture_transform (CoglPipeline *pipeline); gboolean _cogl_pipeline_has_vertex_snippets (CoglPipeline *pipeline); diff --git a/cogl/cogl-pipeline-state.c b/cogl/cogl-pipeline-state.c index 4b18d239..2fc8cb6d 100644 --- a/cogl/cogl-pipeline-state.c +++ b/cogl/cogl-pipeline-state.c @@ -43,19 +43,6 @@ #define GL_FUNC_ADD 0x8006 #endif -CoglPipeline * -_cogl_pipeline_get_user_program (CoglPipeline *pipeline) -{ - CoglPipeline *authority; - - _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), NULL); - - authority = - _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_USER_SHADER); - - return authority->big_state->user_program; -} - gboolean _cogl_pipeline_color_equal (CoglPipeline *authority0, CoglPipeline *authority1) @@ -231,14 +218,6 @@ _cogl_pipeline_cull_face_state_equal (CoglPipeline *authority0, cull_face_state0->front_winding == cull_face_state1->front_winding); } -gboolean -_cogl_pipeline_user_shader_equal (CoglPipeline *authority0, - CoglPipeline *authority1) -{ - return (authority0->big_state->user_program == - authority1->big_state->user_program); -} - typedef struct { const CoglBoxedValue **dst_values; @@ -1080,84 +1059,6 @@ cogl_pipeline_set_blend_constant (CoglPipeline *pipeline, #endif } -CoglHandle -cogl_pipeline_get_user_program (CoglPipeline *pipeline) -{ - CoglPipeline *authority; - - _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), COGL_INVALID_HANDLE); - - authority = - _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_USER_SHADER); - - return authority->big_state->user_program; -} - -/* XXX: for now we don't mind if the program has vertex shaders - * attached but if we ever make a similar API public we should only - * allow attaching of programs containing fragment shaders. Eventually - * we will have a CoglPipeline abstraction to also cover vertex - * processing. - */ -void -cogl_pipeline_set_user_program (CoglPipeline *pipeline, - CoglHandle program) -{ - CoglPipelineState state = COGL_PIPELINE_STATE_USER_SHADER; - CoglPipeline *authority; - - _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline)); - - authority = _cogl_pipeline_get_authority (pipeline, state); - - if (authority->big_state->user_program == program) - return; - - /* - Flush journal primitives referencing the current state. - * - Make sure the pipeline has no dependants so it may be modified. - * - If the pipeline isn't currently an authority for the state being - * changed, then initialize that state from the current authority. - */ - _cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE); - - if (program != COGL_INVALID_HANDLE) - { - _cogl_pipeline_set_fragend (pipeline, COGL_PIPELINE_FRAGEND_DEFAULT); - _cogl_pipeline_set_vertend (pipeline, COGL_PIPELINE_VERTEND_DEFAULT); - } - - /* If we are the current authority see if we can revert to one of our - * ancestors being the authority */ - if (pipeline == authority && - _cogl_pipeline_get_parent (authority) != NULL) - { - CoglPipeline *parent = _cogl_pipeline_get_parent (authority); - CoglPipeline *old_authority = - _cogl_pipeline_get_authority (parent, state); - - if (old_authority->big_state->user_program == program) - pipeline->differences &= ~state; - } - else if (pipeline != authority) - { - /* If we weren't previously the authority on this state then we - * need to extended our differences mask and so it's possible - * that some of our ancestry will now become redundant, so we - * aim to reparent ourselves if that's true... */ - pipeline->differences |= state; - _cogl_pipeline_prune_redundant_ancestry (pipeline); - } - - if (program != COGL_INVALID_HANDLE) - cogl_handle_ref (program); - if (authority == pipeline && - pipeline->big_state->user_program != COGL_INVALID_HANDLE) - cogl_handle_unref (pipeline->big_state->user_program); - pipeline->big_state->user_program = program; - - _cogl_pipeline_update_blend_enable (pipeline, state); -} - gboolean cogl_pipeline_set_depth_state (CoglPipeline *pipeline, const CoglDepthState *depth_state, @@ -1704,6 +1605,58 @@ _cogl_pipeline_has_fragment_snippets (CoglPipeline *pipeline) return found_fragment_snippet; } +static gboolean +check_maybe_has_custom_texture_transform (CoglPipelineLayer *layer, + void *user_data) +{ + gboolean *maybe_has_custom_texture_transform = user_data; + unsigned long matrix_state = COGL_PIPELINE_LAYER_STATE_USER_MATRIX; + unsigned long frag_state = COGL_PIPELINE_LAYER_STATE_FRAGMENT_SNIPPETS; + unsigned long vert_state = COGL_PIPELINE_LAYER_STATE_VERTEX_SNIPPETS; + CoglPipelineLayer *matrix_authority; + CoglPipelineLayer *frag_authority; + CoglPipelineLayer *vert_authority; + + matrix_authority = _cogl_pipeline_layer_get_authority (layer, matrix_state); + if (!_cogl_pipeline_layer_get_parent (matrix_authority)) + { + *maybe_has_custom_texture_transform = TRUE; + return FALSE; + } + + frag_authority = _cogl_pipeline_layer_get_authority (layer, frag_state); + if (!COGL_LIST_EMPTY (&frag_authority->big_state->fragment_snippets)) + { + *maybe_has_custom_texture_transform = TRUE; + return FALSE; + } + + vert_authority = _cogl_pipeline_layer_get_authority (layer, vert_state); + if (!COGL_LIST_EMPTY (&vert_authority->big_state->vertex_snippets)) + { + *maybe_has_custom_texture_transform = TRUE; + return FALSE; + } + + return TRUE; +} + +gboolean +_cogl_pipeline_maybe_has_custom_texture_transform (CoglPipeline *pipeline) +{ + gboolean maybe_has_custom_texture_transform = FALSE; + + if (_cogl_pipeline_has_non_layer_fragment_snippets (pipeline)) + return TRUE; + + _cogl_pipeline_foreach_layer_internal ( + pipeline, + check_maybe_has_custom_texture_transform, + &maybe_has_custom_texture_transform); + + return maybe_has_custom_texture_transform; +} + void _cogl_pipeline_hash_color_state (CoglPipeline *authority, CoglPipelineHashState *state) @@ -1804,15 +1757,6 @@ _cogl_pipeline_hash_blend_state (CoglPipeline *authority, } void -_cogl_pipeline_hash_user_shader_state (CoglPipeline *authority, - CoglPipelineHashState *state) -{ - CoglHandle user_program = authority->big_state->user_program; - state->hash = _cogl_util_one_at_a_time_hash (state->hash, &user_program, - sizeof (user_program)); -} - -void _cogl_pipeline_hash_depth_state (CoglPipeline *authority, CoglPipelineHashState *state) { diff --git a/cogl/cogl-pipeline-state.h b/cogl/cogl-pipeline-state.h index 86866294..d10dd21a 100644 --- a/cogl/cogl-pipeline-state.h +++ b/cogl/cogl-pipeline-state.h @@ -550,72 +550,6 @@ cogl_pipeline_set_color_mask (CoglPipeline *pipeline, CoglColorMask color_mask); /** - * cogl_pipeline_get_user_program: - * @pipeline: a #CoglPipeline object. - * - * Queries what user program has been associated with the given - * @pipeline using cogl_pipeline_set_user_program(). - * - * Return value: The current user program or %COGL_INVALID_HANDLE. - * - * Since: 2.0 - * Stability: Unstable - */ -CoglHandle -cogl_pipeline_get_user_program (CoglPipeline *pipeline); - -/** - * cogl_pipeline_set_user_program: - * @pipeline: a #CoglPipeline object. - * @program: A #CoglHandle to a linked CoglProgram - * - * Associates a linked CoglProgram with the given pipeline so that the - * program can take full control of vertex and/or fragment processing. - * - * This is an example of how it can be used to associate an ARBfp - * program with a #CoglPipeline: - * |[ - * CoglHandle shader; - * CoglHandle program; - * CoglPipeline *pipeline; - * - * shader = cogl_create_shader (COGL_SHADER_TYPE_FRAGMENT); - * cogl_shader_source (shader, - * "!!ARBfp1.0\n" - * "MOV result.color,fragment.color;\n" - * "END\n"); - * cogl_shader_compile (shader); - * - * program = cogl_create_program (); - * cogl_program_attach_shader (program, shader); - * cogl_program_link (program); - * - * pipeline = cogl_pipeline_new (); - * cogl_pipeline_set_user_program (pipeline, program); - * - * cogl_set_source_color4ub (0xff, 0x00, 0x00, 0xff); - * cogl_rectangle (0, 0, 100, 100); - * ]| - * - * It is possibly worth keeping in mind that this API is not part of - * the long term design for how we want to expose shaders to Cogl - * developers (We are planning on deprecating the cogl_program and - * cogl_shader APIs in favour of a "snippet" framework) but in the - * meantime we hope this will handle most practical GLSL and ARBfp - * requirements. - * - * Also remember you need to check for either the - * %COGL_FEATURE_SHADERS_GLSL or %COGL_FEATURE_SHADERS_ARBFP before - * using the cogl_program or cogl_shader API. - * - * Since: 2.0 - * Stability: Unstable - */ -void -cogl_pipeline_set_user_program (CoglPipeline *pipeline, - CoglHandle program); - -/** * cogl_pipeline_set_depth_state: * @pipeline: A #CoglPipeline object * @state: A #CoglDepthState struct diff --git a/cogl/cogl-pipeline-vertend-fixed.c b/cogl/cogl-pipeline-vertend-fixed.c index 2df593bf..c3f06e23 100644 --- a/cogl/cogl-pipeline-vertend-fixed.c +++ b/cogl/cogl-pipeline-vertend-fixed.c @@ -38,8 +38,7 @@ #include "cogl-internal.h" #include "cogl-context-private.h" -#include "cogl-handle.h" -#include "cogl-program-private.h" +#include "cogl-object-private.h" const CoglPipelineVertend _cogl_pipeline_fixed_vertend; @@ -49,8 +48,6 @@ _cogl_pipeline_vertend_fixed_start (CoglPipeline *pipeline, unsigned long pipelines_difference, int n_tex_coord_attribs) { - CoglProgram *user_program; - _COGL_GET_CONTEXT (ctx, FALSE); if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_FIXED))) @@ -63,15 +60,6 @@ _cogl_pipeline_vertend_fixed_start (CoglPipeline *pipeline, if (_cogl_pipeline_has_vertex_snippets (pipeline)) return FALSE; - /* If there is a user program with a vertex shader then the - appropriate backend for that language should handle it. We can - still use the fixed vertex backend if the program only contains - a fragment shader */ - user_program = cogl_pipeline_get_user_program (pipeline); - if (user_program != COGL_INVALID_HANDLE && - _cogl_program_has_vertex_shader (user_program)) - return FALSE; - _cogl_use_vertex_program (0, COGL_PIPELINE_PROGRAM_TYPE_FIXED); return TRUE; diff --git a/cogl/cogl-pipeline-vertend-glsl.c b/cogl/cogl-pipeline-vertend-glsl.c index 6ecec90a..1ceac164 100644 --- a/cogl/cogl-pipeline-vertend-glsl.c +++ b/cogl/cogl-pipeline-vertend-glsl.c @@ -39,10 +39,10 @@ #include "cogl-internal.h" #include "cogl-context-private.h" -#include "cogl-handle.h" -#include "cogl-program-private.h" +#include "cogl-object-private.h" #include "cogl-pipeline-vertend-glsl-private.h" #include "cogl-pipeline-state-private.h" +#include "cogl-glsl-shader-private.h" const CoglPipelineVertend _cogl_pipeline_glsl_vertend; @@ -53,12 +53,6 @@ typedef struct GLuint gl_shader; GString *header, *source; - /* Age of the user program that was current when the shader was - generated. We need to keep track of this because if the user - program changes then we may need to redecide whether to generate - a shader at all */ - unsigned int user_program_age; - /* The number of tex coord attributes that the shader was generated for. If this changes on GLES2 then we need to regenerate the shader */ @@ -157,22 +151,12 @@ _cogl_pipeline_vertend_glsl_start (CoglPipeline *pipeline, { CoglPipelineShaderState *shader_state; CoglPipeline *template_pipeline = NULL; - CoglProgram *user_program; _COGL_GET_CONTEXT (ctx, FALSE); if (!cogl_has_feature (ctx, COGL_FEATURE_ID_GLSL)) return FALSE; - user_program = cogl_pipeline_get_user_program (pipeline); - - /* If the user program has a vertex shader that isn't GLSL then the - appropriate vertend for that language should handle it */ - if (user_program && - _cogl_program_has_vertex_shader (user_program) && - _cogl_program_get_language (user_program) != COGL_SHADER_LANGUAGE_GLSL) - return FALSE; - /* Now lookup our glsl backend private state (allocating if * necessary) */ shader_state = get_shader_state (pipeline); @@ -229,15 +213,11 @@ _cogl_pipeline_vertend_glsl_start (CoglPipeline *pipeline, if (shader_state->gl_shader) { /* If we already have a valid GLSL shader then we don't need to - generate a new one. However if there's a user program and it - has changed since the last link then we do need a new - shader. If the number of tex coord attribs changes on GLES2 - then we need to regenerate the shader with a different boiler - plate */ - if ((user_program == NULL || - shader_state->user_program_age == user_program->age) - && (ctx->driver != COGL_DRIVER_GLES2 || - shader_state->n_tex_coord_attribs == n_tex_coord_attribs)) + generate a new one. However if the number of tex coord + attribs changes on GLES2 then we need to regenerate the + shader with a different boiler plate */ + if (ctx->driver != COGL_DRIVER_GLES2 || + shader_state->n_tex_coord_attribs == n_tex_coord_attribs) return TRUE; /* We need to recreate the shader so destroy the existing one */ @@ -246,20 +226,10 @@ _cogl_pipeline_vertend_glsl_start (CoglPipeline *pipeline, } /* If we make it here then we have a shader_state struct without a gl_shader - either because this is the first time we've encountered it or - because the user program has changed */ - - if (user_program) - shader_state->user_program_age = user_program->age; + because this is the first time we've encountered it */ shader_state->n_tex_coord_attribs = n_tex_coord_attribs; - /* If the user program contains a vertex shader then we don't need - to generate one */ - if (user_program && - _cogl_program_has_vertex_shader (user_program)) - return TRUE; - /* We reuse two grow-only GStrings for code-gen. One string contains the uniform and attribute declarations while the other contains the main function. We need two strings @@ -472,11 +442,12 @@ _cogl_pipeline_vertend_glsl_end (CoglPipeline *pipeline, lengths[1] = shader_state->source->len; source_strings[1] = shader_state->source->str; - _cogl_shader_set_source_with_boilerplate (shader, GL_VERTEX_SHADER, - shader_state - ->n_tex_coord_attribs, - 2, /* count */ - source_strings, lengths); + _cogl_glsl_shader_set_source_with_boilerplate (ctx, + shader, GL_VERTEX_SHADER, + shader_state + ->n_tex_coord_attribs, + 2, /* count */ + source_strings, lengths); GE( ctx, glCompileShader (shader) ); GE( ctx, glGetShaderiv (shader, GL_COMPILE_STATUS, &compile_status) ); diff --git a/cogl/cogl-pipeline.c b/cogl/cogl-pipeline.c index 0b37695c..b0f08007 100644 --- a/cogl/cogl-pipeline.c +++ b/cogl/cogl-pipeline.c @@ -207,8 +207,6 @@ _cogl_pipeline_init_default_pipeline (void) blend_state->blend_src_factor_rgb = GL_ONE; blend_state->blend_dst_factor_rgb = GL_ONE_MINUS_SRC_ALPHA; - big_state->user_program = COGL_INVALID_HANDLE; - cogl_depth_state_init (&big_state->depth_state); big_state->point_size = 1.0f; @@ -453,10 +451,6 @@ _cogl_pipeline_free (CoglPipeline *pipeline) _cogl_pipeline_unparent (COGL_NODE (pipeline)); - if (pipeline->differences & COGL_PIPELINE_STATE_USER_SHADER && - pipeline->big_state->user_program) - cogl_handle_unref (pipeline->big_state->user_program); - if (pipeline->differences & COGL_PIPELINE_STATE_UNIFORMS) { CoglPipelineUniformsState *uniforms_state @@ -744,17 +738,6 @@ _cogl_pipeline_needs_blending_enabled (CoglPipeline *pipeline, return TRUE; } - if (changes & COGL_PIPELINE_STATE_USER_SHADER) - { - /* We can't make any assumptions about the alpha channel if the user - * is using an unknown fragment shader. - * - * TODO: check that it isn't just a vertex shader! - */ - if (_cogl_pipeline_get_user_program (pipeline) != COGL_INVALID_HANDLE) - return TRUE; - } - if (changes & COGL_PIPELINE_STATE_FRAGMENT_SNIPPETS) { if (!_cogl_pipeline_has_non_layer_fragment_snippets (pipeline)) @@ -919,15 +902,6 @@ _cogl_pipeline_copy_differences (CoglPipeline *dest, sizeof (CoglPipelineBlendState)); } - if (differences & COGL_PIPELINE_STATE_USER_SHADER) - { - if (src->big_state->user_program) - big_state->user_program = - cogl_handle_ref (src->big_state->user_program); - else - big_state->user_program = COGL_INVALID_HANDLE; - } - if (differences & COGL_PIPELINE_STATE_DEPTH) { memcpy (&big_state->depth_state, @@ -1027,7 +1001,6 @@ _cogl_pipeline_init_multi_property_sparse_state (CoglPipeline *pipeline, case COGL_PIPELINE_STATE_ALPHA_FUNC: case COGL_PIPELINE_STATE_ALPHA_FUNC_REFERENCE: case COGL_PIPELINE_STATE_POINT_SIZE: - case COGL_PIPELINE_STATE_USER_SHADER: case COGL_PIPELINE_STATE_REAL_BLEND_ENABLE: g_return_if_reached (); @@ -1906,7 +1879,7 @@ fallback_layer_cb (CoglPipelineLayer *layer, void *user_data) typedef struct { CoglPipeline *pipeline; - CoglHandle texture; + CoglTexture *texture; } CoglPipelineOverrideLayerState; static gboolean @@ -2251,11 +2224,6 @@ _cogl_pipeline_equal (CoglPipeline *pipeline0, authorities1[bit])) goto done; break; - case COGL_PIPELINE_STATE_USER_SHADER_INDEX: - if (!_cogl_pipeline_user_shader_equal (authorities0[bit], - authorities1[bit])) - goto done; - break; case COGL_PIPELINE_STATE_UNIFORMS_INDEX: if (!_cogl_pipeline_uniforms_state_equal (authorities0[bit], authorities1[bit])) @@ -2522,12 +2490,6 @@ _cogl_pipeline_apply_legacy_state (CoglPipeline *pipeline) * the cogl_pipeline API instead. */ - /* A program explicitly set on the pipeline has higher precedence than - * one associated with the context using cogl_program_use() */ - if (ctx->current_program && - cogl_pipeline_get_user_program (pipeline) == COGL_INVALID_HANDLE) - cogl_pipeline_set_user_program (pipeline, ctx->current_program); - if (ctx->legacy_depth_test_enabled) { CoglDepthState depth_state; @@ -2683,8 +2645,6 @@ _cogl_pipeline_init_state_hash_functions (void) _cogl_pipeline_hash_alpha_func_reference_state; state_hash_functions[COGL_PIPELINE_STATE_BLEND_INDEX] = _cogl_pipeline_hash_blend_state; - state_hash_functions[COGL_PIPELINE_STATE_USER_SHADER_INDEX] = - _cogl_pipeline_hash_user_shader_state; state_hash_functions[COGL_PIPELINE_STATE_DEPTH_INDEX] = _cogl_pipeline_hash_depth_state; state_hash_functions[COGL_PIPELINE_STATE_FOG_INDEX] = @@ -2704,7 +2664,7 @@ _cogl_pipeline_init_state_hash_functions (void) { /* So we get a big error if we forget to update this code! */ - _COGL_STATIC_ASSERT (COGL_PIPELINE_STATE_SPARSE_COUNT == 16, + _COGL_STATIC_ASSERT (COGL_PIPELINE_STATE_SPARSE_COUNT == 15, "Make sure to install a hash function for " "newly added pipeline state and update assert " "in _cogl_pipeline_init_state_hash_functions"); @@ -2897,7 +2857,6 @@ CoglPipelineState _cogl_pipeline_get_state_for_fragment_codegen (CoglContext *context) { CoglPipelineState state = (COGL_PIPELINE_STATE_LAYERS | - COGL_PIPELINE_STATE_USER_SHADER | COGL_PIPELINE_STATE_FRAGMENT_SNIPPETS); if (context->driver == COGL_DRIVER_GLES2) diff --git a/cogl/cogl-pipeline.h b/cogl/cogl-pipeline.h index d990e244..20f54fa6 100644 --- a/cogl/cogl-pipeline.h +++ b/cogl/cogl-pipeline.h @@ -95,18 +95,18 @@ cogl_pipeline_copy (CoglPipeline *source); /** * cogl_is_pipeline: - * @handle: A CoglHandle + * @object: A #CoglObject * - * Gets whether the given handle references an existing pipeline object. + * Gets whether the given @object references an existing pipeline object. * - * Return value: %TRUE if the handle references a #CoglPipeline, + * Return value: %TRUE if the @object references a #CoglPipeline, * %FALSE otherwise * * Since: 2.0 * Stability: Unstable */ gboolean -cogl_is_pipeline (CoglHandle handle); +cogl_is_pipeline (void *object); /** * CoglPipelineLayerCallback: diff --git a/cogl/cogl-pixel-buffer-private.h b/cogl/cogl-pixel-buffer-private.h index 5db2a27d..974afa61 100644 --- a/cogl/cogl-pixel-buffer-private.h +++ b/cogl/cogl-pixel-buffer-private.h @@ -28,7 +28,7 @@ #ifndef __COGL_PIXEL_BUFFER_PRIVATE_H__ #define __COGL_PIXEL_BUFFER_PRIVATE_H__ -#include "cogl-handle.h" +#include "cogl-object-private.h" #include "cogl-buffer-private.h" #include <glib.h> diff --git a/cogl/cogl-pixel-buffer.h b/cogl/cogl-pixel-buffer.h index 49bd603a..7c22d16b 100644 --- a/cogl/cogl-pixel-buffer.h +++ b/cogl/cogl-pixel-buffer.h @@ -81,9 +81,9 @@ cogl_pixel_buffer_new (CoglContext *context, * cogl_is_pixel_buffer: * @object: a #CoglObject to test * - * Checks whether @handle is a pixel array. + * Checks whether @object is a pixel buffer. * - * Return value: %TRUE if the @handle is a pixel array, and %FALSE + * Return value: %TRUE if the @object is a pixel buffer, and %FALSE * otherwise * * Since: 1.2 @@ -95,7 +95,7 @@ cogl_is_pixel_buffer (void *object); #if 0 /* * cogl_pixel_buffer_set_region: - * @array: the #CoglHandle of a pixel array + * @buffer: A #CoglPixelBuffer object * @data: pixel data to upload to @array * @src_width: width in pixels of the region to update * @src_height: height in pixels of the region to update @@ -114,13 +114,13 @@ cogl_is_pixel_buffer (void *object); * Stability: Unstable */ gboolean -cogl_pixel_buffer_set_region (CoglHandle array, - guint8 *data, - unsigned int src_width, - unsigned int src_height, - unsigned int src_rowstride, - unsigned int dst_x, - unsigned int dst_y); +cogl_pixel_buffer_set_region (CoglPixelBuffer *buffer, + guint8 *data, + unsigned int src_width, + unsigned int src_height, + unsigned int src_rowstride, + unsigned int dst_x, + unsigned int dst_y); #endif G_END_DECLS diff --git a/cogl/cogl-primitive.h b/cogl/cogl-primitive.h index b99ae871..657507aa 100644 --- a/cogl/cogl-primitive.h +++ b/cogl/cogl-primitive.h @@ -827,7 +827,7 @@ cogl_primitive_copy (CoglPrimitive *primitive); * * Gets whether the given object references a #CoglPrimitive. * - * Returns: %TRUE if the handle references a #CoglPrimitive, + * Returns: %TRUE if the @object references a #CoglPrimitive, * %FALSE otherwise * * Since: 1.6 diff --git a/cogl/cogl-program-private.h b/cogl/cogl-program-private.h deleted file mode 100644 index 5c33f61c..00000000 --- a/cogl/cogl-program-private.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Cogl - * - * An object oriented GL/GLES Abstraction/Utility Layer - * - * Copyright (C) 2008,2009 Intel Corporation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see <http://www.gnu.org/licenses/>. - * - * - */ - -#ifndef __COGL_PROGRAM_H -#define __COGL_PROGRAM_H - -#include "cogl-handle.h" -#include "cogl-internal.h" -#include "cogl-shader-private.h" - -typedef struct _CoglProgram CoglProgram; - -struct _CoglProgram -{ - CoglHandleObject _parent; - - GSList *attached_shaders; - - GArray *custom_uniforms; - - /* An age counter that changes whenever the list of shaders is modified */ - unsigned int age; -}; - -typedef struct _CoglProgramUniform CoglProgramUniform; - -struct _CoglProgramUniform -{ - char *name; - CoglBoxedValue value; - /* The cached GL location for this uniform. This is only valid - between calls to _cogl_program_dirty_all_uniforms */ - GLint location; - /* Whether we have a location yet */ - unsigned int location_valid : 1; - /* Whether the uniform value has changed since the last time the - uniforms were flushed */ - unsigned int dirty : 1; -}; - -/* Internal function to flush the custom uniforms for the given use - program. This assumes the target GL program is already bound. The - gl_program still needs to be passed so that CoglProgram can query - the uniform locations. gl_program_changed should be set to TRUE if - we are flushing the uniforms against a different GL program from - the last time it was flushed. This will cause it to requery all of - the locations and assume that all uniforms are dirty */ -void -_cogl_program_flush_uniforms (CoglProgram *program, - GLuint gl_program, - gboolean gl_program_changed); - -CoglShaderLanguage -_cogl_program_get_language (CoglHandle handle); - -gboolean -_cogl_program_has_fragment_shader (CoglHandle handle); - -gboolean -_cogl_program_has_vertex_shader (CoglHandle handle); - -#endif /* __COGL_PROGRAM_H */ diff --git a/cogl/cogl-program.c b/cogl/cogl-program.c deleted file mode 100644 index 3d265ffd..00000000 --- a/cogl/cogl-program.c +++ /dev/null @@ -1,496 +0,0 @@ -/* - * Cogl - * - * An object oriented GL/GLES Abstraction/Utility Layer - * - * Copyright (C) 2008,2009,2010 Intel Corporation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see <http://www.gnu.org/licenses/>. - * - * - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - - -#include "cogl-util.h" -#include "cogl-internal.h" -#include "cogl-context-private.h" -#include "cogl-handle.h" - -#include "cogl-shader-private.h" -#include "cogl-program-private.h" - -#include <string.h> - -static void _cogl_program_free (CoglProgram *program); - -COGL_HANDLE_DEFINE (Program, program); -COGL_OBJECT_DEFINE_DEPRECATED_REF_COUNTING (program); - -/* A CoglProgram is effectively just a list of shaders that will be - used together and a set of values for the custom uniforms. No - actual GL program is created - instead this is the responsibility - of the GLSL material backend. The uniform values are collected in - an array and then flushed whenever the material backend requests - it. */ - -static void -_cogl_program_free (CoglProgram *program) -{ - int i; - - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - - /* Unref all of the attached shaders */ - g_slist_foreach (program->attached_shaders, (GFunc) cogl_handle_unref, NULL); - /* Destroy the list */ - g_slist_free (program->attached_shaders); - - for (i = 0; i < program->custom_uniforms->len; i++) - { - CoglProgramUniform *uniform = - &g_array_index (program->custom_uniforms, CoglProgramUniform, i); - - g_free (uniform->name); - - if (uniform->value.count > 1) - g_free (uniform->value.v.array); - } - - g_array_free (program->custom_uniforms, TRUE); - - g_slice_free (CoglProgram, program); -} - -CoglHandle -cogl_create_program (void) -{ - CoglProgram *program; - - program = g_slice_new0 (CoglProgram); - - program->custom_uniforms = - g_array_new (FALSE, FALSE, sizeof (CoglProgramUniform)); - program->age = 0; - - return _cogl_program_handle_new (program); -} - -void -cogl_program_attach_shader (CoglHandle program_handle, - CoglHandle shader_handle) -{ - CoglProgram *program; - CoglShader *shader; - - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - - if (!cogl_is_program (program_handle) || !cogl_is_shader (shader_handle)) - return; - - program = program_handle; - shader = shader_handle; - - /* Only one shader is allowed if the type is ARBfp */ - if (shader->language == COGL_SHADER_LANGUAGE_ARBFP) - _COGL_RETURN_IF_FAIL (program->attached_shaders == NULL); - else if (shader->language == COGL_SHADER_LANGUAGE_GLSL) - _COGL_RETURN_IF_FAIL (_cogl_program_get_language (program) == - COGL_SHADER_LANGUAGE_GLSL); - - program->attached_shaders - = g_slist_prepend (program->attached_shaders, - cogl_handle_ref (shader_handle)); - - program->age++; -} - -void -cogl_program_link (CoglHandle handle) -{ - /* There's no point in linking the program here because it will have - to be relinked with a different fixed functionality shader - whenever the settings change */ -} - -void -cogl_program_use (CoglHandle handle) -{ - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - - _COGL_RETURN_IF_FAIL (handle == COGL_INVALID_HANDLE || - cogl_is_program (handle)); - - if (ctx->current_program == 0 && handle != 0) - ctx->legacy_state_set++; - else if (handle == 0 && ctx->current_program != 0) - ctx->legacy_state_set--; - - if (handle != COGL_INVALID_HANDLE) - cogl_handle_ref (handle); - if (ctx->current_program != COGL_INVALID_HANDLE) - cogl_handle_unref (ctx->current_program); - ctx->current_program = handle; -} - -int -cogl_program_get_uniform_location (CoglHandle handle, - const char *uniform_name) -{ - int i; - CoglProgram *program; - CoglProgramUniform *uniform; - - if (!cogl_is_program (handle)) - return -1; - - program = handle; - - /* We can't just ask the GL program object for the uniform location - directly because it will change every time the program is linked - with a different shader. Instead we make our own mapping of - uniform numbers and cache the names */ - for (i = 0; i < program->custom_uniforms->len; i++) - { - uniform = &g_array_index (program->custom_uniforms, - CoglProgramUniform, i); - - if (!strcmp (uniform->name, uniform_name)) - return i; - } - - /* Create a new uniform with the given name */ - g_array_set_size (program->custom_uniforms, - program->custom_uniforms->len + 1); - uniform = &g_array_index (program->custom_uniforms, - CoglProgramUniform, - program->custom_uniforms->len - 1); - - uniform->name = g_strdup (uniform_name); - memset (&uniform->value, 0, sizeof (CoglBoxedValue)); - uniform->dirty = TRUE; - uniform->location_valid = FALSE; - - return program->custom_uniforms->len - 1; -} - -static CoglProgramUniform * -cogl_program_modify_uniform (CoglProgram *program, - int uniform_no) -{ - CoglProgramUniform *uniform; - - _COGL_RETURN_VAL_IF_FAIL (cogl_is_program (program), NULL); - _COGL_RETURN_VAL_IF_FAIL (uniform_no >= 0 && - uniform_no < program->custom_uniforms->len, - NULL); - - uniform = &g_array_index (program->custom_uniforms, - CoglProgramUniform, uniform_no); - uniform->dirty = TRUE; - - return uniform; -} - -void -cogl_program_uniform_1f (int uniform_no, - float value) -{ - CoglProgramUniform *uniform; - - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - - uniform = cogl_program_modify_uniform (ctx->current_program, uniform_no); - _cogl_boxed_value_set_1f (&uniform->value, value); -} - -void -cogl_program_set_uniform_1f (CoglHandle handle, - int uniform_location, - float value) -{ - CoglProgramUniform *uniform; - - uniform = cogl_program_modify_uniform (handle, uniform_location); - _cogl_boxed_value_set_1f (&uniform->value, value); -} - -void -cogl_program_uniform_1i (int uniform_no, - int value) -{ - CoglProgramUniform *uniform; - - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - - uniform = cogl_program_modify_uniform (ctx->current_program, uniform_no); - _cogl_boxed_value_set_1i (&uniform->value, value); -} - -void -cogl_program_set_uniform_1i (CoglHandle handle, - int uniform_location, - int value) -{ - CoglProgramUniform *uniform; - - uniform = cogl_program_modify_uniform (handle, uniform_location); - _cogl_boxed_value_set_1i (&uniform->value, value); -} - -void -cogl_program_uniform_float (int uniform_no, - int size, - int count, - const float *value) -{ - CoglProgramUniform *uniform; - - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - - uniform = cogl_program_modify_uniform (ctx->current_program, uniform_no); - _cogl_boxed_value_set_float (&uniform->value, size, count, value); -} - -void -cogl_program_set_uniform_float (CoglHandle handle, - int uniform_location, - int n_components, - int count, - const float *value) -{ - CoglProgramUniform *uniform; - - uniform = cogl_program_modify_uniform (handle, uniform_location); - _cogl_boxed_value_set_float (&uniform->value, n_components, count, value); -} - -void -cogl_program_uniform_int (int uniform_no, - int size, - int count, - const int *value) -{ - CoglProgramUniform *uniform; - - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - - uniform = cogl_program_modify_uniform (ctx->current_program, uniform_no); - _cogl_boxed_value_set_int (&uniform->value, size, count, value); -} - -void -cogl_program_set_uniform_int (CoglHandle handle, - int uniform_location, - int n_components, - int count, - const int *value) -{ - CoglProgramUniform *uniform; - - uniform = cogl_program_modify_uniform (handle, uniform_location); - _cogl_boxed_value_set_int (&uniform->value, n_components, count, value); -} - -void -cogl_program_set_uniform_matrix (CoglHandle handle, - int uniform_location, - int dimensions, - int count, - gboolean transpose, - const float *value) -{ - CoglProgramUniform *uniform; - - uniform = cogl_program_modify_uniform (handle, uniform_location); - _cogl_boxed_value_set_matrix (&uniform->value, - dimensions, - count, - transpose, - value); -} - -void -cogl_program_uniform_matrix (int uniform_no, - int size, - int count, - gboolean transpose, - const float *value) -{ - CoglProgramUniform *uniform; - - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - - uniform = cogl_program_modify_uniform (ctx->current_program, uniform_no); - _cogl_boxed_value_set_matrix (&uniform->value, size, count, transpose, value); -} - -/* ARBfp local parameters can be referenced like: - * - * "program.local[5]" - * ^14char offset (after whitespace is stripped) - */ -static int -get_local_param_index (const char *uniform_name) -{ - char *input = g_strdup (uniform_name); - int i; - char *p = input; - char *endptr; - int _index; - - for (i = 0; input[i] != '\0'; i++) - if (input[i] != '_' && input[i] != '\t') - *p++ = input[i]; - input[i] = '\0'; - - _COGL_RETURN_VAL_IF_FAIL (strncmp ("program.local[", input, 14) == 0, -1); - - _index = g_ascii_strtoull (input + 14, &endptr, 10); - _COGL_RETURN_VAL_IF_FAIL (endptr != input + 14, -1); - _COGL_RETURN_VAL_IF_FAIL (*endptr == ']', -1); - - _COGL_RETURN_VAL_IF_FAIL (_index >= 0, -1); - - g_free (input); - - return _index; -} - -#ifdef HAVE_COGL_GL - -static void -_cogl_program_flush_uniform_arbfp (GLint location, - CoglBoxedValue *value) -{ - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - - if (value->type != COGL_BOXED_NONE) - { - _COGL_RETURN_IF_FAIL (value->type == COGL_BOXED_FLOAT); - _COGL_RETURN_IF_FAIL (value->size == 4); - _COGL_RETURN_IF_FAIL (value->count == 1); - - GE( ctx, glProgramLocalParameter4fv (GL_FRAGMENT_PROGRAM_ARB, location, - value->v.float_value) ); - } -} - -#endif /* HAVE_COGL_GL */ - -void -_cogl_program_flush_uniforms (CoglProgram *program, - GLuint gl_program, - gboolean gl_program_changed) -{ - CoglProgramUniform *uniform; - int i; - - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - - _COGL_RETURN_IF_FAIL (ctx->driver != COGL_DRIVER_GLES1); - - for (i = 0; i < program->custom_uniforms->len; i++) - { - uniform = &g_array_index (program->custom_uniforms, - CoglProgramUniform, i); - - if (gl_program_changed || uniform->dirty) - { - if (gl_program_changed || !uniform->location_valid) - { - if (_cogl_program_get_language (program) == - COGL_SHADER_LANGUAGE_GLSL) - uniform->location = - ctx->glGetUniformLocation (gl_program, uniform->name); - else - uniform->location = - get_local_param_index (uniform->name); - - uniform->location_valid = TRUE; - } - - /* If the uniform isn't really in the program then there's - no need to actually set it */ - if (uniform->location != -1) - { - switch (_cogl_program_get_language (program)) - { - case COGL_SHADER_LANGUAGE_GLSL: - _cogl_boxed_value_set_uniform (ctx, - uniform->location, - &uniform->value); - break; - - case COGL_SHADER_LANGUAGE_ARBFP: -#ifdef HAVE_COGL_GL - _cogl_program_flush_uniform_arbfp (uniform->location, - &uniform->value); -#endif - break; - } - } - - uniform->dirty = FALSE; - } - } -} - -CoglShaderLanguage -_cogl_program_get_language (CoglHandle handle) -{ - CoglProgram *program = handle; - - /* Use the language of the first shader */ - - if (program->attached_shaders) - { - CoglShader *shader = program->attached_shaders->data; - return shader->language; - } - else - return COGL_SHADER_LANGUAGE_GLSL; -} - -static gboolean -_cogl_program_has_shader_type (CoglProgram *program, - CoglShaderType type) -{ - GSList *l; - - for (l = program->attached_shaders; l; l = l->next) - { - CoglShader *shader = l->data; - - if (shader->type == type) - return TRUE; - } - - return FALSE; -} - -gboolean -_cogl_program_has_fragment_shader (CoglHandle handle) -{ - return _cogl_program_has_shader_type (handle, COGL_SHADER_TYPE_FRAGMENT); -} - -gboolean -_cogl_program_has_vertex_shader (CoglHandle handle) -{ - return _cogl_program_has_shader_type (handle, COGL_SHADER_TYPE_VERTEX); -} diff --git a/cogl/cogl-shader-private.h b/cogl/cogl-shader-private.h deleted file mode 100644 index 06575e6d..00000000 --- a/cogl/cogl-shader-private.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Cogl - * - * An object oriented GL/GLES Abstraction/Utility Layer - * - * Copyright (C) 2008,2009 Intel Corporation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see <http://www.gnu.org/licenses/>. - * - * - */ - -#ifndef __COGL_SHADER_H -#define __COGL_SHADER_H - -#include "cogl-handle.h" -#include "cogl-shader.h" -#include "cogl-gl-header.h" - -typedef struct _CoglShader CoglShader; - -typedef enum -{ - COGL_SHADER_LANGUAGE_GLSL, - COGL_SHADER_LANGUAGE_ARBFP -} CoglShaderLanguage; - -struct _CoglShader -{ - CoglHandleObject _parent; - GLuint gl_handle; - int n_tex_coord_attribs; - CoglShaderType type; - CoglShaderLanguage language; - char *source; -}; - -void -_cogl_shader_compile_real (CoglHandle handle, int n_tex_coord_attribs); - -CoglShaderLanguage -_cogl_program_get_language (CoglHandle handle); - -void -_cogl_shader_set_source_with_boilerplate (GLuint shader_gl_handle, - GLenum shader_gl_type, - int n_tex_coord_attribs, - GLsizei count_in, - const char **strings_in, - const GLint *lengths_in); - -#endif /* __COGL_SHADER_H */ diff --git a/cogl/cogl-shader.c b/cogl/cogl-shader.c deleted file mode 100644 index c80020ed..00000000 --- a/cogl/cogl-shader.c +++ /dev/null @@ -1,505 +0,0 @@ -/* - * Cogl - * - * An object oriented GL/GLES Abstraction/Utility Layer - * - * Copyright (C) 2007,2008,2009,2010 Intel Corporation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see <http://www.gnu.org/licenses/>. - * - * - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "cogl-shader-private.h" -#include "cogl-shader-boilerplate.h" -#include "cogl-internal.h" -#include "cogl-context-private.h" -#include "cogl-handle.h" - -#include <glib.h> - -#include <string.h> - -static void _cogl_shader_free (CoglShader *shader); - -COGL_HANDLE_DEFINE (Shader, shader); -COGL_OBJECT_DEFINE_DEPRECATED_REF_COUNTING (shader); - -#ifndef GL_FRAGMENT_SHADER -#define GL_FRAGMENT_SHADER 0x8B30 -#endif -#ifndef GL_VERTEX_SHADER -#define GL_VERTEX_SHADER 0x8B31 -#endif - -static void -_cogl_shader_free (CoglShader *shader) -{ - /* Frees shader resources but its handle is not - released! Do that separately before this! */ - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - -#ifdef HAVE_COGL_GL - if (shader->language == COGL_SHADER_LANGUAGE_ARBFP) - { - if (shader->gl_handle) - GE (ctx, glDeletePrograms (1, &shader->gl_handle)); - } - else -#endif - if (shader->gl_handle) - GE (ctx, glDeleteShader (shader->gl_handle)); - - g_slice_free (CoglShader, shader); -} - -CoglHandle -cogl_create_shader (CoglShaderType type) -{ - CoglShader *shader; - - _COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE); - - switch (type) - { - case COGL_SHADER_TYPE_VERTEX: - case COGL_SHADER_TYPE_FRAGMENT: - break; - default: - g_warning ("Unexpected shader type (0x%08lX) given to " - "cogl_create_shader", (unsigned long) type); - return COGL_INVALID_HANDLE; - } - - shader = g_slice_new (CoglShader); - shader->language = COGL_SHADER_LANGUAGE_GLSL; - shader->gl_handle = 0; -#ifdef HAVE_COGL_GLES2 - shader->n_tex_coord_attribs = 0; -#endif - shader->type = type; - - return _cogl_shader_handle_new (shader); -} - -static void -delete_shader (CoglShader *shader) -{ - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - -#ifdef HAVE_COGL_GL - if (shader->language == COGL_SHADER_LANGUAGE_ARBFP) - { - if (shader->gl_handle) - GE (ctx, glDeletePrograms (1, &shader->gl_handle)); - } - else -#endif - { - if (shader->gl_handle) - GE (ctx, glDeleteShader (shader->gl_handle)); - } - - shader->gl_handle = 0; -} - -void -cogl_shader_source (CoglHandle handle, - const char *source) -{ - CoglShader *shader; - CoglShaderLanguage language; - - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - - if (!cogl_is_shader (handle)) - return; - - shader = handle; - -#ifdef HAVE_COGL_GL - if (strncmp (source, "!!ARBfp1.0", 10) == 0) - language = COGL_SHADER_LANGUAGE_ARBFP; - else -#endif - language = COGL_SHADER_LANGUAGE_GLSL; - - /* Delete the old object if the language is changing... */ - if (G_UNLIKELY (language != shader->language) && - shader->gl_handle) - delete_shader (shader); - - shader->source = g_strdup (source); - - shader->language = language; -} - -void -cogl_shader_compile (CoglHandle handle) -{ - CoglShader *shader = handle; - - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - - if (!cogl_is_shader (handle)) - return; - - if (ctx->driver == COGL_DRIVER_GL) - _cogl_shader_compile_real (shader, 0 /* ignored */); - - /* XXX: For GLES2 we don't actually compile anything until the - * shader gets used so we have an opportunity to add some - * boilerplate to the shader. - * - * At the end of the day this is obviously a badly designed API - * given that we are having to lie to the user. It was a mistake to - * so thinly wrap the OpenGL shader API and the current plan is to - * replace it with a pipeline snippets API. */ -} - -void -_cogl_shader_set_source_with_boilerplate (GLuint shader_gl_handle, - GLenum shader_gl_type, - int n_tex_coord_attribs, - GLsizei count_in, - const char **strings_in, - const GLint *lengths_in) -{ - const char *vertex_boilerplate; - const char *fragment_boilerplate; - - const char **strings = g_alloca (sizeof (char *) * (count_in + 3)); - GLint *lengths = g_alloca (sizeof (GLint) * (count_in + 3)); - int count = 0; - char *tex_coord_declarations = NULL; - - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - - if (ctx->driver == COGL_DRIVER_GLES2) - { - vertex_boilerplate = _COGL_VERTEX_SHADER_BOILERPLATE_GLES2; - fragment_boilerplate = _COGL_FRAGMENT_SHADER_BOILERPLATE_GLES2; - } - else - { - vertex_boilerplate = _COGL_VERTEX_SHADER_BOILERPLATE_GL; - fragment_boilerplate = _COGL_FRAGMENT_SHADER_BOILERPLATE_GL; - } - - if (ctx->driver == COGL_DRIVER_GLES2 && - cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_3D)) - { - static const char texture_3d_extension[] = - "#extension GL_OES_texture_3D : enable\n"; - strings[count] = texture_3d_extension; - lengths[count++] = sizeof (texture_3d_extension) - 1; - } - - if (shader_gl_type == GL_VERTEX_SHADER) - { - strings[count] = vertex_boilerplate; - lengths[count++] = strlen (vertex_boilerplate); - } - else if (shader_gl_type == GL_FRAGMENT_SHADER) - { - strings[count] = fragment_boilerplate; - lengths[count++] = strlen (fragment_boilerplate); - } - - if (ctx->driver == COGL_DRIVER_GLES2 && - n_tex_coord_attribs) - { - GString *declarations = g_string_new (NULL); - - g_string_append_printf (declarations, - "varying vec4 _cogl_tex_coord[%d];\n", - n_tex_coord_attribs); - - if (shader_gl_type == GL_VERTEX_SHADER) - { - int i; - - g_string_append_printf (declarations, - "uniform mat4 cogl_texture_matrix[%d];\n", - n_tex_coord_attribs); - - for (i = 0; i < n_tex_coord_attribs; i++) - g_string_append_printf (declarations, - "attribute vec4 cogl_tex_coord%d_in;\n", - i); - } - - tex_coord_declarations = g_string_free (declarations, FALSE); - strings[count] = tex_coord_declarations; - lengths[count++] = -1; /* null terminated */ - } - - memcpy (strings + count, strings_in, sizeof (char *) * count_in); - if (lengths_in) - memcpy (lengths + count, lengths_in, sizeof (GLint) * count_in); - else - { - int i; - - for (i = 0; i < count_in; i++) - lengths[count + i] = -1; /* null terminated */ - } - count += count_in; - - if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_SHOW_SOURCE))) - { - GString *buf = g_string_new (NULL); - int i; - - g_string_append_printf (buf, - "%s shader:\n", - shader_gl_type == GL_VERTEX_SHADER ? - "vertex" : "fragment"); - for (i = 0; i < count; i++) - if (lengths[i] != -1) - g_string_append_len (buf, strings[i], lengths[i]); - else - g_string_append (buf, strings[i]); - - g_message ("%s", buf->str); - - g_string_free (buf, TRUE); - } - - GE( ctx, glShaderSource (shader_gl_handle, count, - (const char **) strings, lengths) ); - - g_free (tex_coord_declarations); -} - -void -_cogl_shader_compile_real (CoglHandle handle, - int n_tex_coord_attribs) -{ - CoglShader *shader = handle; - - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - -#ifdef HAVE_COGL_GL - if (shader->language == COGL_SHADER_LANGUAGE_ARBFP) - { -#ifdef COGL_GL_DEBUG - GLenum gl_error; -#endif - - if (shader->gl_handle) - return; - - GE (ctx, glGenPrograms (1, &shader->gl_handle)); - - GE (ctx, glBindProgram (GL_FRAGMENT_PROGRAM_ARB, shader->gl_handle)); - - if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_SHOW_SOURCE))) - g_message ("user ARBfp program:\n%s", shader->source); - -#ifdef COGL_GL_DEBUG - while ((gl_error = ctx->glGetError ()) != GL_NO_ERROR) - ; -#endif - ctx->glProgramString (GL_FRAGMENT_PROGRAM_ARB, - GL_PROGRAM_FORMAT_ASCII_ARB, - strlen (shader->source), - shader->source); -#ifdef COGL_GL_DEBUG - gl_error = ctx->glGetError (); - if (gl_error != GL_NO_ERROR) - { - g_warning ("%s: GL error (%d): Failed to compile ARBfp:\n%s\n%s", - G_STRLOC, - gl_error, - shader->source, - ctx->glGetString (GL_PROGRAM_ERROR_STRING_ARB)); - } -#endif - } - else -#endif - { - GLenum gl_type; - - if (shader->gl_handle -#ifdef HAVE_COGL_GLES2 - && - (ctx->driver != COGL_DRIVER_GLES2 || - shader->n_tex_coord_attribs == n_tex_coord_attribs) -#endif - ) - return; - - if (shader->gl_handle) - delete_shader (shader); - - switch (shader->type) - { - case COGL_SHADER_TYPE_VERTEX: - gl_type = GL_VERTEX_SHADER; - break; - case COGL_SHADER_TYPE_FRAGMENT: - gl_type = GL_FRAGMENT_SHADER; - break; - default: - g_assert_not_reached (); - break; - } - - shader->gl_handle = ctx->glCreateShader (gl_type); - - _cogl_shader_set_source_with_boilerplate (shader->gl_handle, - gl_type, - n_tex_coord_attribs, - 1, - (const char **) &shader->source, - NULL); - - GE (ctx, glCompileShader (shader->gl_handle)); - -#ifdef HAVE_COGL_GLES2 - shader->n_tex_coord_attribs = n_tex_coord_attribs; -#endif - -#ifdef COGL_GL_DEBUG - if (!cogl_shader_is_compiled (handle)) - { - char *log = cogl_shader_get_info_log (handle); - g_warning ("Failed to compile GLSL program:\nsrc:\n%s\nerror:\n%s\n", - shader->source, - log); - g_free (log); - } -#endif - } -} - -char * -cogl_shader_get_info_log (CoglHandle handle) -{ - CoglShader *shader; - - _COGL_GET_CONTEXT (ctx, NULL); - - if (!cogl_is_shader (handle)) - return NULL; - - shader = handle; - -#ifdef HAVE_COGL_GL - if (shader->language == COGL_SHADER_LANGUAGE_ARBFP) - { - /* ARBfp exposes a program error string, but since cogl_program - * doesn't have any API to query an error log it is not currently - * exposed. */ - return g_strdup (""); - } - else -#endif - { - char buffer[512]; - int len = 0; - - /* We don't normally compile the shader when the user calls - * cogl_shader_compile() because we want to be able to add - * boilerplate code that depends on how it ends up finally being - * used. - * - * Here we force an early compile if the user is interested in - * log information to increase the chance that the log will be - * useful! We have to guess the number of texture coordinate - * attributes that may be used since that affects the - * boilerplate. We use four so that the shader will still - * compile if the user is using more than one - * layer. Unfortunately this is likely to end up causing it to - * be compiled again when we know the actual number of layers */ - if (!shader->gl_handle) - _cogl_shader_compile_real (handle, 4); - - ctx->glGetShaderInfoLog (shader->gl_handle, 511, &len, buffer); - buffer[len] = '\0'; - return g_strdup (buffer); - } -} - -CoglShaderType -cogl_shader_get_type (CoglHandle handle) -{ - CoglShader *shader; - - _COGL_GET_CONTEXT (ctx, COGL_SHADER_TYPE_VERTEX); - - if (!cogl_is_shader (handle)) - { - g_warning ("Non shader handle type passed to cogl_shader_get_type"); - return COGL_SHADER_TYPE_VERTEX; - } - - shader = handle; - return shader->type; -} - -gboolean -cogl_shader_is_compiled (CoglHandle handle) -{ -#if defined (HAVE_COGL_GL) || defined (HAVE_COGL_GLES2) - GLint status; - CoglShader *shader; - - _COGL_GET_CONTEXT (ctx, FALSE); - - if (!cogl_is_shader (handle)) - return FALSE; - - shader = handle; - -#ifdef HAVE_COGL_GL - if (shader->language == COGL_SHADER_LANGUAGE_ARBFP) - return TRUE; - else -#endif - { - /* FIXME: We currently have an arbitrary limit of 4 texture - * coordinate attributes since our API means we have to add - * some boilerplate to the users GLSL program (for GLES2) - * before we actually know how many attributes are in use. - * - * 4 will probably be enough (or at least that limitation should - * be enough until we can replace this API with the pipeline - * snippets API) but if it isn't then the shader won't compile, - * through no fault of the user. - * - * To some extent this is just a symptom of bad API design; it - * was a mistake for Cogl to so thinly wrap the OpenGL shader - * API. Eventually we plan for this whole API will be deprecated - * by the pipeline snippets framework. - */ - if (!shader->gl_handle) - _cogl_shader_compile_real (handle, 4); - - GE (ctx, glGetShaderiv (shader->gl_handle, GL_COMPILE_STATUS, &status)); - if (status == GL_TRUE) - return TRUE; - else - return FALSE; - } -#else - return FALSE; -#endif -} diff --git a/cogl/cogl-shader.h b/cogl/cogl-shader.h deleted file mode 100644 index c9aad74d..00000000 --- a/cogl/cogl-shader.h +++ /dev/null @@ -1,654 +0,0 @@ -/* - * Cogl - * - * An object oriented GL/GLES Abstraction/Utility Layer - * - * Copyright (C) 2008,2009 Intel Corporation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see <http://www.gnu.org/licenses/>. - * - * - */ - -#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION) -#error "Only <cogl/cogl.h> can be included directly." -#endif - -#ifndef __COGL_SHADER_H__ -#define __COGL_SHADER_H__ - -#include <cogl/cogl-types.h> -#include <cogl/cogl-defines.h> - -G_BEGIN_DECLS - -/** - * SECTION:cogl-shaders - * @short_description: Fuctions for accessing the programmable GL pipeline - * - * Cogl allows accessing the GL programmable pipeline in order to create - * vertex and fragment shaders. - * - * The shader source code can either be GLSL or ARBfp. If the source - * code is ARBfp, it must begin with the string “!!ARBfp1.0”. The - * application should check for the %COGL_FEATURE_SHADERS_GLSL or - * %COGL_FEATURE_SHADERS_ARBFP features before using shaders. - * - * When using GLSL Cogl provides replacement names for most of the - * builtin varyings and uniforms. It is recommended to use these names - * wherever possible to increase portability between OpenGL 2.0 and - * GLES 2.0. GLES 2.0 does not have most of the builtins under their - * original names so they will only work with the Cogl names. - * - * For use in all GLSL shaders, the Cogl builtins are as follows: - * - * <tip> - * <glosslist> - * <glossentry> - * <glossterm>uniform mat4 - * <emphasis>cogl_modelview_matrix</emphasis></glossterm> - * <glossdef><para> - * The current modelview matrix. This is equivalent to - * #gl_ModelViewMatrix. - * </para></glossdef> - * </glossentry> - * <glossentry> - * <glossterm>uniform mat4 - * <emphasis>cogl_projection_matrix</emphasis></glossterm> - * <glossdef><para> - * The current projection matrix. This is equivalent to - * #gl_ProjectionMatrix. - * </para></glossdef> - * </glossentry> - * <glossentry> - * <glossterm>uniform mat4 - * <emphasis>cogl_modelview_projection_matrix</emphasis></glossterm> - * <glossdef><para> - * The combined modelview and projection matrix. A vertex shader - * would typically use this to transform the incoming vertex - * position. The separate modelview and projection matrices are - * usually only needed for lighting calculations. This is - * equivalent to #gl_ModelViewProjectionMatrix. - * </para></glossdef> - * </glossentry> - * <glossentry> - * <glossterm>uniform mat4 - * <emphasis>cogl_texture_matrix</emphasis>[]</glossterm> - * <glossdef><para> - * An array of matrices for transforming the texture - * coordinates. This is equivalent to #gl_TextureMatrix. - * </para></glossdef> - * </glossentry> - * </glosslist> - * </tip> - * - * In a vertex shader, the following are also available: - * - * <tip> - * <glosslist> - * <glossentry> - * <glossterm>attribute vec4 - * <emphasis>cogl_position_in</emphasis></glossterm> - * <glossdef><para> - * The incoming vertex position. This is equivalent to #gl_Vertex. - * </para></glossdef> - * </glossentry> - * <glossentry> - * <glossterm>attribute vec4 - * <emphasis>cogl_color_in</emphasis></glossterm> - * <glossdef><para> - * The incoming vertex color. This is equivalent to #gl_Color. - * </para></glossdef> - * </glossentry> - * <glossentry> - * <glossterm>attribute vec4 - * <emphasis>cogl_tex_coord_in</emphasis></glossterm> - * <glossdef><para> - * The texture coordinate for the first texture unit. This is - * equivalent to #gl_MultiTexCoord0. - * </para></glossdef> - * </glossentry> - * <glossentry> - * <glossterm>attribute vec4 - * <emphasis>cogl_tex_coord0_in</emphasis></glossterm> - * <glossdef><para> - * The texture coordinate for the first texture unit. This is - * equivalent to #gl_MultiTexCoord0. There is also - * #cogl_tex_coord1_in and so on. - * </para></glossdef> - * </glossentry> - * <glossentry> - * <glossterm>attribute vec3 - * <emphasis>cogl_normal_in</emphasis></glossterm> - * <glossdef><para> - * The normal of the vertex. This is equivalent to #gl_Normal. - * </para></glossdef> - * </glossentry> - * <glossentry> - * <glossterm>vec4 - * <emphasis>cogl_position_out</emphasis></glossterm> - * <glossdef><para> - * The calculated position of the vertex. This must be written to - * in all vertex shaders. This is equivalent to #gl_Position. - * </para></glossdef> - * </glossentry> - * <glossentry> - * <glossterm>float - * <emphasis>cogl_point_size_out</emphasis></glossterm> - * <glossdef><para> - * The calculated size of a point. This is equivalent to #gl_PointSize. - * </para></glossdef> - * </glossentry> - * <glossentry> - * <glossterm>varying vec4 - * <emphasis>cogl_color_out</emphasis></glossterm> - * <glossdef><para> - * The calculated color of a vertex. This is equivalent to #gl_FrontColor. - * </para></glossdef> - * </glossentry> - * <glossentry> - * <glossterm>varying vec4 - * <emphasis>cogl_tex_coord_out</emphasis>[]</glossterm> - * <glossdef><para> - * An array of calculated texture coordinates for a vertex. This is - * equivalent to #gl_TexCoord. - * </para></glossdef> - * </glossentry> - * </glosslist> - * </tip> - * - * In a fragment shader, the following are also available: - * - * <tip> - * <glosslist> - * <glossentry> - * <glossterm>varying vec4 <emphasis>cogl_color_in</emphasis></glossterm> - * <glossdef><para> - * The calculated color of a vertex. This is equivalent to #gl_FrontColor. - * </para></glossdef> - * </glossentry> - * <glossentry> - * <glossterm>varying vec4 - * <emphasis>cogl_tex_coord_in</emphasis>[]</glossterm> - * <glossdef><para> - * An array of calculated texture coordinates for a vertex. This is - * equivalent to #gl_TexCoord. - * </para></glossdef> - * </glossentry> - * <glossentry> - * <glossterm>vec4 <emphasis>cogl_color_out</emphasis></glossterm> - * <glossdef><para> - * The final calculated color of the fragment. All fragment shaders - * must write to this variable. This is equivalent to - * #gl_FrontColor. - * </para></glossdef> - * </glossentry> - * <glossentry> - * <glossterm>float <emphasis>cogl_depth_out</emphasis></glossterm> - * <glossdef><para> - * An optional output variable specifying the depth value to use - * for this fragment. This is equivalent to #gl_FragDepth. - * </para></glossdef> - * </glossentry> - * <glossentry> - * <glossterm>bool <emphasis>cogl_front_facing</emphasis></glossterm> - * <glossdef><para> - * A readonly variable that will be true if the current primitive - * is front facing. This can be used to implement two-sided - * coloring algorithms. This is equivalent to #gl_FrontFacing. - * </para></glossdef> - * </glossentry> - * </glosslist> - * </tip> - * - * It's worth nothing that this API isn't what Cogl would like to have - * in the long term and it may be removed in Cogl 2.0. The - * experimental #CoglShader API is the proposed replacement. - */ - -/** - * CoglShaderType: - * @COGL_SHADER_TYPE_VERTEX: A program for proccessing vertices - * @COGL_SHADER_TYPE_FRAGMENT: A program for processing fragments - * - * Types of shaders - * - * Since: 1.0 - */ -typedef enum { - COGL_SHADER_TYPE_VERTEX, - COGL_SHADER_TYPE_FRAGMENT -} CoglShaderType; - -/** - * cogl_create_shader: - * @shader_type: COGL_SHADER_TYPE_VERTEX or COGL_SHADER_TYPE_FRAGMENT. - * - * Create a new shader handle, use cogl_shader_source() to set the - * source code to be used on it. - * - * Returns: a new shader handle. - */ -CoglHandle -cogl_create_shader (CoglShaderType shader_type); - -#ifndef COGL_DISABLE_DEPRECATED - -/** - * cogl_shader_ref: - * @handle: A #CoglHandle to a shader. - * - * Add an extra reference to a shader. - * - * Deprecated: 1.0: Please use cogl_handle_ref() instead. - * - * Returns: @handle - */ -CoglHandle -cogl_shader_ref (CoglHandle handle) G_GNUC_DEPRECATED; - -/** - * cogl_shader_unref: - * @handle: A #CoglHandle to a shader. - * - * Removes a reference to a shader. If it was the last reference the - * shader object will be destroyed. - * - * Deprecated: 1.0: Please use cogl_handle_unref() instead. - */ -void -cogl_shader_unref (CoglHandle handle) G_GNUC_DEPRECATED; - -#endif /* COGL_DISABLE_DEPRECATED */ - -/** - * cogl_is_shader: - * @handle: A CoglHandle - * - * Gets whether the given handle references an existing shader object. - * - * Returns: %TRUE if the handle references a shader, - * %FALSE otherwise - */ -gboolean -cogl_is_shader (CoglHandle handle); - -/** - * cogl_shader_source: - * @shader: #CoglHandle for a shader. - * @source: Shader source. - * - * Replaces the current source associated with a shader with a new - * one. - * - * Please see <link - * linkend="cogl-Shaders-and-Programmable-Pipeline.description">above</link> - * for a description of the recommended format for the shader code. - */ -void -cogl_shader_source (CoglHandle shader, - const char *source); -/** - * cogl_shader_compile: - * @handle: #CoglHandle for a shader. - * - * Compiles the shader, no return value, but the shader is now ready - * for linking into a program. Note that calling this function is - * optional. If it is not called then the shader will be automatically - * compiled when it is linked. - */ -void -cogl_shader_compile (CoglHandle handle); - -/** - * cogl_shader_get_info_log: - * @handle: #CoglHandle for a shader. - * - * Retrieves the information log for a coglobject, can be used in conjunction - * with cogl_shader_get_parameteriv() to retrieve the compiler warnings/error - * messages that caused a shader to not compile correctly, mainly useful for - * debugging purposes. - * - * Return value: a newly allocated string containing the info log. Use - * g_free() to free it - */ -char * -cogl_shader_get_info_log (CoglHandle handle); - -/** - * cogl_shader_get_type: - * @handle: #CoglHandle for a shader. - * - * Retrieves the type of a shader #CoglHandle - * - * Return value: %COGL_SHADER_TYPE_VERTEX if the shader is a vertex processor - * or %COGL_SHADER_TYPE_FRAGMENT if the shader is a frament processor - */ -CoglShaderType -cogl_shader_get_type (CoglHandle handle); - -/** - * cogl_shader_is_compiled: - * @handle: #CoglHandle for a shader. - * - * Retrieves whether a shader #CoglHandle has been compiled - * - * Return value: %TRUE if the shader object has sucessfully be compiled - */ -gboolean -cogl_shader_is_compiled (CoglHandle handle); - -/** - * cogl_create_program: - * - * Create a new cogl program object that can be used to replace parts of the GL - * rendering pipeline with custom code. - * - * Returns: a new cogl program. - */ -CoglHandle -cogl_create_program (void); - -#ifndef COGL_DISABLE_DEPRECATED - -/** - * cogl_program_ref: - * @handle: A #CoglHandle to a program. - * - * Add an extra reference to a program. - * - * Deprecated: 1.0: Please use cogl_handle_ref() instead. - * - * Returns: @handle - */ -CoglHandle -cogl_program_ref (CoglHandle handle) G_GNUC_DEPRECATED; - -/** - * cogl_program_unref: - * @handle: A #CoglHandle to a program. - * - * Removes a reference to a program. If it was the last reference the - * program object will be destroyed. - * - * Deprecated: 1.0: Please use cogl_handle_unref() instead. - */ -void -cogl_program_unref (CoglHandle handle) G_GNUC_DEPRECATED; - -#endif /* COGL_DISABLE_DEPRECATED */ - -/** - * cogl_is_program: - * @handle: A CoglHandle - * - * Gets whether the given handle references an existing program object. - * - * Returns: %TRUE if the handle references a program, - * %FALSE otherwise - */ -gboolean -cogl_is_program (CoglHandle handle); - -/** - * cogl_program_attach_shader: - * @program_handle: a #CoglHandle for a shdaer program. - * @shader_handle: a #CoglHandle for a vertex of fragment shader. - * - * Attaches a shader to a program object. A program can have multiple - * vertex or fragment shaders but only one of them may provide a - * main() function. It is allowed to use a program with only a vertex - * shader or only a fragment shader. - */ -void -cogl_program_attach_shader (CoglHandle program_handle, - CoglHandle shader_handle); - -/** - * cogl_program_link: - * @handle: a #CoglHandle for a shader program. - * - * Links a program making it ready for use. Note that calling this - * function is optional. If it is not called the program will - * automatically be linked the first time it is used. - */ -void -cogl_program_link (CoglHandle handle); - -/** - * cogl_program_use: - * @handle: a #CoglHandle for a shader program or %COGL_INVALID_HANDLE. - * - * Activate a specific shader program replacing that part of the GL - * rendering pipeline, if passed in %COGL_INVALID_HANDLE the default - * behavior of GL is reinstated. - * - * This function affects the global state of the current Cogl - * context. It is much more efficient to attach the shader to a - * specific material used for rendering instead by calling - * cogl_material_set_user_program(). - */ -void -cogl_program_use (CoglHandle handle); - -/** - * cogl_program_get_uniform_location: - * @handle: a #CoglHandle for a shader program. - * @uniform_name: the name of a uniform. - * - * Retrieve the location (offset) of a uniform variable in a shader program, - * a uniform is a variable that is constant for all vertices/fragments for a - * shader object and is possible to modify as an external parameter. - * - * Return value: the offset of a uniform in a specified program. - * This uniform can be set using cogl_program_uniform_1f() when the - * program is in use. - */ -int -cogl_program_get_uniform_location (CoglHandle handle, - const char *uniform_name); - -/** - * cogl_program_set_uniform_1f: - * @program: A #CoglHandle for a linked program - * @uniform_location: the uniform location retrieved from - * cogl_program_get_uniform_location(). - * @value: the new value of the uniform. - * - * Changes the value of a floating point uniform for the given linked - * @program. - * - * Since: 1.4 - */ -void -cogl_program_set_uniform_1f (CoglHandle program, - int uniform_location, - float value); - -/** - * cogl_program_set_uniform_1i: - * @program: A #CoglHandle for a linked program - * @uniform_location: the uniform location retrieved from - * cogl_program_get_uniform_location(). - * @value: the new value of the uniform. - * - * Changes the value of an integer uniform for the given linked - * @program. - * - * Since: 1.4 - */ -void -cogl_program_set_uniform_1i (CoglHandle program, - int uniform_location, - int value); - -/** - * cogl_program_set_uniform_float: - * @program: A #CoglHandle for a linked program - * @uniform_location: the uniform location retrieved from - * cogl_program_get_uniform_location(). - * @n_components: The number of components for the uniform. For - * example with glsl you'd use 3 for a vec3 or 4 for a vec4. - * @count: For uniform arrays this is the array length otherwise just - * pass 1 - * @value: (array length=count): the new value of the uniform[s]. - * - * Changes the value of a float vector uniform, or uniform array for - * the given linked @program. - * - * Since: 1.4 - */ -void -cogl_program_set_uniform_float (CoglHandle program, - int uniform_location, - int n_components, - int count, - const float *value); - -/** - * cogl_program_set_uniform_int: - * @program: A #CoglHandle for a linked program - * @uniform_location: the uniform location retrieved from - * cogl_program_get_uniform_location(). - * @n_components: The number of components for the uniform. For - * example with glsl you'd use 3 for a vec3 or 4 for a vec4. - * @count: For uniform arrays this is the array length otherwise just - * pass 1 - * @value: (array length=count): the new value of the uniform[s]. - * - * Changes the value of a int vector uniform, or uniform array for - * the given linked @program. - * - * Since: 1.4 - */ -void -cogl_program_set_uniform_int (CoglHandle program, - int uniform_location, - int n_components, - int count, - const int *value); - -/** - * cogl_program_set_uniform_matrix: - * @program: A #CoglHandle for a linked program - * @uniform_location: the uniform location retrieved from - * cogl_program_get_uniform_location(). - * @dimensions: The dimensions of the matrix. So for for example pass - * 2 for a 2x2 matrix or 3 for 3x3. - * @count: For uniform arrays this is the array length otherwise just - * pass 1 - * @transpose: Whether to transpose the matrix when setting the uniform. - * @value: (array length=count): the new value of the uniform. - * - * Changes the value of a matrix uniform, or uniform array in the - * given linked @program. - * - * Since: 1.4 - */ -void -cogl_program_set_uniform_matrix (CoglHandle program, - int uniform_location, - int dimensions, - int count, - gboolean transpose, - const float *value); - -#ifndef COGL_DISABLE_DEPRECATED - -/** - * cogl_program_uniform_1f: - * @uniform_no: the uniform to set. - * @value: the new value of the uniform. - * - * Changes the value of a floating point uniform in the currently - * used (see cogl_program_use()) shader program. - * - * Deprecated: 1.4: Use cogl_program_set_uniform_1f() instead. - */ -void -cogl_program_uniform_1f (int uniform_no, - float value) G_GNUC_DEPRECATED; - -/** - * cogl_program_uniform_1i: - * @uniform_no: the uniform to set. - * @value: the new value of the uniform. - * - * Changes the value of an integer uniform in the currently - * used (see cogl_program_use()) shader program. - * - * Deprecated: 1.4: Use cogl_program_set_uniform_1i() instead. - */ -void -cogl_program_uniform_1i (int uniform_no, - int value) G_GNUC_DEPRECATED; - -/** - * cogl_program_uniform_float: - * @uniform_no: the uniform to set. - * @size: Size of float vector. - * @count: Size of array of uniforms. - * @value: (array length=count): the new value of the uniform. - * - * Changes the value of a float vector uniform, or uniform array in the - * currently used (see cogl_program_use()) shader program. - * - * Deprecated: 1.4: Use cogl_program_set_uniform_float() instead. - */ -void -cogl_program_uniform_float (int uniform_no, - int size, - int count, - const float *value) G_GNUC_DEPRECATED; - -/** - * cogl_program_uniform_int: - * @uniform_no: the uniform to set. - * @size: Size of int vector. - * @count: Size of array of uniforms. - * @value: (array length=count): the new value of the uniform. - * - * Changes the value of a int vector uniform, or uniform array in the - * currently used (see cogl_program_use()) shader program. - */ -void -cogl_program_uniform_int (int uniform_no, - int size, - int count, - const int *value) G_GNUC_DEPRECATED; - -/** - * cogl_program_uniform_matrix: - * @uniform_no: the uniform to set. - * @size: Size of matrix. - * @count: Size of array of uniforms. - * @transpose: Whether to transpose the matrix when setting the uniform. - * @value: (array length=count): the new value of the uniform. - * - * Changes the value of a matrix uniform, or uniform array in the - * currently used (see cogl_program_use()) shader program. The @size - * parameter is used to determine the square size of the matrix. - */ -void -cogl_program_uniform_matrix (int uniform_no, - int size, - int count, - gboolean transpose, - const float *value) G_GNUC_DEPRECATED; - -#endif /* COGL_DISABLE_DEPRECATED */ - -G_END_DECLS - -#endif /* __COGL_SHADER_H__ */ diff --git a/cogl/cogl-snippet.h b/cogl/cogl-snippet.h index 88a49d26..60eccc62 100644 --- a/cogl/cogl-snippet.h +++ b/cogl/cogl-snippet.h @@ -601,11 +601,11 @@ cogl_snippet_get_hook (CoglSnippet *snippet); /** * cogl_is_snippet: - * @handle: A CoglHandle + * @object: A #CoglObject pointer * - * Gets whether the given handle references an existing snippet object. + * Gets whether the given @object references an existing snippet object. * - * Return value: %TRUE if the handle references a #CoglSnippet, + * Return value: %TRUE if the @object references a #CoglSnippet, * %FALSE otherwise * * Since: 1.10 diff --git a/cogl/cogl-spans.h b/cogl/cogl-spans.h index ac8d13aa..b0b6c1de 100644 --- a/cogl/cogl-spans.h +++ b/cogl/cogl-spans.h @@ -24,7 +24,7 @@ #ifndef __COGL_SPANS_PRIVATE_H #define __COGL_SPANS_PRIVATE_H -#include "cogl-handle.h" +#include "cogl-object-private.h" #include "cogl-pipeline-layer-state.h" typedef struct _CoglSpan diff --git a/cogl/cogl-sub-texture.c b/cogl/cogl-sub-texture.c index ee8a10f7..38aac159 100644 --- a/cogl/cogl-sub-texture.c +++ b/cogl/cogl-sub-texture.c @@ -253,7 +253,7 @@ cogl_sub_texture_new (CoglContext *ctx, sub_tex->sub_width = sub_width; sub_tex->sub_height = sub_height; - return _cogl_sub_texture_handle_new (sub_tex); + return _cogl_sub_texture_object_new (sub_tex); } CoglTexture * diff --git a/cogl/cogl-texture-2d-private.h b/cogl/cogl-texture-2d-private.h index 89076103..855b2fbf 100644 --- a/cogl/cogl-texture-2d-private.h +++ b/cogl/cogl-texture-2d-private.h @@ -24,7 +24,7 @@ #ifndef __COGL_TEXTURE_2D_H #define __COGL_TEXTURE_2D_H -#include "cogl-handle.h" +#include "cogl-object-private.h" #include "cogl-pipeline-private.h" #include "cogl-texture-private.h" #include "cogl-texture-2d.h" @@ -68,18 +68,18 @@ _cogl_egl_texture_2d_new_from_image (CoglContext *ctx, /* * _cogl_texture_2d_externally_modified: - * @handle: A handle to a 2D texture + * @texture: A #CoglTexture2D object * * This should be called whenever the texture is modified other than * by using cogl_texture_set_region. It will cause the mipmaps to be * invalidated */ void -_cogl_texture_2d_externally_modified (CoglHandle handle); +_cogl_texture_2d_externally_modified (CoglTexture *texture); /* * _cogl_texture_2d_copy_from_framebuffer: - * @handle: A handle to a 2D texture + * @texture: A #CoglTexture2D pointer * @dst_x: X-position to store the image within the texture * @dst_y: Y-position to store the image within the texture * @src_x: X-position to within the framebuffer to read from @@ -91,7 +91,7 @@ _cogl_texture_2d_externally_modified (CoglHandle handle); * texture. */ void -_cogl_texture_2d_copy_from_framebuffer (CoglHandle handle, +_cogl_texture_2d_copy_from_framebuffer (CoglTexture2D *texture, int dst_x, int dst_y, int src_x, diff --git a/cogl/cogl-texture-2d-sliced.c b/cogl/cogl-texture-2d-sliced.c index 5f432526..f2872ad5 100644 --- a/cogl/cogl-texture-2d-sliced.c +++ b/cogl/cogl-texture-2d-sliced.c @@ -40,7 +40,7 @@ #include "cogl-texture-2d-sliced-private.h" #include "cogl-texture-driver.h" #include "cogl-context-private.h" -#include "cogl-handle.h" +#include "cogl-object-private.h" #include "cogl-spans.h" #include "cogl-journal-private.h" #include "cogl-pipeline-opengl-private.h" @@ -790,7 +790,7 @@ _cogl_texture_2d_sliced_slices_free (CoglTexture2DSliced *tex_2ds) { CoglTexture2D *slice_tex = g_array_index (tex_2ds->slice_textures, CoglTexture2D *, i); - cogl_handle_unref (slice_tex); + cogl_object_unref (slice_tex); } g_array_free (tex_2ds->slice_textures, TRUE); @@ -867,7 +867,7 @@ cogl_texture_2d_sliced_new_with_size (CoglContext *ctx, return NULL; } - return _cogl_texture_2d_sliced_handle_new (tex_2ds); + return _cogl_texture_2d_sliced_object_new (tex_2ds); } CoglTexture2DSliced * @@ -935,7 +935,7 @@ _cogl_texture_2d_sliced_new_from_bitmap (CoglBitmap *bmp, cogl_primitive_texture_set_auto_mipmap (slice_tex, FALSE); } - return _cogl_texture_2d_sliced_handle_new (tex_2ds); + return _cogl_texture_2d_sliced_object_new (tex_2ds); error: cogl_object_unref (dst_bmp); @@ -1030,7 +1030,7 @@ _cogl_texture_2d_sliced_new_from_foreign (GLuint gl_handle, g_array_append_val (tex_2ds->slice_textures, tex_2d); - return _cogl_texture_2d_sliced_handle_new (tex_2ds); + return _cogl_texture_2d_sliced_object_new (tex_2ds); } static gboolean diff --git a/cogl/cogl-texture-2d.c b/cogl/cogl-texture-2d.c index 5e988bd6..beaf9650 100644 --- a/cogl/cogl-texture-2d.c +++ b/cogl/cogl-texture-2d.c @@ -34,7 +34,7 @@ #include "cogl-texture-2d-private.h" #include "cogl-texture-driver.h" #include "cogl-context-private.h" -#include "cogl-handle.h" +#include "cogl-object-private.h" #include "cogl-journal-private.h" #include "cogl-pipeline-opengl-private.h" #include "cogl-framebuffer-private.h" @@ -218,7 +218,7 @@ cogl_texture_2d_new_with_size (CoglContext *ctx, GE( ctx, glTexImage2D (GL_TEXTURE_2D, 0, gl_intformat, width, height, 0, gl_format, gl_type, NULL) ); - return _cogl_texture_2d_handle_new (tex_2d); + return _cogl_texture_2d_object_new (tex_2d); } CoglTexture2D * @@ -234,7 +234,7 @@ cogl_texture_2d_new_from_bitmap (CoglBitmap *bmp, guint8 *data; CoglContext *ctx; - _COGL_RETURN_VAL_IF_FAIL (bmp != NULL, COGL_INVALID_HANDLE); + _COGL_RETURN_VAL_IF_FAIL (bmp != NULL, NULL); ctx = _cogl_bitmap_get_context (bmp); @@ -300,7 +300,7 @@ cogl_texture_2d_new_from_bitmap (CoglBitmap *bmp, cogl_object_unref (dst_bmp); - return _cogl_texture_2d_handle_new (tex_2d); + return _cogl_texture_2d_object_new (tex_2d); } CoglTexture2D * @@ -314,7 +314,7 @@ cogl_texture_2d_new_from_data (CoglContext *ctx, GError **error) { CoglBitmap *bmp; - CoglHandle tex; + CoglTexture2D *tex_2d; _COGL_RETURN_VAL_IF_FAIL (format != COGL_PIXEL_FORMAT_ANY, NULL); _COGL_RETURN_VAL_IF_FAIL (data != NULL, NULL); @@ -330,13 +330,13 @@ cogl_texture_2d_new_from_data (CoglContext *ctx, rowstride, (guint8 *) data); - tex = cogl_texture_2d_new_from_bitmap (bmp, - internal_format, - error); + tex_2d = cogl_texture_2d_new_from_bitmap (bmp, + internal_format, + error); cogl_object_unref (bmp); - return tex; + return tex_2d; } CoglTexture2D * @@ -357,11 +357,11 @@ cogl_texture_2d_new_from_foreign (CoglContext *ctx, CoglTexture2D *tex_2d; if (!ctx->texture_driver->allows_foreign_gl_target (ctx, GL_TEXTURE_2D)) - return COGL_INVALID_HANDLE; + return NULL; /* Make sure it is a valid GL texture object */ if (!ctx->glIsTexture (gl_handle)) - return COGL_INVALID_HANDLE; + return NULL; /* Make sure binding succeeds */ while ((gl_error = ctx->glGetError ()) != GL_NO_ERROR) @@ -369,7 +369,7 @@ cogl_texture_2d_new_from_foreign (CoglContext *ctx, _cogl_bind_gl_texture_transient (GL_TEXTURE_2D, gl_handle, TRUE); if (ctx->glGetError () != GL_NO_ERROR) - return COGL_INVALID_HANDLE; + return NULL; /* Obtain texture parameters (only level 0 we are interested in) */ @@ -396,7 +396,7 @@ cogl_texture_2d_new_from_foreign (CoglContext *ctx, if (!ctx->driver_vtable->pixel_format_from_gl_internal (ctx, gl_int_format, &format)) - return COGL_INVALID_HANDLE; + return NULL; } else #endif @@ -419,11 +419,11 @@ cogl_texture_2d_new_from_foreign (CoglContext *ctx, /* Validate width and height */ if (width <= 0 || height <= 0) - return COGL_INVALID_HANDLE; + return NULL; /* Compressed texture images not supported */ if (gl_compressed == GL_TRUE) - return COGL_INVALID_HANDLE; + return NULL; /* Note: previously this code would query the texture object for whether it has GL_GENERATE_MIPMAP enabled to determine whether to @@ -454,7 +454,7 @@ cogl_texture_2d_new_from_foreign (CoglContext *ctx, tex_2d->min_filter = GL_FALSE; tex_2d->mag_filter = GL_FALSE; - return _cogl_texture_2d_handle_new (tex_2d); + return _cogl_texture_2d_object_new (tex_2d); } #if defined (COGL_HAS_EGL_SUPPORT) && defined (EGL_KHR_image_base) @@ -500,7 +500,7 @@ _cogl_egl_texture_2d_new_from_image (CoglContext *ctx, return NULL; } - return _cogl_texture_2d_handle_new (tex_2d); + return _cogl_texture_2d_object_new (tex_2d); } #endif /* defined (COGL_HAS_EGL_SUPPORT) && defined (EGL_KHR_image_base) */ @@ -574,16 +574,16 @@ cogl_wayland_texture_2d_new_from_buffer (CoglContext *ctx, #endif /* COGL_HAS_WAYLAND_EGL_SERVER_SUPPORT */ void -_cogl_texture_2d_externally_modified (CoglHandle handle) +_cogl_texture_2d_externally_modified (CoglTexture *texture) { - if (!cogl_is_texture_2d (handle)) + if (!cogl_is_texture_2d (texture)) return; - COGL_TEXTURE_2D (handle)->mipmaps_dirty = TRUE; + COGL_TEXTURE_2D (texture)->mipmaps_dirty = TRUE; } void -_cogl_texture_2d_copy_from_framebuffer (CoglHandle handle, +_cogl_texture_2d_copy_from_framebuffer (CoglTexture2D *tex_2d, int dst_x, int dst_y, int src_x, @@ -591,13 +591,9 @@ _cogl_texture_2d_copy_from_framebuffer (CoglHandle handle, int width, int height) { - CoglTexture2D *tex_2d; - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - _COGL_RETURN_IF_FAIL (cogl_is_texture_2d (handle)); - - tex_2d = COGL_TEXTURE_2D (handle); + _COGL_RETURN_IF_FAIL (cogl_is_texture_2d (tex_2d)); /* Make sure the current framebuffers are bound, though we don't need to * flush the clip state here since we aren't going to draw to the diff --git a/cogl/cogl-texture-3d-private.h b/cogl/cogl-texture-3d-private.h index db7194e7..dec63907 100644 --- a/cogl/cogl-texture-3d-private.h +++ b/cogl/cogl-texture-3d-private.h @@ -25,7 +25,7 @@ #ifndef __COGL_TEXTURE_3D_PRIVATE_H #define __COGL_TEXTURE_3D_PRIVATE_H -#include "cogl-handle.h" +#include "cogl-object-private.h" #include "cogl-pipeline-private.h" #include "cogl-texture-private.h" #include "cogl-texture-3d.h" diff --git a/cogl/cogl-texture-3d.c b/cogl/cogl-texture-3d.c index c4500d5d..290b89b9 100644 --- a/cogl/cogl-texture-3d.c +++ b/cogl/cogl-texture-3d.c @@ -33,7 +33,7 @@ #include "cogl-texture-3d.h" #include "cogl-texture-driver.h" #include "cogl-context-private.h" -#include "cogl-handle.h" +#include "cogl-object-private.h" #include "cogl-journal-private.h" #include "cogl-pipeline-private.h" #include "cogl-pipeline-opengl-private.h" @@ -241,7 +241,7 @@ cogl_texture_3d_new_with_size (CoglContext *ctx, GE( ctx, glTexImage3D (GL_TEXTURE_3D, 0, gl_intformat, width, height, depth, 0, gl_format, gl_type, NULL) ); - return _cogl_texture_3d_handle_new (tex_3d); + return _cogl_texture_3d_object_new (tex_3d); } CoglTexture3D * @@ -325,7 +325,7 @@ cogl_texture_3d_new_from_bitmap (CoglBitmap *bmp, cogl_object_unref (dst_bmp); - return _cogl_texture_3d_handle_new (tex_3d); + return _cogl_texture_3d_object_new (tex_3d); } CoglTexture3D * diff --git a/cogl/cogl-texture-private.h b/cogl/cogl-texture-private.h index 505d5159..6d5dc7a0 100644 --- a/cogl/cogl-texture-private.h +++ b/cogl/cogl-texture-private.h @@ -25,7 +25,7 @@ #define __COGL_TEXTURE_PRIVATE_H #include "cogl-bitmap-private.h" -#include "cogl-handle.h" +#include "cogl-object-private.h" #include "cogl-pipeline-private.h" #include "cogl-spans.h" #include "cogl-meta-texture.h" @@ -181,12 +181,12 @@ void _cogl_texture_register_texture_type (const CoglObjectClass *klass); #define COGL_TEXTURE_DEFINE(TypeName, type_name) \ - COGL_HANDLE_DEFINE_WITH_CODE \ + COGL_OBJECT_DEFINE_WITH_CODE \ (TypeName, type_name, \ _cogl_texture_register_texture_type (&_cogl_##type_name##_class)) #define COGL_TEXTURE_INTERNAL_DEFINE(TypeName, type_name) \ - COGL_HANDLE_INTERNAL_DEFINE_WITH_CODE \ + COGL_OBJECT_INTERNAL_DEFINE_WITH_CODE \ (TypeName, type_name, \ _cogl_texture_register_texture_type (&_cogl_##type_name##_class)) diff --git a/cogl/cogl-texture-rectangle.c b/cogl/cogl-texture-rectangle.c index 192e0dc0..e50c699c 100644 --- a/cogl/cogl-texture-rectangle.c +++ b/cogl/cogl-texture-rectangle.c @@ -34,7 +34,7 @@ #include "cogl-texture-rectangle-private.h" #include "cogl-texture-driver.h" #include "cogl-context-private.h" -#include "cogl-handle.h" +#include "cogl-object-private.h" #include "cogl-journal-private.h" #include "cogl-pipeline-opengl-private.h" @@ -387,7 +387,7 @@ _cogl_texture_rectangle_new_from_foreign (GLuint gl_handle, tex_rect->min_filter = GL_FALSE; tex_rect->mag_filter = GL_FALSE; - return _cogl_texture_rectangle_handle_new (tex_rect); + return _cogl_texture_rectangle_object_new (tex_rect); } static int diff --git a/cogl/cogl-texture.c b/cogl/cogl-texture.c index 29489838..900ae9ee 100644 --- a/cogl/cogl-texture.c +++ b/cogl/cogl-texture.c @@ -47,7 +47,7 @@ #include "cogl-atlas-texture-private.h" #include "cogl-pipeline.h" #include "cogl-context-private.h" -#include "cogl-handle.h" +#include "cogl-object-private.h" #include "cogl-object-private.h" #include "cogl-primitives.h" #include "cogl-framebuffer-private.h" @@ -66,8 +66,8 @@ cogl_texture_error_quark (void) } /* XXX: - * The CoglHandle macros don't support any form of inheritance, so for - * now we implement the CoglHandle support for the CoglTexture + * The CoglObject macros don't support any form of inheritance, so for + * now we implement the CoglObject support for the CoglTexture * abstract class manually. */ @@ -320,7 +320,7 @@ cogl_texture_new_with_size (unsigned int width, { CoglTexture *tex; - _COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE); + _COGL_GET_CONTEXT (ctx, NULL); /* First try creating a fast-path non-sliced texture */ tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx, @@ -392,14 +392,14 @@ cogl_texture_new_from_bitmap (CoglBitmap *bitmap, CoglTextureFlags flags, CoglPixelFormat internal_format) { - CoglTexture *tex; + CoglAtlasTexture *atlas_tex; CoglTexture2D *tex_2d; /* First try putting the texture in the atlas */ - if ((tex = _cogl_atlas_texture_new_from_bitmap (bitmap, - flags, - internal_format))) - return tex; + if ((atlas_tex = _cogl_atlas_texture_new_from_bitmap (bitmap, + flags, + internal_format))) + return COGL_TEXTURE (atlas_tex); /* If that doesn't work try a fast path 2D texture */ if ((tex_2d = cogl_texture_2d_new_from_bitmap (bitmap, @@ -467,7 +467,7 @@ cogl_texture_new_from_foreign (GLuint gl_handle, CoglTextureRectangle *texture_rectangle; CoglSubTexture *sub_texture; - _COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE); + _COGL_GET_CONTEXT (ctx, NULL); if (x_pot_waste != 0 || y_pot_waste != 0) { @@ -475,7 +475,7 @@ cogl_texture_new_from_foreign (GLuint gl_handle, * the texture isn't limited to power of two sizes. */ g_warning ("You can't create a foreign GL_TEXTURE_RECTANGLE cogl " "texture with waste\n"); - return COGL_INVALID_HANDLE; + return NULL; } texture_rectangle = _cogl_texture_rectangle_new_from_foreign (gl_handle, @@ -503,7 +503,7 @@ cogl_texture_new_from_foreign (GLuint gl_handle, format)); else { - _COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE); + _COGL_GET_CONTEXT (ctx, NULL); return COGL_TEXTURE (cogl_texture_2d_new_from_foreign (ctx, gl_handle, width, diff --git a/cogl/cogl-texture.h b/cogl/cogl-texture.h index c73ea8a8..825e83df 100644 --- a/cogl/cogl-texture.h +++ b/cogl/cogl-texture.h @@ -239,7 +239,7 @@ cogl_texture_new_from_bitmap (CoglBitmap *bitmap, * * Gets whether the given object references a texture object. * - * Return value: %TRUE if the handle references a texture, and + * Return value: %TRUE if the @object references a texture, and * %FALSE otherwise */ gboolean diff --git a/cogl/cogl-types.h b/cogl/cogl-types.h index 215e08d4..6f3f3535 100644 --- a/cogl/cogl-types.h +++ b/cogl/cogl-types.h @@ -55,51 +55,10 @@ typedef struct { \ } _ ## TYPE ## SizeCheck /** - * CoglHandle: - * - * Type used for storing references to cogl objects, the CoglHandle is - * a fully opaque type without any public data members. - */ -typedef gpointer CoglHandle; - -/** - * COGL_INVALID_HANDLE: - * - * A COGL handle that is not valid, used for unitialized handles as well as - * error conditions. - */ -#define COGL_INVALID_HANDLE NULL - -#define COGL_TYPE_HANDLE (cogl_handle_get_type ()) -GType -cogl_handle_get_type (void) G_GNUC_CONST; - -/** - * cogl_handle_ref: - * @handle: a #CoglHandle - * - * Increases the reference count of @handle by 1 - * - * Return value: (transfer none): the handle, with its reference count increased - */ -CoglHandle -cogl_handle_ref (CoglHandle handle); - -/** - * cogl_handle_unref: - * @handle: a #CoglHandle - * - * Drecreases the reference count of @handle by 1; if the reference - * count reaches 0, the resources allocated by @handle will be freed - */ -void -cogl_handle_unref (CoglHandle handle); - -/** * cogl_object_ref: (skip) * @object: a #CoglObject * - * Increases the reference count of @handle by 1 + * Increases the reference count of @object by 1 * * Returns: the @object, with its reference count increased */ diff --git a/cogl/cogl-xlib.c b/cogl/cogl-xlib.c index 6c8ebea3..53078d99 100644 --- a/cogl/cogl-xlib.c +++ b/cogl/cogl-xlib.c @@ -32,7 +32,7 @@ #include <cogl-xlib.h> #include <cogl-internal.h> -#include <cogl-handle.h> +#include <cogl-object-private.h> #include <cogl-context-private.h> #include <cogl-framebuffer-private.h> #include <cogl-display-private.h> diff --git a/cogl/cogl.h b/cogl/cogl.h index 6f2a5d10..1984e3f6 100644 --- a/cogl/cogl.h +++ b/cogl/cogl.h @@ -68,7 +68,6 @@ #ifndef COGL_ENABLE_EXPERIMENTAL_2_0_API #include <cogl/cogl-clip-state.h> #include <cogl/cogl-enum-types.h> -#include <cogl/cogl-shader.h> #endif /* diff --git a/cogl/cogl.symbols b/cogl/cogl.symbols index a18f8399..9a9d2f92 100644 --- a/cogl/cogl.symbols +++ b/cogl/cogl.symbols @@ -290,10 +290,6 @@ cogl_glib_source_new /* cogl_gtype_matrix_get_type */ /* Not Implemented */ #endif -cogl_handle_get_type -cogl_handle_ref -cogl_handle_unref - cogl_has_feature cogl_has_features @@ -428,7 +424,6 @@ cogl_pipeline_get_point_size cogl_pipeline_get_shininess cogl_pipeline_get_specular cogl_pipeline_get_uniform_location -cogl_pipeline_get_user_program cogl_pipeline_new cogl_pipeline_set_alpha_test_function cogl_pipeline_set_ambient @@ -464,7 +459,6 @@ cogl_pipeline_set_uniform_int cogl_pipeline_set_uniform_matrix cogl_pipeline_set_uniform_1f cogl_pipeline_set_uniform_1i -cogl_pipeline_set_user_program cogl_pixel_buffer_new_EXP #if 0 diff --git a/cogl/cogl1-context.h b/cogl/cogl1-context.h index 519b8b07..a07bb56b 100644 --- a/cogl/cogl1-context.h +++ b/cogl/cogl1-context.h @@ -962,25 +962,6 @@ cogl_pop_framebuffer (void); #ifndef COGL_DISABLE_DEPRECATED /** - * cogl_set_draw_buffer: - * @target: A #CoglBufferTarget that specifies what kind of framebuffer you - * are setting as the render target. - * @offscreen: If you are setting a framebuffer of type COGL_OFFSCREEN_BUFFER - * then this is a CoglHandle for the offscreen buffer. - * - * Redirects all subsequent drawing to the specified framebuffer. This - * can either be an offscreen buffer created with - * cogl_offscreen_new_to_texture () or you can revert to your original - * on screen window buffer. - * - * Deprecated: 1.2: The target argument was redundant since we could look at - * the type of CoglHandle given instead. - */ -void -cogl_set_draw_buffer (CoglBufferTarget target, - CoglHandle offscreen) G_GNUC_DEPRECATED; - -/** * cogl_push_draw_buffer: * * Save cogl_set_draw_buffer() state. diff --git a/cogl/driver/gl/cogl-texture-driver-gl.c b/cogl/driver/gl/cogl-texture-driver-gl.c index bb8c67d2..4f8b8f57 100644 --- a/cogl/driver/gl/cogl-texture-driver-gl.c +++ b/cogl/driver/gl/cogl-texture-driver-gl.c @@ -37,7 +37,7 @@ #include "cogl-texture-private.h" #include "cogl-pipeline.h" #include "cogl-context-private.h" -#include "cogl-handle.h" +#include "cogl-object-private.h" #include "cogl-primitives.h" #include "cogl-pipeline-opengl-private.h" diff --git a/cogl/driver/gles/cogl-texture-driver-gles.c b/cogl/driver/gles/cogl-texture-driver-gles.c index bce772ef..0cbb9866 100644 --- a/cogl/driver/gles/cogl-texture-driver-gles.c +++ b/cogl/driver/gles/cogl-texture-driver-gles.c @@ -38,7 +38,7 @@ #include "cogl-pipeline.h" #include "cogl-pipeline-opengl-private.h" #include "cogl-context-private.h" -#include "cogl-handle.h" +#include "cogl-object-private.h" #include "cogl-primitives.h" #include <string.h> diff --git a/cogl/winsys/cogl-texture-pixmap-x11-private.h b/cogl/winsys/cogl-texture-pixmap-x11-private.h index 92b672c1..515aa05f 100644 --- a/cogl/winsys/cogl-texture-pixmap-x11-private.h +++ b/cogl/winsys/cogl-texture-pixmap-x11-private.h @@ -34,7 +34,7 @@ #include <GL/glx.h> #endif -#include "cogl-handle.h" +#include "cogl-object-private.h" #include "cogl-texture-private.h" #include "cogl-texture-pixmap-x11.h" @@ -53,7 +53,7 @@ struct _CoglTexturePixmapX11 CoglTexture _parent; Pixmap pixmap; - CoglHandle tex; + CoglTexture *tex; unsigned int depth; Visual *visual; diff --git a/cogl/winsys/cogl-texture-pixmap-x11.c b/cogl/winsys/cogl-texture-pixmap-x11.c index 3e6b12af..92e8c21a 100644 --- a/cogl/winsys/cogl-texture-pixmap-x11.c +++ b/cogl/winsys/cogl-texture-pixmap-x11.c @@ -43,7 +43,7 @@ #include "cogl-context-private.h" #include "cogl-display-private.h" #include "cogl-renderer-private.h" -#include "cogl-handle.h" +#include "cogl-object-private.h" #include "cogl-winsys-private.h" #include "cogl-pipeline-opengl-private.h" #include "cogl-xlib.h" @@ -290,7 +290,7 @@ cogl_texture_pixmap_x11_new (CoglContext *ctxt, tex_pixmap->pixmap = pixmap; tex_pixmap->image = NULL; tex_pixmap->shm_info.shmid = -1; - tex_pixmap->tex = COGL_INVALID_HANDLE; + tex_pixmap->tex = NULL; tex_pixmap->damage_owned = FALSE; tex_pixmap->damage = 0; @@ -354,7 +354,7 @@ cogl_texture_pixmap_x11_new (CoglContext *ctxt, if (!tex_pixmap->use_winsys_texture) tex_pixmap->winsys = NULL; - return _cogl_texture_pixmap_x11_handle_new (tex_pixmap); + return _cogl_texture_pixmap_x11_object_new (tex_pixmap); } /* Tries to allocate enough shared mem to handle a full size @@ -495,7 +495,7 @@ _cogl_texture_pixmap_x11_update_image_texture (CoglTexturePixmapX11 *tex_pixmap) /* We lazily create the texture the first time it is needed in case this texture can be entirely handled using the GLX texture instead */ - if (tex_pixmap->tex == COGL_INVALID_HANDLE) + if (tex_pixmap->tex == NULL) { CoglPixelFormat texture_format; @@ -638,10 +638,10 @@ _cogl_texture_pixmap_x11_update (CoglTexturePixmapX11 *tex_pixmap, _cogl_texture_pixmap_x11_update_image_texture (tex_pixmap); } -static CoglHandle +static CoglTexture * _cogl_texture_pixmap_x11_get_texture (CoglTexturePixmapX11 *tex_pixmap) { - CoglHandle tex; + CoglTexture *tex; int i; /* We try getting the texture twice, once without flushing the @@ -672,7 +672,7 @@ _cogl_texture_pixmap_x11_get_texture (CoglTexturePixmapX11 *tex_pixmap) g_assert_not_reached (); - return COGL_INVALID_HANDLE; + return NULL; } static gboolean @@ -697,9 +697,7 @@ _cogl_texture_pixmap_x11_get_data (CoglTexture *tex, guint8 *data) { CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex); - CoglHandle child_tex; - - child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap); + CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap); /* Forward on to the child texture */ return cogl_texture_get_data (child_tex, format, rowstride, data); @@ -743,7 +741,7 @@ _cogl_texture_pixmap_x11_foreach_sub_texture_in_region void *user_data) { CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex); - CoglHandle child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap); + CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap); /* Forward on to the child texture */ @@ -793,9 +791,7 @@ static int _cogl_texture_pixmap_x11_get_max_waste (CoglTexture *tex) { CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex); - CoglHandle child_tex; - - child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap); + CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap); return cogl_texture_get_max_waste (child_tex); } @@ -804,9 +800,7 @@ static gboolean _cogl_texture_pixmap_x11_is_sliced (CoglTexture *tex) { CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex); - CoglHandle child_tex; - - child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap); + CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap); return cogl_texture_is_sliced (child_tex); } @@ -815,9 +809,7 @@ static gboolean _cogl_texture_pixmap_x11_can_hardware_repeat (CoglTexture *tex) { CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex); - CoglHandle child_tex; - - child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap); + CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap); return _cogl_texture_can_hardware_repeat (child_tex); } @@ -828,9 +820,7 @@ _cogl_texture_pixmap_x11_transform_coords_to_gl (CoglTexture *tex, float *t) { CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex); - CoglHandle child_tex; - - child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap); + CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap); /* Forward on to the child texture */ _cogl_texture_transform_coords_to_gl (child_tex, s, t); @@ -841,9 +831,7 @@ _cogl_texture_pixmap_x11_transform_quad_coords_to_gl (CoglTexture *tex, float *coords) { CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex); - CoglHandle child_tex; - - child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap); + CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap); /* Forward on to the child texture */ return _cogl_texture_transform_quad_coords_to_gl (child_tex, coords); @@ -855,9 +843,7 @@ _cogl_texture_pixmap_x11_get_gl_texture (CoglTexture *tex, GLenum *out_gl_target) { CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex); - CoglHandle child_tex; - - child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap); + CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap); /* Forward on to the child texture */ return cogl_texture_get_gl_texture (child_tex, @@ -871,9 +857,7 @@ _cogl_texture_pixmap_x11_set_filters (CoglTexture *tex, GLenum mag_filter) { CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex); - CoglHandle child_tex; - - child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap); + CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap); /* Forward on to the child texture */ _cogl_texture_set_filters (child_tex, min_filter, mag_filter); @@ -884,7 +868,7 @@ _cogl_texture_pixmap_x11_pre_paint (CoglTexture *tex, CoglTexturePrePaintFlags flags) { CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex); - CoglHandle child_tex; + CoglTexture *child_tex; _cogl_texture_pixmap_x11_update (tex_pixmap, !!(flags & COGL_TEXTURE_NEEDS_MIPMAP)); @@ -898,9 +882,7 @@ static void _cogl_texture_pixmap_x11_ensure_non_quad_rendering (CoglTexture *tex) { CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex); - CoglHandle child_tex; - - child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap); + CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap); /* Forward on to the child texture */ _cogl_texture_ensure_non_quad_rendering (child_tex); @@ -913,9 +895,7 @@ _cogl_texture_pixmap_x11_set_wrap_mode_parameters (CoglTexture *tex, GLenum wrap_mode_p) { CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex); - CoglHandle child_tex; - - child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap); + CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap); /* Forward on to the child texture */ _cogl_texture_set_wrap_mode_parameters (child_tex, @@ -928,9 +908,7 @@ static CoglPixelFormat _cogl_texture_pixmap_x11_get_format (CoglTexture *tex) { CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex); - CoglHandle child_tex; - - child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap); + CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap); /* Forward on to the child texture */ return cogl_texture_get_format (child_tex); @@ -940,9 +918,7 @@ static GLenum _cogl_texture_pixmap_x11_get_gl_format (CoglTexture *tex) { CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex); - CoglHandle child_tex; - - child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap); + CoglTexture *child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap); return _cogl_texture_get_gl_format (child_tex); } @@ -993,7 +969,7 @@ _cogl_texture_pixmap_x11_free (CoglTexturePixmapX11 *tex_pixmap) } if (tex_pixmap->tex) - cogl_handle_unref (tex_pixmap->tex); + cogl_object_unref (tex_pixmap->tex); if (tex_pixmap->winsys) { diff --git a/cogl/winsys/cogl-winsys-egl-x11.c b/cogl/winsys/cogl-winsys-egl-x11.c index 55cbbc2d..61b1b6da 100644 --- a/cogl/winsys/cogl-winsys-egl-x11.c +++ b/cogl/winsys/cogl-winsys-egl-x11.c @@ -680,7 +680,7 @@ _cogl_winsys_texture_pixmap_x11_damage_notify (CoglTexturePixmapX11 *tex_pixmap) { } -static CoglHandle +static CoglTexture * _cogl_winsys_texture_pixmap_x11_get_texture (CoglTexturePixmapX11 *tex_pixmap) { CoglTexturePixmapEGL *egl_tex_pixmap = tex_pixmap->winsys; diff --git a/cogl/winsys/cogl-winsys-glx.c b/cogl/winsys/cogl-winsys-glx.c index b8ba90d9..4e0abfa9 100644 --- a/cogl/winsys/cogl-winsys-glx.c +++ b/cogl/winsys/cogl-winsys-glx.c @@ -88,7 +88,7 @@ typedef struct _CoglTexturePixmapGLX gboolean has_mipmap_space; gboolean can_mipmap; - CoglHandle glx_tex; + CoglTexture *glx_tex; gboolean bind_tex_image_queued; gboolean pixmap_bound; @@ -1715,7 +1715,7 @@ _cogl_winsys_texture_pixmap_x11_create (CoglTexturePixmapX11 *tex_pixmap) glx_tex_pixmap->can_mipmap = FALSE; glx_tex_pixmap->has_mipmap_space = FALSE; - glx_tex_pixmap->glx_tex = COGL_INVALID_HANDLE; + glx_tex_pixmap->glx_tex = NULL; glx_tex_pixmap->bind_tex_image_queued = TRUE; glx_tex_pixmap->pixmap_bound = FALSE; @@ -1793,7 +1793,7 @@ _cogl_winsys_texture_pixmap_x11_free (CoglTexturePixmapX11 *tex_pixmap) free_glx_pixmap (ctx, glx_tex_pixmap); if (glx_tex_pixmap->glx_tex) - cogl_handle_unref (glx_tex_pixmap->glx_tex); + cogl_object_unref (glx_tex_pixmap->glx_tex); tex_pixmap->winsys = NULL; g_free (glx_tex_pixmap); @@ -1817,7 +1817,7 @@ _cogl_winsys_texture_pixmap_x11_update (CoglTexturePixmapX11 *tex_pixmap, glx_renderer = ctx->display->renderer->winsys; /* Lazily create a texture to hold the pixmap */ - if (glx_tex_pixmap->glx_tex == COGL_INVALID_HANDLE) + if (glx_tex_pixmap->glx_tex == NULL) { CoglPixelFormat texture_format; GError *error = NULL; @@ -1828,12 +1828,12 @@ _cogl_winsys_texture_pixmap_x11_update (CoglTexturePixmapX11 *tex_pixmap, if (should_use_rectangle (ctx)) { - glx_tex_pixmap->glx_tex = + glx_tex_pixmap->glx_tex = COGL_TEXTURE ( cogl_texture_rectangle_new_with_size (ctx, tex_pixmap->width, tex_pixmap->height, texture_format, - &error); + &error)); if (glx_tex_pixmap->glx_tex) COGL_NOTE (TEXTURE_PIXMAP, "Created a texture rectangle for %p", @@ -1850,12 +1850,12 @@ _cogl_winsys_texture_pixmap_x11_update (CoglTexturePixmapX11 *tex_pixmap, } else { - glx_tex_pixmap->glx_tex = + glx_tex_pixmap->glx_tex = COGL_TEXTURE ( cogl_texture_2d_new_with_size (ctx, tex_pixmap->width, tex_pixmap->height, texture_format, - NULL); + NULL)); if (glx_tex_pixmap->glx_tex) COGL_NOTE (TEXTURE_PIXMAP, "Created a texture 2d for %p", @@ -1895,7 +1895,7 @@ _cogl_winsys_texture_pixmap_x11_update (CoglTexturePixmapX11 *tex_pixmap, "with mipmap support failed", tex_pixmap); if (glx_tex_pixmap->glx_tex) - cogl_handle_unref (glx_tex_pixmap->glx_tex); + cogl_object_unref (glx_tex_pixmap->glx_tex); return FALSE; } @@ -1953,7 +1953,7 @@ _cogl_winsys_texture_pixmap_x11_damage_notify (CoglTexturePixmapX11 *tex_pixmap) glx_tex_pixmap->bind_tex_image_queued = TRUE; } -static CoglHandle +static CoglTexture * _cogl_winsys_texture_pixmap_x11_get_texture (CoglTexturePixmapX11 *tex_pixmap) { CoglTexturePixmapGLX *glx_tex_pixmap = tex_pixmap->winsys; diff --git a/cogl/winsys/cogl-winsys-private.h b/cogl/winsys/cogl-winsys-private.h index 0e6c78b7..e924fff5 100644 --- a/cogl/winsys/cogl-winsys-private.h +++ b/cogl/winsys/cogl-winsys-private.h @@ -154,7 +154,7 @@ typedef struct _CoglWinsysVtable void (*texture_pixmap_x11_damage_notify) (CoglTexturePixmapX11 *tex_pixmap); - CoglHandle + CoglTexture * (*texture_pixmap_x11_get_texture) (CoglTexturePixmapX11 *tex_pixmap); #endif diff --git a/examples/cogl-msaa.c b/examples/cogl-msaa.c index 0b1b590e..446f443a 100644 --- a/examples/cogl-msaa.c +++ b/examples/cogl-msaa.c @@ -17,8 +17,8 @@ main (int argc, char **argv) {0.7, -0.7, 0x00, 0x00, 0xff, 0xff} }; CoglPrimitive *triangle; - CoglHandle tex; - CoglHandle offscreen; + CoglTexture *tex; + CoglOffscreen *offscreen; CoglFramebuffer *offscreen_fb; CoglPipeline *pipeline; diff --git a/tests/conform/test-materials.c b/tests/conform/test-materials.c index 84b1444d..ab483e85 100644 --- a/tests/conform/test-materials.c +++ b/tests/conform/test-materials.c @@ -85,7 +85,7 @@ test_invalid_texture_layers (TestState *state, int x, int y) /* explicitly create a layer with an invalid handle. This may be desireable * if the user also sets a texture combine string that e.g. refers to a * constant color. */ - cogl_material_set_layer (material, 0, COGL_INVALID_HANDLE); + cogl_material_set_layer (material, 0, NULL); cogl_set_source (material); @@ -172,7 +172,7 @@ test_invalid_texture_layers_with_constant_colors (TestState *state, CoglColor constant_color; /* explicitly create a layer with an invalid handle */ - cogl_material_set_layer (material, 0, COGL_INVALID_HANDLE); + cogl_material_set_layer (material, 0, NULL); /* ignore the fallback texture on the layer and use a constant color instead */ diff --git a/tests/conform/test-texture-rectangle.c b/tests/conform/test-texture-rectangle.c index d7cc354e..3aadd040 100644 --- a/tests/conform/test-texture-rectangle.c +++ b/tests/conform/test-texture-rectangle.c @@ -78,7 +78,7 @@ create_source_rect (void) #else /* GL_TEXTURE_RECTANGLE_ARB */ - return COGL_INVALID_HANDLE; + return NULL; #endif /* GL_TEXTURE_RECTANGLE_ARB */ } @@ -119,7 +119,7 @@ draw_frame (TestState *state) CoglHandle tex_2d = create_source_2d (); CoglHandle material_2d = cogl_material_new (); - g_assert (tex_rect != COGL_INVALID_HANDLE); + g_assert (tex_rect != NULL); cogl_material_set_layer (material_rect, 0, tex_rect); cogl_material_set_layer_filters (material_rect, 0, diff --git a/tests/conform/test-utils.c b/tests/conform/test-utils.c index 97f06fab..500ad23d 100644 --- a/tests/conform/test-utils.c +++ b/tests/conform/test-utils.c @@ -87,15 +87,15 @@ test_utils_init (TestFlags flags) } else { - CoglHandle offscreen; - CoglHandle tex = cogl_texture_2d_new_with_size (test_ctx, - FB_WIDTH, FB_HEIGHT, - COGL_PIXEL_FORMAT_ANY, - &error); + CoglOffscreen *offscreen; + CoglTexture2D *tex = cogl_texture_2d_new_with_size (test_ctx, + FB_WIDTH, FB_HEIGHT, + COGL_PIXEL_FORMAT_ANY, + &error); if (!tex) g_critical ("Failed to allocate texture: %s", error->message); - offscreen = cogl_offscreen_new_to_texture (tex); + offscreen = cogl_offscreen_new_to_texture (COGL_TEXTURE (tex)); test_fb = COGL_FRAMEBUFFER (offscreen); } |