mirror of
https://github.com/brl/mutter.git
synced 2024-12-27 05:12:15 +00:00
cogl: Reduce the usage of _COGL_GET_CONTEXT
In cases where we already have the context where the function ends up being called Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3353>
This commit is contained in:
parent
10a840c92d
commit
ac2f6e8b9e
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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 =
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user