[Cogl] [PATCH 4/4] Fix places that ignore the COGL_TEXTURE_NO_AUTO_MIPMAP flag

Robert Bragg robert at sixbynine.org
Thu Apr 5 03:06:22 PDT 2012


Reviewed-by: Robert Bragg <robert at linux.intel.com>

On Wed, Apr 4, 2012 at 5:13 PM, Neil Roberts <neil at linux.intel.com> wrote:
> Two of the meta texture constructors which take a flags parameter were
> ignoring the COGL_TEXTURE_NO_AUTO_MIPMAP flag when creating an
> underlying CoglTexture2D. These have now been fixed to call
> cogl_primitive_texture_set_auto_mipmap after constructing the texture.
> ---
>  cogl/cogl-texture-2d-sliced.c |   14 ++++++++++++++
>  cogl/cogl-texture.c           |   10 ++++++++--
>  2 files changed, 22 insertions(+), 2 deletions(-)
>
> diff --git a/cogl/cogl-texture-2d-sliced.c b/cogl/cogl-texture-2d-sliced.c
> index 3fb0338..5f43252 100644
> --- a/cogl/cogl-texture-2d-sliced.c
> +++ b/cogl/cogl-texture-2d-sliced.c
> @@ -44,6 +44,7 @@
>  #include "cogl-spans.h"
>  #include "cogl-journal-private.h"
>  #include "cogl-pipeline-opengl-private.h"
> +#include "cogl-primitive-texture.h"
>
>  #include <string.h>
>  #include <stdlib.h>
> @@ -881,6 +882,7 @@ _cogl_texture_2d_sliced_new_from_bitmap (CoglBitmap      *bmp,
>   GLenum               gl_type;
>   int                  width, height;
>   CoglContext         *ctx;
> +  int                  i;
>
>   _COGL_RETURN_VAL_IF_FAIL (cogl_is_bitmap (bmp), NULL);
>
> @@ -921,6 +923,18 @@ _cogl_texture_2d_sliced_new_from_bitmap (CoglBitmap      *bmp,
>
>   cogl_object_unref (dst_bmp);
>
> +  if ((flags & COGL_TEXTURE_NO_AUTO_MIPMAP))
> +    for (i = 0; i < tex_2ds->slice_textures->len; i++)
> +      {
> +        CoglPrimitiveTexture *slice_tex;
> +
> +        slice_tex = g_array_index (tex_2ds->slice_textures,
> +                                   CoglPrimitiveTexture *,
> +                                   i);
> +
> +        cogl_primitive_texture_set_auto_mipmap (slice_tex, FALSE);
> +      }
> +
>   return _cogl_texture_2d_sliced_handle_new (tex_2ds);
>
>  error:
> diff --git a/cogl/cogl-texture.c b/cogl/cogl-texture.c
> index dcf89a8..579281f 100644
> --- a/cogl/cogl-texture.c
> +++ b/cogl/cogl-texture.c
> @@ -315,9 +315,15 @@ cogl_texture_new_with_size (unsigned int     width,
>                                                      internal_format,
>                                                      NULL));
>
> -  /* If it fails resort to sliced textures */
> -  if (tex == NULL)
> +  if (tex)
>     {
> +      gboolean auto_mipmap = !(flags & COGL_TEXTURE_NO_AUTO_MIPMAP);
> +      cogl_primitive_texture_set_auto_mipmap (COGL_PRIMITIVE_TEXTURE (tex),
> +                                              auto_mipmap);
> +    }
> +  else
> +    {
> +      /* If it fails resort to sliced textures */
>       int max_waste = flags & COGL_TEXTURE_NO_SLICING ? -1 : COGL_TEXTURE_MAX_WASTE;
>       tex = COGL_TEXTURE (cogl_texture_2d_sliced_new_with_size (ctx,
>                                                                 width,
> --
> 1.7.3.16.g9464b
>
> _______________________________________________
> Cogl mailing list
> Cogl at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/cogl


More information about the Cogl mailing list