[Cogl] [PATCH] Allocate immediately in _cogl_egl_texture_2d_new_from_image

Robert Bragg robert at sixbynine.org
Thu Feb 20 07:05:18 PST 2014


Like you said, I agree it would be good at some point for us to make
this api support deferred allocation, but for now this seems like a
good patch to land:

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

thanks,
Robert


On Wed, Feb 19, 2014 at 5:26 PM, Neil Roberts <neil at linux.intel.com> wrote:
> The _cogl_egl_texture_2d_new_from_image function has a CoglError
> argument which implies that it is unlike the other texture
> constructors and returns errors immediately rather than having a
> delayed-allocation mechanism. cogl_wayland_texture_2d_new_from_buffer
> which calls it is also like this. We can't rely on delayed-allocation
> semantics for this without changing the applications because the
> texture needs to be allocated before the corresponding EGLImage is
> destroyed. This patch just makes it immediately allocate.
>
> A better patch might be to remove the error argument to make it
> obvious that there are delayed-allocation semantics and then fix all
> of the applications.
>
> This was breaking Cogland and Mutter.
> ---
>  cogl/cogl-texture-2d.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/cogl/cogl-texture-2d.c b/cogl/cogl-texture-2d.c
> index 28f32e0..94b34ef 100644
> --- a/cogl/cogl-texture-2d.c
> +++ b/cogl/cogl-texture-2d.c
> @@ -241,6 +241,7 @@ _cogl_egl_texture_2d_new_from_image (CoglContext *ctx,
>                                       CoglError **error)
>  {
>    CoglTextureLoader *loader;
> +  CoglTexture2D *tex;
>
>    _COGL_RETURN_VAL_IF_FAIL (_cogl_context_get_winsys (ctx)->constraints &
>                              COGL_RENDERER_CONSTRAINT_USES_EGL,
> @@ -258,7 +259,15 @@ _cogl_egl_texture_2d_new_from_image (CoglContext *ctx,
>    loader->src.egl_image.height = height;
>    loader->src.egl_image.format = format;
>
> -  return _cogl_texture_2d_create_base (ctx, width, height, format, loader);
> +  tex = _cogl_texture_2d_create_base (ctx, width, height, format, loader);
> +
> +  if (!cogl_texture_allocate (COGL_TEXTURE (tex), error))
> +    {
> +      cogl_object_unref (tex);
> +      return NULL;
> +    }
> +
> +  return tex;
>  }
>  #endif /* defined (COGL_HAS_EGL_SUPPORT) && defined (EGL_KHR_image_base) */
>
> --
> 1.8.5.3
>
> _______________________________________________
> Cogl mailing list
> Cogl at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/cogl


More information about the Cogl mailing list