mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 11:32:04 +00:00
2008-06-06 Matthew Allum <mallum@openedhand.com>
Bug #948 - Remove texture rectangle support * clutter/clutter-feature.c: * clutter/clutter-feature.h: * clutter/clutter-texture.c: * clutter/cogl/gl/cogl.c: * clutter/glx/clutter-glx-texture-pixmap.c: Remove support for GL_TEXTURE_RECTANGLE_ARB (now using just regular 2D textures, with optional npots extension). Simplifys code, + makes mipmap & shader support much more sane.
This commit is contained in:
parent
986ea1cb8f
commit
9d8bfaf997
13
ChangeLog
13
ChangeLog
@ -1,3 +1,16 @@
|
|||||||
|
2008-06-06 Matthew Allum <mallum@openedhand.com>
|
||||||
|
|
||||||
|
Bug #948 - Remove texture rectangle support
|
||||||
|
|
||||||
|
* clutter/clutter-feature.c:
|
||||||
|
* clutter/clutter-feature.h:
|
||||||
|
* clutter/clutter-texture.c:
|
||||||
|
* clutter/cogl/gl/cogl.c:
|
||||||
|
* clutter/glx/clutter-glx-texture-pixmap.c:
|
||||||
|
Remove support for GL_TEXTURE_RECTANGLE_ARB (now using just regular
|
||||||
|
2D textures, with optional npots extension). Simplifys code, + makes
|
||||||
|
mipmap & shader support much more sane.
|
||||||
|
|
||||||
2008-06-06 Øyvind Kolås <pippin@o-hand.com>
|
2008-06-06 Øyvind Kolås <pippin@o-hand.com>
|
||||||
|
|
||||||
Bug #931 - suspicious size allocation for pixel data.
|
Bug #931 - suspicious size allocation for pixel data.
|
||||||
|
@ -58,9 +58,6 @@ _clutter_features_from_cogl (guint cogl_flags)
|
|||||||
{
|
{
|
||||||
ClutterFeatureFlags clutter_flags = 0;
|
ClutterFeatureFlags clutter_flags = 0;
|
||||||
|
|
||||||
if (cogl_flags & COGL_FEATURE_TEXTURE_RECTANGLE)
|
|
||||||
clutter_flags |= CLUTTER_FEATURE_TEXTURE_RECTANGLE;
|
|
||||||
|
|
||||||
if (cogl_flags & COGL_FEATURE_TEXTURE_NPOT)
|
if (cogl_flags & COGL_FEATURE_TEXTURE_NPOT)
|
||||||
clutter_flags |= CLUTTER_FEATURE_TEXTURE_NPOT;
|
clutter_flags |= CLUTTER_FEATURE_TEXTURE_NPOT;
|
||||||
|
|
||||||
|
@ -39,7 +39,6 @@ G_BEGIN_DECLS
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* ClutterFeatureFlags:
|
* ClutterFeatureFlags:
|
||||||
* @CLUTTER_FEATURE_TEXTURE_RECTANGLE: Set if rectangular textures supported.
|
|
||||||
* @CLUTTER_FEATURE_TEXTURE_RECTANGLE: Set if NPOTS textures supported.
|
* @CLUTTER_FEATURE_TEXTURE_RECTANGLE: Set if NPOTS textures supported.
|
||||||
* @CLUTTER_FEATURE_SYNC_TO_VBLANK: Set if vblank syncing supported.
|
* @CLUTTER_FEATURE_SYNC_TO_VBLANK: Set if vblank syncing supported.
|
||||||
* @CLUTTER_FEATURE_TEXTURE_YUV: Set if YUV based textures supported.
|
* @CLUTTER_FEATURE_TEXTURE_YUV: Set if YUV based textures supported.
|
||||||
@ -58,7 +57,6 @@ G_BEGIN_DECLS
|
|||||||
*/
|
*/
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
CLUTTER_FEATURE_TEXTURE_RECTANGLE = (1 << 1),
|
|
||||||
CLUTTER_FEATURE_TEXTURE_NPOT = (1 << 2),
|
CLUTTER_FEATURE_TEXTURE_NPOT = (1 << 2),
|
||||||
CLUTTER_FEATURE_SYNC_TO_VBLANK = (1 << 3),
|
CLUTTER_FEATURE_SYNC_TO_VBLANK = (1 << 3),
|
||||||
CLUTTER_FEATURE_TEXTURE_YUV = (1 << 4),
|
CLUTTER_FEATURE_TEXTURE_YUV = (1 << 4),
|
||||||
|
@ -1479,7 +1479,7 @@ on_fbo_source_size_change (GObject *object,
|
|||||||
|
|
||||||
priv->texture = cogl_texture_new_with_size (priv->width,
|
priv->texture = cogl_texture_new_with_size (priv->width,
|
||||||
priv->height,
|
priv->height,
|
||||||
priv->max_tile_waste,
|
-1,
|
||||||
FALSE,
|
FALSE,
|
||||||
COGL_PIXEL_FORMAT_RGBA_8888);
|
COGL_PIXEL_FORMAT_RGBA_8888);
|
||||||
|
|
||||||
@ -1529,8 +1529,8 @@ on_fbo_parent_change (ClutterActor *actor,
|
|||||||
*
|
*
|
||||||
* Note this function is intented as a utility call for uniformly applying
|
* Note this function is intented as a utility call for uniformly applying
|
||||||
* shaders to groups and other potential visual effects. It requires that
|
* shaders to groups and other potential visual effects. It requires that
|
||||||
* both %CLUTTER_FEATURE_TEXTURE_RECTANGLE and %CLUTTER_FEATURE_OFFSCREEN
|
* the %CLUTTER_FEATURE_OFFSCREEN feature is supported by the current backend
|
||||||
* features are supported by the current backend and the target system.
|
* and the target system.
|
||||||
*
|
*
|
||||||
* Some tips on usage:
|
* Some tips on usage:
|
||||||
*
|
*
|
||||||
@ -1579,10 +1579,6 @@ clutter_texture_new_from_actor (ClutterActor *actor)
|
|||||||
|
|
||||||
g_return_val_if_fail (CLUTTER_IS_ACTOR (actor), NULL);
|
g_return_val_if_fail (CLUTTER_IS_ACTOR (actor), NULL);
|
||||||
|
|
||||||
/* FIXME: Some error result on below could be useful */
|
|
||||||
if (clutter_feature_available (CLUTTER_FEATURE_TEXTURE_RECTANGLE) == FALSE)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (clutter_feature_available (CLUTTER_FEATURE_OFFSCREEN) == FALSE)
|
if (clutter_feature_available (CLUTTER_FEATURE_OFFSCREEN) == FALSE)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -1600,7 +1596,9 @@ clutter_texture_new_from_actor (ClutterActor *actor)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Hopefully now were good.. */
|
/* Hopefully now were good.. */
|
||||||
texture = g_object_new (CLUTTER_TYPE_TEXTURE, NULL);
|
texture = g_object_new (CLUTTER_TYPE_TEXTURE,
|
||||||
|
"disable-slicing", TRUE,
|
||||||
|
NULL);
|
||||||
|
|
||||||
priv = texture->priv;
|
priv = texture->priv;
|
||||||
|
|
||||||
|
@ -539,20 +539,7 @@ _cogl_texture_size_supported (GLenum gl_target,
|
|||||||
int width,
|
int width,
|
||||||
int height)
|
int height)
|
||||||
{
|
{
|
||||||
if (gl_target == GL_TEXTURE_RECTANGLE_ARB)
|
if (gl_target == GL_TEXTURE_2D)
|
||||||
{
|
|
||||||
/* There is no proxy rectangle texture target so best we can
|
|
||||||
* do is to check against the safest value (although depending
|
|
||||||
* on our specific format and type the size could be supported
|
|
||||||
* when it seems it is not) */
|
|
||||||
|
|
||||||
GLint max_size = 0;
|
|
||||||
|
|
||||||
GE( glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB, &max_size) );
|
|
||||||
|
|
||||||
return (max_size && width <= max_size && height <= max_size);
|
|
||||||
}
|
|
||||||
else if (gl_target == GL_TEXTURE_2D)
|
|
||||||
{
|
{
|
||||||
/* Proxy texture allows for a quick check for supported size */
|
/* Proxy texture allows for a quick check for supported size */
|
||||||
|
|
||||||
@ -601,13 +588,6 @@ _cogl_texture_slices_create (CoglTexture *tex)
|
|||||||
tex->gl_target = GL_TEXTURE_2D;
|
tex->gl_target = GL_TEXTURE_2D;
|
||||||
slices_for_size = _cogl_rect_slices_for_size;
|
slices_for_size = _cogl_rect_slices_for_size;
|
||||||
}
|
}
|
||||||
else if (cogl_features_available (COGL_FEATURE_TEXTURE_RECTANGLE))
|
|
||||||
{
|
|
||||||
max_width = tex->bitmap.width;
|
|
||||||
max_height = tex->bitmap.height;
|
|
||||||
tex->gl_target = GL_TEXTURE_RECTANGLE_ARB;
|
|
||||||
slices_for_size = _cogl_rect_slices_for_size;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
max_width = cogl_util_next_p2 (tex->bitmap.width);
|
max_width = cogl_util_next_p2 (tex->bitmap.width);
|
||||||
@ -1230,8 +1210,7 @@ cogl_texture_new_from_foreign (GLuint gl_handle,
|
|||||||
CoglTexSliceSpan y_span;
|
CoglTexSliceSpan y_span;
|
||||||
|
|
||||||
/* Allow 2-dimensional textures only */
|
/* Allow 2-dimensional textures only */
|
||||||
if (gl_target != GL_TEXTURE_2D &&
|
if (gl_target != GL_TEXTURE_2D)
|
||||||
gl_target != GL_TEXTURE_RECTANGLE_ARB)
|
|
||||||
return COGL_INVALID_HANDLE;
|
return COGL_INVALID_HANDLE;
|
||||||
|
|
||||||
/* Make sure it is a valid GL texture object */
|
/* Make sure it is a valid GL texture object */
|
||||||
@ -1747,9 +1726,6 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
|||||||
/* Prepare GL state */
|
/* Prepare GL state */
|
||||||
gulong enable_flags = 0;
|
gulong enable_flags = 0;
|
||||||
|
|
||||||
if (tex->gl_target == GL_TEXTURE_RECTANGLE_ARB)
|
|
||||||
enable_flags |= COGL_ENABLE_TEXTURE_RECT;
|
|
||||||
else
|
|
||||||
enable_flags |= COGL_ENABLE_TEXTURE_2D;
|
enable_flags |= COGL_ENABLE_TEXTURE_2D;
|
||||||
|
|
||||||
if (ctx->color_alpha < 255
|
if (ctx->color_alpha < 255
|
||||||
@ -1806,11 +1782,8 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
|||||||
|
|
||||||
/* Normalize texture coordinates to current slice
|
/* Normalize texture coordinates to current slice
|
||||||
(rectangle texture targets take denormalized) */
|
(rectangle texture targets take denormalized) */
|
||||||
if (tex->gl_target != GL_TEXTURE_RECTANGLE_ARB)
|
|
||||||
{
|
|
||||||
slice_ty1 /= iter_y.span->size;
|
slice_ty1 /= iter_y.span->size;
|
||||||
slice_ty2 /= iter_y.span->size;
|
slice_ty2 /= iter_y.span->size;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Iterate until whole quad width covered */
|
/* Iterate until whole quad width covered */
|
||||||
@ -1835,11 +1808,8 @@ _cogl_texture_quad_sw (CoglTexture *tex,
|
|||||||
|
|
||||||
/* Normalize texture coordinates to current slice
|
/* Normalize texture coordinates to current slice
|
||||||
(rectangle texture targets take denormalized) */
|
(rectangle texture targets take denormalized) */
|
||||||
if (tex->gl_target != GL_TEXTURE_RECTANGLE_ARB)
|
|
||||||
{
|
|
||||||
slice_tx1 /= iter_x.span->size;
|
slice_tx1 /= iter_x.span->size;
|
||||||
slice_tx2 /= iter_x.span->size;
|
slice_tx2 /= iter_x.span->size;
|
||||||
}
|
|
||||||
|
|
||||||
#if COGL_DEBUG
|
#if COGL_DEBUG
|
||||||
printf("~~~~~ slice (%d,%d)\n", iter_x.index, iter_y.index);
|
printf("~~~~~ slice (%d,%d)\n", iter_x.index, iter_y.index);
|
||||||
@ -1908,9 +1878,6 @@ _cogl_texture_quad_hw (CoglTexture *tex,
|
|||||||
/* Prepare GL state */
|
/* Prepare GL state */
|
||||||
gulong enable_flags = 0;
|
gulong enable_flags = 0;
|
||||||
|
|
||||||
if (tex->gl_target == GL_TEXTURE_RECTANGLE_ARB)
|
|
||||||
enable_flags |= COGL_ENABLE_TEXTURE_RECT;
|
|
||||||
else
|
|
||||||
enable_flags |= COGL_ENABLE_TEXTURE_2D;
|
enable_flags |= COGL_ENABLE_TEXTURE_2D;
|
||||||
|
|
||||||
if (ctx->color_alpha < 255
|
if (ctx->color_alpha < 255
|
||||||
@ -1934,15 +1901,6 @@ _cogl_texture_quad_hw (CoglTexture *tex,
|
|||||||
ty1 = ty1 * (y_span->size - y_span->waste) / y_span->size;
|
ty1 = ty1 * (y_span->size - y_span->waste) / y_span->size;
|
||||||
ty2 = ty2 * (y_span->size - y_span->waste) / y_span->size;
|
ty2 = ty2 * (y_span->size - y_span->waste) / y_span->size;
|
||||||
|
|
||||||
/* Denormalize texture coordinates for rectangle textures */
|
|
||||||
if (tex->gl_target == GL_TEXTURE_RECTANGLE_ARB)
|
|
||||||
{
|
|
||||||
tx1 *= x_span->size;
|
|
||||||
tx2 *= x_span->size;
|
|
||||||
ty1 *= y_span->size;
|
|
||||||
ty2 *= y_span->size;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define CFX_F(x) CLUTTER_FIXED_TO_FLOAT(x)
|
#define CFX_F(x) CLUTTER_FIXED_TO_FLOAT(x)
|
||||||
|
|
||||||
/* Draw textured quad */
|
/* Draw textured quad */
|
||||||
@ -2088,9 +2046,6 @@ cogl_texture_polygon (CoglHandle handle,
|
|||||||
tex = _cogl_texture_pointer_from_handle (handle);
|
tex = _cogl_texture_pointer_from_handle (handle);
|
||||||
|
|
||||||
/* Prepare GL state */
|
/* Prepare GL state */
|
||||||
if (tex->gl_target == GL_TEXTURE_RECTANGLE_ARB)
|
|
||||||
cogl_enable (COGL_ENABLE_TEXTURE_RECT | COGL_ENABLE_BLEND);
|
|
||||||
else
|
|
||||||
cogl_enable (COGL_ENABLE_TEXTURE_2D | COGL_ENABLE_BLEND);
|
cogl_enable (COGL_ENABLE_TEXTURE_2D | COGL_ENABLE_BLEND);
|
||||||
|
|
||||||
/* Temporarily change the wrapping mode on all of the slices to use
|
/* Temporarily change the wrapping mode on all of the slices to use
|
||||||
@ -2140,12 +2095,6 @@ cogl_texture_polygon (CoglHandle handle,
|
|||||||
- y_span->start / (GLfloat) tex->bitmap.height)
|
- y_span->start / (GLfloat) tex->bitmap.height)
|
||||||
* tex->bitmap.height / y_span->size;
|
* tex->bitmap.height / y_span->size;
|
||||||
|
|
||||||
if (tex->gl_target == GL_TEXTURE_RECTANGLE_ARB)
|
|
||||||
{
|
|
||||||
tx *= x_span->size;
|
|
||||||
ty *= y_span->size;
|
|
||||||
}
|
|
||||||
|
|
||||||
glTexCoord2f (tx, ty);
|
glTexCoord2f (tx, ty);
|
||||||
|
|
||||||
glVertex3f (CLUTTER_FIXED_TO_FLOAT (vertices[vnum].x),
|
glVertex3f (CLUTTER_FIXED_TO_FLOAT (vertices[vnum].x),
|
||||||
|
@ -323,11 +323,6 @@ cogl_enable (gulong flags)
|
|||||||
COGL_ENABLE_TEXCOORD_ARRAY,
|
COGL_ENABLE_TEXCOORD_ARRAY,
|
||||||
GL_TEXTURE_COORD_ARRAY);
|
GL_TEXTURE_COORD_ARRAY);
|
||||||
|
|
||||||
#ifdef GL_TEXTURE_RECTANGLE_ARB
|
|
||||||
cogl_toggle_flag (ctx, flags,
|
|
||||||
COGL_ENABLE_TEXTURE_RECT,
|
|
||||||
GL_TEXTURE_RECTANGLE_ARB);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gulong
|
gulong
|
||||||
@ -673,14 +668,6 @@ _cogl_features_init ()
|
|||||||
|
|
||||||
gl_extensions = (const gchar*) glGetString (GL_EXTENSIONS);
|
gl_extensions = (const gchar*) glGetString (GL_EXTENSIONS);
|
||||||
|
|
||||||
#if defined(GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB) && defined(GL_TEXTURE_RECTANGLE_ARB)
|
|
||||||
if (cogl_check_extension ("GL_ARB_texture_rectangle", gl_extensions) ||
|
|
||||||
cogl_check_extension ("GL_EXT_texture_rectangle", gl_extensions))
|
|
||||||
{
|
|
||||||
flags |= COGL_FEATURE_TEXTURE_RECTANGLE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (cogl_check_extension ("GL_ARB_texture_non_power_of_two", gl_extensions))
|
if (cogl_check_extension ("GL_ARB_texture_non_power_of_two", gl_extensions))
|
||||||
{
|
{
|
||||||
flags |= COGL_FEATURE_TEXTURE_NPOT;
|
flags |= COGL_FEATURE_TEXTURE_NPOT;
|
||||||
|
@ -202,8 +202,7 @@ clutter_glx_texture_pixmap_realize (ClutterActor *actor)
|
|||||||
|
|
||||||
if (priv->use_fallback
|
if (priv->use_fallback
|
||||||
|| !_have_tex_from_pixmap_ext
|
|| !_have_tex_from_pixmap_ext
|
||||||
|| !(clutter_feature_available (COGL_FEATURE_TEXTURE_NPOT)
|
|| !clutter_feature_available (COGL_FEATURE_TEXTURE_NPOT))
|
||||||
|| clutter_feature_available (COGL_FEATURE_TEXTURE_RECTANGLE)))
|
|
||||||
{
|
{
|
||||||
/* Fall back */
|
/* Fall back */
|
||||||
CLUTTER_NOTE (TEXTURE, "texture from pixmap appears unsupported");
|
CLUTTER_NOTE (TEXTURE, "texture from pixmap appears unsupported");
|
||||||
|
Loading…
Reference in New Issue
Block a user