mirror of
https://github.com/brl/mutter.git
synced 2025-02-18 14:14:10 +00:00
* clutter/cogl/cogl.h.in:
* clutter/cogl/gl(es)/cogl-texture.h: * clutter/cogl/gl(es)/cogl-texture.c: cogl_texture_new_* functions take a gboolean auto_mipmap argument. If TRUE automatic mipmap generation is enabled during the process of slice texture object creation. (cogl_texture_new_from_foreign:) now allows mipmap min filter flags. * clutter/clutter-texture.c: * clutter/glx/clutter-glx-texture-pixmap.c: * tests/test-cogl-offscreen.c: * tests/test-cogl-tex-tile.c: * tests/test-cogl-tex-convert.c: * tests/test-cogl-tex-polygon.c: * tests/test-cogl-tex-getset.c: Pass FALSE for auto_mipmap to cogl_texture_new_*. * clutter/pango/pangoclutter-render.c: (tc_get:) Pass TRUE to cogl_texture_new_with_size and use mipmap min filter for nicer glyphs at small scales. As a result test-text has gone all beautiful now.
This commit is contained in:
parent
073870dbbf
commit
b9827fb945
@ -563,6 +563,8 @@ void cogl_paint_init (const ClutterColor *color);
|
|||||||
* @height: height of texture in pixels.
|
* @height: height of texture in pixels.
|
||||||
* @max_waste: maximum extra horizontal and|or vertical margin pixels to make
|
* @max_waste: maximum extra horizontal and|or vertical margin pixels to make
|
||||||
* texture fit GPU limitations.
|
* texture fit GPU limitations.
|
||||||
|
* @auto_mipmap: enable or disable automatic generation of mipmap pyramid
|
||||||
|
* from the base level image whenever it is updated.
|
||||||
* @internal_format: the #CoglPixelFormat to use for the GPU storage of the
|
* @internal_format: the #CoglPixelFormat to use for the GPU storage of the
|
||||||
* texture.
|
* texture.
|
||||||
*
|
*
|
||||||
@ -574,6 +576,7 @@ void cogl_paint_init (const ClutterColor *color);
|
|||||||
CoglHandle cogl_texture_new_with_size (guint width,
|
CoglHandle cogl_texture_new_with_size (guint width,
|
||||||
guint height,
|
guint height,
|
||||||
gint max_waste,
|
gint max_waste,
|
||||||
|
gboolean auto_mipmap,
|
||||||
CoglPixelFormat internal_format);
|
CoglPixelFormat internal_format);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -581,6 +584,8 @@ CoglHandle cogl_texture_new_with_size (guint width,
|
|||||||
* @filename: the file to load
|
* @filename: the file to load
|
||||||
* @max_waste: maximum extra horizontal and|or vertical margin pixels to make
|
* @max_waste: maximum extra horizontal and|or vertical margin pixels to make
|
||||||
* texture fit GPU limitations.
|
* texture fit GPU limitations.
|
||||||
|
* @auto_mipmap: enable or disable automatic generation of mipmap pyramid
|
||||||
|
* from the base level image whenever it is updated.
|
||||||
* @internal_format: the #CoglPixelFormat to use for the GPU storage of the
|
* @internal_format: the #CoglPixelFormat to use for the GPU storage of the
|
||||||
* texture.
|
* texture.
|
||||||
* @error: a #GError or NULL.
|
* @error: a #GError or NULL.
|
||||||
@ -592,6 +597,7 @@ CoglHandle cogl_texture_new_with_size (guint width,
|
|||||||
*/
|
*/
|
||||||
CoglHandle cogl_texture_new_from_file (const gchar *filename,
|
CoglHandle cogl_texture_new_from_file (const gchar *filename,
|
||||||
gint max_waste,
|
gint max_waste,
|
||||||
|
gboolean auto_mipmap,
|
||||||
CoglPixelFormat internal_format,
|
CoglPixelFormat internal_format,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
@ -600,6 +606,8 @@ CoglHandle cogl_texture_new_from_file (const gchar *filename,
|
|||||||
* @width: width of texture in pixels.
|
* @width: width of texture in pixels.
|
||||||
* @height: height of texture in pixels.
|
* @height: height of texture in pixels.
|
||||||
* @max_waste: maximum extra horizontal and|or vertical margin pixels to make
|
* @max_waste: maximum extra horizontal and|or vertical margin pixels to make
|
||||||
|
* @auto_mipmap: enable or disable automatic generation of mipmap pyramid
|
||||||
|
* from the base level image whenever it is updated.
|
||||||
* @format: the #CoglPixelFormat the buffer is stored in in RAM
|
* @format: the #CoglPixelFormat the buffer is stored in in RAM
|
||||||
* @internal_format: the #CoglPixelFormat that will be used for storing the
|
* @internal_format: the #CoglPixelFormat that will be used for storing the
|
||||||
* buffer on the GPU.
|
* buffer on the GPU.
|
||||||
@ -615,6 +623,7 @@ CoglHandle cogl_texture_new_from_file (const gchar *filename,
|
|||||||
CoglHandle cogl_texture_new_from_data (guint width,
|
CoglHandle cogl_texture_new_from_data (guint width,
|
||||||
guint height,
|
guint height,
|
||||||
gint max_waste,
|
gint max_waste,
|
||||||
|
gboolean auto_mipmap,
|
||||||
CoglPixelFormat format,
|
CoglPixelFormat format,
|
||||||
CoglPixelFormat internal_format,
|
CoglPixelFormat internal_format,
|
||||||
guint rowstride,
|
guint rowstride,
|
||||||
|
@ -750,6 +750,9 @@ _cogl_texture_slices_create (CoglTexture *tex)
|
|||||||
GE( glTexParameteri (tex->gl_target, GL_TEXTURE_WRAP_T,
|
GE( glTexParameteri (tex->gl_target, GL_TEXTURE_WRAP_T,
|
||||||
tex->wrap_mode) );
|
tex->wrap_mode) );
|
||||||
|
|
||||||
|
if (tex->auto_mipmap)
|
||||||
|
GE( glTexParameteri (tex->gl_target, GL_GENERATE_MIPMAP, GL_TRUE) );
|
||||||
|
|
||||||
/* Use a transparent border color so that we can leave the
|
/* Use a transparent border color so that we can leave the
|
||||||
color buffer alone when using texture co-ordinates
|
color buffer alone when using texture co-ordinates
|
||||||
outside of the texture */
|
outside of the texture */
|
||||||
@ -989,6 +992,7 @@ CoglHandle
|
|||||||
cogl_texture_new_with_size (guint width,
|
cogl_texture_new_with_size (guint width,
|
||||||
guint height,
|
guint height,
|
||||||
gint max_waste,
|
gint max_waste,
|
||||||
|
gboolean auto_mipmap,
|
||||||
CoglPixelFormat internal_format)
|
CoglPixelFormat internal_format)
|
||||||
{
|
{
|
||||||
CoglTexture *tex;
|
CoglTexture *tex;
|
||||||
@ -1010,6 +1014,7 @@ cogl_texture_new_with_size (guint width,
|
|||||||
COGL_HANDLE_DEBUG_NEW (texture, tex);
|
COGL_HANDLE_DEBUG_NEW (texture, tex);
|
||||||
|
|
||||||
tex->is_foreign = FALSE;
|
tex->is_foreign = FALSE;
|
||||||
|
tex->auto_mipmap = auto_mipmap;
|
||||||
|
|
||||||
tex->bitmap.width = width;
|
tex->bitmap.width = width;
|
||||||
tex->bitmap.height = height;
|
tex->bitmap.height = height;
|
||||||
@ -1047,6 +1052,7 @@ CoglHandle
|
|||||||
cogl_texture_new_from_data (guint width,
|
cogl_texture_new_from_data (guint width,
|
||||||
guint height,
|
guint height,
|
||||||
gint max_waste,
|
gint max_waste,
|
||||||
|
gboolean auto_mipmap,
|
||||||
CoglPixelFormat format,
|
CoglPixelFormat format,
|
||||||
CoglPixelFormat internal_format,
|
CoglPixelFormat internal_format,
|
||||||
guint rowstride,
|
guint rowstride,
|
||||||
@ -1072,6 +1078,7 @@ cogl_texture_new_from_data (guint width,
|
|||||||
COGL_HANDLE_DEBUG_NEW (texture, tex);
|
COGL_HANDLE_DEBUG_NEW (texture, tex);
|
||||||
|
|
||||||
tex->is_foreign = FALSE;
|
tex->is_foreign = FALSE;
|
||||||
|
tex->auto_mipmap = auto_mipmap;
|
||||||
|
|
||||||
tex->bitmap.width = width;
|
tex->bitmap.width = width;
|
||||||
tex->bitmap.height = height;
|
tex->bitmap.height = height;
|
||||||
@ -1119,6 +1126,7 @@ cogl_texture_new_from_data (guint width,
|
|||||||
CoglHandle
|
CoglHandle
|
||||||
cogl_texture_new_from_file (const gchar *filename,
|
cogl_texture_new_from_file (const gchar *filename,
|
||||||
gint max_waste,
|
gint max_waste,
|
||||||
|
gboolean auto_mipmap,
|
||||||
CoglPixelFormat internal_format,
|
CoglPixelFormat internal_format,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
@ -1147,6 +1155,7 @@ cogl_texture_new_from_file (const gchar *filename,
|
|||||||
COGL_HANDLE_DEBUG_NEW (texture, tex);
|
COGL_HANDLE_DEBUG_NEW (texture, tex);
|
||||||
|
|
||||||
tex->is_foreign = FALSE;
|
tex->is_foreign = FALSE;
|
||||||
|
tex->auto_mipmap = auto_mipmap;
|
||||||
|
|
||||||
tex->bitmap = bmp;
|
tex->bitmap = bmp;
|
||||||
tex->bitmap_owner = TRUE;
|
tex->bitmap_owner = TRUE;
|
||||||
@ -1214,6 +1223,7 @@ cogl_texture_new_from_foreign (GLuint gl_handle,
|
|||||||
GLint gl_height = 0;
|
GLint gl_height = 0;
|
||||||
GLint gl_min_filter;
|
GLint gl_min_filter;
|
||||||
GLint gl_mag_filter;
|
GLint gl_mag_filter;
|
||||||
|
GLint gl_gen_mipmap;
|
||||||
guint bpp;
|
guint bpp;
|
||||||
CoglTexture *tex;
|
CoglTexture *tex;
|
||||||
CoglTexSliceSpan x_span;
|
CoglTexSliceSpan x_span;
|
||||||
@ -1257,11 +1267,15 @@ cogl_texture_new_from_foreign (GLuint gl_handle,
|
|||||||
|
|
||||||
GE( glGetTexParameteriv (gl_target,
|
GE( glGetTexParameteriv (gl_target,
|
||||||
GL_TEXTURE_MIN_FILTER,
|
GL_TEXTURE_MIN_FILTER,
|
||||||
&gl_min_filter));
|
&gl_min_filter) );
|
||||||
|
|
||||||
GE( glGetTexParameteriv (gl_target,
|
GE( glGetTexParameteriv (gl_target,
|
||||||
GL_TEXTURE_MAG_FILTER,
|
GL_TEXTURE_MAG_FILTER,
|
||||||
&gl_mag_filter));
|
&gl_mag_filter) );
|
||||||
|
|
||||||
|
GE( glGetTexParameteriv (gl_target,
|
||||||
|
GL_GENERATE_MIPMAP,
|
||||||
|
&gl_gen_mipmap) );
|
||||||
|
|
||||||
/* Validate width and height */
|
/* Validate width and height */
|
||||||
if (gl_width <= 0 || gl_height <= 0)
|
if (gl_width <= 0 || gl_height <= 0)
|
||||||
@ -1293,6 +1307,7 @@ cogl_texture_new_from_foreign (GLuint gl_handle,
|
|||||||
|
|
||||||
/* Setup bitmap info */
|
/* Setup bitmap info */
|
||||||
tex->is_foreign = TRUE;
|
tex->is_foreign = TRUE;
|
||||||
|
tex->auto_mipmap = (gl_gen_mipmap == GL_TRUE) ? TRUE : FALSE;
|
||||||
|
|
||||||
tex->bitmap.format = format;
|
tex->bitmap.format = format;
|
||||||
tex->bitmap.width = gl_width - x_pot_waste;
|
tex->bitmap.width = gl_width - x_pot_waste;
|
||||||
@ -1335,21 +1350,6 @@ cogl_texture_new_from_foreign (GLuint gl_handle,
|
|||||||
|
|
||||||
g_array_append_val (tex->slice_gl_handles, gl_handle);
|
g_array_append_val (tex->slice_gl_handles, gl_handle);
|
||||||
|
|
||||||
/* Replace mipmap min filter modes with single level ones */
|
|
||||||
if (gl_min_filter != GL_NEAREST && gl_min_filter != GL_LINEAR)
|
|
||||||
{
|
|
||||||
if (gl_min_filter == GL_NEAREST_MIPMAP_NEAREST)
|
|
||||||
{
|
|
||||||
GE( glTexParameteri (tex->gl_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST) );
|
|
||||||
tex->min_filter = CGL_NEAREST;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GE( glTexParameteri (tex->gl_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR) );
|
|
||||||
tex->min_filter = CGL_LINEAR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Force appropriate wrap parameter */
|
/* Force appropriate wrap parameter */
|
||||||
if (cogl_features_available (COGL_FEATURE_TEXTURE_NPOT) &&
|
if (cogl_features_available (COGL_FEATURE_TEXTURE_NPOT) &&
|
||||||
gl_target == GL_TEXTURE_2D)
|
gl_target == GL_TEXTURE_2D)
|
||||||
|
@ -56,6 +56,7 @@ struct _CoglTexture
|
|||||||
COGLenum mag_filter;
|
COGLenum mag_filter;
|
||||||
gboolean is_foreign;
|
gboolean is_foreign;
|
||||||
GLint wrap_mode;
|
GLint wrap_mode;
|
||||||
|
gboolean auto_mipmap;
|
||||||
};
|
};
|
||||||
|
|
||||||
CoglTexture*
|
CoglTexture*
|
||||||
|
@ -731,11 +731,14 @@ _cogl_texture_slices_create (CoglTexture *tex)
|
|||||||
y_span->size - y_span->waste);
|
y_span->size - y_span->waste);
|
||||||
#endif
|
#endif
|
||||||
/* Setup texture parameters */
|
/* Setup texture parameters */
|
||||||
GE( glBindTexture (tex->gl_target, gl_handles[y * n_x_slices + x]) );
|
GE( glBindTexture (tex->gl_target, gl_handles[y * n_x_slices + x]) );
|
||||||
GE( glTexParameteri (tex->gl_target, GL_TEXTURE_MAG_FILTER, tex->mag_filter) );
|
GE( glTexParameteri (tex->gl_target, GL_TEXTURE_MAG_FILTER, tex->mag_filter) );
|
||||||
GE( glTexParameteri (tex->gl_target, GL_TEXTURE_MIN_FILTER, tex->min_filter) );
|
GE( glTexParameteri (tex->gl_target, GL_TEXTURE_MIN_FILTER, tex->min_filter) );
|
||||||
GE( glTexParameteri (tex->gl_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE) );
|
GE( glTexParameteri (tex->gl_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE) );
|
||||||
GE( glTexParameteri (tex->gl_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE) );
|
GE( glTexParameteri (tex->gl_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE) );
|
||||||
|
|
||||||
|
if (tex->auto_mipmap)
|
||||||
|
GE( glTexParameteri (tex->gl_target, GL_GENERATE_MIPMAP, GL_TRUE) );
|
||||||
|
|
||||||
/* Pass NULL data to init size and internal format */
|
/* Pass NULL data to init size and internal format */
|
||||||
GE( glTexImage2D (tex->gl_target, 0, tex->gl_intformat,
|
GE( glTexImage2D (tex->gl_target, 0, tex->gl_intformat,
|
||||||
@ -938,6 +941,7 @@ CoglHandle
|
|||||||
cogl_texture_new_with_size (guint width,
|
cogl_texture_new_with_size (guint width,
|
||||||
guint height,
|
guint height,
|
||||||
gint max_waste,
|
gint max_waste,
|
||||||
|
gboolean auto_mipmap,
|
||||||
CoglPixelFormat internal_format)
|
CoglPixelFormat internal_format)
|
||||||
{
|
{
|
||||||
CoglTexture *tex;
|
CoglTexture *tex;
|
||||||
@ -959,6 +963,7 @@ cogl_texture_new_with_size (guint width,
|
|||||||
COGL_HANDLE_DEBUG_NEW (texture, tex);
|
COGL_HANDLE_DEBUG_NEW (texture, tex);
|
||||||
|
|
||||||
tex->is_foreign = FALSE;
|
tex->is_foreign = FALSE;
|
||||||
|
tex->auto_mipmap = auto_mipmap;
|
||||||
|
|
||||||
tex->bitmap.width = width;
|
tex->bitmap.width = width;
|
||||||
tex->bitmap.height = height;
|
tex->bitmap.height = height;
|
||||||
@ -995,6 +1000,7 @@ CoglHandle
|
|||||||
cogl_texture_new_from_data (guint width,
|
cogl_texture_new_from_data (guint width,
|
||||||
guint height,
|
guint height,
|
||||||
gint max_waste,
|
gint max_waste,
|
||||||
|
gboolean auto_mipmap,
|
||||||
CoglPixelFormat format,
|
CoglPixelFormat format,
|
||||||
CoglPixelFormat internal_format,
|
CoglPixelFormat internal_format,
|
||||||
guint rowstride,
|
guint rowstride,
|
||||||
@ -1020,6 +1026,7 @@ cogl_texture_new_from_data (guint width,
|
|||||||
COGL_HANDLE_DEBUG_NEW (texture, tex);
|
COGL_HANDLE_DEBUG_NEW (texture, tex);
|
||||||
|
|
||||||
tex->is_foreign = FALSE;
|
tex->is_foreign = FALSE;
|
||||||
|
tex->auto_mipmap = auto_mipmap;
|
||||||
|
|
||||||
tex->bitmap.width = width;
|
tex->bitmap.width = width;
|
||||||
tex->bitmap.height = height;
|
tex->bitmap.height = height;
|
||||||
@ -1067,6 +1074,7 @@ cogl_texture_new_from_data (guint width,
|
|||||||
CoglHandle
|
CoglHandle
|
||||||
cogl_texture_new_from_file (const gchar *filename,
|
cogl_texture_new_from_file (const gchar *filename,
|
||||||
gint max_waste,
|
gint max_waste,
|
||||||
|
gboolean auto_mipmap,
|
||||||
CoglPixelFormat internal_format,
|
CoglPixelFormat internal_format,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
@ -1095,6 +1103,7 @@ cogl_texture_new_from_file (const gchar *filename,
|
|||||||
COGL_HANDLE_DEBUG_NEW (texture, tex);
|
COGL_HANDLE_DEBUG_NEW (texture, tex);
|
||||||
|
|
||||||
tex->is_foreign = FALSE;
|
tex->is_foreign = FALSE;
|
||||||
|
tex->auto_mipmap = auto_mipmap;
|
||||||
|
|
||||||
tex->bitmap = bmp;
|
tex->bitmap = bmp;
|
||||||
tex->bitmap_owner = TRUE;
|
tex->bitmap_owner = TRUE;
|
||||||
@ -1151,6 +1160,7 @@ cogl_texture_new_from_foreign (GLuint gl_handle,
|
|||||||
GLboolean gl_istexture;
|
GLboolean gl_istexture;
|
||||||
GLint gl_min_filter;
|
GLint gl_min_filter;
|
||||||
GLint gl_mag_filter;
|
GLint gl_mag_filter;
|
||||||
|
GLint gl_gen_mipmap;
|
||||||
guint bpp;
|
guint bpp;
|
||||||
CoglTexture *tex;
|
CoglTexture *tex;
|
||||||
CoglTexSliceSpan x_span;
|
CoglTexSliceSpan x_span;
|
||||||
@ -1191,6 +1201,10 @@ cogl_texture_new_from_foreign (GLuint gl_handle,
|
|||||||
GL_TEXTURE_MAG_FILTER,
|
GL_TEXTURE_MAG_FILTER,
|
||||||
&gl_mag_filter));
|
&gl_mag_filter));
|
||||||
|
|
||||||
|
GE( glGetTexParameteriv (gl_target,
|
||||||
|
GL_GENERATE_MIPMAP,
|
||||||
|
&gl_gen_mipmap) );
|
||||||
|
|
||||||
/* Validate width and height */
|
/* Validate width and height */
|
||||||
if (width <= 0 || height <= 0)
|
if (width <= 0 || height <= 0)
|
||||||
return COGL_INVALID_HANDLE;
|
return COGL_INVALID_HANDLE;
|
||||||
@ -1208,6 +1222,7 @@ cogl_texture_new_from_foreign (GLuint gl_handle,
|
|||||||
|
|
||||||
/* Setup bitmap info */
|
/* Setup bitmap info */
|
||||||
tex->is_foreign = TRUE;
|
tex->is_foreign = TRUE;
|
||||||
|
tex->auto_mipmap = (gl_gen_mipmap == GL_TRUE) ? TRUE : FALSE;
|
||||||
|
|
||||||
bpp = _cogl_get_format_bpp (format);
|
bpp = _cogl_get_format_bpp (format);
|
||||||
tex->bitmap.format = format;
|
tex->bitmap.format = format;
|
||||||
@ -1251,21 +1266,6 @@ cogl_texture_new_from_foreign (GLuint gl_handle,
|
|||||||
|
|
||||||
g_array_append_val (tex->slice_gl_handles, gl_handle);
|
g_array_append_val (tex->slice_gl_handles, gl_handle);
|
||||||
|
|
||||||
/* Replace mipmap min filter modes with single level ones */
|
|
||||||
if (gl_min_filter != GL_NEAREST && gl_min_filter != GL_LINEAR)
|
|
||||||
{
|
|
||||||
if (gl_min_filter == GL_NEAREST_MIPMAP_NEAREST)
|
|
||||||
{
|
|
||||||
GE( glTexParameteri (tex->gl_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST) );
|
|
||||||
tex->min_filter = CGL_NEAREST;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GE( glTexParameteri (tex->gl_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR) );
|
|
||||||
tex->min_filter = CGL_LINEAR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Force appropriate wrap parameter */
|
/* Force appropriate wrap parameter */
|
||||||
GE( glTexParameteri (tex->gl_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE) );
|
GE( glTexParameteri (tex->gl_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE) );
|
||||||
GE( glTexParameteri (tex->gl_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE) );
|
GE( glTexParameteri (tex->gl_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE) );
|
||||||
|
@ -55,6 +55,7 @@ struct _CoglTexture
|
|||||||
COGLenum min_filter;
|
COGLenum min_filter;
|
||||||
COGLenum mag_filter;
|
COGLenum mag_filter;
|
||||||
gboolean is_foreign;
|
gboolean is_foreign;
|
||||||
|
gboolean auto_mipmap;
|
||||||
};
|
};
|
||||||
|
|
||||||
CoglTexture*
|
CoglTexture*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user