Always use mipmap emulation
Rather than trying to find out from Clutter whether mipmap generation can be used together with texture_from_pixmap, just always assume it can't and use the MutterTextureTower emulation code. This fixes a problem with our previous hack for doing the query no longer working. In the rare cases where mipmap generation is supported, it is unlikely to produce significantly more efficient or better looking results than the emulation. (In terms of efficiency, we have better knowledge of when we need to update the lower mipmaps and when we don't than CoglTexturePixmapX11.) Some care is taken so mutter_shaped_texture_set_create_mipmaps() works when changed on the fly and properly discards the old mipmap levels. This isn't necesary currently, since it can only be controlled via envvar, but is easier than future-proofing through documentation. https://bugzilla.gnome.org/show_bug.cgi?id=627087
This commit is contained in:
parent
15a214e435
commit
c9ebc0ea25
@ -73,6 +73,8 @@ struct _MutterShapedTexturePrivate
|
|||||||
guint mask_width, mask_height;
|
guint mask_width, mask_height;
|
||||||
|
|
||||||
GArray *rectangles;
|
GArray *rectangles;
|
||||||
|
|
||||||
|
guint create_mipmaps : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -105,6 +107,7 @@ mutter_shaped_texture_init (MutterShapedTexture *self)
|
|||||||
|
|
||||||
priv->paint_tower = mutter_texture_tower_new ();
|
priv->paint_tower = mutter_texture_tower_new ();
|
||||||
priv->mask_texture = COGL_INVALID_HANDLE;
|
priv->mask_texture = COGL_INVALID_HANDLE;
|
||||||
|
priv->create_mipmaps = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -163,8 +166,9 @@ mutter_shaped_texture_notify (GObject *object,
|
|||||||
MutterShapedTexture *stex = (MutterShapedTexture *) object;
|
MutterShapedTexture *stex = (MutterShapedTexture *) object;
|
||||||
MutterShapedTexturePrivate *priv = stex->priv;
|
MutterShapedTexturePrivate *priv = stex->priv;
|
||||||
|
|
||||||
mutter_texture_tower_set_base_texture (priv->paint_tower,
|
if (priv->create_mipmaps)
|
||||||
clutter_texture_get_cogl_texture (CLUTTER_TEXTURE (stex)));
|
mutter_texture_tower_set_base_texture (priv->paint_tower,
|
||||||
|
clutter_texture_get_cogl_texture (CLUTTER_TEXTURE (stex)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,27 +300,25 @@ mutter_shaped_texture_paint (ClutterActor *actor)
|
|||||||
if (!CLUTTER_ACTOR_IS_REALIZED (CLUTTER_ACTOR (stex)))
|
if (!CLUTTER_ACTOR_IS_REALIZED (CLUTTER_ACTOR (stex)))
|
||||||
clutter_actor_realize (CLUTTER_ACTOR (stex));
|
clutter_actor_realize (CLUTTER_ACTOR (stex));
|
||||||
|
|
||||||
/* If mipmaps are supported, then the texture filter quality will
|
/* The GL EXT_texture_from_pixmap extension does allow for it to be
|
||||||
* still be HIGH here. In that case we just want to use the base
|
* used together with SGIS_generate_mipmap, however this is very
|
||||||
* texture. If mipmaps are not support then
|
* rarely supported. Also, even when it is supported there
|
||||||
* on_glx_texture_pixmap_pre_paint() will have reset the texture
|
* are distinct performance implications from:
|
||||||
* filter quality to MEDIUM, and we should use the MutterTextureTower
|
|
||||||
* mipmap emulation.
|
|
||||||
*
|
*
|
||||||
* http://bugzilla.openedhand.com/show_bug.cgi?id=1877 is an RFE
|
* - Updating mipmaps that we don't need
|
||||||
* for a better way of handling this.
|
* - Having to reallocate pixmaps on the server into larger buffers
|
||||||
*
|
*
|
||||||
* While it would be nice to have direct access to the 'can_mipmap'
|
* So, we just unconditionally use our mipmap emulation code. If we
|
||||||
* boolean in ClutterGLXTexturePixmap, since since MutterTextureTower
|
* wanted to use SGIS_generate_mipmap, we'd have to query COGL to
|
||||||
* creates the scaled down images on demand there is no substantial
|
* see if it was supported (no API currently), and then if and only
|
||||||
* overhead from doing the work to create and update the tower and
|
* if that was the case, set the clutter texture quality to HIGH.
|
||||||
* not using it, other than the memory allocated for the MutterTextureTower
|
* Setting the texture quality to high without SGIS_generate_mipmap
|
||||||
* structure itself.
|
* support for TFP textures will result in fallbacks to XGetImage.
|
||||||
*/
|
*/
|
||||||
if (clutter_texture_get_filter_quality (CLUTTER_TEXTURE (stex)) == CLUTTER_TEXTURE_QUALITY_HIGH)
|
if (priv->create_mipmaps)
|
||||||
paint_tex = clutter_texture_get_cogl_texture (CLUTTER_TEXTURE (stex));
|
|
||||||
else
|
|
||||||
paint_tex = mutter_texture_tower_get_paint_texture (priv->paint_tower);
|
paint_tex = mutter_texture_tower_get_paint_texture (priv->paint_tower);
|
||||||
|
else
|
||||||
|
paint_tex = clutter_texture_get_cogl_texture (CLUTTER_TEXTURE (stex));
|
||||||
|
|
||||||
if (paint_tex == COGL_INVALID_HANDLE)
|
if (paint_tex == COGL_INVALID_HANDLE)
|
||||||
return;
|
return;
|
||||||
@ -490,6 +492,31 @@ mutter_shaped_texture_new (void)
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
mutter_shaped_texture_set_create_mipmaps (MutterShapedTexture *stex,
|
||||||
|
gboolean create_mipmaps)
|
||||||
|
{
|
||||||
|
MutterShapedTexturePrivate *priv;
|
||||||
|
|
||||||
|
g_return_if_fail (MUTTER_IS_SHAPED_TEXTURE (stex));
|
||||||
|
|
||||||
|
priv = stex->priv;
|
||||||
|
|
||||||
|
create_mipmaps = create_mipmaps != FALSE;
|
||||||
|
|
||||||
|
if (create_mipmaps != priv->create_mipmaps)
|
||||||
|
{
|
||||||
|
CoglHandle base_texture;
|
||||||
|
|
||||||
|
priv->create_mipmaps = create_mipmaps;
|
||||||
|
|
||||||
|
base_texture = create_mipmaps ?
|
||||||
|
clutter_texture_get_cogl_texture (CLUTTER_TEXTURE (stex)) : COGL_INVALID_HANDLE;
|
||||||
|
|
||||||
|
mutter_texture_tower_set_base_texture (priv->paint_tower, base_texture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mutter_shaped_texture_clear_rectangles (MutterShapedTexture *stex)
|
mutter_shaped_texture_clear_rectangles (MutterShapedTexture *stex)
|
||||||
{
|
{
|
||||||
|
@ -86,6 +86,9 @@ GType mutter_shaped_texture_get_type (void) G_GNUC_CONST;
|
|||||||
|
|
||||||
ClutterActor *mutter_shaped_texture_new (void);
|
ClutterActor *mutter_shaped_texture_new (void);
|
||||||
|
|
||||||
|
void mutter_shaped_texture_set_create_mipmaps (MutterShapedTexture *stex,
|
||||||
|
gboolean create_mipmaps);
|
||||||
|
|
||||||
void mutter_shaped_texture_clear_rectangles (MutterShapedTexture *stex);
|
void mutter_shaped_texture_clear_rectangles (MutterShapedTexture *stex);
|
||||||
|
|
||||||
void mutter_shaped_texture_add_rectangle (MutterShapedTexture *stex,
|
void mutter_shaped_texture_add_rectangle (MutterShapedTexture *stex,
|
||||||
|
@ -1606,13 +1606,9 @@ check_needs_pixmap (MutterWindow *self)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* MUST call before setting pixmap or serious performance issues
|
if (compositor->no_mipmaps)
|
||||||
* seemingly caused by cogl_texture_set_filters() in set_filter
|
mutter_shaped_texture_set_create_mipmaps (MUTTER_SHAPED_TEXTURE (priv->actor),
|
||||||
* Not sure if that call is actually needed.
|
FALSE);
|
||||||
*/
|
|
||||||
if (!compositor->no_mipmaps)
|
|
||||||
clutter_texture_set_filter_quality (CLUTTER_TEXTURE (priv->actor),
|
|
||||||
CLUTTER_TEXTURE_QUALITY_HIGH );
|
|
||||||
|
|
||||||
clutter_x11_texture_pixmap_set_pixmap
|
clutter_x11_texture_pixmap_set_pixmap
|
||||||
(CLUTTER_X11_TEXTURE_PIXMAP (priv->actor),
|
(CLUTTER_X11_TEXTURE_PIXMAP (priv->actor),
|
||||||
|
Loading…
Reference in New Issue
Block a user