From 4f692cc3ee9089c568952e758406954bc5cf72dd Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Thu, 30 Apr 2009 14:32:19 +0100 Subject: [PATCH] [ClutterTexture] Attach the FBO texture to a layer in the material Bug 1565 - test-fbo case failed in many platform clutter_texture_new_from_actor was broken because it created the FBO texture but then never attached it to the material so it was never used for rendering. The old behaviour in Clutter 0.8 was to assign the texture directly to priv->tex. In 0.9 priv->tex is replaced with priv->material which has a reference to the tex in layer 0. So putting the FBO texture directly in layer 0 more closely matches the original behaviour. --- clutter/clutter-texture.c | 47 ++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/clutter/clutter-texture.c b/clutter/clutter-texture.c index 52dc01c98..9eb1a3152 100644 --- a/clutter/clutter-texture.c +++ b/clutter/clutter-texture.c @@ -82,7 +82,6 @@ struct _ClutterTexturePrivate gint max_tile_waste; ClutterTextureQuality filter_quality; CoglHandle material; - CoglHandle fbo_texture; gboolean no_slice; ClutterActor *fbo_source; @@ -289,31 +288,34 @@ clutter_texture_realize (ClutterActor *actor) CoglTextureFlags flags = COGL_TEXTURE_NONE; gint min_filter, mag_filter; gint max_waste = -1; + CoglHandle tex; /* Handle FBO's */ - if (priv->fbo_texture != COGL_INVALID_HANDLE) - cogl_handle_unref (priv->fbo_texture); - if (!priv->no_slice) max_waste = priv->max_tile_waste; if (priv->filter_quality == CLUTTER_TEXTURE_QUALITY_HIGH) flags |= COGL_TEXTURE_AUTO_MIPMAP; - priv->fbo_texture = - cogl_texture_new_with_size (priv->width, - priv->height, - max_waste, flags, - COGL_PIXEL_FORMAT_RGBA_8888); + tex = cogl_texture_new_with_size (priv->width, + priv->height, + max_waste, flags, + COGL_PIXEL_FORMAT_RGBA_8888); + + cogl_material_set_layer (priv->material, 0, tex); clutter_texture_quality_to_filters (priv->filter_quality, &min_filter, &mag_filter); - cogl_texture_set_filters (priv->fbo_texture, min_filter, mag_filter); + cogl_texture_set_filters (tex, min_filter, mag_filter); - priv->fbo_handle = cogl_offscreen_new_to_texture (priv->fbo_texture); + priv->fbo_handle = cogl_offscreen_new_to_texture (tex); + + /* The material now has a reference to the texture so it will + stick around */ + cogl_handle_unref (tex); if (priv->fbo_handle == COGL_INVALID_HANDLE) { @@ -1216,7 +1218,6 @@ clutter_texture_init (ClutterTexture *self) priv->repeat_y = FALSE; priv->sync_actor_size = TRUE; priv->material = cogl_material_new (); - priv->fbo_texture = COGL_INVALID_HANDLE; priv->fbo_handle = COGL_INVALID_HANDLE; priv->local_data = NULL; priv->keep_aspect_ratio = FALSE; @@ -2299,6 +2300,7 @@ on_fbo_source_size_change (GObject *object, { CoglTextureFlags flags = COGL_TEXTURE_NONE; gint min_filter, mag_filter; + CoglHandle tex; /* tear down the FBO */ cogl_handle_unref (priv->fbo_handle); @@ -2311,20 +2313,25 @@ on_fbo_source_size_change (GObject *object, if (priv->filter_quality == CLUTTER_TEXTURE_QUALITY_HIGH) flags |= COGL_TEXTURE_AUTO_MIPMAP; - priv->fbo_texture = - cogl_texture_new_with_size (MAX (priv->width, 1), - MAX (priv->height, 1), - -1, - flags, - COGL_PIXEL_FORMAT_RGBA_8888); + tex = cogl_texture_new_with_size (MAX (priv->width, 1), + MAX (priv->height, 1), + -1, + flags, + COGL_PIXEL_FORMAT_RGBA_8888); + + cogl_material_set_layer (priv->material, 0, tex); clutter_texture_quality_to_filters (priv->filter_quality, &min_filter, &mag_filter); - cogl_texture_set_filters (priv->fbo_texture, min_filter, mag_filter); + cogl_texture_set_filters (tex, min_filter, mag_filter); - priv->fbo_handle = cogl_offscreen_new_to_texture (priv->fbo_texture); + priv->fbo_handle = cogl_offscreen_new_to_texture (tex); + + /* The material now has a reference to the texture so it will + stick around */ + cogl_handle_unref (tex); if (priv->fbo_handle == COGL_INVALID_HANDLE) {