From 9d8bfaf997617ee9fd21863683257936256e92da Mon Sep 17 00:00:00 2001 From: Matthew Allum Date: Fri, 6 Jun 2008 13:44:22 +0000 Subject: [PATCH] 2008-06-06 Matthew Allum 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. --- ChangeLog | 13 +++++ clutter/clutter-feature.c | 3 -- clutter/clutter-feature.h | 2 - clutter/clutter-texture.c | 14 +++-- clutter/cogl/gl/cogl-texture.c | 69 ++++-------------------- clutter/cogl/gl/cogl.c | 13 ----- clutter/glx/clutter-glx-texture-pixmap.c | 3 +- 7 files changed, 29 insertions(+), 88 deletions(-) diff --git a/ChangeLog b/ChangeLog index 80fd11a19..1a2135dad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2008-06-06 Matthew Allum + + 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 Bug #931 - suspicious size allocation for pixel data. diff --git a/clutter/clutter-feature.c b/clutter/clutter-feature.c index 10edfe994..54ac41e70 100644 --- a/clutter/clutter-feature.c +++ b/clutter/clutter-feature.c @@ -58,9 +58,6 @@ _clutter_features_from_cogl (guint cogl_flags) { ClutterFeatureFlags clutter_flags = 0; - if (cogl_flags & COGL_FEATURE_TEXTURE_RECTANGLE) - clutter_flags |= CLUTTER_FEATURE_TEXTURE_RECTANGLE; - if (cogl_flags & COGL_FEATURE_TEXTURE_NPOT) clutter_flags |= CLUTTER_FEATURE_TEXTURE_NPOT; diff --git a/clutter/clutter-feature.h b/clutter/clutter-feature.h index b8c4264bb..9624c2a24 100644 --- a/clutter/clutter-feature.h +++ b/clutter/clutter-feature.h @@ -39,7 +39,6 @@ G_BEGIN_DECLS /** * ClutterFeatureFlags: - * @CLUTTER_FEATURE_TEXTURE_RECTANGLE: Set if rectangular textures supported. * @CLUTTER_FEATURE_TEXTURE_RECTANGLE: Set if NPOTS textures supported. * @CLUTTER_FEATURE_SYNC_TO_VBLANK: Set if vblank syncing supported. * @CLUTTER_FEATURE_TEXTURE_YUV: Set if YUV based textures supported. @@ -58,7 +57,6 @@ G_BEGIN_DECLS */ typedef enum { - CLUTTER_FEATURE_TEXTURE_RECTANGLE = (1 << 1), CLUTTER_FEATURE_TEXTURE_NPOT = (1 << 2), CLUTTER_FEATURE_SYNC_TO_VBLANK = (1 << 3), CLUTTER_FEATURE_TEXTURE_YUV = (1 << 4), diff --git a/clutter/clutter-texture.c b/clutter/clutter-texture.c index 8ff297fbb..637d8c2b0 100644 --- a/clutter/clutter-texture.c +++ b/clutter/clutter-texture.c @@ -1479,7 +1479,7 @@ on_fbo_source_size_change (GObject *object, priv->texture = cogl_texture_new_with_size (priv->width, priv->height, - priv->max_tile_waste, + -1, FALSE, 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 * shaders to groups and other potential visual effects. It requires that - * both %CLUTTER_FEATURE_TEXTURE_RECTANGLE and %CLUTTER_FEATURE_OFFSCREEN - * features are supported by the current backend and the target system. + * the %CLUTTER_FEATURE_OFFSCREEN feature is supported by the current backend + * and the target system. * * 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); - /* 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) return NULL; @@ -1600,7 +1596,9 @@ clutter_texture_new_from_actor (ClutterActor *actor) return NULL; /* 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; diff --git a/clutter/cogl/gl/cogl-texture.c b/clutter/cogl/gl/cogl-texture.c index 209b771e6..24f37b9b1 100644 --- a/clutter/cogl/gl/cogl-texture.c +++ b/clutter/cogl/gl/cogl-texture.c @@ -539,20 +539,7 @@ _cogl_texture_size_supported (GLenum gl_target, int width, int height) { - if (gl_target == GL_TEXTURE_RECTANGLE_ARB) - { - /* 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) +if (gl_target == GL_TEXTURE_2D) { /* 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; 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 { max_width = cogl_util_next_p2 (tex->bitmap.width); @@ -1230,8 +1210,7 @@ cogl_texture_new_from_foreign (GLuint gl_handle, CoglTexSliceSpan y_span; /* Allow 2-dimensional textures only */ - if (gl_target != GL_TEXTURE_2D && - gl_target != GL_TEXTURE_RECTANGLE_ARB) + if (gl_target != GL_TEXTURE_2D) return COGL_INVALID_HANDLE; /* Make sure it is a valid GL texture object */ @@ -1747,10 +1726,7 @@ _cogl_texture_quad_sw (CoglTexture *tex, /* Prepare GL state */ 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 || tex->bitmap.format & COGL_A_BIT) @@ -1806,11 +1782,8 @@ _cogl_texture_quad_sw (CoglTexture *tex, /* Normalize texture coordinates to current slice (rectangle texture targets take denormalized) */ - if (tex->gl_target != GL_TEXTURE_RECTANGLE_ARB) - { - slice_ty1 /= iter_y.span->size; - slice_ty2 /= iter_y.span->size; - } + slice_ty1 /= iter_y.span->size; + slice_ty2 /= iter_y.span->size; /* Iterate until whole quad width covered */ @@ -1835,11 +1808,8 @@ _cogl_texture_quad_sw (CoglTexture *tex, /* Normalize texture coordinates to current slice (rectangle texture targets take denormalized) */ - if (tex->gl_target != GL_TEXTURE_RECTANGLE_ARB) - { - slice_tx1 /= iter_x.span->size; - slice_tx2 /= iter_x.span->size; - } + slice_tx1 /= iter_x.span->size; + slice_tx2 /= iter_x.span->size; #if COGL_DEBUG printf("~~~~~ slice (%d,%d)\n", iter_x.index, iter_y.index); @@ -1908,10 +1878,7 @@ _cogl_texture_quad_hw (CoglTexture *tex, /* Prepare GL state */ 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 || tex->bitmap.format & COGL_A_BIT) @@ -1934,15 +1901,6 @@ _cogl_texture_quad_hw (CoglTexture *tex, ty1 = ty1 * (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) /* Draw textured quad */ @@ -2088,10 +2046,7 @@ cogl_texture_polygon (CoglHandle handle, tex = _cogl_texture_pointer_from_handle (handle); /* 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 a transparent border */ @@ -2140,12 +2095,6 @@ cogl_texture_polygon (CoglHandle handle, - y_span->start / (GLfloat) tex->bitmap.height) * 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); glVertex3f (CLUTTER_FIXED_TO_FLOAT (vertices[vnum].x), diff --git a/clutter/cogl/gl/cogl.c b/clutter/cogl/gl/cogl.c index 013c81e91..cec05eca2 100644 --- a/clutter/cogl/gl/cogl.c +++ b/clutter/cogl/gl/cogl.c @@ -323,11 +323,6 @@ cogl_enable (gulong flags) COGL_ENABLE_TEXCOORD_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 @@ -673,14 +668,6 @@ _cogl_features_init () 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)) { flags |= COGL_FEATURE_TEXTURE_NPOT; diff --git a/clutter/glx/clutter-glx-texture-pixmap.c b/clutter/glx/clutter-glx-texture-pixmap.c index 619f93051..0066bd818 100644 --- a/clutter/glx/clutter-glx-texture-pixmap.c +++ b/clutter/glx/clutter-glx-texture-pixmap.c @@ -202,8 +202,7 @@ clutter_glx_texture_pixmap_realize (ClutterActor *actor) if (priv->use_fallback || !_have_tex_from_pixmap_ext - || !(clutter_feature_available (COGL_FEATURE_TEXTURE_NPOT) - || clutter_feature_available (COGL_FEATURE_TEXTURE_RECTANGLE))) + || !clutter_feature_available (COGL_FEATURE_TEXTURE_NPOT)) { /* Fall back */ CLUTTER_NOTE (TEXTURE, "texture from pixmap appears unsupported");