[cogl/cogl-1.12] texture: Add a context pointer to each texture



commit 0f0ee4a9090c72646ae6fb47d363caf6180ed8ff
Author: Robert Bragg <robert linux intel com>
Date:   Fri Sep 7 15:26:34 2012 +0100

    texture: Add a context pointer to each texture
    
    As part of our on-going goal to remove our dependence on a global Cogl
    context this patch adds a pointer to the context to each CoglTexture
    so that the various texture apis no longer need to use
    _COGL_GET_CONTEXT.
    
    Reviewed-by: Neil Roberts <neil linux intel com>
    
    (cherry picked from commit 83131072eea395f18ab0525ea2446f443a6033b1)

 cogl/cogl-atlas-texture.c             |    1 +
 cogl/cogl-sub-texture.c               |    2 +-
 cogl/cogl-texture-2d-sliced.c         |   11 ++----
 cogl/cogl-texture-2d.c                |   61 +++++++++++++++++----------------
 cogl/cogl-texture-3d.c                |   11 ++----
 cogl/cogl-texture-private.h           |    6 ++-
 cogl/cogl-texture-rectangle.c         |   52 +++++++++++++--------------
 cogl/cogl-texture.c                   |   31 ++++++++---------
 cogl/winsys/cogl-texture-pixmap-x11.c |    2 +-
 9 files changed, 86 insertions(+), 91 deletions(-)
---
diff --git a/cogl/cogl-atlas-texture.c b/cogl/cogl-atlas-texture.c
index f485893..2749f0b 100644
--- a/cogl/cogl-atlas-texture.c
+++ b/cogl/cogl-atlas-texture.c
@@ -685,6 +685,7 @@ _cogl_atlas_texture_new_with_size (unsigned int width,
   atlas_tex->atlas = NULL;
 
   _cogl_texture_init (COGL_TEXTURE (atlas_tex),
+                      ctx,
                       &cogl_atlas_texture_vtable);
 
   atlas_tex->sub_texture = NULL;
diff --git a/cogl/cogl-sub-texture.c b/cogl/cogl-sub-texture.c
index 97a5aad..8ca193f 100644
--- a/cogl/cogl-sub-texture.c
+++ b/cogl/cogl-sub-texture.c
@@ -230,7 +230,7 @@ cogl_sub_texture_new (CoglContext *ctx,
 
   tex = COGL_TEXTURE (sub_tex);
 
-  _cogl_texture_init (tex, &cogl_sub_texture_vtable);
+  _cogl_texture_init (tex, ctx, &cogl_sub_texture_vtable);
 
   /* If the next texture is also a sub texture we can avoid one level
      of indirection by referencing the full texture of that texture
diff --git a/cogl/cogl-texture-2d-sliced.c b/cogl/cogl-texture-2d-sliced.c
index fc33abe..d8b229e 100644
--- a/cogl/cogl-texture-2d-sliced.c
+++ b/cogl/cogl-texture-2d-sliced.c
@@ -175,8 +175,7 @@ _cogl_texture_2d_sliced_set_waste (CoglTexture2DSliced *tex_2ds,
                                    int dst_y)
 {
   CoglBool need_x, need_y;
-
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+  CoglContext *ctx = COGL_TEXTURE (tex_2ds)->context;
 
   /* If the x_span is sliced and the upload touches the
      rightmost pixels then fill the waste with copies of the
@@ -818,7 +817,7 @@ _cogl_texture_2d_sliced_init_base (CoglContext *ctx,
 {
   CoglTexture *tex = COGL_TEXTURE (tex_2ds);
 
-  _cogl_texture_init (tex, &cogl_texture_2d_sliced_vtable);
+  _cogl_texture_init (tex, ctx, &cogl_texture_2d_sliced_vtable);
 
   tex_2ds->slice_x_spans = NULL;
   tex_2ds->slice_y_spans = NULL;
@@ -1243,10 +1242,8 @@ _cogl_texture_2d_sliced_set_region (CoglTexture    *tex,
                                     CoglBitmap     *bmp)
 {
   CoglTexture2DSliced *tex_2ds = COGL_TEXTURE_2D_SLICED (tex);
-  GLenum               gl_format;
-  GLenum               gl_type;
-
-  _COGL_GET_CONTEXT (ctx, FALSE);
+  GLenum gl_format;
+  GLenum gl_type;
 
   bmp = _cogl_texture_prepare_for_upload (bmp,
                                           cogl_texture_get_format (tex),
diff --git a/cogl/cogl-texture-2d.c b/cogl/cogl-texture-2d.c
index c5a8dd0..f3f6b5f 100644
--- a/cogl/cogl-texture-2d.c
+++ b/cogl/cogl-texture-2d.c
@@ -69,8 +69,7 @@ _cogl_texture_2d_set_wrap_mode_parameters (CoglTexture *tex,
                                            GLenum wrap_mode_p)
 {
   CoglTexture2D *tex_2d = COGL_TEXTURE_2D (tex);
-
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+  CoglContext *ctx = tex->context;
 
   /* Only set the wrap mode if it's different from the current value
      to avoid too many GL calls. Texture 2D doesn't make use of the r
@@ -104,7 +103,8 @@ _cogl_texture_2d_free (CoglTexture2D *tex_2d)
 }
 
 static CoglBool
-_cogl_texture_2d_can_create (unsigned int width,
+_cogl_texture_2d_can_create (CoglContext *ctx,
+                             unsigned int width,
                              unsigned int height,
                              CoglPixelFormat internal_format)
 {
@@ -112,8 +112,6 @@ _cogl_texture_2d_can_create (unsigned int width,
   GLenum gl_format;
   GLenum gl_type;
 
-  _COGL_GET_CONTEXT (ctx, FALSE);
-
   /* If NPOT textures aren't supported then the size must be a power
      of two */
   if (!cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_BASIC) &&
@@ -150,14 +148,15 @@ _cogl_texture_2d_set_auto_mipmap (CoglTexture *tex,
 }
 
 static CoglTexture2D *
-_cogl_texture_2d_create_base (unsigned int     width,
-                              unsigned int     height,
-                              CoglPixelFormat  internal_format)
+_cogl_texture_2d_create_base (CoglContext *ctx,
+                              int width,
+                              int height,
+                              CoglPixelFormat internal_format)
 {
   CoglTexture2D *tex_2d = g_new (CoglTexture2D, 1);
   CoglTexture *tex = COGL_TEXTURE (tex_2d);
 
-  _cogl_texture_init (tex, &cogl_texture_2d_vtable);
+  _cogl_texture_init (tex, ctx, &cogl_texture_2d_vtable);
 
   tex_2d->width = width;
   tex_2d->height = height;
@@ -195,7 +194,7 @@ cogl_texture_2d_new_with_size (CoglContext *ctx,
   if (internal_format == COGL_PIXEL_FORMAT_ANY)
     internal_format = COGL_PIXEL_FORMAT_RGBA_8888_PRE;
 
-  if (!_cogl_texture_2d_can_create (width, height, internal_format))
+  if (!_cogl_texture_2d_can_create (ctx, width, height, internal_format))
     {
       g_set_error (error, COGL_TEXTURE_ERROR,
                    COGL_TEXTURE_ERROR_SIZE,
@@ -210,7 +209,8 @@ cogl_texture_2d_new_with_size (CoglContext *ctx,
                                                             &gl_format,
                                                             &gl_type);
 
-  tex_2d = _cogl_texture_2d_create_base (width, height,
+  tex_2d = _cogl_texture_2d_create_base (ctx,
+                                         width, height,
                                          internal_format);
 
   ctx->texture_driver->gen (ctx, GL_TEXTURE_2D, 1, &tex_2d->gl_texture);
@@ -244,7 +244,8 @@ cogl_texture_2d_new_from_bitmap (CoglBitmap *bmp,
     _cogl_texture_determine_internal_format (cogl_bitmap_get_format (bmp),
                                              internal_format);
 
-  if (!_cogl_texture_2d_can_create (cogl_bitmap_get_width (bmp),
+  if (!_cogl_texture_2d_can_create (ctx,
+                                    cogl_bitmap_get_width (bmp),
                                     cogl_bitmap_get_height (bmp),
                                     internal_format))
     {
@@ -269,7 +270,8 @@ cogl_texture_2d_new_from_bitmap (CoglBitmap *bmp,
       return NULL;
     }
 
-  tex_2d = _cogl_texture_2d_create_base (cogl_bitmap_get_width (bmp),
+  tex_2d = _cogl_texture_2d_create_base (ctx,
+                                         cogl_bitmap_get_width (bmp),
                                          cogl_bitmap_get_height (bmp),
                                          internal_format);
 
@@ -463,7 +465,8 @@ cogl_texture_2d_new_from_foreign (CoglContext *ctx,
      the dirtiness tracking that Cogl would do. */
 
   /* Create new texture */
-  tex_2d = _cogl_texture_2d_create_base (width, height,
+  tex_2d = _cogl_texture_2d_create_base (ctx,
+                                         width, height,
                                          format);
   _cogl_texture_2d_set_auto_mipmap (COGL_TEXTURE (tex_2d), FALSE);
 
@@ -506,7 +509,8 @@ _cogl_egl_texture_2d_new_from_image (CoglContext *ctx,
                         COGL_PRIVATE_FEATURE_TEXTURE_2D_FROM_EGL_IMAGE,
                         NULL);
 
-  tex_2d = _cogl_texture_2d_create_base (width, height,
+  tex_2d = _cogl_texture_2d_create_base (ctx,
+                                         width, height,
                                          format);
 
   ctx->texture_driver->gen (ctx, GL_TEXTURE_2D, 1, &tex_2d->gl_texture);
@@ -617,10 +621,12 @@ _cogl_texture_2d_copy_from_framebuffer (CoglTexture2D *tex_2d,
                                         int width,
                                         int height)
 {
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+  CoglContext *ctx;
 
   _COGL_RETURN_IF_FAIL (cogl_is_texture_2d (tex_2d));
 
+  ctx = COGL_TEXTURE (tex_2d)->context;
+
   /* Make sure the current framebuffers are bound, though we don't need to
    * flush the clip state here since we aren't going to draw to the
    * framebuffer. */
@@ -658,8 +664,7 @@ static CoglBool
 _cogl_texture_2d_can_hardware_repeat (CoglTexture *tex)
 {
   CoglTexture2D *tex_2d = COGL_TEXTURE_2D (tex);
-
-  _COGL_GET_CONTEXT (ctx, FALSE);
+  CoglContext *ctx = tex->context;
 
   if (cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_REPEAT) ||
       (_cogl_util_is_pot (tex_2d->width) &&
@@ -722,8 +727,7 @@ _cogl_texture_2d_set_filters (CoglTexture *tex,
                               GLenum       mag_filter)
 {
   CoglTexture2D *tex_2d = COGL_TEXTURE_2D (tex);
-
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+  CoglContext *ctx = tex->context;
 
   if (min_filter == tex_2d->min_filter
       && mag_filter == tex_2d->mag_filter)
@@ -745,8 +749,7 @@ static void
 _cogl_texture_2d_pre_paint (CoglTexture *tex, CoglTexturePrePaintFlags flags)
 {
   CoglTexture2D *tex_2d = COGL_TEXTURE_2D (tex);
-
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+  CoglContext *ctx = tex->context;
 
   /* Only update if the mipmaps are dirty */
   if ((flags & COGL_TEXTURE_NEEDS_MIPMAP) &&
@@ -798,12 +801,11 @@ _cogl_texture_2d_set_region (CoglTexture    *tex,
                              CoglBitmap     *bmp)
 {
   CoglTexture2D *tex_2d = COGL_TEXTURE_2D (tex);
+  CoglContext *ctx = tex->context;
   GLenum gl_format;
   GLenum gl_type;
   uint8_t *data;
 
-  _COGL_GET_CONTEXT (ctx, FALSE);
-
   bmp = _cogl_texture_prepare_for_upload (bmp,
                                           cogl_texture_get_format (tex),
                                           NULL,
@@ -852,12 +854,11 @@ _cogl_texture_2d_get_data (CoglTexture *tex,
                            unsigned int rowstride,
                            uint8_t *data)
 {
-  CoglTexture2D   *tex_2d = COGL_TEXTURE_2D (tex);
-  int              bpp;
-  GLenum           gl_format;
-  GLenum           gl_type;
-
-  _COGL_GET_CONTEXT (ctx, FALSE);
+  CoglTexture2D *tex_2d = COGL_TEXTURE_2D (tex);
+  CoglContext *ctx = tex->context;
+  int bpp;
+  GLenum gl_format;
+  GLenum gl_type;
 
   bpp = _cogl_pixel_format_get_bytes_per_pixel (format);
 
diff --git a/cogl/cogl-texture-3d.c b/cogl/cogl-texture-3d.c
index f6a3fd7..1a2b84d 100644
--- a/cogl/cogl-texture-3d.c
+++ b/cogl/cogl-texture-3d.c
@@ -62,8 +62,7 @@ _cogl_texture_3d_set_wrap_mode_parameters (CoglTexture *tex,
                                            GLenum wrap_mode_p)
 {
   CoglTexture3D *tex_3d = COGL_TEXTURE_3D (tex);
-
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+  CoglContext *ctx = tex->context;
 
   /* Only set the wrap mode if it's different from the current value
      to avoid too many GL calls. */
@@ -118,7 +117,7 @@ _cogl_texture_3d_create_base (CoglContext *ctx,
   CoglTexture3D *tex_3d = g_new (CoglTexture3D, 1);
   CoglTexture *tex = COGL_TEXTURE (tex_3d);
 
-  _cogl_texture_init (tex, &cogl_texture_3d_vtable);
+  _cogl_texture_init (tex, ctx, &cogl_texture_3d_vtable);
 
   tex_3d->width = width;
   tex_3d->height = height;
@@ -485,8 +484,7 @@ _cogl_texture_3d_set_filters (CoglTexture *tex,
                               GLenum       mag_filter)
 {
   CoglTexture3D *tex_3d = COGL_TEXTURE_3D (tex);
-
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+  CoglContext *ctx = tex->context;
 
   if (min_filter == tex_3d->min_filter
       && mag_filter == tex_3d->mag_filter)
@@ -508,8 +506,7 @@ static void
 _cogl_texture_3d_pre_paint (CoglTexture *tex, CoglTexturePrePaintFlags flags)
 {
   CoglTexture3D *tex_3d = COGL_TEXTURE_3D (tex);
-
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+  CoglContext *ctx = tex->context;
 
   /* Only update if the mipmaps are dirty */
   if ((flags & COGL_TEXTURE_NEEDS_MIPMAP) &&
diff --git a/cogl/cogl-texture-private.h b/cogl/cogl-texture-private.h
index 1eeb9fd..a3888de 100644
--- a/cogl/cogl-texture-private.h
+++ b/cogl/cogl-texture-private.h
@@ -136,8 +136,9 @@ struct _CoglTextureVtable
 
 struct _CoglTexture
 {
-  CoglObject               _parent;
-  GList                   *framebuffers;
+  CoglObject _parent;
+  CoglContext *context;
+  GList *framebuffers;
   const CoglTextureVtable *vtable;
 };
 
@@ -170,6 +171,7 @@ struct _CoglTexturePixel
 
 void
 _cogl_texture_init (CoglTexture *texture,
+                    CoglContext *ctx,
                     const CoglTextureVtable *vtable);
 
 void
diff --git a/cogl/cogl-texture-rectangle.c b/cogl/cogl-texture-rectangle.c
index 688bc18..9af59c9 100644
--- a/cogl/cogl-texture-rectangle.c
+++ b/cogl/cogl-texture-rectangle.c
@@ -73,8 +73,7 @@ _cogl_texture_rectangle_set_wrap_mode_parameters (CoglTexture *tex,
                                                   GLenum wrap_mode_p)
 {
   CoglTextureRectangle *tex_rect = COGL_TEXTURE_RECTANGLE (tex);
-
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+  CoglContext *ctx = tex->context;
 
   /* Only set the wrap mode if it's different from the current value
      to avoid too many GL calls. Texture rectangle doesn't make use of
@@ -109,7 +108,8 @@ _cogl_texture_rectangle_free (CoglTextureRectangle *tex_rect)
 }
 
 static CoglBool
-_cogl_texture_rectangle_can_create (unsigned int width,
+_cogl_texture_rectangle_can_create (CoglContext *ctx,
+                                    unsigned int width,
                                     unsigned int height,
                                     CoglPixelFormat internal_format,
                                     GError **error)
@@ -118,8 +118,6 @@ _cogl_texture_rectangle_can_create (unsigned int width,
   GLenum gl_format;
   GLenum gl_type;
 
-  _COGL_GET_CONTEXT (ctx, FALSE);
-
   if (!cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_RECTANGLE))
     {
       g_set_error (error,
@@ -163,14 +161,15 @@ _cogl_texture_rectangle_set_auto_mipmap (CoglTexture *tex,
 }
 
 static CoglTextureRectangle *
-_cogl_texture_rectangle_create_base (unsigned int     width,
-                                     unsigned int     height,
-                                     CoglPixelFormat  internal_format)
+_cogl_texture_rectangle_create_base (CoglContext *ctx,
+                                     int width,
+                                     int height,
+                                     CoglPixelFormat internal_format)
 {
   CoglTextureRectangle *tex_rect = g_new (CoglTextureRectangle, 1);
   CoglTexture *tex = COGL_TEXTURE (tex_rect);
 
-  _cogl_texture_init (tex, &cogl_texture_rectangle_vtable);
+  _cogl_texture_init (tex, ctx, &cogl_texture_rectangle_vtable);
 
   tex_rect->width = width;
   tex_rect->height = height;
@@ -204,7 +203,8 @@ cogl_texture_rectangle_new_with_size (CoglContext *ctx,
   if (internal_format == COGL_PIXEL_FORMAT_ANY)
     internal_format = COGL_PIXEL_FORMAT_RGBA_8888_PRE;
 
-  if (!_cogl_texture_rectangle_can_create (width, height,
+  if (!_cogl_texture_rectangle_can_create (ctx,
+                                           width, height,
                                            internal_format, error))
     return NULL;
 
@@ -214,7 +214,8 @@ cogl_texture_rectangle_new_with_size (CoglContext *ctx,
                                                             &gl_format,
                                                             &gl_type);
 
-  tex_rect = _cogl_texture_rectangle_create_base (width, height,
+  tex_rect = _cogl_texture_rectangle_create_base (ctx,
+                                                  width, height,
                                                   internal_format);
 
   ctx->texture_driver->gen (ctx,
@@ -250,7 +251,8 @@ cogl_texture_rectangle_new_from_bitmap (CoglBitmap *bmp,
     _cogl_texture_determine_internal_format (cogl_bitmap_get_format (bmp),
                                              internal_format);
 
-  if (!_cogl_texture_rectangle_can_create (cogl_bitmap_get_width (bmp),
+  if (!_cogl_texture_rectangle_can_create (ctx,
+                                           cogl_bitmap_get_width (bmp),
                                            cogl_bitmap_get_height (bmp),
                                            internal_format,
                                            error))
@@ -266,7 +268,8 @@ cogl_texture_rectangle_new_from_bitmap (CoglBitmap *bmp,
   if (dst_bmp == NULL)
     return NULL;
 
-  tex_rect = _cogl_texture_rectangle_create_base (cogl_bitmap_get_width (bmp),
+  tex_rect = _cogl_texture_rectangle_create_base (ctx,
+                                                  cogl_bitmap_get_width (bmp),
                                                   cogl_bitmap_get_height (bmp),
                                                   internal_format);
 
@@ -375,7 +378,7 @@ _cogl_texture_rectangle_new_from_foreign (GLuint gl_handle,
     return NULL;
 
   /* Create new texture */
-  tex_rect = _cogl_texture_rectangle_create_base (width, height, format);
+  tex_rect = _cogl_texture_rectangle_create_base (ctx, width, height, format);
 
   /* Setup bitmap info */
   tex_rect->is_foreign = TRUE;
@@ -462,8 +465,7 @@ _cogl_texture_rectangle_set_filters (CoglTexture *tex,
                                      GLenum       mag_filter)
 {
   CoglTextureRectangle *tex_rect = COGL_TEXTURE_RECTANGLE (tex);
-
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+  CoglContext *ctx = tex->context;
 
   if (min_filter == tex_rect->min_filter
       && mag_filter == tex_rect->mag_filter)
@@ -490,8 +492,6 @@ static void
 _cogl_texture_rectangle_pre_paint (CoglTexture *tex,
                                    CoglTexturePrePaintFlags flags)
 {
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
   /* Rectangle textures don't support mipmaps */
   g_assert ((flags & COGL_TEXTURE_NEEDS_MIPMAP) == 0);
 }
@@ -513,10 +513,9 @@ _cogl_texture_rectangle_set_region (CoglTexture    *tex,
                                     CoglBitmap     *bmp)
 {
   CoglTextureRectangle *tex_rect = COGL_TEXTURE_RECTANGLE (tex);
-  GLenum                gl_format;
-  GLenum                gl_type;
-
-  _COGL_GET_CONTEXT (ctx, FALSE);
+  GLenum gl_format;
+  GLenum gl_type;
+  CoglContext *ctx = tex->context;
 
   bmp = _cogl_texture_prepare_for_upload (bmp,
                                           cogl_texture_get_format (tex),
@@ -549,11 +548,10 @@ _cogl_texture_rectangle_get_data (CoglTexture *tex,
                                   uint8_t *data)
 {
   CoglTextureRectangle *tex_rect = COGL_TEXTURE_RECTANGLE (tex);
-  int                   bpp;
-  GLenum                gl_format;
-  GLenum                gl_type;
-
-  _COGL_GET_CONTEXT (ctx, FALSE);
+  CoglContext *ctx = tex->context;
+  int bpp;
+  GLenum gl_format;
+  GLenum gl_type;
 
   bpp = _cogl_pixel_format_get_bytes_per_pixel (format);
 
diff --git a/cogl/cogl-texture.c b/cogl/cogl-texture.c
index c6a02ad..ccbeaa6 100644
--- a/cogl/cogl-texture.c
+++ b/cogl/cogl-texture.c
@@ -128,8 +128,10 @@ cogl_texture_unref (void *object)
 
 void
 _cogl_texture_init (CoglTexture *texture,
+                    CoglContext *context,
                     const CoglTextureVtable *vtable)
 {
+  texture->context = context;
   texture->vtable = vtable;
   texture->framebuffers = NULL;
 }
@@ -721,10 +723,9 @@ cogl_texture_set_region (CoglTexture *texture,
 			 unsigned int rowstride,
 			 const uint8_t *data)
 {
+  CoglContext *ctx = texture->context;
   CoglBitmap *source_bmp;
-  CoglBool    ret;
-
-  _COGL_GET_CONTEXT (ctx, FALSE);
+  CoglBool ret;
 
   _COGL_RETURN_VAL_IF_FAIL ((width - src_x) >= dst_width, FALSE);
   _COGL_RETURN_VAL_IF_FAIL ((height - src_y) >= dst_height, FALSE);
@@ -1010,13 +1011,12 @@ get_texture_bits_via_offscreen (CoglTexture    *texture,
                                 unsigned int    dst_rowstride,
                                 CoglPixelFormat dst_format)
 {
+  CoglContext *ctx = texture->context;
   CoglOffscreen *offscreen;
   CoglFramebuffer *framebuffer;
   CoglBitmap *bitmap;
   CoglBool ret;
 
-  _COGL_GET_CONTEXT (ctx, FALSE);
-
   if (!cogl_has_feature (ctx, COGL_FEATURE_ID_OFFSCREEN))
     return FALSE;
 
@@ -1175,20 +1175,19 @@ cogl_texture_get_data (CoglTexture *texture,
 		       unsigned int rowstride,
 		       uint8_t *data)
 {
-  int              bpp;
-  int              byte_size;
-  CoglPixelFormat  closest_format;
-  GLenum           closest_gl_format;
-  GLenum           closest_gl_type;
-  CoglBitmap      *target_bmp;
-  int              tex_width;
-  int              tex_height;
-  CoglPixelFormat  texture_format;
+  CoglContext *ctx = texture->context;
+  int bpp;
+  int byte_size;
+  CoglPixelFormat closest_format;
+  GLenum closest_gl_format;
+  GLenum closest_gl_type;
+  CoglBitmap *target_bmp;
+  int tex_width;
+  int tex_height;
+  CoglPixelFormat texture_format;
 
   CoglTextureGetData tg_data;
 
-  _COGL_GET_CONTEXT (ctx, 0);
-
   texture_format = cogl_texture_get_format (texture);
 
   /* Default to internal format if none specified */
diff --git a/cogl/winsys/cogl-texture-pixmap-x11.c b/cogl/winsys/cogl-texture-pixmap-x11.c
index ec855b3..aebf8e6 100644
--- a/cogl/winsys/cogl-texture-pixmap-x11.c
+++ b/cogl/winsys/cogl-texture-pixmap-x11.c
@@ -285,7 +285,7 @@ cogl_texture_pixmap_x11_new (CoglContext *ctxt,
   int damage_base;
   const CoglWinsysVtable *winsys;
 
-  _cogl_texture_init (tex, &cogl_texture_pixmap_x11_vtable);
+  _cogl_texture_init (tex, ctxt, &cogl_texture_pixmap_x11_vtable);
 
   tex_pixmap->pixmap = pixmap;
   tex_pixmap->image = NULL;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]