mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 18:11:05 -05:00
[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.
This commit is contained in:
parent
8e6e09c8ef
commit
4f692cc3ee
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user