diff --git a/cogl/cogl/cogl-atlas-texture.c b/cogl/cogl/cogl-atlas-texture.c index 731a0b9fe..40ceae08f 100644 --- a/cogl/cogl/cogl-atlas-texture.c +++ b/cogl/cogl/cogl-atlas-texture.c @@ -139,7 +139,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, @@ -336,11 +336,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 @@ -351,7 +353,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-context.c b/cogl/cogl/cogl-context.c index 12dbd006e..04a8ae0a6 100644 --- a/cogl/cogl/cogl-context.c +++ b/cogl/cogl/cogl-context.c @@ -575,3 +575,12 @@ cogl_context_has_winsys_feature (CoglContext *context, { 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 36ed70844..fcc32a169 100644 --- a/cogl/cogl/cogl-context.h +++ b/cogl/cogl/cogl-context.h @@ -345,5 +345,32 @@ 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-pipeline.c b/cogl/cogl/cogl-pipeline.c index 4f33c4055..e5b9764a0 100644 --- a/cogl/cogl/cogl-pipeline.c +++ b/cogl/cogl/cogl-pipeline.c @@ -1084,7 +1084,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.c b/cogl/cogl/cogl.c index 40c85706c..626dae976 100644 --- a/cogl/cogl/cogl.c +++ b/cogl/cogl/cogl.c @@ -80,17 +80,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) { diff --git a/cogl/cogl/cogl1-context.h b/cogl/cogl/cogl1-context.h index 9164ea7fe..6b7996f38 100644 --- a/cogl/cogl/cogl1-context.h +++ b/cogl/cogl/cogl1-context.h @@ -62,31 +62,5 @@ G_BEGIN_DECLS 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/src/compositor/meta-surface-actor-x11.c b/src/compositor/meta-surface-actor-x11.c index 346e1c502..954361316 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/tests/cogl/conform/test-sub-texture.c b/src/tests/cogl/conform/test-sub-texture.c index 5f0a50ac4..7587517b3 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,