1
0
Fork 0

cogl: Pass a Context param to winsys_has_feature

Avoids using the global variable

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3857>
This commit is contained in:
Bilal Elmoussaoui 2024-06-29 15:07:44 +02:00 committed by Marge Bot
parent 3fd7cdba09
commit 194fa80cdd
12 changed files with 29 additions and 124 deletions

View file

@ -567,3 +567,11 @@ cogl_context_get_gpu_time_ns (CoglContext *context)
return context->driver_vtable->get_gpu_time_ns (context);
}
/* FIXME: we should distinguish renderer and context features */
gboolean
cogl_context_has_winsys_feature (CoglContext *context,
CoglWinsysFeature feature)
{
return COGL_FLAGS_GET (context->winsys_features, feature);
}

View file

@ -342,4 +342,8 @@ cogl_context_get_gpu_time_ns (CoglContext *context);
COGL_EXPORT int
cogl_context_get_latest_sync_fd (CoglContext *context);
COGL_EXPORT gboolean
cogl_context_has_winsys_feature (CoglContext *context,
CoglWinsysFeature feature);
G_END_DECLS

View file

@ -334,7 +334,7 @@ cogl_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen,
info,
user_data);
if (!_cogl_winsys_has_feature (COGL_WINSYS_FEATURE_SYNC_AND_COMPLETE_EVENT))
if (!cogl_context_has_winsys_feature (context, COGL_WINSYS_FEATURE_SYNC_AND_COMPLETE_EVENT))
{
g_autoptr (CoglFrameInfo) pending_info = NULL;
@ -367,6 +367,7 @@ cogl_onscreen_swap_region (CoglOnscreen *onscreen,
CoglOnscreenPrivate *priv = cogl_onscreen_get_instance_private (onscreen);
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglOnscreenClass *klass = COGL_ONSCREEN_GET_CLASS (onscreen);
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
g_return_if_fail (COGL_IS_ONSCREEN (framebuffer));
@ -392,7 +393,7 @@ cogl_onscreen_swap_region (CoglOnscreen *onscreen,
info,
user_data);
if (!_cogl_winsys_has_feature (COGL_WINSYS_FEATURE_SYNC_AND_COMPLETE_EVENT))
if (!cogl_context_has_winsys_feature (context, COGL_WINSYS_FEATURE_SYNC_AND_COMPLETE_EVENT))
{
g_autoptr (CoglFrameInfo) pending_info = NULL;
@ -431,9 +432,10 @@ cogl_onscreen_direct_scanout (CoglOnscreen *onscreen,
CoglOnscreenPrivate *priv = cogl_onscreen_get_instance_private (onscreen);
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
CoglOnscreenClass *klass = COGL_ONSCREEN_GET_CLASS (onscreen);
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
g_warn_if_fail (COGL_IS_ONSCREEN (framebuffer));
g_warn_if_fail (_cogl_winsys_has_feature (COGL_WINSYS_FEATURE_SYNC_AND_COMPLETE_EVENT));
g_warn_if_fail (cogl_context_has_winsys_feature (context, COGL_WINSYS_FEATURE_SYNC_AND_COMPLETE_EVENT));
if (!klass->direct_scanout)
{

View file

@ -92,9 +92,6 @@
#include "cogl/cogl-trace.h"
#include "cogl/cogl-scanout.h"
#include "cogl/cogl-graphene.h"
/* XXX: This will definitely go away once all the Clutter winsys
* code has been migrated down into Cogl! */
#include "cogl/deprecated/cogl-clutter.h"
/* The gobject introspection scanner seems to parse public headers in
* isolation which means we need to be extra careful about how we

View file

@ -1,53 +0,0 @@
/*
* Cogl
*
* A Low Level GPU Graphics and Utilities API
*
* Copyright (C) 2011 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Authors:
* Robert Bragg <robert@linux.intel.com>
*/
#include "config.h"
#include <glib.h>
#include <string.h>
#include "cogl/cogl-util.h"
#include "cogl/cogl-types.h"
#include "cogl/cogl-private.h"
#include "cogl/cogl-context-private.h"
#include "cogl/cogl-framebuffer-private.h"
#include "cogl/cogl-onscreen-private.h"
#ifdef HAVE_X11
#include "cogl/cogl-xlib-renderer.h"
#endif
#include "cogl/winsys/cogl-winsys-private.h"
#include "cogl/deprecated/cogl-clutter.h"
gboolean
cogl_clutter_winsys_has_feature (CoglWinsysFeature feature)
{
return _cogl_winsys_has_feature (feature);
}

View file

@ -1,41 +0,0 @@
/*
* Cogl
*
* A Low Level GPU Graphics and Utilities API
*
* Copyright (C) 2011 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#pragma once
#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION)
#error "Only <cogl/cogl.h> can be included directly."
#endif
G_BEGIN_DECLS
COGL_DEPRECATED_FOR (cogl_has_feature)
COGL_EXPORT gboolean
cogl_clutter_winsys_has_feature (CoglWinsysFeature feature);
G_END_DECLS

View file

@ -16,7 +16,6 @@ endif
cogl_deprecated_headers = [
'deprecated/cogl-program.h',
'deprecated/cogl-shader.h',
'deprecated/cogl-clutter.h',
]
cogl_headers = [
@ -283,7 +282,6 @@ cogl_sources = [
'cogl-util.c',
'cogl-util.h',
'cogl.c',
'deprecated/cogl-clutter.c',
'deprecated/cogl-program-private.h',
'deprecated/cogl-program.c',
'deprecated/cogl-shader-private.h',

View file

@ -192,7 +192,7 @@ cogl_onscreen_glx_allocate (CoglFramebuffer *framebuffer,
}
#ifdef GLX_INTEL_swap_event
if (_cogl_winsys_has_feature (COGL_WINSYS_FEATURE_SYNC_AND_COMPLETE_EVENT))
if (cogl_context_has_winsys_feature (context, COGL_WINSYS_FEATURE_SYNC_AND_COMPLETE_EVENT))
{
GLXDrawable drawable =
onscreen_glx->glxwin ? onscreen_glx->glxwin : onscreen_glx->xwin;
@ -530,7 +530,7 @@ cogl_onscreen_glx_get_buffer_age (CoglOnscreen *onscreen)
GLXDrawable drawable;
unsigned int age = 0;
if (!_cogl_winsys_has_feature (COGL_WINSYS_FEATURE_BUFFER_AGE))
if (!cogl_context_has_winsys_feature (context, COGL_WINSYS_FEATURE_BUFFER_AGE))
return 0;
cogl_onscreen_bind (onscreen);
@ -677,7 +677,7 @@ cogl_onscreen_glx_swap_region (CoglOnscreen *onscreen,
* we only need it to throttle redraws.
*/
gboolean blit_sub_buffer_is_synchronized =
_cogl_winsys_has_feature (COGL_WINSYS_FEATURE_SWAP_REGION_SYNCHRONIZED);
cogl_context_has_winsys_feature (context, COGL_WINSYS_FEATURE_SWAP_REGION_SYNCHRONIZED);
int framebuffer_width = cogl_framebuffer_get_width (framebuffer);
int framebuffer_height = cogl_framebuffer_get_height (framebuffer);
@ -844,7 +844,7 @@ cogl_onscreen_glx_swap_region (CoglOnscreen *onscreen,
* handling _SYNC and _COMPLETE events in the winsys then we need to
* send fake events in this case.
*/
if (_cogl_winsys_has_feature (COGL_WINSYS_FEATURE_SYNC_AND_COMPLETE_EVENT))
if (cogl_context_has_winsys_feature (context, COGL_WINSYS_FEATURE_SYNC_AND_COMPLETE_EVENT))
{
set_sync_pending (onscreen);
set_complete_pending (onscreen);

View file

@ -473,12 +473,12 @@ update_winsys_features (CoglContext *context, GError **error)
/* Note: glXCopySubBuffer and glBlitFramebuffer won't be throttled
* by the SwapInterval so we have to throttle swap_region requests
* manually... */
if (_cogl_winsys_has_feature (COGL_WINSYS_FEATURE_SWAP_REGION) &&
if (cogl_context_has_winsys_feature (context, COGL_WINSYS_FEATURE_SWAP_REGION) &&
(glx_display->have_vblank_counter || glx_display->can_vblank_wait))
COGL_FLAGS_SET (context->winsys_features,
COGL_WINSYS_FEATURE_SWAP_REGION_THROTTLE, TRUE);
if (_cogl_winsys_has_feature (COGL_WINSYS_FEATURE_SYNC_AND_COMPLETE_EVENT))
if (cogl_context_has_winsys_feature (context, COGL_WINSYS_FEATURE_SYNC_AND_COMPLETE_EVENT))
{
COGL_FLAGS_SET (context->winsys_features,
COGL_WINSYS_FEATURE_SWAP_BUFFERS_EVENT, TRUE);
@ -490,7 +490,7 @@ update_winsys_features (CoglContext *context, GError **error)
COGL_PRIVATE_FEATURE_DIRTY_EVENTS,
TRUE);
if (_cogl_winsys_has_feature (COGL_WINSYS_FEATURE_BUFFER_AGE))
if (cogl_context_has_winsys_feature (context, COGL_WINSYS_FEATURE_BUFFER_AGE))
COGL_FLAGS_SET (context->features, COGL_FEATURE_ID_BUFFER_AGE, TRUE);
return TRUE;
@ -1123,7 +1123,7 @@ _cogl_winsys_texture_pixmap_x11_create (CoglTexturePixmapX11 *tex_pixmap)
CoglTexturePixmapGLX *glx_tex_pixmap;
CoglContext *ctx = cogl_texture_get_context (COGL_TEXTURE (tex_pixmap));
if (!_cogl_winsys_has_feature (COGL_WINSYS_FEATURE_TEXTURE_FROM_PIXMAP))
if (!cogl_context_has_winsys_feature (ctx, COGL_WINSYS_FEATURE_TEXTURE_FROM_PIXMAP))
{
tex_pixmap->winsys = NULL;
return FALSE;

View file

@ -135,6 +135,3 @@ typedef struct _CoglWinsysVtable
} CoglWinsysVtable;
typedef const CoglWinsysVtable *(*CoglWinsysVtableGetter) (void);
gboolean
_cogl_winsys_has_feature (CoglWinsysFeature feature);

View file

@ -39,12 +39,3 @@ _cogl_winsys_error_quark (void)
{
return g_quark_from_static_string ("cogl-winsys-error-quark");
}
/* FIXME: we should distinguish renderer and context features */
gboolean
_cogl_winsys_has_feature (CoglWinsysFeature feature)
{
_COGL_GET_CONTEXT (ctx, FALSE);
return COGL_FLAGS_GET (ctx->winsys_features, feature);
}

View file

@ -472,6 +472,7 @@ should_use_clipped_redraw (gboolean is_full_redraw,
gboolean can_blit_sub_buffer;
gboolean can_use_clipped_redraw;
gboolean is_warmed_up;
CoglContext *context = cogl_framebuffer_get_context (framebuffer);
if (is_full_redraw)
return FALSE;
@ -490,7 +491,7 @@ should_use_clipped_redraw (gboolean is_full_redraw,
}
can_blit_sub_buffer =
cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_SWAP_REGION);
cogl_context_has_winsys_feature (context, COGL_WINSYS_FEATURE_SWAP_REGION);
can_use_clipped_redraw =
_clutter_stage_window_can_clip_redraws (stage_window) &&
(can_blit_sub_buffer || has_buffer_age);
@ -509,6 +510,7 @@ meta_stage_impl_redraw_view_primary (MetaStageImpl *stage_impl,
ClutterStageWindow *stage_window = CLUTTER_STAGE_WINDOW (stage_impl);
MetaStageView *view = META_STAGE_VIEW (stage_view);
CoglFramebuffer *fb = clutter_stage_view_get_framebuffer (stage_view);
CoglContext *context = cogl_framebuffer_get_context (fb);
CoglFramebuffer *onscreen = clutter_stage_view_get_onscreen (stage_view);
MtkRectangle view_rect;
gboolean is_full_redraw;
@ -536,7 +538,7 @@ meta_stage_impl_redraw_view_primary (MetaStageImpl *stage_impl,
has_buffer_age =
COGL_IS_ONSCREEN (onscreen) &&
cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_BUFFER_AGE);
cogl_context_has_winsys_feature (context, COGL_WINSYS_FEATURE_BUFFER_AGE);
redraw_clip = clutter_stage_view_take_accumulated_redraw_clip (stage_view);