diff --git a/cogl/cogl/cogl-bitmap-conversion.c b/cogl/cogl/cogl-bitmap-conversion.c index acaa240de..62e2192a3 100644 --- a/cogl/cogl/cogl-bitmap-conversion.c +++ b/cogl/cogl/cogl-bitmap-conversion.c @@ -512,9 +512,9 @@ _cogl_bitmap_convert (CoglBitmap *src_bmp, { CoglBitmap *dst_bmp; int width, height; + CoglContext *ctx; - _COGL_GET_CONTEXT (ctx, NULL); - + ctx = _cogl_bitmap_get_context (src_bmp); width = cogl_bitmap_get_width (src_bmp); height = cogl_bitmap_get_height (src_bmp); diff --git a/cogl/cogl/cogl-context.c b/cogl/cogl/cogl-context.c index 34353c0ae..fad7b0f67 100644 --- a/cogl/cogl/cogl-context.c +++ b/cogl/cogl/cogl-context.c @@ -298,8 +298,8 @@ cogl_context_new (CoglDisplay *display, context->sampler_cache = _cogl_sampler_cache_new (context); - _cogl_pipeline_init_default_pipeline (); - _cogl_pipeline_init_default_layers (); + _cogl_pipeline_init_default_pipeline (context); + _cogl_pipeline_init_default_layers (context); _cogl_pipeline_init_state_hash_functions (); _cogl_pipeline_init_layer_state_hash_functions (); @@ -357,7 +357,7 @@ cogl_context_new (CoglDisplay *display, context->depth_range_near_cache = 0; context->depth_range_far_cache = 1; - context->pipeline_cache = _cogl_pipeline_cache_new (); + context->pipeline_cache = _cogl_pipeline_cache_new (context); for (i = 0; i < COGL_BUFFER_BIND_TARGET_COUNT; i++) context->current_buffer[i] = NULL; diff --git a/cogl/cogl/cogl-pipeline-cache.c b/cogl/cogl/cogl-pipeline-cache.c index df82807de..8cc64df4c 100644 --- a/cogl/cogl/cogl-pipeline-cache.c +++ b/cogl/cogl/cogl-pipeline-cache.c @@ -47,7 +47,7 @@ struct _CoglPipelineCache }; CoglPipelineCache * -_cogl_pipeline_cache_new (void) +_cogl_pipeline_cache_new (CoglContext *ctx) { g_autofree CoglPipelineCache *cache = g_new (CoglPipelineCache, 1); unsigned long vertex_state; @@ -55,8 +55,6 @@ _cogl_pipeline_cache_new (void) unsigned int fragment_state; unsigned int layer_fragment_state; - _COGL_GET_CONTEXT (ctx, 0); - vertex_state = _cogl_pipeline_get_state_for_vertex_codegen (ctx); layer_vertex_state = diff --git a/cogl/cogl/cogl-pipeline-cache.h b/cogl/cogl/cogl-pipeline-cache.h index 2869ac866..99b9c3efe 100644 --- a/cogl/cogl/cogl-pipeline-cache.h +++ b/cogl/cogl/cogl-pipeline-cache.h @@ -44,7 +44,7 @@ typedef struct } CoglPipelineCacheEntry; CoglPipelineCache * -_cogl_pipeline_cache_new (void); +_cogl_pipeline_cache_new (CoglContext *ctx); void _cogl_pipeline_cache_free (CoglPipelineCache *cache); diff --git a/cogl/cogl/cogl-pipeline-layer-private.h b/cogl/cogl/cogl-pipeline-layer-private.h index dfe4786be..b2e2d504d 100644 --- a/cogl/cogl/cogl-pipeline-layer-private.h +++ b/cogl/cogl/cogl-pipeline-layer-private.h @@ -276,7 +276,7 @@ typedef gboolean void -_cogl_pipeline_init_default_layers (void); +_cogl_pipeline_init_default_layers (CoglContext *ctx); static inline CoglPipelineLayer * _cogl_pipeline_layer_get_parent (CoglPipelineLayer *layer) diff --git a/cogl/cogl/cogl-pipeline-layer.c b/cogl/cogl/cogl-pipeline-layer.c index f1dbb18e5..5ae59e258 100644 --- a/cogl/cogl/cogl-pipeline-layer.c +++ b/cogl/cogl/cogl-pipeline-layer.c @@ -715,15 +715,13 @@ _cogl_pipeline_layer_equal (CoglPipelineLayer *layer0, } void -_cogl_pipeline_init_default_layers (void) +_cogl_pipeline_init_default_layers (CoglContext *ctx) { CoglPipelineLayer *layer = g_object_new (COGL_TYPE_PIPELINE_LAYER, NULL); CoglPipelineLayerBigState *big_state = g_new0 (CoglPipelineLayerBigState, 1); CoglPipelineLayer *new; - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - layer->index = 0; layer->differences = COGL_PIPELINE_LAYER_STATE_ALL_SPARSE; diff --git a/cogl/cogl/cogl-pipeline-private.h b/cogl/cogl/cogl-pipeline-private.h index f177f26a2..77d49fb74 100644 --- a/cogl/cogl/cogl-pipeline-private.h +++ b/cogl/cogl/cogl-pipeline-private.h @@ -439,7 +439,7 @@ extern const CoglPipelineVertend *_cogl_pipeline_vertend; extern const CoglPipelineProgend *_cogl_pipeline_progend; void -_cogl_pipeline_init_default_pipeline (void); +_cogl_pipeline_init_default_pipeline (CoglContext *ctx); static inline CoglPipeline * _cogl_pipeline_get_parent (CoglPipeline *pipeline) diff --git a/cogl/cogl/cogl-pipeline.c b/cogl/cogl/cogl-pipeline.c index b1bd21d57..563b3eab4 100644 --- a/cogl/cogl/cogl-pipeline.c +++ b/cogl/cogl/cogl-pipeline.c @@ -178,7 +178,7 @@ cogl_pipeline_init (CoglPipeline *pipeline) * The default pipeline is the topmost ancestor for all pipelines. */ void -_cogl_pipeline_init_default_pipeline (void) +_cogl_pipeline_init_default_pipeline (CoglContext *ctx) { /* Create new - blank - pipeline */ CoglPipeline *pipeline = g_object_new (COGL_TYPE_PIPELINE, NULL); @@ -190,8 +190,6 @@ _cogl_pipeline_init_default_pipeline (void) CoglPipelineCullFaceState *cull_face_state = &big_state->cull_face_state; CoglPipelineUniformsState *uniforms_state = &big_state->uniforms_state; - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - /* Take this opportunity to setup the backends... */ _cogl_pipeline_fragend = &_cogl_pipeline_glsl_fragend; _cogl_pipeline_progend = &_cogl_pipeline_glsl_progend; diff --git a/cogl/cogl/winsys/cogl-texture-pixmap-x11.c b/cogl/cogl/winsys/cogl-texture-pixmap-x11.c index 963582e03..b1e71075a 100644 --- a/cogl/cogl/winsys/cogl-texture-pixmap-x11.c +++ b/cogl/cogl/winsys/cogl-texture-pixmap-x11.c @@ -69,21 +69,19 @@ G_DEFINE_FINAL_TYPE (CoglTexturePixmapX11, cogl_texture_pixmap_x11, COGL_TYPE_TE static const CoglWinsysVtable * _cogl_texture_pixmap_x11_get_winsys (CoglTexturePixmapX11 *tex_pixmap) { - /* FIXME: A CoglContext should be reachable from a CoglTexture - * pointer */ - _COGL_GET_CONTEXT (ctx, NULL); + CoglContext *ctx; + ctx = cogl_texture_get_context (COGL_TEXTURE (tex_pixmap)); return ctx->display->renderer->winsys_vtable; } static int -_cogl_xlib_get_damage_base (void) +_cogl_xlib_get_damage_base (CoglContext *ctx) { CoglX11Renderer *x11_renderer; - _COGL_GET_CONTEXT (ctxt, -1); x11_renderer = - (CoglX11Renderer *) _cogl_xlib_renderer_get_data (ctxt->display->renderer); + (CoglX11Renderer *) _cogl_xlib_renderer_get_data (ctx->display->renderer); return x11_renderer->damage_base; } @@ -135,10 +133,10 @@ process_damage_event (CoglTexturePixmapX11 *tex_pixmap, enum { DO_NOTHING, NEEDS_SUBTRACT, NEED_BOUNDING_BOX } handle_mode; const CoglWinsysVtable *winsys; - - _COGL_GET_CONTEXT (ctxt, NO_RETVAL); - - display = cogl_xlib_renderer_get_display (ctxt->display->renderer); + CoglContext *ctx; + + ctx = cogl_texture_get_context (COGL_TEXTURE (tex_pixmap)); + display = cogl_xlib_renderer_get_display (ctx->display->renderer); COGL_NOTE (TEXTURE_PIXMAP, "Damage event received for %p", tex_pixmap); @@ -235,10 +233,10 @@ _cogl_texture_pixmap_x11_filter (XEvent *event, void *data) { CoglTexturePixmapX11 *tex_pixmap = data; int damage_base; + CoglContext *ctx; - _COGL_GET_CONTEXT (ctxt, COGL_FILTER_CONTINUE); - - damage_base = _cogl_xlib_get_damage_base (); + ctx = cogl_texture_get_context (COGL_TEXTURE (tex_pixmap)); + damage_base = _cogl_xlib_get_damage_base (ctx); if (event->type == damage_base + XDamageNotify) { XDamageNotifyEvent *damage_event = (XDamageNotifyEvent *) event; @@ -284,10 +282,10 @@ static void cogl_texture_pixmap_x11_dispose (GObject *object) { CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (object); - + CoglContext *ctx; Display *display; - _COGL_GET_CONTEXT (ctxt, NO_RETVAL); + ctx = cogl_texture_get_context (COGL_TEXTURE (tex_pixmap)); if (tex_pixmap->stereo_mode == COGL_TEXTURE_PIXMAP_RIGHT) { @@ -296,9 +294,9 @@ cogl_texture_pixmap_x11_dispose (GObject *object) return; } - display = cogl_xlib_renderer_get_display (ctxt->display->renderer); + display = cogl_xlib_renderer_get_display (ctx->display->renderer); - set_damage_object_internal (ctxt, tex_pixmap, 0, 0); + set_damage_object_internal (ctx, tex_pixmap, 0, 0); if (tex_pixmap->image) XDestroyImage (tex_pixmap->image); @@ -384,10 +382,10 @@ try_alloc_shm (CoglTexturePixmapX11 *tex_pixmap) { CoglTexture *tex = COGL_TEXTURE (tex_pixmap); XImage *dummy_image; + CoglContext *ctx; Display *display; - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - + ctx = cogl_texture_get_context (COGL_TEXTURE (tex_pixmap)); display = cogl_xlib_renderer_get_display (ctx->display->renderer); if (!XShmQueryExtension (display)) @@ -456,6 +454,7 @@ _cogl_texture_pixmap_x11_update_image_texture (CoglTexturePixmapX11 *tex_pixmap) CoglTexture *tex = COGL_TEXTURE (tex_pixmap); Display *display; Visual *visual; + CoglContext *ctx; CoglPixelFormat image_format; XImage *image; int src_x, src_y; @@ -464,8 +463,7 @@ _cogl_texture_pixmap_x11_update_image_texture (CoglTexturePixmapX11 *tex_pixmap) int offset; GError *ignore = NULL; - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - + ctx = cogl_texture_get_context (COGL_TEXTURE (tex_pixmap)); display = cogl_xlib_renderer_get_display (ctx->display->renderer); visual = tex_pixmap->visual; @@ -974,7 +972,7 @@ _cogl_texture_pixmap_x11_new (CoglContext *ctx, /* If automatic updates are requested and the Xlib connection supports damage events then we'll register a damage object on the pixmap */ - damage_base = _cogl_xlib_get_damage_base (); + damage_base = _cogl_xlib_get_damage_base (ctx); if (automatic_updates && damage_base >= 0) { Damage damage = XDamageCreate (display, diff --git a/cogl/cogl/winsys/cogl-winsys-egl-x11.c b/cogl/cogl/winsys/cogl-winsys-egl-x11.c index 461ec5309..be12ff39e 100644 --- a/cogl/cogl/winsys/cogl-winsys-egl-x11.c +++ b/cogl/cogl/winsys/cogl-winsys-egl-x11.c @@ -510,10 +510,9 @@ static void _cogl_winsys_texture_pixmap_x11_free (CoglTexturePixmapX11 *tex_pixmap) { CoglTexturePixmapEGL *egl_tex_pixmap; + CoglContext *ctx; - /* FIXME: It should be possible to get to a CoglContext from any - * CoglTexture pointer. */ - _COGL_GET_CONTEXT (ctx, NO_RETVAL); + ctx = cogl_texture_get_context (COGL_TEXTURE (tex_pixmap)); if (!tex_pixmap->winsys) return;