mirror of
https://github.com/brl/mutter.git
synced 2025-02-06 08:34:10 +00:00
[texture] Consolidate the quality to filter conversions
To convert from a TextureQuality to a COGL filter enumeration we need to perform two function calls. Since we need both filters when calling cogl_texture_set_filters() we can safely consolidate the two conversion functions into one. This also allows using a shorter function name, thus reducing the lenght of the lines involved and, more importantly preventing Emmanuele from crying.
This commit is contained in:
parent
41ef2ef587
commit
29bff6890a
@ -152,41 +152,42 @@ clutter_texture_error_quark (void)
|
|||||||
return g_quark_from_static_string ("clutter-texture-error-quark");
|
return g_quark_from_static_string ("clutter-texture-error-quark");
|
||||||
}
|
}
|
||||||
|
|
||||||
static COGLenum
|
static inline void
|
||||||
clutter_texture_quality_to_cogl_min_filter (ClutterTextureQuality buf_filter)
|
clutter_texture_quality_to_filters (ClutterTextureQuality quality,
|
||||||
|
gint *min_filter_p,
|
||||||
|
gint *mag_filter_p)
|
||||||
{
|
{
|
||||||
switch (buf_filter)
|
gint min_filter, mag_filter;
|
||||||
{
|
|
||||||
case CLUTTER_TEXTURE_QUALITY_LOW:
|
|
||||||
return CGL_NEAREST;
|
|
||||||
case CLUTTER_TEXTURE_QUALITY_MEDIUM:
|
|
||||||
return CGL_LINEAR;
|
|
||||||
case CLUTTER_TEXTURE_QUALITY_HIGH:
|
|
||||||
return CGL_LINEAR_MIPMAP_LINEAR;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static COGLenum
|
switch (quality)
|
||||||
clutter_texture_quality_to_cogl_mag_filter (ClutterTextureQuality buf_filter)
|
|
||||||
{
|
|
||||||
switch (buf_filter)
|
|
||||||
{
|
{
|
||||||
case CLUTTER_TEXTURE_QUALITY_LOW:
|
case CLUTTER_TEXTURE_QUALITY_LOW:
|
||||||
return CGL_NEAREST;
|
min_filter = CGL_NEAREST;
|
||||||
case CLUTTER_TEXTURE_QUALITY_MEDIUM:
|
mag_filter = CGL_NEAREST;
|
||||||
case CLUTTER_TEXTURE_QUALITY_HIGH:
|
break;
|
||||||
return CGL_LINEAR;
|
|
||||||
|
case CLUTTER_TEXTURE_QUALITY_MEDIUM:
|
||||||
|
min_filter = CGL_LINEAR;
|
||||||
|
mag_filter = CGL_LINEAR;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CLUTTER_TEXTURE_QUALITY_HIGH:
|
||||||
|
min_filter = CGL_LINEAR_MIPMAP_LINEAR;
|
||||||
|
mag_filter = CGL_LINEAR;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
|
if (min_filter_p)
|
||||||
|
*min_filter_p = min_filter;
|
||||||
|
|
||||||
|
if (mag_filter_p)
|
||||||
|
*mag_filter_p = mag_filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
texture_free_gl_resources (ClutterTexture *texture)
|
texture_free_gl_resources (ClutterTexture *texture)
|
||||||
{
|
{
|
||||||
ClutterTexturePrivate *priv;
|
ClutterTexturePrivate *priv = texture->priv;
|
||||||
|
|
||||||
priv = texture->priv;
|
|
||||||
|
|
||||||
CLUTTER_MARK();
|
CLUTTER_MARK();
|
||||||
|
|
||||||
@ -259,6 +260,7 @@ clutter_texture_realize (ClutterActor *actor)
|
|||||||
if (priv->fbo_source)
|
if (priv->fbo_source)
|
||||||
{
|
{
|
||||||
CoglTextureFlags flags = COGL_TEXTURE_NONE;
|
CoglTextureFlags flags = COGL_TEXTURE_NONE;
|
||||||
|
gint min_filter, mag_filter;
|
||||||
gint max_waste = -1;
|
gint max_waste = -1;
|
||||||
|
|
||||||
/* Handle FBO's */
|
/* Handle FBO's */
|
||||||
@ -278,9 +280,11 @@ clutter_texture_realize (ClutterActor *actor)
|
|||||||
max_waste, flags,
|
max_waste, flags,
|
||||||
COGL_PIXEL_FORMAT_RGBA_8888);
|
COGL_PIXEL_FORMAT_RGBA_8888);
|
||||||
|
|
||||||
cogl_texture_set_filters (priv->fbo_texture,
|
clutter_texture_quality_to_filters (priv->filter_quality,
|
||||||
clutter_texture_quality_to_cogl_min_filter (priv->filter_quality),
|
&min_filter,
|
||||||
clutter_texture_quality_to_cogl_mag_filter (priv->filter_quality));
|
&mag_filter);
|
||||||
|
|
||||||
|
cogl_texture_set_filters (priv->fbo_texture, min_filter, mag_filter);
|
||||||
|
|
||||||
priv->fbo_handle = cogl_offscreen_new_to_texture (priv->fbo_texture);
|
priv->fbo_handle = cogl_offscreen_new_to_texture (priv->fbo_texture);
|
||||||
|
|
||||||
@ -1309,6 +1313,7 @@ clutter_texture_set_cogl_texture (ClutterTexture *texture,
|
|||||||
/* Remove FBO if exisiting */
|
/* Remove FBO if exisiting */
|
||||||
if (priv->fbo_source)
|
if (priv->fbo_source)
|
||||||
texture_fbo_free_resources (texture);
|
texture_fbo_free_resources (texture);
|
||||||
|
|
||||||
/* Remove old texture */
|
/* Remove old texture */
|
||||||
texture_free_gl_resources (texture);
|
texture_free_gl_resources (texture);
|
||||||
/* Use the new texture */
|
/* Use the new texture */
|
||||||
@ -1362,6 +1367,7 @@ clutter_texture_set_from_data (ClutterTexture *texture,
|
|||||||
ClutterTexturePrivate *priv = texture->priv;
|
ClutterTexturePrivate *priv = texture->priv;
|
||||||
CoglHandle new_texture = COGL_INVALID_HANDLE;
|
CoglHandle new_texture = COGL_INVALID_HANDLE;
|
||||||
CoglTextureFlags flags = COGL_TEXTURE_NONE;
|
CoglTextureFlags flags = COGL_TEXTURE_NONE;
|
||||||
|
gint min_filter, mag_filter;
|
||||||
gint max_waste = -1;
|
gint max_waste = -1;
|
||||||
|
|
||||||
if (!priv->no_slice)
|
if (!priv->no_slice)
|
||||||
@ -1386,9 +1392,11 @@ clutter_texture_set_from_data (ClutterTexture *texture,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
cogl_texture_set_filters (new_texture,
|
clutter_texture_quality_to_filters (priv->filter_quality,
|
||||||
clutter_texture_quality_to_cogl_min_filter (priv->filter_quality),
|
&min_filter,
|
||||||
clutter_texture_quality_to_cogl_mag_filter (priv->filter_quality));
|
&mag_filter);
|
||||||
|
|
||||||
|
cogl_texture_set_filters (new_texture, min_filter, mag_filter);
|
||||||
|
|
||||||
clutter_texture_set_cogl_texture (texture, new_texture);
|
clutter_texture_set_cogl_texture (texture, new_texture);
|
||||||
|
|
||||||
@ -1739,6 +1747,7 @@ clutter_texture_set_from_file (ClutterTexture *texture,
|
|||||||
CoglHandle new_texture = COGL_INVALID_HANDLE;
|
CoglHandle new_texture = COGL_INVALID_HANDLE;
|
||||||
GError *internal_error = NULL;
|
GError *internal_error = NULL;
|
||||||
CoglTextureFlags flags = COGL_TEXTURE_NONE;
|
CoglTextureFlags flags = COGL_TEXTURE_NONE;
|
||||||
|
gint min_filter, mag_filter;
|
||||||
gint max_waste = -1;
|
gint max_waste = -1;
|
||||||
|
|
||||||
priv = texture->priv;
|
priv = texture->priv;
|
||||||
@ -1781,9 +1790,11 @@ clutter_texture_set_from_file (ClutterTexture *texture,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
cogl_texture_set_filters (new_texture,
|
clutter_texture_quality_to_filters (priv->filter_quality,
|
||||||
clutter_texture_quality_to_cogl_min_filter (priv->filter_quality),
|
&min_filter,
|
||||||
clutter_texture_quality_to_cogl_mag_filter (priv->filter_quality));
|
&mag_filter);
|
||||||
|
|
||||||
|
cogl_texture_set_filters (new_texture, min_filter, mag_filter);
|
||||||
|
|
||||||
clutter_texture_set_cogl_texture (texture, new_texture);
|
clutter_texture_set_cogl_texture (texture, new_texture);
|
||||||
|
|
||||||
@ -1826,13 +1837,17 @@ clutter_texture_set_filter_quality (ClutterTexture *texture,
|
|||||||
if (filter_quality != old_quality)
|
if (filter_quality != old_quality)
|
||||||
{
|
{
|
||||||
CoglHandle cogl_texture = clutter_texture_get_cogl_texture (texture);
|
CoglHandle cogl_texture = clutter_texture_get_cogl_texture (texture);
|
||||||
|
gint min_filter, mag_filter;
|
||||||
|
|
||||||
priv->filter_quality = filter_quality;
|
priv->filter_quality = filter_quality;
|
||||||
|
|
||||||
|
clutter_texture_quality_to_filters (priv->filter_quality,
|
||||||
|
&min_filter,
|
||||||
|
&mag_filter);
|
||||||
|
|
||||||
/* Is this actually needed - causes problems with TFP mipmaps */
|
/* Is this actually needed - causes problems with TFP mipmaps */
|
||||||
if (cogl_texture != COGL_INVALID_HANDLE)
|
if (cogl_texture != COGL_INVALID_HANDLE)
|
||||||
cogl_texture_set_filters (cogl_texture,
|
cogl_texture_set_filters (cogl_texture, min_filter, mag_filter);
|
||||||
clutter_texture_quality_to_cogl_min_filter (priv->filter_quality),
|
|
||||||
clutter_texture_quality_to_cogl_mag_filter (priv->filter_quality));
|
|
||||||
|
|
||||||
if ((old_quality == CLUTTER_TEXTURE_QUALITY_HIGH ||
|
if ((old_quality == CLUTTER_TEXTURE_QUALITY_HIGH ||
|
||||||
filter_quality == CLUTTER_TEXTURE_QUALITY_HIGH) &&
|
filter_quality == CLUTTER_TEXTURE_QUALITY_HIGH) &&
|
||||||
@ -2132,6 +2147,7 @@ on_fbo_source_size_change (GObject *object,
|
|||||||
if (w != priv->width || h != priv->height)
|
if (w != priv->width || h != priv->height)
|
||||||
{
|
{
|
||||||
CoglTextureFlags flags = COGL_TEXTURE_NONE;
|
CoglTextureFlags flags = COGL_TEXTURE_NONE;
|
||||||
|
gint min_filter, mag_filter;
|
||||||
|
|
||||||
/* tear down the FBO */
|
/* tear down the FBO */
|
||||||
cogl_offscreen_unref (priv->fbo_handle);
|
cogl_offscreen_unref (priv->fbo_handle);
|
||||||
@ -2151,9 +2167,11 @@ on_fbo_source_size_change (GObject *object,
|
|||||||
flags,
|
flags,
|
||||||
COGL_PIXEL_FORMAT_RGBA_8888);
|
COGL_PIXEL_FORMAT_RGBA_8888);
|
||||||
|
|
||||||
cogl_texture_set_filters (priv->fbo_texture,
|
clutter_texture_quality_to_filters (priv->filter_quality,
|
||||||
clutter_texture_quality_to_cogl_min_filter (priv->filter_quality),
|
&min_filter,
|
||||||
clutter_texture_quality_to_cogl_mag_filter (priv->filter_quality));
|
&mag_filter);
|
||||||
|
|
||||||
|
cogl_texture_set_filters (priv->fbo_texture, min_filter, mag_filter);
|
||||||
|
|
||||||
priv->fbo_handle = cogl_offscreen_new_to_texture (priv->fbo_texture);
|
priv->fbo_handle = cogl_offscreen_new_to_texture (priv->fbo_texture);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user