[Cogl] [PATCH] texture: Add a context pointer to each texture

Robert Bragg robert at sixbynine.org
Mon Sep 10 04:04:16 PDT 2012


From: Robert Bragg <robert at linux.intel.com>

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.
---
 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 b284602..f1944a0 100644
--- a/cogl/cogl-texture-2d-sliced.c
+++ b/cogl/cogl-texture-2d-sliced.c
@@ -176,8 +176,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
@@ -819,7 +818,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;
@@ -1242,10 +1241,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 a4d572c..bcfe684 100644
--- a/cogl/cogl-texture-2d.c
+++ b/cogl/cogl-texture-2d.c
@@ -70,8 +70,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
@@ -105,7 +104,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)
 {
@@ -113,8 +113,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) &&
@@ -151,14 +149,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;
@@ -196,7 +195,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))
     {
       _cogl_set_error (error, COGL_TEXTURE_ERROR,
                        COGL_TEXTURE_ERROR_SIZE,
@@ -211,7 +210,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);
@@ -245,7 +245,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))
     {
@@ -270,7 +271,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);
 
@@ -464,7 +466,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);
 
@@ -507,7 +510,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);
@@ -619,10 +623,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. */
@@ -660,8 +666,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) &&
@@ -724,8 +729,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)
@@ -747,8 +751,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) &&
@@ -800,12 +803,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,
@@ -854,12 +856,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 3a3f19e..7b781cb 100644
--- a/cogl/cogl-texture-3d.c
+++ b/cogl/cogl-texture-3d.c
@@ -63,8 +63,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. */
@@ -119,7 +118,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;
@@ -486,8 +485,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)
@@ -509,8 +507,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 83b7b78..b3952a3 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 e498175..2b55564 100644
--- a/cogl/cogl-texture-rectangle.c
+++ b/cogl/cogl-texture-rectangle.c
@@ -74,8 +74,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
@@ -110,7 +109,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,
                                     CoglError **error)
@@ -119,8 +119,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))
     {
       _cogl_set_error (error,
@@ -164,14 +162,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;
@@ -205,7 +204,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;
 
@@ -215,7 +215,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,
@@ -251,7 +252,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))
@@ -267,7 +269,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);
 
@@ -399,7 +402,7 @@ cogl_texture_rectangle_new_from_foreign (CoglContext *ctx,
     }
 
   /* 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;
@@ -486,8 +489,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)
@@ -514,8 +516,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);
 }
@@ -537,10 +537,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),
@@ -573,11 +572,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 c51e714..d5d8218 100644
--- a/cogl/cogl-texture.c
+++ b/cogl/cogl-texture.c
@@ -99,8 +99,10 @@ cogl_is_texture (void *object)
 
 void
 _cogl_texture_init (CoglTexture *texture,
+                    CoglContext *context,
                     const CoglTextureVtable *vtable)
 {
+  texture->context = context;
   texture->vtable = vtable;
   texture->framebuffers = NULL;
 }
@@ -605,10 +607,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);
@@ -894,13 +895,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;
 
@@ -1059,20 +1059,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 18a2370..04ad2a0 100644
--- a/cogl/winsys/cogl-texture-pixmap-x11.c
+++ b/cogl/winsys/cogl-texture-pixmap-x11.c
@@ -286,7 +286,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;
-- 
1.7.7.6



More information about the Cogl mailing list