From 8f8b05f0e5f6bd3a82abc9355397ef0640934e68 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Thu, 17 Feb 2011 13:11:34 +0000 Subject: cogl-atlas-texture: Don't let textures be destroyed during migration If an atlas texture's last reference is held by the journal or by the last flushed pipeline then if an atlas migration is started it can cause a crash. This is because the atlas migration will cause a journal flush and can sometimes change the current pipeline which means that the texture would be destroyed during migration. This patch adds an extra 'post_reorganize' callback to the existing 'reorganize' callback (which is now renamed to 'pre_reorganize'). The pre_reorganize callback is now called before the atlas grabs a list of the current textures instead of after so that it doesn't matter if the journal flush destroys some of those textures. The pre_reorganize callback for CoglAtlasTexture grabs a reference to all of the textures so that they can not be destroyed when the migration changes the pipeline. In the post_reorganize callback the reference is removed again. http://bugzilla.clutter-project.org/show_bug.cgi?id=2538 --- cogl/cogl-atlas.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'cogl/cogl-atlas.h') diff --git a/cogl/cogl-atlas.h b/cogl/cogl-atlas.h index 1c5ae30c..72eb8ad8 100644 --- a/cogl/cogl-atlas.h +++ b/cogl/cogl-atlas.h @@ -3,7 +3,7 @@ * * An object oriented GL/GLES Abstraction/Utility Layer * - * Copyright (C) 2010 Intel Corporation. + * Copyright (C) 2010,2011 Intel Corporation. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -55,7 +55,8 @@ struct _CoglAtlas CoglAtlasUpdatePositionCallback update_position_cb; - CoglCallbackList reorganize_callbacks; + CoglCallbackList pre_reorganize_callbacks; + CoglCallbackList post_reorganize_callbacks; }; CoglAtlas * @@ -84,12 +85,14 @@ _cogl_atlas_copy_rectangle (CoglAtlas *atlas, void _cogl_atlas_add_reorganize_callback (CoglAtlas *atlas, - CoglCallbackListFunc callback, + CoglCallbackListFunc pre_callback, + CoglCallbackListFunc post_callback, void *user_data); void _cogl_atlas_remove_reorganize_callback (CoglAtlas *atlas, - CoglCallbackListFunc callback, + CoglCallbackListFunc pre_callback, + CoglCallbackListFunc post_callback, void *user_data); #endif /* __COGL_ATLAS_H */ -- cgit v1.2.1