clutter/stage-view: Pass around view when creating shadow fb

Instead of passing around the CoglContext, pass around the view, which
can be used to fetch the CoglContext. We'll use it for more stuff later.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3443>
This commit is contained in:
Jonas Ådahl 2023-10-13 15:20:33 +08:00 committed by Marge Bot
parent b282097834
commit d8ff97ebf6

View File

@ -323,13 +323,13 @@ is_shadowfb_double_buffered (ClutterStageView *view)
static gboolean static gboolean
init_dma_buf_shadowfbs (ClutterStageView *view, init_dma_buf_shadowfbs (ClutterStageView *view,
CoglContext *cogl_context,
int width, int width,
int height, int height,
GError **error) GError **error)
{ {
ClutterStageViewPrivate *priv = ClutterStageViewPrivate *priv =
clutter_stage_view_get_instance_private (view); clutter_stage_view_get_instance_private (view);
CoglContext *cogl_context = cogl_framebuffer_get_context (priv->framebuffer);
CoglRenderer *cogl_renderer = cogl_context_get_renderer (cogl_context); CoglRenderer *cogl_renderer = cogl_context_get_renderer (cogl_context);
CoglFramebuffer *initial_shadowfb; CoglFramebuffer *initial_shadowfb;
@ -375,15 +375,19 @@ init_dma_buf_shadowfbs (ClutterStageView *view,
} }
static CoglOffscreen * static CoglOffscreen *
create_offscreen_framebuffer (CoglContext *context, create_offscreen_framebuffer (ClutterStageView *view,
int width, int width,
int height, int height,
GError **error) GError **error)
{ {
ClutterStageViewPrivate *priv =
clutter_stage_view_get_instance_private (view);
CoglContext *cogl_context;
CoglOffscreen *framebuffer; CoglOffscreen *framebuffer;
CoglTexture *texture; CoglTexture *texture;
texture = cogl_texture_2d_new_with_size (context, width, height); cogl_context = cogl_framebuffer_get_context (priv->framebuffer);
texture = cogl_texture_2d_new_with_size (cogl_context, width, height);
cogl_primitive_texture_set_auto_mipmap (texture, FALSE); cogl_primitive_texture_set_auto_mipmap (texture, FALSE);
if (!cogl_texture_allocate (texture, error)) if (!cogl_texture_allocate (texture, error))
@ -405,7 +409,6 @@ create_offscreen_framebuffer (CoglContext *context,
static gboolean static gboolean
init_fallback_shadowfb (ClutterStageView *view, init_fallback_shadowfb (ClutterStageView *view,
CoglContext *cogl_context,
int width, int width,
int height, int height,
GError **error) GError **error)
@ -414,7 +417,7 @@ init_fallback_shadowfb (ClutterStageView *view,
clutter_stage_view_get_instance_private (view); clutter_stage_view_get_instance_private (view);
CoglOffscreen *offscreen; CoglOffscreen *offscreen;
offscreen = create_offscreen_framebuffer (cogl_context, width, height, error); offscreen = create_offscreen_framebuffer (view, width, height, error);
if (!offscreen) if (!offscreen)
return FALSE; return FALSE;
@ -430,15 +433,13 @@ init_shadowfb (ClutterStageView *view)
g_autoptr (GError) error = NULL; g_autoptr (GError) error = NULL;
int width; int width;
int height; int height;
CoglContext *cogl_context;
width = cogl_framebuffer_get_width (priv->framebuffer); width = cogl_framebuffer_get_width (priv->framebuffer);
height = cogl_framebuffer_get_height (priv->framebuffer); height = cogl_framebuffer_get_height (priv->framebuffer);
cogl_context = cogl_framebuffer_get_context (priv->framebuffer);
if (g_strcmp0 (g_getenv ("MUTTER_DEBUG_ENABLE_DOUBLE_SHADOWFB"), "1") == 0) if (g_strcmp0 (g_getenv ("MUTTER_DEBUG_ENABLE_DOUBLE_SHADOWFB"), "1") == 0)
{ {
if (init_dma_buf_shadowfbs (view, cogl_context, width, height, &error)) if (init_dma_buf_shadowfbs (view, width, height, &error))
{ {
g_message ("Initialized double buffered shadow fb for %s", g_message ("Initialized double buffered shadow fb for %s",
priv->name); priv->name);
@ -450,7 +451,7 @@ init_shadowfb (ClutterStageView *view)
g_clear_error (&error); g_clear_error (&error);
} }
if (!init_fallback_shadowfb (view, cogl_context, width, height, &error)) if (!init_fallback_shadowfb (view, width, height, &error))
{ {
g_warning ("Failed to initialize single buffered shadow fb for %s: %s", g_warning ("Failed to initialize single buffered shadow fb for %s: %s",
priv->name, error->message); priv->name, error->message);