diff --git a/clutter/clutter/clutter-backend.c b/clutter/clutter/clutter-backend.c index 32ac02e3088321fd5d826023a009e026e819f08d..d97d9275dc7850044776d769046155df37eafd76 100644 --- a/clutter/clutter/clutter-backend.c +++ b/clutter/clutter/clutter-backend.c @@ -26,7 +26,7 @@ /** * ClutterBackend: - * + * * Backend abstraction * * Clutter can be compiled against different backends. Each backend @@ -117,8 +117,9 @@ clutter_backend_do_real_create_context (ClutterBackend *backend, { ClutterBackendClass *klass; - klass = CLUTTER_BACKEND_GET_CLASS (backend); + cogl_init (); + klass = CLUTTER_BACKEND_GET_CLASS (backend); CLUTTER_NOTE (BACKEND, "Creating Cogl renderer"); backend->cogl_renderer = klass->get_renderer (backend, error); diff --git a/clutter/clutter/clutter-context.c b/clutter/clutter/clutter-context.c index 90f68ba1c5a9b1c53b9a3721884091e802fa037a..9a85b9aaf0558ea607ed2153bff4f29c3461d3f7 100644 --- a/clutter/clutter/clutter-context.c +++ b/clutter/clutter/clutter-context.c @@ -301,11 +301,15 @@ clutter_context_get_pango_fontmap (ClutterContext *context) CoglPangoFontMap *font_map; gdouble resolution; gboolean use_mipmapping; + ClutterBackend *backend; + CoglContext *cogl_context; if (G_LIKELY (context->font_map != NULL)) return context->font_map; - font_map = COGL_PANGO_FONT_MAP (cogl_pango_font_map_new ()); + backend = clutter_context_get_backend (context); + cogl_context = clutter_backend_get_cogl_context (backend); + font_map = COGL_PANGO_FONT_MAP (cogl_pango_font_map_new (cogl_context)); resolution = clutter_backend_get_resolution (context->backend); cogl_pango_font_map_set_resolution (font_map, resolution); diff --git a/cogl/cogl-pango/cogl-pango-fontmap.c b/cogl/cogl-pango/cogl-pango-fontmap.c index a3563585558c04d43f2d6cdac00f7cfc6a38c2fa..4d089c24215db24c60da80fb3b2c87b5ed6f47ea 100644 --- a/cogl/cogl-pango/cogl-pango-fontmap.c +++ b/cogl/cogl-pango/cogl-pango-fontmap.c @@ -57,13 +57,11 @@ free_priv (gpointer data) } PangoFontMap * -cogl_pango_font_map_new (void) +cogl_pango_font_map_new (CoglContext *context) { PangoFontMap *fm = pango_cairo_font_map_new (); g_autofree CoglPangoFontMapPriv *priv = g_new0 (CoglPangoFontMapPriv, 1); - _COGL_GET_CONTEXT (context, NULL); - priv->ctx = g_object_ref (context); /* XXX: The public pango api doesn't let us sub-class diff --git a/cogl/cogl-pango/cogl-pango-glyph-cache.c b/cogl/cogl-pango/cogl-pango-glyph-cache.c index 13ffa6b30fa884a2386497748b5f87324a316ac8..e92addac8516c9874735848cbe4e0b3508935eb1 100644 --- a/cogl/cogl-pango/cogl-pango-glyph-cache.c +++ b/cogl/cogl-pango/cogl-pango-glyph-cache.c @@ -261,6 +261,7 @@ cogl_pango_glyph_cache_add_to_global_atlas (CoglPangoGlyphCache *cache, static gboolean cogl_pango_glyph_cache_add_to_local_atlas (CoglPangoGlyphCache *cache, + CoglContext *context, PangoFont *font, PangoGlyph glyph, CoglPangoGlyphCacheValue *value) @@ -282,7 +283,8 @@ cogl_pango_glyph_cache_add_to_local_atlas (CoglPangoGlyphCache *cache, /* If we couldn't find one then start a new atlas */ if (atlas == NULL) { - atlas = _cogl_atlas_new (COGL_PIXEL_FORMAT_A_8, + atlas = _cogl_atlas_new (context, + COGL_PIXEL_FORMAT_A_8, COGL_ATLAS_CLEAR_TEXTURE | COGL_ATLAS_DISABLE_MIGRATION, cogl_pango_glyph_cache_update_position_cb); @@ -309,6 +311,7 @@ cogl_pango_glyph_cache_add_to_local_atlas (CoglPangoGlyphCache *cache, CoglPangoGlyphCacheValue * cogl_pango_glyph_cache_lookup (CoglPangoGlyphCache *cache, + CoglContext *context, gboolean create, PangoFont *font, PangoGlyph glyph) @@ -350,6 +353,7 @@ cogl_pango_glyph_cache_lookup (CoglPangoGlyphCache *cache, value) && /* If it fails try the local atlas */ !cogl_pango_glyph_cache_add_to_local_atlas (cache, + context, font, glyph, value)) diff --git a/cogl/cogl-pango/cogl-pango-glyph-cache.h b/cogl/cogl-pango/cogl-pango-glyph-cache.h index 8739c2329de135e1021a73078fd4d37bb4fbc785..1503c614e136e2d70d6011f1683eddd0ac6dec98 100644 --- a/cogl/cogl-pango/cogl-pango-glyph-cache.h +++ b/cogl/cogl-pango/cogl-pango-glyph-cache.h @@ -75,6 +75,7 @@ cogl_pango_glyph_cache_free (CoglPangoGlyphCache *cache); COGL_EXPORT CoglPangoGlyphCacheValue * cogl_pango_glyph_cache_lookup (CoglPangoGlyphCache *cache, + CoglContext *context, gboolean create, PangoFont *font, PangoGlyph glyph); diff --git a/cogl/cogl-pango/cogl-pango-render.c b/cogl/cogl-pango/cogl-pango-render.c index e88e87eecf2c286980386fee5b26df89af87129d..03fbda8392a62e73b74155e37725506668d65632 100644 --- a/cogl/cogl-pango/cogl-pango-render.c +++ b/cogl/cogl-pango/cogl-pango-render.c @@ -503,6 +503,7 @@ cogl_pango_renderer_get_cached_glyph (PangoRenderer *renderer, &priv->no_mipmap_caches); return cogl_pango_glyph_cache_lookup (caches->glyph_cache, + priv->ctx, create, font, glyph); } diff --git a/cogl/cogl-pango/cogl-pango.h b/cogl/cogl-pango/cogl-pango.h index 99b970db1e3331ae36544191c750a3013b8302cf..cf16ebd567c40c41d923719b97418d3913f452f5 100644 --- a/cogl/cogl-pango/cogl-pango.h +++ b/cogl/cogl-pango/cogl-pango.h @@ -73,7 +73,7 @@ typedef PangoCairoFontMap CoglPangoFontMap; * Return value: (transfer full): the newly created #PangoFontMap */ COGL_EXPORT PangoFontMap * -cogl_pango_font_map_new (void); +cogl_pango_font_map_new (CoglContext *context); /** * cogl_pango_font_map_create_context: @@ -92,9 +92,9 @@ cogl_pango_font_map_create_context (CoglPangoFontMap *font_map); * @dpi: The resolution in "dots per inch". (Physical inches aren't * actually involved; the terminology is conventional.) * - * Sets the resolution for the @font_map. - * - * This is a scale factor between points specified in a + * Sets the resolution for the @font_map. + * + * This is a scale factor between points specified in a * [struct@Pango.FontDescription] and Cogl units. * The default value is %96, meaning that a 10 point font will be 13 * units high. (10 * 96. / 72. = 13.3). diff --git a/cogl/cogl/cogl-atlas-texture.c b/cogl/cogl/cogl-atlas-texture.c index 7b4acfd6a7530adcd399d03c181fd6ab9a8aa8ab..2e0a13b27711aa15d1b1bf34e0693c12c32a4bea 100644 --- a/cogl/cogl/cogl-atlas-texture.c +++ b/cogl/cogl/cogl-atlas-texture.c @@ -44,14 +44,11 @@ #include "cogl/cogl-rectangle-map.h" #include "cogl/cogl-journal-private.h" #include "cogl/cogl-atlas.h" -#include "cogl/cogl1-context.h" #include "cogl/cogl-sub-texture.h" #include "cogl/driver/gl/cogl-texture-gl-private.h" #include -static GQuark atlas_private_key = 0; - G_DEFINE_FINAL_TYPE (CoglAtlasTexture, cogl_atlas_texture, COGL_TYPE_TEXTURE) static void @@ -141,7 +138,7 @@ _cogl_atlas_texture_pre_reorganize_cb (void *data) * We are assuming that texture atlas migration never happens * during a flush so we don't have to consider recursion here. */ - cogl_flush (); + cogl_context_flush (atlas->context); if (atlas->map) _cogl_rectangle_map_foreach (atlas->map, @@ -171,8 +168,6 @@ _cogl_atlas_texture_post_reorganize_cb (void *user_data) { CoglAtlas *atlas = user_data; - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - if (atlas->map) { CoglAtlasTextureGetRectanglesData data; @@ -204,24 +199,13 @@ _cogl_atlas_texture_post_reorganize_cb (void *user_data) } /* Notify any listeners that an atlas has changed */ - g_hook_list_invoke (&ctx->atlas_reorganize_callbacks, FALSE); -} - -static void -_cogl_atlas_texture_atlas_destroyed_cb (void *user_data) -{ - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - - /* Remove the atlas from the global list */ - ctx->atlases = g_slist_remove (ctx->atlases, user_data); + g_hook_list_invoke (&atlas->context->atlas_reorganize_callbacks, FALSE); } static CoglAtlas * _cogl_atlas_texture_create_atlas (CoglContext *ctx) { - atlas_private_key = g_quark_from_static_string ("-cogl-atlas-texture-create-key"); - - CoglAtlas *atlas = _cogl_atlas_new (COGL_PIXEL_FORMAT_RGBA_8888, + CoglAtlas *atlas = _cogl_atlas_new (ctx, COGL_PIXEL_FORMAT_RGBA_8888, 0, _cogl_atlas_texture_update_position_cb); @@ -231,17 +215,6 @@ _cogl_atlas_texture_create_atlas (CoglContext *ctx) atlas); ctx->atlases = g_slist_prepend (ctx->atlases, atlas); - - /* Set some data on the atlas so we can get notification when it is - destroyed in order to remove it from the list. ctx->atlases - effectively holds a weak reference. We don't need a strong - reference because the atlas textures take a reference on the - atlas so it will stay alive */ - g_object_set_qdata_full (G_OBJECT (atlas), - atlas_private_key, - atlas, - _cogl_atlas_texture_atlas_destroyed_cb); - return atlas; } @@ -362,11 +335,13 @@ static void _cogl_atlas_texture_migrate_out_of_atlas (CoglAtlasTexture *atlas_tex) { CoglTexture *standalone_tex; + CoglContext *ctx; /* Make sure this texture is not in the atlas */ if (!atlas_tex->atlas) return; + ctx = cogl_texture_get_context (COGL_TEXTURE (atlas_tex)); COGL_NOTE (ATLAS, "Migrating texture out of the atlas"); /* We don't know if any journal entries currently depend on @@ -377,7 +352,7 @@ _cogl_atlas_texture_migrate_out_of_atlas (CoglAtlasTexture *atlas_tex) * We are assuming that texture atlas migration never happens * during a flush so we don't have to consider recursion here. */ - cogl_flush (); + cogl_context_flush (ctx); standalone_tex = _cogl_atlas_copy_rectangle (atlas_tex->atlas, diff --git a/cogl/cogl/cogl-atlas.c b/cogl/cogl/cogl-atlas.c index cb8c8a51a2797f1d2d147f8f33adf905d843a257..a154655bd041dec3e6a0f3424ccc1109a172b38a 100644 --- a/cogl/cogl/cogl-atlas.c +++ b/cogl/cogl/cogl-atlas.c @@ -54,8 +54,11 @@ cogl_atlas_dispose (GObject *object) COGL_NOTE (ATLAS, "%p: Atlas destroyed", atlas); - if (atlas->texture) - g_object_unref (atlas->texture); + /* Remove the atlas from the global list */ + atlas->context->atlases = g_slist_remove (atlas->context->atlases, atlas); + + g_clear_object (&atlas->texture); + g_clear_object (&atlas->context); if (atlas->map) _cogl_rectangle_map_free (atlas->map); @@ -79,7 +82,8 @@ cogl_atlas_class_init (CoglAtlasClass *class) } CoglAtlas * -_cogl_atlas_new (CoglPixelFormat texture_format, +_cogl_atlas_new (CoglContext *context, + CoglPixelFormat texture_format, CoglAtlasFlags flags, CoglAtlasUpdatePositionCallback update_position_cb) { @@ -88,6 +92,7 @@ _cogl_atlas_new (CoglPixelFormat texture_format, atlas->update_position_cb = update_position_cb; atlas->map = NULL; atlas->texture = NULL; + atlas->context = g_object_ref (context); atlas->flags = flags; atlas->texture_format = texture_format; g_hook_list_init (&atlas->pre_reorganize_callbacks, sizeof (GHook)); @@ -183,7 +188,8 @@ _cogl_atlas_get_next_size (unsigned int *map_width, } static void -_cogl_atlas_get_initial_size (CoglPixelFormat format, +_cogl_atlas_get_initial_size (CoglContext *ctx, + CoglPixelFormat format, unsigned int *map_width, unsigned int *map_height) { @@ -192,8 +198,6 @@ _cogl_atlas_get_initial_size (CoglPixelFormat format, GLenum gl_format; GLenum gl_type; - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - g_return_if_fail (cogl_pixel_format_get_n_planes (format) == 1); ctx->driver_vtable->pixel_format_to_gl (ctx, @@ -228,7 +232,8 @@ _cogl_atlas_get_initial_size (CoglPixelFormat format, } static CoglRectangleMap * -_cogl_atlas_create_map (CoglPixelFormat format, +_cogl_atlas_create_map (CoglContext *ctx, + CoglPixelFormat format, unsigned int map_width, unsigned int map_height, unsigned int n_textures, @@ -238,8 +243,6 @@ _cogl_atlas_create_map (CoglPixelFormat format, GLenum gl_format; GLenum gl_type; - _COGL_GET_CONTEXT (ctx, NULL); - ctx->driver_vtable->pixel_format_to_gl (ctx, format, &gl_intformat, @@ -299,8 +302,6 @@ _cogl_atlas_create_texture (CoglAtlas *atlas, CoglTexture *tex; GError *ignore_error = NULL; - _COGL_GET_CONTEXT (ctx, NULL); - g_return_val_if_fail ( cogl_pixel_format_get_n_planes (atlas->texture_format) == 1, NULL); @@ -314,7 +315,7 @@ _cogl_atlas_create_texture (CoglAtlas *atlas, /* Create a buffer of zeroes to initially clear the texture */ clear_data = g_malloc0 (width * height * bpp); - clear_bmp = cogl_bitmap_new_for_data (ctx, + clear_bmp = cogl_bitmap_new_for_data (atlas->context, width, height, atlas->texture_format, @@ -339,7 +340,7 @@ _cogl_atlas_create_texture (CoglAtlas *atlas, } else { - tex = cogl_texture_2d_new_with_size (ctx, width, height); + tex = cogl_texture_2d_new_with_size (atlas->context, width, height); _cogl_texture_set_internal_format (tex, atlas->texture_format); @@ -469,10 +470,12 @@ _cogl_atlas_reserve_space (CoglAtlas *atlas, _cogl_atlas_get_next_size (&map_width, &map_height); } else - _cogl_atlas_get_initial_size (atlas->texture_format, + _cogl_atlas_get_initial_size (atlas->context, + atlas->texture_format, &map_width, &map_height); - new_map = _cogl_atlas_create_map (atlas->texture_format, + new_map = _cogl_atlas_create_map (atlas->context, + atlas->texture_format, map_width, map_height, data.n_textures, data.textures); @@ -623,10 +626,8 @@ _cogl_atlas_copy_rectangle (CoglAtlas *atlas, CoglBlitData blit_data; GError *ignore_error = NULL; - _COGL_GET_CONTEXT (ctx, NULL); - /* Create a new texture at the right size */ - tex = create_migration_texture (ctx, width, height, internal_format); + tex = create_migration_texture (atlas->context, width, height, internal_format); if (!cogl_texture_allocate (tex, &ignore_error)) { g_error_free (ignore_error); diff --git a/cogl/cogl/cogl-atlas.h b/cogl/cogl/cogl-atlas.h index ac5c8df102be82c747c2d526a7196508f9245259..62172849f831eb440a9d2fe0baffa2b7f5aff118 100644 --- a/cogl/cogl/cogl-atlas.h +++ b/cogl/cogl/cogl-atlas.h @@ -58,6 +58,7 @@ struct _CoglAtlas GObject parent_instance; CoglRectangleMap *map; + CoglContext *context; CoglTexture *texture; CoglPixelFormat texture_format; @@ -70,8 +71,9 @@ struct _CoglAtlas }; COGL_EXPORT CoglAtlas * -_cogl_atlas_new (CoglPixelFormat texture_format, - CoglAtlasFlags flags, +_cogl_atlas_new (CoglContext *context, + CoglPixelFormat texture_format, + CoglAtlasFlags flags, CoglAtlasUpdatePositionCallback update_position_cb); COGL_EXPORT gboolean diff --git a/cogl/cogl/cogl-blend-string.c b/cogl/cogl/cogl-blend-string.c index 50af35090b2e44fd81c48b793a31ec7074ec7a03..0f60dfbf999f65673e960dc7ae33c34f07f54328 100644 --- a/cogl/cogl/cogl-blend-string.c +++ b/cogl/cogl/cogl-blend-string.c @@ -214,8 +214,6 @@ validate_blend_statements (CoglBlendStringStatement *statements, const char *error_string; CoglBlendStringError detail = COGL_BLEND_STRING_ERROR_INVALID_ERROR; - _COGL_GET_CONTEXT (ctx, 0); - for (i = 0; i < n_statements; i++) for (j = 0; j < statements[i].function->argc; j++) { diff --git a/cogl/cogl/cogl-blit.c b/cogl/cogl/cogl-blit.c index 0468b7f35250e0522c83a784d88d6b873e9459ad..817358500ed8435b527a13bfff5d243efd111718 100644 --- a/cogl/cogl/cogl-blit.c +++ b/cogl/cogl/cogl-blit.c @@ -41,7 +41,6 @@ #include "cogl/cogl-texture-private.h" #include "cogl/cogl-texture-2d-private.h" #include "cogl/cogl-private.h" -#include "cogl/cogl1-context.h" static const CoglBlitMode *_cogl_blit_default_mode = NULL; diff --git a/cogl/cogl/cogl-clip-stack.c b/cogl/cogl/cogl-clip-stack.c index fac0d02ce3ccf52e354e495cdea589b80c22b425..fc3af5a0d80eb3362e2c0922334d78eb1270f19d 100644 --- a/cogl/cogl/cogl-clip-stack.c +++ b/cogl/cogl/cogl-clip-stack.c @@ -44,7 +44,6 @@ #include "cogl/cogl-private.h" #include "cogl/cogl-attribute-private.h" #include "cogl/cogl-primitive-private.h" -#include "cogl/cogl1-context.h" #include "cogl/cogl-offscreen.h" #include "cogl/cogl-matrix-stack.h" #include "mtk/mtk.h" diff --git a/cogl/cogl/cogl-context-private.h b/cogl/cogl/cogl-context-private.h index 70d101a13ec53f3a0f8ca4db8e00b94b902132a5..09931a85bb9c53560025e285d2a0581c4b4cb176 100644 --- a/cogl/cogl/cogl-context-private.h +++ b/cogl/cogl/cogl-context-private.h @@ -276,9 +276,6 @@ struct _CoglContext #undef COGL_EXT_END }; -COGL_EXPORT CoglContext * -_cogl_context_get_default (void); - const CoglWinsysVtable * _cogl_context_get_winsys (CoglContext *context); @@ -292,13 +289,6 @@ gboolean _cogl_context_update_features (CoglContext *context, GError **error); -/* Obtains the context and returns retval if NULL */ -#define _COGL_GET_CONTEXT(ctxvar, retval) \ -CoglContext *ctxvar = _cogl_context_get_default (); \ -if (ctxvar == NULL) return retval; - -#define NO_RETVAL - void _cogl_context_set_current_projection_entry (CoglContext *context, CoglMatrixEntry *entry); diff --git a/cogl/cogl/cogl-context.c b/cogl/cogl/cogl-context.c index 4a352938b379ad78adf20a4f158aba3401eef58b..2c22b70ce8c99401cbf4f62e636c17718f695cfa 100644 --- a/cogl/cogl/cogl-context.c +++ b/cogl/cogl/cogl-context.c @@ -45,7 +45,6 @@ #include "cogl/cogl-framebuffer-private.h" #include "cogl/cogl-onscreen-private.h" #include "cogl/cogl-attribute-private.h" -#include "cogl/cogl1-context.h" #include "cogl/winsys/cogl-winsys-private.h" #include @@ -161,8 +160,6 @@ cogl_context_class_init (CoglContextClass *class) extern void _cogl_create_context_driver (CoglContext *context); -static CoglContext *_cogl_context = NULL; - static void _cogl_init_feature_overrides (CoglContext *ctx) { @@ -183,14 +180,14 @@ CoglContext * cogl_context_new (CoglDisplay *display, GError **error) { + g_return_val_if_fail (display != NULL, NULL); + CoglContext *context; uint8_t white_pixel[] = { 0xff, 0xff, 0xff, 0xff }; const CoglWinsysVtable *winsys; int i; GError *local_error = NULL; - _cogl_init (); - #ifdef COGL_ENABLE_PROFILE /* We need to be absolutely sure that uprof has been initialized * before calling _cogl_uprof_init. uprof_init (NULL, NULL) @@ -210,44 +207,14 @@ cogl_context_new (CoglDisplay *display, /* Allocate context memory */ context = g_object_new (COGL_TYPE_CONTEXT, NULL); - /* XXX: Gross hack! - * Currently everything in Cogl just assumes there is a default - * context which it can access via _COGL_GET_CONTEXT() including - * code used to construct a CoglContext. Until all of that code - * has been updated to take an explicit context argument we have - * to immediately make our pointer the default context. - */ - _cogl_context = context; - /* Init default values */ memset (context->features, 0, sizeof (context->features)); memset (context->private_features, 0, sizeof (context->private_features)); memset (context->winsys_features, 0, sizeof (context->winsys_features)); - if (!display) - { - CoglRenderer *renderer = cogl_renderer_new (); - if (!cogl_renderer_connect (renderer, error)) - { - g_object_unref (renderer); - g_object_unref (context); - return NULL; - } - - display = cogl_display_new (renderer, NULL); - g_object_unref (renderer); - } - else - g_object_ref (display); - - if (!cogl_display_setup (display, error)) - { - g_object_unref (display); - g_object_unref (context); - return NULL; - } - - context->display = display; + context->display = g_object_ref (display); + /* Keep a backpointer to the context */ + display->context = context; /* This is duplicated data, but it's much more convenient to have the driver attached to the context and the value is accessed a @@ -408,25 +375,6 @@ cogl_context_new (CoglDisplay *display, return context; } -CoglContext * -_cogl_context_get_default (void) -{ - GError *error = NULL; - /* Create if doesn't exist yet */ - if (_cogl_context == NULL) - { - _cogl_context = cogl_context_new (NULL, &error); - if (!_cogl_context) - { - g_warning ("Failed to create default context: %s", - error->message); - g_error_free (error); - } - } - - return _cogl_context; -} - CoglDisplay * cogl_context_get_display (CoglContext *context) { @@ -567,3 +515,20 @@ cogl_context_get_gpu_time_ns (CoglContext *context) return context->driver_vtable->get_gpu_time_ns (context); } + +/* FIXME: we should distinguish renderer and context features */ +gboolean +cogl_context_has_winsys_feature (CoglContext *context, + CoglWinsysFeature feature) +{ + return COGL_FLAGS_GET (context->winsys_features, feature); +} + +void +cogl_context_flush (CoglContext *context) +{ + GList *l; + + for (l = context->framebuffers; l; l = l->next) + _cogl_framebuffer_flush_journal (l->data); +} diff --git a/cogl/cogl/cogl-context.h b/cogl/cogl/cogl-context.h index f6e383e9ad63313efadb1e72fc13c08e19c6745f..fcc32a16910fcc8d259ffbabc7945c6a6a0fef5f 100644 --- a/cogl/cogl/cogl-context.h +++ b/cogl/cogl/cogl-context.h @@ -342,4 +342,35 @@ cogl_context_get_gpu_time_ns (CoglContext *context); COGL_EXPORT int cogl_context_get_latest_sync_fd (CoglContext *context); +COGL_EXPORT gboolean +cogl_context_has_winsys_feature (CoglContext *context, + CoglWinsysFeature feature); +/** + * cogl_context_flush: + * @context: A #CoglContext + * + * This function should only need to be called in exceptional circumstances. + * + * As an optimization Cogl drawing functions may batch up primitives + * internally, so if you are trying to use raw GL outside of Cogl you stand a + * better chance of being successful if you ask Cogl to flush any batched + * geometry before making your state changes. + * + * It only ensure that the underlying driver is issued all the commands + * necessary to draw the batched primitives. It provides no guarantees about + * when the driver will complete the rendering. + * + * This provides no guarantees about the GL state upon returning and to avoid + * confusing Cogl you should aim to restore any changes you make before + * resuming use of Cogl. + * + * If you are making state changes with the intention of affecting Cogl drawing + * primitives you are 100% on your own since you stand a good chance of + * conflicting with Cogl internals. For example clutter-gst which currently + * uses direct GL calls to bind ARBfp programs will very likely break when Cogl + * starts to use ARBfb programs itself for the material API. + */ +COGL_EXPORT void +cogl_context_flush (CoglContext *context); + G_END_DECLS diff --git a/cogl/cogl/cogl-debug.c b/cogl/cogl/cogl-debug.c index 2cf0eeb3b1e71bfa6f1532416392de5cb474eb4d..764a86176e70d8dc301cd4b8d4b7e0acf6d665ec 100644 --- a/cogl/cogl/cogl-debug.c +++ b/cogl/cogl/cogl-debug.c @@ -35,7 +35,6 @@ #include "cogl/cogl-i18n-private.h" #include "cogl/cogl-private.h" #include "cogl/cogl-debug.h" -#include "cogl/cogl1-context.h" /* XXX: If you add a debug option, please also add an option * definition to cogl-debug-options.h. This will enable us - for diff --git a/cogl/cogl/cogl-display-private.h b/cogl/cogl/cogl-display-private.h index d88a0847b2b0358c3693e05162970c4bd42f10d1..d09c994b16738497ac9ff1306adcff864250433d 100644 --- a/cogl/cogl/cogl-display-private.h +++ b/cogl/cogl/cogl-display-private.h @@ -38,6 +38,8 @@ struct _CoglDisplay { GObjectClass parnet_class; + CoglContext *context; + gboolean setup; CoglRenderer *renderer; CoglOnscreenTemplate *onscreen_template; diff --git a/cogl/cogl/cogl-display.c b/cogl/cogl/cogl-display.c index 16a50d05836e625aed7c5d54eff3effe63c201b1..796031db800fe61cf05a4709bc9ada436bef79c2 100644 --- a/cogl/cogl/cogl-display.c +++ b/cogl/cogl/cogl-display.c @@ -85,20 +85,12 @@ CoglDisplay * cogl_display_new (CoglRenderer *renderer, CoglOnscreenTemplate *onscreen_template) { - CoglDisplay *display = g_object_new (COGL_TYPE_DISPLAY, NULL); - GError *error = NULL; - - _cogl_init (); + g_return_val_if_fail (renderer != NULL, NULL); - display->renderer = renderer; - if (renderer) - g_object_ref (renderer); - else - display->renderer = cogl_renderer_new (); - - if (!cogl_renderer_connect (display->renderer, &error)) - g_error ("Failed to connect to renderer: %s\n", error->message); + CoglDisplay *display = g_object_new (COGL_TYPE_DISPLAY, NULL); + display->renderer = g_object_ref (renderer); + renderer->display = display; display->setup = FALSE; cogl_display_set_onscreen_template (display, onscreen_template); diff --git a/cogl/cogl/cogl-feature-private.c b/cogl/cogl/cogl-feature-private.c index 1ef42b87ddfad67cbf83a883c8cef7294f6eb69c..1f986188efca7ae301ab026257cc7586d051f980 100644 --- a/cogl/cogl/cogl-feature-private.c +++ b/cogl/cogl/cogl-feature-private.c @@ -143,8 +143,8 @@ _cogl_feature_check (CoglRenderer *renderer, full_function_name = g_strconcat (data->functions[func_num].name, suffix, NULL); - func = _cogl_renderer_get_proc_address (renderer, - full_function_name); + func = cogl_renderer_get_proc_address (renderer, + full_function_name); g_free (full_function_name); if (func == NULL) diff --git a/cogl/cogl/cogl-framebuffer.c b/cogl/cogl/cogl-framebuffer.c index 1df320a30b329a9c632f71f47ed283465f1cad0d..780c2aab8424a2703e98e0b92b315c7ed6bde9d6 100644 --- a/cogl/cogl/cogl-framebuffer.c +++ b/cogl/cogl/cogl-framebuffer.c @@ -46,7 +46,6 @@ #include "cogl/cogl-pipeline-state-private.h" #include "cogl/cogl-primitive-private.h" #include "cogl/cogl-offscreen.h" -#include "cogl/cogl1-context.h" #include "cogl/cogl-private.h" #include "cogl/cogl-primitives-private.h" #include "cogl/cogl-trace.h" diff --git a/cogl/cogl/cogl-journal.c b/cogl/cogl/cogl-journal.c index 4fbba6871709173acb1fa1a07e230d89f7e2ea4a..0e3ffa367b5362b2d9408ceaeda85ee8cade99e3 100644 --- a/cogl/cogl/cogl-journal.c +++ b/cogl/cogl/cogl-journal.c @@ -43,7 +43,6 @@ #include "cogl/cogl-point-in-poly-private.h" #include "cogl/cogl-trace.h" #include "cogl/cogl-private.h" -#include "cogl/cogl1-context.h" #include #include diff --git a/cogl/cogl/cogl-mutter.h b/cogl/cogl/cogl-mutter.h index aadbb63eb9fc45b4f673dd64ebf1810bd4a3bb6c..cf02b1a49282e9ec77a51cecddea78ee8c485596 100644 --- a/cogl/cogl/cogl-mutter.h +++ b/cogl/cogl/cogl-mutter.h @@ -55,3 +55,6 @@ void cogl_renderer_set_custom_winsys (CoglRenderer *renderer, COGL_EXPORT gboolean cogl_context_format_supports_upload (CoglContext *ctx, CoglPixelFormat format); + +COGL_EXPORT +void cogl_init (void); diff --git a/cogl/cogl/cogl-onscreen.c b/cogl/cogl/cogl-onscreen.c index 71a9367224dfc85ebbec35ec8ad68e1f238cd6ae..93245267d85b5b17e9b4d2ba909a6f6ef98c0ab0 100644 --- a/cogl/cogl/cogl-onscreen.c +++ b/cogl/cogl/cogl-onscreen.c @@ -38,7 +38,6 @@ #include "cogl/cogl-framebuffer-private.h" #include "cogl/cogl-onscreen-template-private.h" #include "cogl/cogl-context-private.h" -#include "cogl/cogl1-context.h" #include "cogl/cogl-closure-list-private.h" #include "cogl/cogl-poll-private.h" @@ -334,7 +333,7 @@ cogl_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen, info, user_data); - if (!_cogl_winsys_has_feature (COGL_WINSYS_FEATURE_SYNC_AND_COMPLETE_EVENT)) + if (!cogl_context_has_winsys_feature (context, COGL_WINSYS_FEATURE_SYNC_AND_COMPLETE_EVENT)) { g_autoptr (CoglFrameInfo) pending_info = NULL; @@ -367,6 +366,7 @@ cogl_onscreen_swap_region (CoglOnscreen *onscreen, CoglOnscreenPrivate *priv = cogl_onscreen_get_instance_private (onscreen); CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen); CoglOnscreenClass *klass = COGL_ONSCREEN_GET_CLASS (onscreen); + CoglContext *context = cogl_framebuffer_get_context (framebuffer); g_return_if_fail (COGL_IS_ONSCREEN (framebuffer)); @@ -392,7 +392,7 @@ cogl_onscreen_swap_region (CoglOnscreen *onscreen, info, user_data); - if (!_cogl_winsys_has_feature (COGL_WINSYS_FEATURE_SYNC_AND_COMPLETE_EVENT)) + if (!cogl_context_has_winsys_feature (context, COGL_WINSYS_FEATURE_SYNC_AND_COMPLETE_EVENT)) { g_autoptr (CoglFrameInfo) pending_info = NULL; @@ -431,9 +431,10 @@ cogl_onscreen_direct_scanout (CoglOnscreen *onscreen, CoglOnscreenPrivate *priv = cogl_onscreen_get_instance_private (onscreen); CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen); CoglOnscreenClass *klass = COGL_ONSCREEN_GET_CLASS (onscreen); + CoglContext *context = cogl_framebuffer_get_context (framebuffer); g_warn_if_fail (COGL_IS_ONSCREEN (framebuffer)); - g_warn_if_fail (_cogl_winsys_has_feature (COGL_WINSYS_FEATURE_SYNC_AND_COMPLETE_EVENT)); + g_warn_if_fail (cogl_context_has_winsys_feature (context, COGL_WINSYS_FEATURE_SYNC_AND_COMPLETE_EVENT)); if (!klass->direct_scanout) { diff --git a/cogl/cogl/cogl-pipeline-debug.c b/cogl/cogl/cogl-pipeline-debug.c index 455ffaec8cb45858c80d4923ebe04eee73b7d94e..2e4ff70743c7c653426e19248a20ec4a71401db1 100644 --- a/cogl/cogl/cogl-pipeline-debug.c +++ b/cogl/cogl/cogl-pipeline-debug.c @@ -241,10 +241,12 @@ dump_pipeline_cb (CoglNode *node, void *user_data) want to put a declaration in a header and we just add it here to avoid a warning */ void -_cogl_debug_dump_pipelines_dot_file (const char *filename); +_cogl_debug_dump_pipelines_dot_file (const char *filename, + CoglContext *ctx); void -_cogl_debug_dump_pipelines_dot_file (const char *filename) +_cogl_debug_dump_pipelines_dot_file (const char *filename, + CoglContext *ctx) { GString *graph; PrintDebugState layer_state; @@ -252,8 +254,6 @@ _cogl_debug_dump_pipelines_dot_file (const char *filename) int layer_id = 0; int pipeline_id = 0; - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - if (!ctx->default_pipeline) return; diff --git a/cogl/cogl/cogl-pipeline-layer-state.c b/cogl/cogl/cogl-pipeline-layer-state.c index 4d1a3e7a07d783418de18d1e839c33f949c9b28d..95d44514f66e08513af4836217c0194fbac397ce 100644 --- a/cogl/cogl/cogl-pipeline-layer-state.c +++ b/cogl/cogl/cogl-pipeline-layer-state.c @@ -303,8 +303,7 @@ cogl_pipeline_set_layer_wrap_mode_s (CoglPipeline *pipeline, CoglSamplerCacheWrapMode internal_mode = public_to_internal_wrap_mode (mode); const CoglSamplerCacheEntry *sampler_state; - - _COGL_GET_CONTEXT (ctx, NO_RETVAL); + CoglContext *ctx = pipeline->context; g_return_if_fail (COGL_IS_PIPELINE (pipeline)); @@ -343,11 +342,12 @@ cogl_pipeline_set_layer_wrap_mode_t (CoglPipeline *pipeline, CoglSamplerCacheWrapMode internal_mode = public_to_internal_wrap_mode (mode); const CoglSamplerCacheEntry *sampler_state; - - _COGL_GET_CONTEXT (ctx, NO_RETVAL); + CoglContext *ctx; g_return_if_fail (COGL_IS_PIPELINE (pipeline)); + ctx = pipeline->context; + /* Note: this will ensure that the layer exists, creating one if it * doesn't already. * @@ -383,11 +383,11 @@ cogl_pipeline_set_layer_wrap_mode (CoglPipeline *pipeline, CoglSamplerCacheWrapMode internal_mode = public_to_internal_wrap_mode (mode); const CoglSamplerCacheEntry *sampler_state; - - _COGL_GET_CONTEXT (ctx, NO_RETVAL); + CoglContext *ctx; g_return_if_fail (COGL_IS_PIPELINE (pipeline)); + ctx = pipeline->context; /* Note: this will ensure that the layer exists, creating one if it * doesn't already. * @@ -510,8 +510,6 @@ cogl_pipeline_set_layer_point_sprite_coords_enabled (CoglPipeline *pipeline, CoglPipelineLayer *new; CoglPipelineLayer *authority; - _COGL_GET_CONTEXT (ctx, FALSE); - g_return_val_if_fail (COGL_IS_PIPELINE (pipeline), FALSE); /* Note: this will ensure that the layer exists, creating one if it @@ -1268,14 +1266,14 @@ cogl_pipeline_set_layer_filters (CoglPipeline *pipeline, CoglPipelineLayer *layer; CoglPipelineLayer *authority; const CoglSamplerCacheEntry *sampler_state; - - _COGL_GET_CONTEXT (ctx, NO_RETVAL); + CoglContext *ctx; g_return_if_fail (COGL_IS_PIPELINE (pipeline)); g_return_if_fail (mag_filter == COGL_PIPELINE_FILTER_NEAREST || mag_filter == COGL_PIPELINE_FILTER_LINEAR); + ctx = pipeline->context; /* Note: this will ensure that the layer exists, creating one if it * doesn't already. * diff --git a/cogl/cogl/cogl-pipeline-state.c b/cogl/cogl/cogl-pipeline-state.c index 3caf6f922f8a1960b22e340c4122de0b33a8ad94..982b30bea8fe88149354f63bad19dc8d4fb4ff50 100644 --- a/cogl/cogl/cogl-pipeline-state.c +++ b/cogl/cogl/cogl-pipeline-state.c @@ -86,8 +86,6 @@ _cogl_pipeline_blend_state_equal (CoglPipeline *authority0, CoglPipelineBlendState *blend_state0 = &authority0->big_state->blend_state; CoglPipelineBlendState *blend_state1 = &authority1->big_state->blend_state; - _COGL_GET_CONTEXT (ctx, FALSE); - if (blend_state0->blend_equation_rgb != blend_state1->blend_equation_rgb) return FALSE; @@ -217,8 +215,7 @@ _cogl_pipeline_get_all_uniform_values (CoglPipeline *pipeline, const CoglBoxedValue **values) { GetUniformsClosure data; - - _COGL_GET_CONTEXT (ctx, NO_RETVAL); + CoglContext *ctx = pipeline->context; memset (values, 0, sizeof (const CoglBoxedValue *) * ctx->n_uniform_names); @@ -252,8 +249,7 @@ _cogl_pipeline_uniforms_state_equal (CoglPipeline *authority0, const CoglBoxedValue **values0, **values1; int n_longs; int i; - - _COGL_GET_CONTEXT (ctx, FALSE); + CoglContext *ctx = authority0->context; if (authority0 == authority1) return TRUE; @@ -556,8 +552,6 @@ cogl_pipeline_set_blend (CoglPipeline *pipeline, int count; CoglPipelineBlendState *blend_state; - _COGL_GET_CONTEXT (ctx, FALSE); - g_return_val_if_fail (COGL_IS_PIPELINE (pipeline), FALSE); count = @@ -633,8 +627,6 @@ cogl_pipeline_set_blend_constant (CoglPipeline *pipeline, CoglPipeline *authority; CoglPipelineBlendState *blend_state; - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - g_return_if_fail (COGL_IS_PIPELINE (pipeline)); authority = _cogl_pipeline_get_authority (pipeline, state); @@ -740,8 +732,6 @@ cogl_pipeline_set_depth_state (CoglPipeline *pipeline, CoglPipeline *authority; CoglDepthState *orig_state; - _COGL_GET_CONTEXT (ctx, FALSE); - g_return_val_if_fail (COGL_IS_PIPELINE (pipeline), FALSE); g_return_val_if_fail (depth_state->magic == COGL_DEPTH_STATE_MAGIC, FALSE); @@ -949,7 +939,6 @@ cogl_pipeline_set_per_vertex_point_size (CoglPipeline *pipeline, CoglPipelineState state = COGL_PIPELINE_STATE_PER_VERTEX_POINT_SIZE; CoglPipeline *authority; - _COGL_GET_CONTEXT (ctx, FALSE); g_return_val_if_fail (COGL_IS_PIPELINE (pipeline), FALSE); authority = _cogl_pipeline_get_authority (pipeline, state); @@ -996,11 +985,9 @@ _cogl_pipeline_override_uniform (CoglPipeline *pipeline, CoglPipelineUniformsState *uniforms_state; int override_index; - _COGL_GET_CONTEXT (ctx, NULL); - g_return_val_if_fail (COGL_IS_PIPELINE (pipeline), NULL); g_return_val_if_fail (location >= 0, NULL); - g_return_val_if_fail (location < ctx->n_uniform_names, NULL); + g_return_val_if_fail (location < pipeline->context->n_uniform_names, NULL); /* - Flush journal primitives referencing the current state. * - Make sure the pipeline has no dependants so it may be modified. @@ -1271,8 +1258,6 @@ _cogl_pipeline_hash_blend_state (CoglPipeline *authority, CoglPipelineBlendState *blend_state = &authority->big_state->blend_state; unsigned int hash; - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - if (!authority->real_blend_enable) return; diff --git a/cogl/cogl/cogl-pipeline.c b/cogl/cogl/cogl-pipeline.c index 4f33c40550d1b4ab7249d1006825db70bc289cd4..0b47d46c304145f9f967dccc18be4af1e5673720 100644 --- a/cogl/cogl/cogl-pipeline.c +++ b/cogl/cogl/cogl-pipeline.c @@ -46,7 +46,6 @@ #include "cogl/cogl-profile.h" #include "cogl/cogl-depth-state-private.h" #include "cogl/cogl-snippet-private.h" -#include "cogl/cogl1-context.h" #include #include @@ -1084,7 +1083,7 @@ _cogl_pipeline_pre_change_notify (CoglPipeline *pipeline, /* XXX: note we use cogl_flush() not _cogl_flush_journal() so * we will flush *all* known journals that might reference the * current pipeline. */ - cogl_flush (); + cogl_context_flush (pipeline->context); } } diff --git a/cogl/cogl/cogl-primitives.c b/cogl/cogl/cogl-primitives.c index 6582c277c147e680ddb83fb187246b0cfb1e5862..214d03416bba6ea1e06205e9f290541ecd762e8e 100644 --- a/cogl/cogl/cogl-primitives.c +++ b/cogl/cogl/cogl-primitives.c @@ -40,7 +40,6 @@ #include "cogl/cogl-private.h" #include "cogl/cogl-meta-texture.h" #include "cogl/cogl-framebuffer-private.h" -#include "cogl/cogl1-context.h" #include "cogl/cogl-primitives-private.h" #include diff --git a/cogl/cogl/cogl-private.h b/cogl/cogl/cogl-private.h index fb18c8b9f52ca7ca877810c0a64896a3cd033765..636af1febe9df3de7e3c447b235fd564e802f464 100644 --- a/cogl/cogl/cogl-private.h +++ b/cogl/cogl/cogl-private.h @@ -82,9 +82,6 @@ _cogl_transform_point (const graphene_matrix_t *matrix_mv, gboolean _cogl_check_extension (const char *name, char * const *ext); -void -_cogl_init (void); - #define _cogl_has_private_feature(ctx, feature) \ COGL_FLAGS_GET ((ctx)->private_features, (feature)) diff --git a/cogl/cogl/cogl-renderer-private.h b/cogl/cogl/cogl-renderer-private.h index f1dbab2b9f5cbebc3fcdcb8bdc60a01e74fb5831..d5e832e551bcea02fca8bb638a0d7bf59485eb5b 100644 --- a/cogl/cogl/cogl-renderer-private.h +++ b/cogl/cogl/cogl-renderer-private.h @@ -43,6 +43,9 @@ typedef const CoglWinsysVtable *(*CoglCustomWinsysVtableGetter) (CoglRenderer *r struct _CoglRenderer { GObject parent_instance; + + CoglDisplay *display; + gboolean connected; CoglDriver driver_override; const CoglDriverVtable *driver_vtable; @@ -89,7 +92,3 @@ void _cogl_renderer_remove_native_filter (CoglRenderer *renderer, CoglNativeFilterFunc func, void *data); - -void * -_cogl_renderer_get_proc_address (CoglRenderer *renderer, - const char *name); diff --git a/cogl/cogl/cogl-renderer.c b/cogl/cogl/cogl-renderer.c index eae6f88909cb4fe445cd92c2030a0313bc527fdb..2a9e3cb53e22ceb2af8a352d9b22ff91215222de 100644 --- a/cogl/cogl/cogl-renderer.c +++ b/cogl/cogl/cogl-renderer.c @@ -194,8 +194,6 @@ cogl_renderer_new (void) { CoglRenderer *renderer = g_object_new (COGL_TYPE_RENDERER, NULL); - _cogl_init (); - renderer->connected = FALSE; renderer->event_filters = NULL; @@ -615,7 +613,7 @@ cogl_renderer_get_winsys_id (CoglRenderer *renderer) } void * -_cogl_renderer_get_proc_address (CoglRenderer *renderer, +cogl_renderer_get_proc_address (CoglRenderer *renderer, const char *name) { const CoglWinsysVtable *winsys = _cogl_renderer_get_winsys (renderer); diff --git a/cogl/cogl/cogl-renderer.h b/cogl/cogl/cogl-renderer.h index 11557314aaee3370af0fadfbe09a96d56f7248fe..657b73ec00adf6fc7fdb73a2d56f9421b2aa169f 100644 --- a/cogl/cogl/cogl-renderer.h +++ b/cogl/cogl/cogl-renderer.h @@ -311,4 +311,24 @@ cogl_renderer_is_dma_buf_supported (CoglRenderer *renderer); COGL_EXPORT void cogl_renderer_bind_api (CoglRenderer *renderer); +/** + * cogl_renderer_get_proc_address: + * @renderer: A #CoglRenderer. + * @name: the name of the function. + * + * Gets a pointer to a given GL or GL ES extension function. This acts + * as a wrapper around glXGetProcAddress() or whatever is the + * appropriate function for the current backend. + * + * This function should not be used to query core opengl API + * symbols since eglGetProcAddress for example doesn't allow this and + * and may return a junk pointer if you do. + * + * Return value: a pointer to the requested function or %NULL if the + * function is not available. + */ +COGL_EXPORT void * +cogl_renderer_get_proc_address (CoglRenderer *renderer, + const char *name); + G_END_DECLS diff --git a/cogl/cogl/cogl-texture.c b/cogl/cogl/cogl-texture.c index 30f4c2d89a76898ab3f7a0b05ae1fb6d194a61cf..924960441e851677eac4d91bfb69a5005898b834 100644 --- a/cogl/cogl/cogl-texture.c +++ b/cogl/cogl/cogl-texture.c @@ -53,7 +53,6 @@ #include "cogl/cogl-context-private.h" #include "cogl/cogl-offscreen-private.h" #include "cogl/cogl-framebuffer-private.h" -#include "cogl/cogl1-context.h" #include "cogl/cogl-sub-texture.h" #include "cogl/cogl-primitive-texture.h" diff --git a/cogl/cogl/cogl.c b/cogl/cogl/cogl.c index 40c85706cf03471aed83dc290083c973e7c3c802..34325fa1db7aad63c300a354c5842b32f12c2061 100644 --- a/cogl/cogl/cogl.c +++ b/cogl/cogl/cogl.c @@ -50,17 +50,9 @@ #include "cogl/cogl-framebuffer-private.h" #include "cogl/cogl-renderer-private.h" #include "cogl/cogl-private.h" -#include "cogl/cogl1-context.h" #include "cogl/cogl-offscreen.h" #include "cogl/winsys/cogl-winsys-private.h" - -GCallback -cogl_get_proc_address (const char* name) -{ - _COGL_GET_CONTEXT (ctx, NULL); - - return _cogl_renderer_get_proc_address (ctx->display->renderer, name); -} +#include "cogl/cogl-mutter.h" gboolean _cogl_check_extension (const char *name, char * const *ext) @@ -80,17 +72,6 @@ cogl_has_feature (CoglContext *ctx, CoglFeatureID feature) return COGL_FLAGS_GET (ctx->features, feature); } -void -cogl_flush (void) -{ - GList *l; - - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - - for (l = ctx->framebuffers; l; l = l->next) - _cogl_framebuffer_flush_journal (l->data); -} - uint32_t _cogl_driver_error_quark (void) { @@ -144,7 +125,7 @@ _cogl_system_error_quark (void) } void -_cogl_init (void) +cogl_init (void) { static gboolean initialized = FALSE; diff --git a/cogl/cogl/cogl.h b/cogl/cogl/cogl.h index 652bc89439657125b94f95e8f8ec691ee9c3d147..17cdc8c621512190084678e55f67920f09e91719 100644 --- a/cogl/cogl/cogl.h +++ b/cogl/cogl/cogl.h @@ -45,7 +45,6 @@ #include "cogl/cogl-macros.h" -#include "cogl/cogl1-context.h" #include "cogl/cogl-bitmap.h" #include "cogl/cogl-color.h" #include "cogl/cogl-dma-buf-handle.h" @@ -92,9 +91,6 @@ #include "cogl/cogl-trace.h" #include "cogl/cogl-scanout.h" #include "cogl/cogl-graphene.h" -/* XXX: This will definitely go away once all the Clutter winsys - * code has been migrated down into Cogl! */ -#include "cogl/deprecated/cogl-clutter.h" /* The gobject introspection scanner seems to parse public headers in * isolation which means we need to be extra careful about how we diff --git a/cogl/cogl/cogl1-context.h b/cogl/cogl/cogl1-context.h deleted file mode 100644 index 9164ea7fe77b3a3be2e48e792afc1dd2c29f7e33..0000000000000000000000000000000000000000 --- a/cogl/cogl/cogl1-context.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Cogl - * - * A Low Level GPU Graphics and Utilities API - * - * Copyright (C) 2010 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Authors: - * Robert Bragg - * - */ - -#pragma once - -#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION) -#error "Only can be included directly." -#endif - -#include "cogl/cogl-types.h" -#include "cogl/cogl-texture.h" -#include "cogl/cogl-framebuffer.h" -#include "cogl/cogl-macros.h" - -G_BEGIN_DECLS - -/* Misc */ -/** - * cogl_get_proc_address: (skip) - * @name: the name of the function. - * - * Gets a pointer to a given GL or GL ES extension function. This acts - * as a wrapper around glXGetProcAddress() or whatever is the - * appropriate function for the current backend. - * - * This function should not be used to query core opengl API - * symbols since eglGetProcAddress for example doesn't allow this and - * and may return a junk pointer if you do. - * - * Return value: a pointer to the requested function or %NULL if the - * function is not available. - */ -COGL_EXPORT GCallback -cogl_get_proc_address (const char *name); - -/** - * cogl_flush: - * - * This function should only need to be called in exceptional circumstances. - * - * As an optimization Cogl drawing functions may batch up primitives - * internally, so if you are trying to use raw GL outside of Cogl you stand a - * better chance of being successful if you ask Cogl to flush any batched - * geometry before making your state changes. - * - * It only ensure that the underlying driver is issued all the commands - * necessary to draw the batched primitives. It provides no guarantees about - * when the driver will complete the rendering. - * - * This provides no guarantees about the GL state upon returning and to avoid - * confusing Cogl you should aim to restore any changes you make before - * resuming use of Cogl. - * - * If you are making state changes with the intention of affecting Cogl drawing - * primitives you are 100% on your own since you stand a good chance of - * conflicting with Cogl internals. For example clutter-gst which currently - * uses direct GL calls to bind ARBfp programs will very likely break when Cogl - * starts to use ARBfb programs itself for the material API. - */ -COGL_EXPORT void -cogl_flush (void); - -G_END_DECLS diff --git a/cogl/cogl/deprecated/cogl-clutter.c b/cogl/cogl/deprecated/cogl-clutter.c deleted file mode 100644 index f1fc685b12a61c1ce3fb0048648d1bbe0fd8e493..0000000000000000000000000000000000000000 --- a/cogl/cogl/deprecated/cogl-clutter.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Cogl - * - * A Low Level GPU Graphics and Utilities API - * - * Copyright (C) 2011 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Authors: - * Robert Bragg - */ - -#include "config.h" - -#include -#include - -#include "cogl/cogl-util.h" -#include "cogl/cogl-types.h" -#include "cogl/cogl-private.h" -#include "cogl/cogl-context-private.h" -#include "cogl/cogl-framebuffer-private.h" -#include "cogl/cogl-onscreen-private.h" -#ifdef HAVE_X11 -#include "cogl/cogl-xlib-renderer.h" -#endif -#include "cogl/winsys/cogl-winsys-private.h" -#include "cogl/deprecated/cogl-clutter.h" - -gboolean -cogl_clutter_winsys_has_feature (CoglWinsysFeature feature) -{ - return _cogl_winsys_has_feature (feature); -} diff --git a/cogl/cogl/deprecated/cogl-clutter.h b/cogl/cogl/deprecated/cogl-clutter.h deleted file mode 100644 index 604ad3f3a2231ffbbfd34d97d6f60a500b1c9744..0000000000000000000000000000000000000000 --- a/cogl/cogl/deprecated/cogl-clutter.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Cogl - * - * A Low Level GPU Graphics and Utilities API - * - * Copyright (C) 2011 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION) -#error "Only can be included directly." -#endif - -G_BEGIN_DECLS - -COGL_DEPRECATED_FOR (cogl_has_feature) -COGL_EXPORT gboolean -cogl_clutter_winsys_has_feature (CoglWinsysFeature feature); - -G_END_DECLS diff --git a/cogl/cogl/deprecated/cogl-program-private.h b/cogl/cogl/deprecated/cogl-program-private.h index 761d8d889109d4077b252ac19d6ffd9d5d249849..a1d43ed90beef47724a2db5893f080089ca1f675 100644 --- a/cogl/cogl/deprecated/cogl-program-private.h +++ b/cogl/cogl/deprecated/cogl-program-private.h @@ -71,9 +71,10 @@ struct _CoglProgramUniform 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); +_cogl_program_flush_uniforms (CoglContext *ctx, + CoglProgram *program, + GLuint gl_program, + gboolean gl_program_changed); gboolean _cogl_program_has_fragment_shader (CoglProgram *self); diff --git a/cogl/cogl/deprecated/cogl-program.c b/cogl/cogl/deprecated/cogl-program.c index 9d257fd79cdb4143572d0da16544aa43d36c0a5a..de824bb6d088ac84bbcfcd2938025ab4d59f6a86 100644 --- a/cogl/cogl/deprecated/cogl-program.c +++ b/cogl/cogl/deprecated/cogl-program.c @@ -46,8 +46,6 @@ cogl_program_dispose (GObject *object) CoglProgram *program = COGL_PROGRAM (object); int i; - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - /* Unref all of the attached shaders and destroy the list */ g_slist_free_full (program->attached_shaders, g_object_unref); @@ -105,8 +103,6 @@ void cogl_program_attach_shader (CoglProgram *program, CoglShader *shader) { - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - if (!COGL_IS_PROGRAM (program) || !COGL_IS_SHADER (shader)) return; @@ -247,15 +243,14 @@ cogl_program_set_uniform_matrix (CoglProgram *program, } void -_cogl_program_flush_uniforms (CoglProgram *program, +_cogl_program_flush_uniforms (CoglContext *ctx, + CoglProgram *program, GLuint gl_program, gboolean gl_program_changed) { CoglProgramUniform *uniform; int i; - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - for (i = 0; i < program->custom_uniforms->len; i++) { uniform = &g_array_index (program->custom_uniforms, diff --git a/cogl/cogl/deprecated/cogl-shader.c b/cogl/cogl/deprecated/cogl-shader.c index 85d4d8ae5e1511c994b69c8bb14d29aef58df585..0cc43c623ea59311b4c644c6aed96b4e0808775e 100644 --- a/cogl/cogl/deprecated/cogl-shader.c +++ b/cogl/cogl/deprecated/cogl-shader.c @@ -45,10 +45,10 @@ static void cogl_shader_dispose (GObject *object) { CoglShader *shader = COGL_SHADER (object); + CoglContext *ctx = shader->compilation_pipeline->context; /* Frees shader resources but its handle is not released! Do that separately before this! */ - _COGL_GET_CONTEXT (ctx, NO_RETVAL); if (shader->gl_handle) GE (ctx, glDeleteShader (shader->gl_handle)); @@ -74,8 +74,6 @@ cogl_create_shader (CoglShaderType type) { CoglShader *shader; - _COGL_GET_CONTEXT (ctx, NULL); - switch (type) { case COGL_SHADER_TYPE_VERTEX: @@ -101,8 +99,6 @@ cogl_shader_source (CoglShader *self, { g_return_if_fail (COGL_IS_SHADER (self)); - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - self->source = g_strdup (source); } @@ -111,7 +107,5 @@ cogl_shader_get_shader_type (CoglShader *self) { g_return_val_if_fail (COGL_IS_SHADER (self), COGL_SHADER_TYPE_VERTEX); - _COGL_GET_CONTEXT (ctx, COGL_SHADER_TYPE_VERTEX); - return self->type; } diff --git a/cogl/cogl/driver/gl/cogl-pipeline-fragend-glsl.c b/cogl/cogl/driver/gl/cogl-pipeline-fragend-glsl.c index 0a16f46d355162f2c2453ebf7c268c8d9d7d64f2..d44ceab608633c039d8e29fe4d26ce202c2389c0 100644 --- a/cogl/cogl/driver/gl/cogl-pipeline-fragend-glsl.c +++ b/cogl/cogl/driver/gl/cogl-pipeline-fragend-glsl.c @@ -149,8 +149,7 @@ destroy_shader_state (void *user_data) { CoglPipelineFragendShaderStateCache *cache = user_data; CoglPipelineFragendShaderState *shader_state = cache->shader_state; - - _COGL_GET_CONTEXT (ctx, NO_RETVAL); + CoglContext *ctx = cache->instance->context; if (shader_state->cache_entry && shader_state->cache_entry->pipeline != cache->instance) @@ -297,10 +296,9 @@ _cogl_pipeline_fragend_glsl_start (CoglPipeline *pipeline, CoglPipeline *authority; CoglPipelineCacheEntry *cache_entry = NULL; CoglProgram *user_program = cogl_pipeline_get_user_program (pipeline); + CoglContext *ctx = pipeline->context; int i; - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - /* Now lookup our glsl backend private state */ shader_state = get_shader_state (pipeline); @@ -426,8 +424,6 @@ ensure_texture_lookup_generated (CoglPipelineFragendShaderState *shader_state, int unit_index = _cogl_pipeline_layer_get_unit_index (layer); CoglPipelineSnippetData snippet_data; - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - if (shader_state->unit_state[unit_index].sampled) return; @@ -990,8 +986,7 @@ _cogl_pipeline_fragend_glsl_end (CoglPipeline *pipeline, unsigned long pipelines_difference) { CoglPipelineFragendShaderState *shader_state = get_shader_state (pipeline); - - _COGL_GET_CONTEXT (ctx, FALSE); + CoglContext *ctx = pipeline->context; if (shader_state->source) { @@ -1092,7 +1087,7 @@ _cogl_pipeline_fragend_glsl_pre_change_notify (CoglPipeline *pipeline, CoglPipelineState change, const CoglColor *new_color) { - _COGL_GET_CONTEXT (ctx, NO_RETVAL); + CoglContext *ctx = pipeline->context; if ((change & _cogl_pipeline_get_state_for_fragment_codegen (ctx))) dirty_shader_state (pipeline); @@ -1112,7 +1107,7 @@ _cogl_pipeline_fragend_glsl_layer_pre_change_notify ( CoglPipelineLayer *layer, CoglPipelineLayerState change) { - _COGL_GET_CONTEXT (ctx, NO_RETVAL); + CoglContext *ctx = owner->context; if ((change & _cogl_pipeline_get_layer_state_for_fragment_codegen (ctx))) { diff --git a/cogl/cogl/driver/gl/cogl-pipeline-opengl-private.h b/cogl/cogl/driver/gl/cogl-pipeline-opengl-private.h index 187baf1a41b660178391674e2b68fae3b6e871b7..03304772fe3d497b435668ff2fc6afaa6982f7f2 100644 --- a/cogl/cogl/driver/gl/cogl-pipeline-opengl-private.h +++ b/cogl/cogl/driver/gl/cogl-pipeline-opengl-private.h @@ -123,20 +123,24 @@ typedef struct _CoglTextureUnit } CoglTextureUnit; CoglTextureUnit * -_cogl_get_texture_unit (int index_); +_cogl_get_texture_unit (CoglContext *ctx, + int index_); void _cogl_destroy_texture_units (CoglContext *ctx); void -_cogl_set_active_texture_unit (int unit_index); +_cogl_set_active_texture_unit (CoglContext *ctx, + int unit_index); void -_cogl_bind_gl_texture_transient (GLenum gl_target, - GLuint gl_texture); +_cogl_bind_gl_texture_transient (CoglContext *ctx, + GLenum gl_target, + GLuint gl_texture); void -_cogl_delete_gl_texture (GLuint gl_texture); +_cogl_delete_gl_texture (CoglContext *ctx, + GLuint gl_texture); void _cogl_pipeline_flush_gl_state (CoglContext *context, diff --git a/cogl/cogl/driver/gl/cogl-pipeline-opengl.c b/cogl/cogl/driver/gl/cogl-pipeline-opengl.c index 666d477ad0abb094522581f477b649a9a50705ed..13180ca5cc11168be9314bb295f3b14b686cfb78 100644 --- a/cogl/cogl/driver/gl/cogl-pipeline-opengl.c +++ b/cogl/cogl/driver/gl/cogl-pipeline-opengl.c @@ -89,9 +89,9 @@ texture_unit_free (CoglTextureUnit *unit) } CoglTextureUnit * -_cogl_get_texture_unit (int index_) +_cogl_get_texture_unit (CoglContext *ctx, + int index_) { - _COGL_GET_CONTEXT (ctx, NULL); CoglGLContext *glctx = _cogl_driver_gl_context(ctx); if (glctx->texture_units->len < (index_ + 1)) @@ -128,9 +128,9 @@ _cogl_destroy_texture_units (CoglContext *ctx) } void -_cogl_set_active_texture_unit (int unit_index) +_cogl_set_active_texture_unit (CoglContext *ctx, + int unit_index) { - _COGL_GET_CONTEXT (ctx, NO_RETVAL); CoglGLContext *glctx = _cogl_driver_gl_context(ctx); if (glctx->active_texture_unit != unit_index) @@ -161,13 +161,12 @@ _cogl_set_active_texture_unit (int unit_index) * CoglTextureUnit. */ void -_cogl_bind_gl_texture_transient (GLenum gl_target, - GLuint gl_texture) +_cogl_bind_gl_texture_transient (CoglContext *ctx, + GLenum gl_target, + GLuint gl_texture) { CoglTextureUnit *unit; - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - /* We choose to always make texture unit 1 active for transient * binds so that in the common case where multitexturing isn't used * we can simply ignore the state of this texture unit. Notably we @@ -175,8 +174,8 @@ _cogl_bind_gl_texture_transient (GLenum gl_target, * in case the driver doesn't have a sparse data structure for * texture units. */ - _cogl_set_active_texture_unit (1); - unit = _cogl_get_texture_unit (1); + _cogl_set_active_texture_unit (ctx, 1); + unit = _cogl_get_texture_unit (ctx, 1); if (unit->gl_texture == gl_texture && !unit->dirty_gl_texture) return; @@ -187,11 +186,11 @@ _cogl_bind_gl_texture_transient (GLenum gl_target, } void -_cogl_delete_gl_texture (GLuint gl_texture) +_cogl_delete_gl_texture (CoglContext *ctx, + GLuint gl_texture) { int i; - _COGL_GET_CONTEXT (ctx, NO_RETVAL); CoglGLContext *glctx = _cogl_driver_gl_context(ctx); for (i = 0; i < glctx->texture_units->len; i++) @@ -220,7 +219,7 @@ _cogl_pipeline_texture_storage_change_notify (CoglTexture *texture) { int i; - _COGL_GET_CONTEXT (ctx, NO_RETVAL); + CoglContext *ctx = cogl_texture_get_context (texture); CoglGLContext *glctx = _cogl_driver_gl_context(ctx); for (i = 0; i < glctx->texture_units->len; i++) @@ -306,7 +305,7 @@ _cogl_pipeline_flush_color_blend_alpha_depth_state ( unsigned long pipelines_difference, gboolean with_color_attrib) { - _COGL_GET_CONTEXT (ctx, NO_RETVAL); + CoglContext *ctx = pipeline->context; if (pipelines_difference & COGL_PIPELINE_STATE_BLEND) { @@ -410,10 +409,8 @@ _cogl_pipeline_flush_color_blend_alpha_depth_state ( } static int -get_max_activateable_texture_units (void) +get_max_activateable_texture_units (CoglContext *ctx) { - _COGL_GET_CONTEXT (ctx, 0); - if (G_UNLIKELY (ctx->max_activateable_texture_units == -1)) { GLint values[3]; @@ -469,17 +466,16 @@ static gboolean flush_layers_common_gl_state_cb (CoglPipelineLayer *layer, void *user_data) { CoglPipelineFlushLayerState *flush_state = user_data; - int unit_index = flush_state->i; - CoglTextureUnit *unit = _cogl_get_texture_unit (unit_index); - unsigned long layers_difference = + CoglContext *ctx = layer->owner->context; + int unit_index = flush_state->i; + CoglTextureUnit *unit = _cogl_get_texture_unit (ctx, unit_index); + unsigned long layers_difference = flush_state->layer_differences[unit_index]; - _COGL_GET_CONTEXT (ctx, FALSE); - /* There may not be enough texture units so we can bail out if * that's the case... */ - if (G_UNLIKELY (unit_index >= get_max_activateable_texture_units ())) + if (G_UNLIKELY (unit_index >= get_max_activateable_texture_units (ctx))) { static gboolean shown_warning = FALSE; @@ -505,7 +501,7 @@ flush_layers_common_gl_state_cb (CoglPipelineLayer *layer, void *user_data) &gl_texture, &gl_target); - _cogl_set_active_texture_unit (unit_index); + _cogl_set_active_texture_unit (ctx, unit_index); /* NB: There are several Cogl components and some code in * Clutter that will temporarily bind arbitrary GL textures to @@ -579,8 +575,6 @@ _cogl_pipeline_flush_common_gl_state (CoglPipeline *pipeline, { CoglPipelineFlushLayerState state; - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - _cogl_pipeline_flush_color_blend_alpha_depth_state (pipeline, pipelines_difference, with_color_attrib); @@ -706,11 +700,10 @@ _cogl_sampler_gl_free (CoglContext *context, CoglSamplerCacheEntry *entry) * state. */ static void -foreach_texture_unit_update_filter_and_wrap_modes (void) +foreach_texture_unit_update_filter_and_wrap_modes (CoglContext *ctx) { int i; - _COGL_GET_CONTEXT (ctx, NO_RETVAL); CoglGLContext *glctx = _cogl_driver_gl_context(ctx); for (i = 0; i < glctx->texture_units->len; i++) @@ -746,7 +739,8 @@ static gboolean compare_layer_differences_cb (CoglPipelineLayer *layer, void *user_data) { CoglPipelineCompareLayersState *state = user_data; - CoglTextureUnit *unit = _cogl_get_texture_unit (state->i); + CoglContext *ctx = layer->owner->context; + CoglTextureUnit *unit = _cogl_get_texture_unit (ctx, state->i); if (unit->layer == layer) state->layer_differences[state->i] = unit->layer_changes_since_flush; @@ -1137,7 +1131,7 @@ done: /* Handle the fact that OpenGL associates texture filter and wrap * modes with the texture objects not the texture units... */ if (!_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_SAMPLER_OBJECTS)) - foreach_texture_unit_update_filter_and_wrap_modes (); + foreach_texture_unit_update_filter_and_wrap_modes (ctx); /* If this pipeline has more than one layer then we always need * to make sure we rebind the texture for unit 1. @@ -1147,10 +1141,10 @@ done: * object parameters. cogl-pipeline.c (See * _cogl_bind_gl_texture_transient) */ - unit1 = _cogl_get_texture_unit (1); + unit1 = _cogl_get_texture_unit (ctx, 1); if (cogl_pipeline_get_n_layers (pipeline) > 1 && unit1->dirty_gl_texture) { - _cogl_set_active_texture_unit (1); + _cogl_set_active_texture_unit (ctx, 1); GE (ctx, glBindTexture (unit1->gl_target, unit1->gl_texture)); unit1->dirty_gl_texture = FALSE; } diff --git a/cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c b/cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c index 59159d1712eaec973cc3ff3da257a257c7d64113..9532b604ab37fb3ba6b995f37db50f39935da942 100644 --- a/cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c +++ b/cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c @@ -188,8 +188,7 @@ _cogl_pipeline_progend_glsl_get_attrib_location (CoglPipeline *pipeline, { CoglPipelineProgramState *program_state = get_program_state (pipeline); int *locations; - - _COGL_GET_CONTEXT (ctx, -1); + CoglContext *ctx = pipeline->context; g_return_val_if_fail (program_state != NULL, -1); g_return_val_if_fail (program_state->program != 0, -1); @@ -268,8 +267,7 @@ destroy_program_state (void *user_data) { CoglPipelineProgramStateCache *cache = user_data; CoglPipelineProgramState *program_state = cache->program_state; - - _COGL_GET_CONTEXT (ctx, NO_RETVAL); + CoglContext *ctx = cache->instance->context; /* If the program state was last used for this pipeline then clear it so that if same address gets used again for a new pipeline @@ -338,12 +336,11 @@ dirty_program_state (CoglPipeline *pipeline) } static void -link_program (GLint gl_program) +link_program (CoglContext *ctx, + GLint gl_program) { GLint link_status; - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - GE( ctx, glLinkProgram (gl_program) ); GE( ctx, glGetProgramiv (gl_program, GL_LINK_STATUS, &link_status) ); @@ -385,8 +382,7 @@ get_uniform_cb (CoglPipeline *pipeline, CoglPipelineProgramState *program_state = state->program_state; UnitState *unit_state = &program_state->unit_state[state->unit]; GLint uniform_location; - - _COGL_GET_CONTEXT (ctx, FALSE); + CoglContext *ctx = pipeline->context; /* We can reuse the source buffer to create the uniform name because the program has now been linked */ @@ -438,8 +434,7 @@ update_constants_cb (CoglPipeline *pipeline, UpdateUniformsState *state = user_data; CoglPipelineProgramState *program_state = state->program_state; UnitState *unit_state = &program_state->unit_state[state->unit++]; - - _COGL_GET_CONTEXT (ctx, FALSE); + CoglContext *ctx = pipeline->context; if (unit_state->combine_constant_uniform != -1 && (state->update_all || unit_state->dirty_combine_constant)) @@ -569,8 +564,7 @@ _cogl_pipeline_progend_glsl_flush_uniforms (CoglPipeline *pipeline, CoglPipelineUniformsState *uniforms_state; FlushUniformsClosure data; int n_uniform_longs; - - _COGL_GET_CONTEXT (ctx, NO_RETVAL); + CoglContext *ctx = pipeline->context; if (pipeline->differences & COGL_PIPELINE_STATE_UNIFORMS) uniforms_state = &pipeline->big_state->uniforms_state; @@ -664,8 +658,7 @@ _cogl_shader_compile_real (CoglShader *shader, { GLenum gl_type; GLint status; - - _COGL_GET_CONTEXT (ctx, NO_RETVAL); + CoglContext *ctx = pipeline->context; if (shader->gl_handle) { @@ -743,8 +736,7 @@ _cogl_pipeline_progend_glsl_end (CoglPipeline *pipeline, UpdateUniformsState state; CoglProgram *user_program; CoglPipelineCacheEntry *cache_entry = NULL; - - _COGL_GET_CONTEXT (ctx, NO_RETVAL); + CoglContext *ctx = pipeline->context; program_state = get_program_state (pipeline); @@ -845,7 +837,7 @@ _cogl_pipeline_progend_glsl_end (CoglPipeline *pipeline, GE( ctx, glBindAttribLocation (program_state->program, 0, "cogl_position_in")); - link_program (program_state->program); + link_program (ctx, program_state->program); program_changed = TRUE; } @@ -925,7 +917,7 @@ _cogl_pipeline_progend_glsl_end (CoglPipeline *pipeline, program_changed); if (user_program) - _cogl_program_flush_uniforms (user_program, + _cogl_program_flush_uniforms (ctx, user_program, gl_program, program_changed); @@ -939,7 +931,7 @@ _cogl_pipeline_progend_glsl_pre_change_notify (CoglPipeline *pipeline, CoglPipelineState change, const CoglColor *new_color) { - _COGL_GET_CONTEXT (ctx, NO_RETVAL); + CoglContext *ctx = pipeline->context; if ((change & (_cogl_pipeline_get_state_for_vertex_codegen (ctx) | _cogl_pipeline_get_state_for_fragment_codegen (ctx)))) @@ -976,8 +968,8 @@ _cogl_pipeline_progend_glsl_layer_pre_change_notify ( CoglPipelineLayer *layer, CoglPipelineLayerState change) { - _COGL_GET_CONTEXT (ctx, NO_RETVAL); CoglTextureUnit *unit; + CoglContext *ctx = owner->context; if ((change & (_cogl_pipeline_get_layer_state_for_fragment_codegen (ctx) | COGL_PIPELINE_LAYER_STATE_AFFECTS_VERTEX_CODEGEN))) @@ -1008,7 +1000,7 @@ _cogl_pipeline_progend_glsl_layer_pre_change_notify ( * the changes so we can try to minimize redundant OpenGL calls if * the same layer is flushed again. */ - unit = _cogl_get_texture_unit (_cogl_pipeline_layer_get_unit_index (layer)); + unit = _cogl_get_texture_unit (ctx, _cogl_pipeline_layer_get_unit_index (layer)); if (unit->layer == layer) unit->layer_changes_since_flush |= change; } @@ -1026,8 +1018,7 @@ _cogl_pipeline_progend_glsl_pre_paint (CoglPipeline *pipeline, gboolean need_modelview; gboolean need_projection; graphene_matrix_t modelview, projection; - - _COGL_GET_CONTEXT (ctx, NO_RETVAL); + CoglContext *ctx = pipeline->context; program_state = get_program_state (pipeline); @@ -1152,8 +1143,7 @@ update_float_uniform (CoglPipeline *pipeline, { float (* float_getter_func) (CoglPipeline *) = getter_func; float value; - - _COGL_GET_CONTEXT (ctx, NO_RETVAL); + CoglContext *ctx = pipeline->context; value = float_getter_func (pipeline); GE( ctx, glUniform1f (uniform_location, value) ); diff --git a/cogl/cogl/driver/gl/cogl-pipeline-vertend-glsl.c b/cogl/cogl/driver/gl/cogl-pipeline-vertend-glsl.c index 9311c878f14d07d17b1123c3606befda55d9cd3f..dd9161e5ba5cdae7809148f3758accefc580945a 100644 --- a/cogl/cogl/driver/gl/cogl-pipeline-vertend-glsl.c +++ b/cogl/cogl/driver/gl/cogl-pipeline-vertend-glsl.c @@ -108,8 +108,7 @@ destroy_shader_state (void *user_data) { CoglPipelineVertendShaderStateCache *cache = user_data; CoglPipelineVertendShaderState *shader_state = cache->shader_state; - - _COGL_GET_CONTEXT (ctx, NO_RETVAL); + CoglContext *ctx = cache->instance->context; if (shader_state->cache_entry && shader_state->cache_entry->pipeline != cache->instance) @@ -390,8 +389,7 @@ _cogl_pipeline_vertend_glsl_start (CoglPipeline *pipeline, CoglPipelineVertendShaderState *shader_state; CoglPipelineCacheEntry *cache_entry = NULL; CoglProgram *user_program = cogl_pipeline_get_user_program (pipeline); - - _COGL_GET_CONTEXT (ctx, NO_RETVAL); + CoglContext *ctx = pipeline->context; /* Now lookup our glsl backend private state (allocating if * necessary) */ @@ -513,8 +511,6 @@ _cogl_pipeline_vertend_glsl_add_layer (CoglPipeline *pipeline, CoglPipelineSnippetData snippet_data; int layer_index = layer->index; - _COGL_GET_CONTEXT (ctx, FALSE); - shader_state = get_shader_state (pipeline); if (shader_state->source == NULL) @@ -581,8 +577,7 @@ _cogl_pipeline_vertend_glsl_end (CoglPipeline *pipeline, unsigned long pipelines_difference) { CoglPipelineVertendShaderState *shader_state; - - _COGL_GET_CONTEXT (ctx, FALSE); + CoglContext *ctx = pipeline->context; shader_state = get_shader_state (pipeline); @@ -728,7 +723,7 @@ _cogl_pipeline_vertend_glsl_pre_change_notify (CoglPipeline *pipeline, CoglPipelineState change, const CoglColor *new_color) { - _COGL_GET_CONTEXT (ctx, NO_RETVAL); + CoglContext *ctx = pipeline->context; if ((change & _cogl_pipeline_get_state_for_vertex_codegen (ctx))) dirty_shader_state (pipeline); diff --git a/cogl/cogl/driver/gl/cogl-texture-2d-gl.c b/cogl/cogl/driver/gl/cogl-texture-2d-gl.c index e2bb41c78e5e4771db5af827ef2d267bbf9471fa..dc33f0d31c4d4f320ae0f7386050a1af935fa842 100644 --- a/cogl/cogl/driver/gl/cogl-texture-2d-gl.c +++ b/cogl/cogl/driver/gl/cogl-texture-2d-gl.c @@ -63,7 +63,8 @@ void _cogl_texture_2d_gl_free (CoglTexture2D *tex_2d) { if (tex_2d->gl_texture) - _cogl_delete_gl_texture (tex_2d->gl_texture); + _cogl_delete_gl_texture (cogl_texture_get_context (COGL_TEXTURE (tex_2d)), + tex_2d->gl_texture); #if defined (HAVE_EGL) g_clear_pointer (&tex_2d->egl_image_external.user_data, @@ -161,7 +162,7 @@ allocate_with_size (CoglTexture2D *tex_2d, tex_2d->gl_internal_format = gl_intformat; - _cogl_bind_gl_texture_transient (GL_TEXTURE_2D, + _cogl_bind_gl_texture_transient (ctx, GL_TEXTURE_2D, gl_texture); /* Clear any GL errors */ @@ -358,7 +359,7 @@ cogl_texture_2d_gl_bind_egl_image (CoglTexture2D *tex_2d, { CoglContext *ctx = cogl_texture_get_context (COGL_TEXTURE (tex_2d)); - _cogl_bind_gl_texture_transient (GL_TEXTURE_2D, + _cogl_bind_gl_texture_transient (ctx, GL_TEXTURE_2D, tex_2d->gl_texture); _cogl_gl_util_clear_gl_errors (ctx); @@ -464,7 +465,7 @@ _cogl_texture_2d_gl_flush_legacy_texobj_filters (CoglTexture *tex, tex_2d->gl_legacy_texobj_mag_filter = mag_filter; /* Apply new filters to the texture */ - _cogl_bind_gl_texture_transient (GL_TEXTURE_2D, + _cogl_bind_gl_texture_transient (ctx, GL_TEXTURE_2D, tex_2d->gl_texture); GE( ctx, glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter) ); GE( ctx, glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter) ); @@ -493,7 +494,7 @@ _cogl_texture_2d_gl_flush_legacy_texobj_wrap_modes (CoglTexture *tex, if (tex_2d->gl_legacy_texobj_wrap_mode_s != wrap_mode_s || tex_2d->gl_legacy_texobj_wrap_mode_t != wrap_mode_t) { - _cogl_bind_gl_texture_transient (GL_TEXTURE_2D, + _cogl_bind_gl_texture_transient (ctx, GL_TEXTURE_2D, tex_2d->gl_texture); GE( ctx, glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, @@ -530,7 +531,7 @@ _cogl_texture_2d_gl_copy_from_framebuffer (CoglTexture2D *tex_2d, (COGL_FRAMEBUFFER_STATE_ALL & ~COGL_FRAMEBUFFER_STATE_CLIP)); - _cogl_bind_gl_texture_transient (GL_TEXTURE_2D, + _cogl_bind_gl_texture_transient (ctx, GL_TEXTURE_2D, tex_2d->gl_texture); ctx->glCopyTexSubImage2D (GL_TEXTURE_2D, @@ -645,7 +646,7 @@ _cogl_texture_2d_gl_get_data (CoglTexture2D *tex_2d, width, bpp); - _cogl_bind_gl_texture_transient (tex_2d->gl_target, + _cogl_bind_gl_texture_transient (ctx, tex_2d->gl_target, tex_2d->gl_texture); ctx->texture_driver->gl_get_tex_image (ctx, diff --git a/cogl/cogl/driver/gl/cogl-texture-gl.c b/cogl/cogl/driver/gl/cogl-texture-gl.c index c90835df4aec5c776d725ccb2b1bdb243349868b..60396b3850486773da4c3688bd8b9fd71b52f2d6 100644 --- a/cogl/cogl/driver/gl/cogl-texture-gl.c +++ b/cogl/cogl/driver/gl/cogl-texture-gl.c @@ -122,7 +122,7 @@ cogl_texture_gl_set_max_level (CoglTexture *texture, cogl_texture_set_max_level_set (texture, max_level); - _cogl_bind_gl_texture_transient (gl_target, + _cogl_bind_gl_texture_transient (ctx, gl_target, gl_handle); GE( ctx, glTexParameteri (gl_target, @@ -143,7 +143,7 @@ _cogl_texture_gl_generate_mipmaps (CoglTexture *texture) cogl_texture_get_gl_texture (texture, &gl_handle, &gl_target); - _cogl_bind_gl_texture_transient (gl_target, + _cogl_bind_gl_texture_transient (ctx, gl_target, gl_handle); GE( ctx, glGenerateMipmap (gl_target) ); } diff --git a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c index 845b1550eda60391638c7578b243f53b2f5f0ac9..6bc944a178f001a7396f1beec45425f863061f11 100644 --- a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c +++ b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c @@ -429,14 +429,14 @@ _cogl_driver_update_features (CoglContext *ctx, functions because we need to use them to determine what functions we can expect */ ctx->glGetString = - (void *) _cogl_renderer_get_proc_address (ctx->display->renderer, - "glGetString"); + (void *) cogl_renderer_get_proc_address (ctx->display->renderer, + "glGetString"); ctx->glGetStringi = - (void *) _cogl_renderer_get_proc_address (ctx->display->renderer, - "glGetStringi"); + (void *) cogl_renderer_get_proc_address (ctx->display->renderer, + "glGetStringi"); ctx->glGetIntegerv = - (void *) _cogl_renderer_get_proc_address (ctx->display->renderer, - "glGetIntegerv"); + (void *) cogl_renderer_get_proc_address (ctx->display->renderer, + "glGetIntegerv"); gl_extensions = _cogl_context_get_gl_extensions (ctx); diff --git a/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl.c b/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl.c index dd19d956bf234542f0de4523eccc1c8c6e7731ec..c78d48e3f48c534d5dc9ceaf63b02077e4381992 100644 --- a/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl.c +++ b/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl.c @@ -64,7 +64,7 @@ _cogl_texture_driver_gen (CoglContext *ctx, GE (ctx, glGenTextures (1, &tex)); - _cogl_bind_gl_texture_transient (gl_target, tex); + _cogl_bind_gl_texture_transient (ctx, gl_target, tex); switch (gl_target) { @@ -213,7 +213,7 @@ _cogl_texture_driver_upload_subregion_to_gl (CoglContext *ctx, src_y, bpp); - _cogl_bind_gl_texture_transient (gl_target, gl_handle); + _cogl_bind_gl_texture_transient (ctx, gl_target, gl_handle); /* Clear any GL errors */ _cogl_gl_util_clear_gl_errors (ctx); @@ -320,7 +320,7 @@ _cogl_texture_driver_upload_to_gl (CoglContext *ctx, cogl_bitmap_get_rowstride (source_bmp), 0, 0, 0, bpp); - _cogl_bind_gl_texture_transient (gl_target, gl_handle); + _cogl_bind_gl_texture_transient (ctx, gl_target, gl_handle); /* Clear any GL errors */ _cogl_gl_util_clear_gl_errors (ctx); diff --git a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c index 1d9161bbfb6f0c7174a7e8b8c6aa295223c9d5ed..853d1dde08b9b89a7c11e7c5affe124b67160edd 100644 --- a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c +++ b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c @@ -578,11 +578,11 @@ _cogl_driver_update_features (CoglContext *context, function because we need to use it to determine what functions we can expect */ context->glGetString = - (void *) _cogl_renderer_get_proc_address (context->display->renderer, - "glGetString"); + (void *) cogl_renderer_get_proc_address (context->display->renderer, + "glGetString"); context->glGetStringi = - (void *) _cogl_renderer_get_proc_address (context->display->renderer, - "glGetStringi"); + (void *) cogl_renderer_get_proc_address (context->display->renderer, + "glGetStringi"); gl_extensions = _cogl_context_get_gl_extensions (context); diff --git a/cogl/cogl/driver/gl/gles/cogl-texture-driver-gles.c b/cogl/cogl/driver/gl/gles/cogl-texture-driver-gles.c index 72d8155d0ef916edf6310b22466a7b5c00eca373..4737ed131e09231d5a01dc5281a441368157cebb 100644 --- a/cogl/cogl/driver/gl/gles/cogl-texture-driver-gles.c +++ b/cogl/cogl/driver/gl/gles/cogl-texture-driver-gles.c @@ -79,7 +79,7 @@ _cogl_texture_driver_gen (CoglContext *ctx, GE (ctx, glGenTextures (1, &tex)); - _cogl_bind_gl_texture_transient (gl_target, tex); + _cogl_bind_gl_texture_transient (ctx, gl_target, tex); switch (gl_target) { @@ -267,7 +267,7 @@ _cogl_texture_driver_upload_subregion_to_gl (CoglContext *ctx, return FALSE; } - _cogl_bind_gl_texture_transient (gl_target, gl_handle); + _cogl_bind_gl_texture_transient (ctx, gl_target, gl_handle); /* Clear any GL errors */ _cogl_gl_util_clear_gl_errors (ctx); @@ -369,7 +369,7 @@ _cogl_texture_driver_upload_to_gl (CoglContext *ctx, /* Setup gl alignment to match rowstride and top-left corner */ _cogl_texture_driver_prep_gl_for_pixels_upload (ctx, rowstride, bpp); - _cogl_bind_gl_texture_transient (gl_target, gl_handle); + _cogl_bind_gl_texture_transient (ctx, gl_target, gl_handle); data = _cogl_bitmap_gl_bind (bmp, COGL_BUFFER_ACCESS_READ, diff --git a/cogl/cogl/meson.build b/cogl/cogl/meson.build index 604a9a361f4e5e830f71215428cca923a9640e66..d1dd5c00f5614456e3502cbc3da59b63b39e6d7b 100644 --- a/cogl/cogl/meson.build +++ b/cogl/cogl/meson.build @@ -16,7 +16,6 @@ endif cogl_deprecated_headers = [ 'deprecated/cogl-program.h', 'deprecated/cogl-shader.h', - 'deprecated/cogl-clutter.h', ] cogl_headers = [ @@ -26,7 +25,6 @@ cogl_headers = [ 'cogl-attribute.h', 'cogl-bitmap.h', 'cogl-color.h', - 'cogl1-context.h', 'cogl-context.h', 'cogl-depth-state.h', 'cogl-display.h', @@ -283,7 +281,6 @@ cogl_sources = [ 'cogl-util.c', 'cogl-util.h', 'cogl.c', - 'deprecated/cogl-clutter.c', 'deprecated/cogl-program-private.h', 'deprecated/cogl-program.c', 'deprecated/cogl-shader-private.h', diff --git a/cogl/cogl/winsys/cogl-onscreen-glx.c b/cogl/cogl/winsys/cogl-onscreen-glx.c index acb5110064bd597fe9a3449a9413d77deec76fd8..eb11ea06916fafe89d881b6777fda965be99b355 100644 --- a/cogl/cogl/winsys/cogl-onscreen-glx.c +++ b/cogl/cogl/winsys/cogl-onscreen-glx.c @@ -192,7 +192,7 @@ cogl_onscreen_glx_allocate (CoglFramebuffer *framebuffer, } #ifdef GLX_INTEL_swap_event - if (_cogl_winsys_has_feature (COGL_WINSYS_FEATURE_SYNC_AND_COMPLETE_EVENT)) + if (cogl_context_has_winsys_feature (context, COGL_WINSYS_FEATURE_SYNC_AND_COMPLETE_EVENT)) { GLXDrawable drawable = onscreen_glx->glxwin ? onscreen_glx->glxwin : onscreen_glx->xwin; @@ -530,7 +530,7 @@ cogl_onscreen_glx_get_buffer_age (CoglOnscreen *onscreen) GLXDrawable drawable; unsigned int age = 0; - if (!_cogl_winsys_has_feature (COGL_WINSYS_FEATURE_BUFFER_AGE)) + if (!cogl_context_has_winsys_feature (context, COGL_WINSYS_FEATURE_BUFFER_AGE)) return 0; cogl_onscreen_bind (onscreen); @@ -677,7 +677,7 @@ cogl_onscreen_glx_swap_region (CoglOnscreen *onscreen, * we only need it to throttle redraws. */ gboolean blit_sub_buffer_is_synchronized = - _cogl_winsys_has_feature (COGL_WINSYS_FEATURE_SWAP_REGION_SYNCHRONIZED); + cogl_context_has_winsys_feature (context, COGL_WINSYS_FEATURE_SWAP_REGION_SYNCHRONIZED); int framebuffer_width = cogl_framebuffer_get_width (framebuffer); int framebuffer_height = cogl_framebuffer_get_height (framebuffer); @@ -844,7 +844,7 @@ cogl_onscreen_glx_swap_region (CoglOnscreen *onscreen, * handling _SYNC and _COMPLETE events in the winsys then we need to * send fake events in this case. */ - if (_cogl_winsys_has_feature (COGL_WINSYS_FEATURE_SYNC_AND_COMPLETE_EVENT)) + if (cogl_context_has_winsys_feature (context, COGL_WINSYS_FEATURE_SYNC_AND_COMPLETE_EVENT)) { set_sync_pending (onscreen); set_complete_pending (onscreen); diff --git a/cogl/cogl/winsys/cogl-winsys-glx.c b/cogl/cogl/winsys/cogl-winsys-glx.c index 67af975e45f98fc96e296da38838840611807fc1..bed116eff375b51d7f066cade227dd5ac2d3f94c 100644 --- a/cogl/cogl/winsys/cogl-winsys-glx.c +++ b/cogl/cogl/winsys/cogl-winsys-glx.c @@ -261,8 +261,7 @@ static gboolean update_all_outputs (CoglRenderer *renderer) { GList *l; - - _COGL_GET_CONTEXT (context, FALSE); + CoglContext *context = renderer->display->context; if (context->display == NULL) /* during connection */ return FALSE; @@ -473,12 +472,12 @@ update_winsys_features (CoglContext *context, GError **error) /* Note: glXCopySubBuffer and glBlitFramebuffer won't be throttled * by the SwapInterval so we have to throttle swap_region requests * manually... */ - if (_cogl_winsys_has_feature (COGL_WINSYS_FEATURE_SWAP_REGION) && + if (cogl_context_has_winsys_feature (context, COGL_WINSYS_FEATURE_SWAP_REGION) && (glx_display->have_vblank_counter || glx_display->can_vblank_wait)) COGL_FLAGS_SET (context->winsys_features, COGL_WINSYS_FEATURE_SWAP_REGION_THROTTLE, TRUE); - if (_cogl_winsys_has_feature (COGL_WINSYS_FEATURE_SYNC_AND_COMPLETE_EVENT)) + if (cogl_context_has_winsys_feature (context, COGL_WINSYS_FEATURE_SYNC_AND_COMPLETE_EVENT)) { COGL_FLAGS_SET (context->winsys_features, COGL_WINSYS_FEATURE_SWAP_BUFFERS_EVENT, TRUE); @@ -490,7 +489,7 @@ update_winsys_features (CoglContext *context, GError **error) COGL_PRIVATE_FEATURE_DIRTY_EVENTS, TRUE); - if (_cogl_winsys_has_feature (COGL_WINSYS_FEATURE_BUFFER_AGE)) + if (cogl_context_has_winsys_feature (context, COGL_WINSYS_FEATURE_BUFFER_AGE)) COGL_FLAGS_SET (context->features, COGL_FEATURE_ID_BUFFER_AGE, TRUE); return TRUE; @@ -1123,7 +1122,7 @@ _cogl_winsys_texture_pixmap_x11_create (CoglTexturePixmapX11 *tex_pixmap) CoglTexturePixmapGLX *glx_tex_pixmap; CoglContext *ctx = cogl_texture_get_context (COGL_TEXTURE (tex_pixmap)); - if (!_cogl_winsys_has_feature (COGL_WINSYS_FEATURE_TEXTURE_FROM_PIXMAP)) + if (!cogl_context_has_winsys_feature (ctx, COGL_WINSYS_FEATURE_TEXTURE_FROM_PIXMAP)) { tex_pixmap->winsys = NULL; return FALSE; @@ -1329,7 +1328,7 @@ _cogl_winsys_texture_pixmap_x11_update (CoglTexturePixmapX11 *tex_pixmap, COGL_NOTE (TEXTURE_PIXMAP, "Rebinding GLXPixmap for %p", tex_pixmap); - _cogl_bind_gl_texture_transient (gl_target, gl_handle); + _cogl_bind_gl_texture_transient (ctx, gl_target, gl_handle); if (texture_info->pixmap_bound) glx_renderer->glXReleaseTexImage (xlib_renderer->xdpy, diff --git a/cogl/cogl/winsys/cogl-winsys-private.h b/cogl/cogl/winsys/cogl-winsys-private.h index c7670b0f4583dfe9bdc00a75cf05f3a208248090..21ac6113eac1eb7d4c5a11655f35cdf190070c0c 100644 --- a/cogl/cogl/winsys/cogl-winsys-private.h +++ b/cogl/cogl/winsys/cogl-winsys-private.h @@ -135,6 +135,3 @@ typedef struct _CoglWinsysVtable } CoglWinsysVtable; typedef const CoglWinsysVtable *(*CoglWinsysVtableGetter) (void); - -gboolean -_cogl_winsys_has_feature (CoglWinsysFeature feature); diff --git a/cogl/cogl/winsys/cogl-winsys.c b/cogl/cogl/winsys/cogl-winsys.c index 687dbd0d62a0bb8efae6a607471d6aafff488c4f..5b29ae70326cf84306a81887377354407c0972c7 100644 --- a/cogl/cogl/winsys/cogl-winsys.c +++ b/cogl/cogl/winsys/cogl-winsys.c @@ -39,12 +39,3 @@ _cogl_winsys_error_quark (void) { return g_quark_from_static_string ("cogl-winsys-error-quark"); } - -/* FIXME: we should distinguish renderer and context features */ -gboolean -_cogl_winsys_has_feature (CoglWinsysFeature feature) -{ - _COGL_GET_CONTEXT (ctx, FALSE); - - return COGL_FLAGS_GET (ctx->winsys_features, feature); -} diff --git a/src/backends/meta-stage-impl.c b/src/backends/meta-stage-impl.c index 552cc1637cbfc4c1f038c234dccf8e914c370beb..a633d0b08e29ffef8cae65f6aab2656bbaf314c2 100644 --- a/src/backends/meta-stage-impl.c +++ b/src/backends/meta-stage-impl.c @@ -472,6 +472,7 @@ should_use_clipped_redraw (gboolean is_full_redraw, gboolean can_blit_sub_buffer; gboolean can_use_clipped_redraw; gboolean is_warmed_up; + CoglContext *context = cogl_framebuffer_get_context (framebuffer); if (is_full_redraw) return FALSE; @@ -490,7 +491,7 @@ should_use_clipped_redraw (gboolean is_full_redraw, } can_blit_sub_buffer = - cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_SWAP_REGION); + cogl_context_has_winsys_feature (context, COGL_WINSYS_FEATURE_SWAP_REGION); can_use_clipped_redraw = _clutter_stage_window_can_clip_redraws (stage_window) && (can_blit_sub_buffer || has_buffer_age); @@ -509,6 +510,7 @@ meta_stage_impl_redraw_view_primary (MetaStageImpl *stage_impl, ClutterStageWindow *stage_window = CLUTTER_STAGE_WINDOW (stage_impl); MetaStageView *view = META_STAGE_VIEW (stage_view); CoglFramebuffer *fb = clutter_stage_view_get_framebuffer (stage_view); + CoglContext *context = cogl_framebuffer_get_context (fb); CoglFramebuffer *onscreen = clutter_stage_view_get_onscreen (stage_view); MtkRectangle view_rect; gboolean is_full_redraw; @@ -536,7 +538,7 @@ meta_stage_impl_redraw_view_primary (MetaStageImpl *stage_impl, has_buffer_age = COGL_IS_ONSCREEN (onscreen) && - cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_BUFFER_AGE); + cogl_context_has_winsys_feature (context, COGL_WINSYS_FEATURE_BUFFER_AGE); redraw_clip = clutter_stage_view_take_accumulated_redraw_clip (stage_view); diff --git a/src/compositor/meta-compositor-x11.c b/src/compositor/meta-compositor-x11.c index cbc48bcefc86e4d64cb54c74abc603b8c5eb960e..657f9bdb65c7e72e309c3ca759aaacd27f7f3d70 100644 --- a/src/compositor/meta-compositor-x11.c +++ b/src/compositor/meta-compositor-x11.c @@ -133,6 +133,8 @@ meta_compositor_x11_manage (MetaCompositor *compositor, MetaDisplay *display = meta_compositor_get_display (compositor); MetaContext *context = meta_display_get_context (display); MetaBackend *backend = meta_context_get_backend (context); + ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend); + CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend); MetaX11Display *x11_display = display->x11_display; Display *xdisplay = meta_x11_display_get_xdisplay (x11_display); int composite_version; @@ -186,7 +188,7 @@ meta_compositor_x11_manage (MetaCompositor *compositor, */ XMapWindow (xdisplay, compositor_x11->output); - compositor_x11->have_x11_sync_object = meta_sync_ring_init (xdisplay); + compositor_x11->have_x11_sync_object = meta_sync_ring_init (cogl_context, xdisplay); return TRUE; } @@ -332,6 +334,9 @@ maybe_do_sync (MetaCompositor *compositor) if (compositor_x11->frame_has_updated_xsurfaces) { MetaDisplay *display = meta_compositor_get_display (compositor); + MetaBackend *backend = meta_compositor_get_backend (compositor); + ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend); + CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend); /* * We need to make sure that any X drawing that happens before the @@ -354,7 +359,7 @@ maybe_do_sync (MetaCompositor *compositor) * at this point is sufficient to flush the GLX buffers. */ if (compositor_x11->have_x11_sync_object) - compositor_x11->have_x11_sync_object = meta_sync_ring_insert_wait (); + compositor_x11->have_x11_sync_object = meta_sync_ring_insert_wait (cogl_context); else XSync (display->x11_display->xdisplay, False); } @@ -379,8 +384,12 @@ on_after_update (ClutterStage *stage, if (compositor_x11->frame_has_updated_xsurfaces) { + MetaBackend *backend = meta_compositor_get_backend (compositor); + ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend); + CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend); + if (compositor_x11->have_x11_sync_object) - compositor_x11->have_x11_sync_object = meta_sync_ring_after_frame (); + compositor_x11->have_x11_sync_object = meta_sync_ring_after_frame (cogl_context); compositor_x11->frame_has_updated_xsurfaces = FALSE; } diff --git a/src/compositor/meta-surface-actor-x11.c b/src/compositor/meta-surface-actor-x11.c index 346e1c502f0bd40b971c0c63a5c4cb58dfc50dff..9543613161570ab25e06e3d551c4d04e308c8571 100644 --- a/src/compositor/meta-surface-actor-x11.c +++ b/src/compositor/meta-surface-actor-x11.c @@ -88,6 +88,10 @@ detach_pixmap (MetaSurfaceActorX11 *self) { MetaDisplay *display = self->display; MetaShapedTexture *stex = meta_surface_actor_get_texture (META_SURFACE_ACTOR (self)); + MetaContext *context = meta_display_get_context (display); + MetaBackend *backend = meta_context_get_backend (context); + ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend); + CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend); Display *xdisplay; if (self->pixmap == None) @@ -100,7 +104,7 @@ detach_pixmap (MetaSurfaceActorX11 *self) * pixmap, but it certainly doesn't work with current DRI/Mesa */ meta_shaped_texture_set_texture (stex, NULL); - cogl_flush (); + cogl_context_flush (cogl_context); mtk_x11_error_trap_push (xdisplay); XFreePixmap (xdisplay, self->pixmap); diff --git a/src/compositor/meta-sync-ring.c b/src/compositor/meta-sync-ring.c index 1267dd4f2ca1a574a5eac13e5bc90091dca31b6b..81584128d6a7bf320e8be088e617832b41b45ddf 100644 --- a/src/compositor/meta-sync-ring.c +++ b/src/compositor/meta-sync-ring.c @@ -132,10 +132,11 @@ meta_sync_ring_get (void) } static gboolean -load_gl_symbol (const char *name, +load_gl_symbol (CoglContext *ctx, + const char *name, void **func) { - *func = cogl_get_proc_address (name); + *func = cogl_renderer_get_proc_address (ctx->display->renderer, name); if (!*func) { meta_verbose ("MetaSyncRing: failed to resolve required GL symbol \"%s\"", name); @@ -187,7 +188,7 @@ check_gl_extensions (void) } static gboolean -load_required_symbols (void) +load_required_symbols (CoglContext *ctx) { static gboolean success = FALSE; @@ -199,11 +200,11 @@ load_required_symbols (void) * and dynamically loaded libGL at this point. */ - if (!load_gl_symbol ("glGetString", (void **) &meta_gl_get_string)) + if (!load_gl_symbol (ctx, "glGetString", (void **) &meta_gl_get_string)) goto out; - if (!load_gl_symbol ("glGetIntegerv", (void **) &meta_gl_get_integerv)) + if (!load_gl_symbol (ctx, "glGetIntegerv", (void **) &meta_gl_get_integerv)) goto out; - if (!load_gl_symbol ("glGetStringi", (void **) &meta_gl_get_stringi)) + if (!load_gl_symbol (ctx, "glGetStringi", (void **) &meta_gl_get_stringi)) goto out; if (!check_gl_extensions ()) @@ -212,15 +213,15 @@ load_required_symbols (void) goto out; } - if (!load_gl_symbol ("glDeleteSync", (void **) &meta_gl_delete_sync)) + if (!load_gl_symbol (ctx, "glDeleteSync", (void **) &meta_gl_delete_sync)) goto out; - if (!load_gl_symbol ("glClientWaitSync", (void **) &meta_gl_client_wait_sync)) + if (!load_gl_symbol (ctx, "glClientWaitSync", (void **) &meta_gl_client_wait_sync)) goto out; - if (!load_gl_symbol ("glWaitSync", (void **) &meta_gl_wait_sync)) + if (!load_gl_symbol (ctx, "glWaitSync", (void **) &meta_gl_wait_sync)) goto out; - if (!load_gl_symbol ("glImportSyncEXT", (void **) &meta_gl_import_sync)) + if (!load_gl_symbol (ctx, "glImportSyncEXT", (void **) &meta_gl_import_sync)) goto out; - if (!load_gl_symbol ("glFenceSync", (void **) &meta_gl_fence_sync)) + if (!load_gl_symbol (ctx, "glFenceSync", (void **) &meta_gl_fence_sync)) goto out; success = TRUE; @@ -405,7 +406,8 @@ meta_sync_free (MetaSync *self) } gboolean -meta_sync_ring_init (Display *xdisplay) +meta_sync_ring_init (CoglContext *ctx, + Display *xdisplay) { gint major, minor; guint i; @@ -417,7 +419,7 @@ meta_sync_ring_init (Display *xdisplay) g_return_val_if_fail (xdisplay != NULL, FALSE); g_return_val_if_fail (ring->xdisplay == NULL, FALSE); - if (!load_required_symbols ()) + if (!load_required_symbols (ctx)) return FALSE; if (!XSyncQueryExtension (xdisplay, &ring->xsync_event_base, &ring->xsync_error_base) || @@ -477,7 +479,8 @@ meta_sync_ring_destroy (void) } static gboolean -meta_sync_ring_reboot (Display *xdisplay) +meta_sync_ring_reboot (CoglContext *ctx, + Display *xdisplay) { MetaSyncRing *ring = meta_sync_ring_get (); @@ -494,11 +497,11 @@ meta_sync_ring_reboot (Display *xdisplay) return FALSE; } - return meta_sync_ring_init (xdisplay); + return meta_sync_ring_init (ctx, xdisplay); } gboolean -meta_sync_ring_after_frame (void) +meta_sync_ring_after_frame (CoglContext *ctx) { MetaSyncRing *ring = meta_sync_ring_get (); @@ -522,7 +525,7 @@ meta_sync_ring_after_frame (void) if (status != GL_ALREADY_SIGNALED && status != GL_CONDITION_SATISFIED) { meta_warning ("MetaSyncRing: Timed out waiting for sync object."); - return meta_sync_ring_reboot (ring->xdisplay); + return meta_sync_ring_reboot (ctx, ring->xdisplay); } meta_sync_reset (sync_to_reset); @@ -541,7 +544,7 @@ meta_sync_ring_after_frame (void) } gboolean -meta_sync_ring_insert_wait (void) +meta_sync_ring_insert_wait (CoglContext *ctx) { MetaSyncRing *ring = meta_sync_ring_get (); MetaSync *sync; @@ -562,7 +565,7 @@ meta_sync_ring_insert_wait (void) else if (sync->state != META_SYNC_STATE_READY) { meta_warning ("MetaSyncRing: Sync object is not ready -- were events handled properly?"); - if (!meta_sync_ring_reboot (ring->xdisplay)) + if (!meta_sync_ring_reboot (ctx, ring->xdisplay)) return FALSE; } diff --git a/src/compositor/meta-sync-ring.h b/src/compositor/meta-sync-ring.h index 0f96f51e30e64859736a9e03f47ddd02d3a402d9..6b82a349b06d14fa5f854b7d57eeaa6f1f12c81e 100644 --- a/src/compositor/meta-sync-ring.h +++ b/src/compositor/meta-sync-ring.h @@ -3,8 +3,11 @@ #include #include -gboolean meta_sync_ring_init (Display *dpy); +#include "cogl/cogl.h" + +gboolean meta_sync_ring_init (CoglContext *ctx, + Display *dpy); void meta_sync_ring_destroy (void); -gboolean meta_sync_ring_after_frame (void); -gboolean meta_sync_ring_insert_wait (void); +gboolean meta_sync_ring_after_frame (CoglContext *ctx); +gboolean meta_sync_ring_insert_wait (CoglContext *ctx); void meta_sync_ring_handle_event (XEvent *event); diff --git a/src/tests/cogl/conform/test-sub-texture.c b/src/tests/cogl/conform/test-sub-texture.c index 5f0a50ac4607c78cfcf9705c82883d5dd015225f..7587517b370b66260cce807bd62ac886154fd78f 100644 --- a/src/tests/cogl/conform/test-sub-texture.c +++ b/src/tests/cogl/conform/test-sub-texture.c @@ -211,7 +211,7 @@ validate_result (TestState *state) /* Sub sub texture */ p = texture_data = g_malloc (10 * 10 * 4); - cogl_flush (); + cogl_context_flush (cogl_framebuffer_get_context (test_fb)); cogl_framebuffer_read_pixels (test_fb, 0, SOURCE_SIZE * 2, 10, 10, COGL_PIXEL_FORMAT_RGBA_8888,