1
0
Fork 0

cogl/onscreen: Make swap_buffer/region CoglOnscreen class vfuncs

No need to go via the "winsys" vtable.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
This commit is contained in:
Jonas Ådahl 2020-10-19 21:47:41 +02:00 committed by Robert Mader
parent 60e1516b1c
commit fe72876b20
12 changed files with 73 additions and 105 deletions

View file

@ -310,7 +310,7 @@ cogl_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen,
{
CoglOnscreenPrivate *priv = cogl_onscreen_get_instance_private (onscreen);
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
const CoglWinsysVtable *winsys;
CoglOnscreenClass *klass = COGL_ONSCREEN_GET_CLASS (onscreen);
g_return_if_fail (COGL_IS_ONSCREEN (framebuffer));
@ -322,11 +322,12 @@ cogl_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen,
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_SYNC_FRAME)))
cogl_framebuffer_finish (framebuffer);
winsys = _cogl_framebuffer_get_winsys (framebuffer);
winsys->onscreen_swap_buffers_with_damage (onscreen,
rectangles, n_rectangles,
info,
user_data);
klass->swap_buffers_with_damage (onscreen,
rectangles,
n_rectangles,
info,
user_data);
cogl_framebuffer_discard_buffers (framebuffer,
COGL_BUFFER_BIT_COLOR |
COGL_BUFFER_BIT_DEPTH |
@ -366,7 +367,7 @@ cogl_onscreen_swap_region (CoglOnscreen *onscreen,
{
CoglOnscreenPrivate *priv = cogl_onscreen_get_instance_private (onscreen);
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
const CoglWinsysVtable *winsys;
CoglOnscreenClass *klass = COGL_ONSCREEN_GET_CLASS (onscreen);
g_return_if_fail (COGL_IS_ONSCREEN (framebuffer));
@ -378,17 +379,15 @@ cogl_onscreen_swap_region (CoglOnscreen *onscreen,
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_SYNC_FRAME)))
cogl_framebuffer_finish (framebuffer);
winsys = _cogl_framebuffer_get_winsys (framebuffer);
/* This should only be called if the winsys advertises
COGL_WINSYS_FEATURE_SWAP_REGION */
g_return_if_fail (winsys->onscreen_swap_region != NULL);
g_return_if_fail (klass->swap_region);
winsys->onscreen_swap_region (COGL_ONSCREEN (framebuffer),
rectangles,
n_rectangles,
info,
user_data);
klass->swap_region (onscreen,
rectangles,
n_rectangles,
info,
user_data);
cogl_framebuffer_discard_buffers (framebuffer,
COGL_BUFFER_BIT_COLOR |

View file

@ -57,6 +57,19 @@ struct _CoglOnscreenClass
{
/*< private >*/
CoglFramebufferClass parent_class;
void (* swap_buffers_with_damage) (CoglOnscreen *onscreen,
const int *rectangles,
int n_rectangles,
CoglFrameInfo *info,
gpointer user_data);
void (* swap_region) (CoglOnscreen *onscreen,
const int *rectangles,
int n_rectangles,
CoglFrameInfo *info,
gpointer user_data);
};
#define COGL_SCANOUT_ERROR (cogl_scanout_error_quark ())

View file

@ -208,12 +208,12 @@ _cogl_winsys_onscreen_egl_get_buffer_age (CoglOnscreen *onscreen)
return age;
}
void
_cogl_winsys_onscreen_egl_swap_region (CoglOnscreen *onscreen,
const int *user_rectangles,
int n_rectangles,
CoglFrameInfo *info,
gpointer user_data)
static void
cogl_onscreen_egl_swap_region (CoglOnscreen *onscreen,
const int *user_rectangles,
int n_rectangles,
CoglFrameInfo *info,
gpointer user_data)
{
CoglOnscreenEgl *onscreen_egl = COGL_ONSCREEN_EGL (onscreen);
CoglOnscreenEglPrivate *priv =
@ -252,12 +252,12 @@ _cogl_winsys_onscreen_egl_swap_region (CoglOnscreen *onscreen,
g_warning ("Error reported by eglSwapBuffersRegion");
}
void
_cogl_winsys_onscreen_egl_swap_buffers_with_damage (CoglOnscreen *onscreen,
const int *rectangles,
int n_rectangles,
CoglFrameInfo *info,
gpointer user_data)
static void
cogl_onscreen_egl_swap_buffers_with_damage (CoglOnscreen *onscreen,
const int *rectangles,
int n_rectangles,
CoglFrameInfo *info,
gpointer user_data)
{
CoglOnscreenEgl *onscreen_egl = COGL_ONSCREEN_EGL (onscreen);
CoglOnscreenEglPrivate *priv =
@ -354,6 +354,11 @@ static void
cogl_onscreen_egl_class_init (CoglOnscreenEglClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
CoglOnscreenClass *onscreen_class = COGL_ONSCREEN_CLASS (klass);
object_class->dispose = cogl_onscreen_egl_dispose;
onscreen_class->swap_buffers_with_damage =
cogl_onscreen_egl_swap_buffers_with_damage;
onscreen_class->swap_region = cogl_onscreen_egl_swap_region;
}

View file

@ -47,20 +47,6 @@ _cogl_winsys_onscreen_egl_bind (CoglOnscreen *onscreen);
int
_cogl_winsys_onscreen_egl_get_buffer_age (CoglOnscreen *onscreen);
void
_cogl_winsys_onscreen_egl_swap_region (CoglOnscreen *onscreen,
const int *user_rectangles,
int n_rectangles,
CoglFrameInfo *info,
gpointer user_data);
void
_cogl_winsys_onscreen_egl_swap_buffers_with_damage (CoglOnscreen *onscreen,
const int *rectangles,
int n_rectangles,
CoglFrameInfo *info,
gpointer user_data);
COGL_EXPORT void
cogl_onscreen_egl_set_platform (CoglOnscreenEgl *onscreen_egl,
gpointer platform);

View file

@ -661,12 +661,12 @@ set_complete_pending (CoglOnscreen *onscreen)
onscreen_glx->pending_complete_notify++;
}
void
_cogl_winsys_onscreen_glx_swap_region (CoglOnscreen *onscreen,
const int *user_rectangles,
int n_rectangles,
CoglFrameInfo *info,
gpointer user_data)
static void
cogl_onscreen_glx_swap_region (CoglOnscreen *onscreen,
const int *user_rectangles,
int n_rectangles,
CoglFrameInfo *info,
gpointer user_data)
{
CoglOnscreenGlx *onscreen_glx = COGL_ONSCREEN_GLX (onscreen);
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
@ -871,12 +871,12 @@ _cogl_winsys_onscreen_glx_swap_region (CoglOnscreen *onscreen,
}
}
void
_cogl_winsys_onscreen_glx_swap_buffers_with_damage (CoglOnscreen *onscreen,
const int *rectangles,
int n_rectangles,
CoglFrameInfo *info,
gpointer user_data)
static void
cogl_onscreen_glx_swap_buffers_with_damage (CoglOnscreen *onscreen,
const int *rectangles,
int n_rectangles,
CoglFrameInfo *info,
gpointer user_data)
{
CoglOnscreenGlx *onscreen_glx = COGL_ONSCREEN_GLX (onscreen);
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
@ -1154,8 +1154,13 @@ cogl_onscreen_glx_class_init (CoglOnscreenGlxClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
CoglFramebufferClass *framebuffer_class = COGL_FRAMEBUFFER_CLASS (klass);
CoglOnscreenClass *onscreen_class = COGL_ONSCREEN_CLASS (klass);
object_class->dispose = cogl_onscreen_glx_dispose;
framebuffer_class->allocate = cogl_onscreen_glx_allocate;
onscreen_class->swap_buffers_with_damage =
cogl_onscreen_glx_swap_buffers_with_damage;
onscreen_class->swap_region = cogl_onscreen_glx_swap_region;
}

View file

@ -47,20 +47,6 @@ _cogl_winsys_onscreen_glx_bind (CoglOnscreen *onscreen);
int
_cogl_winsys_onscreen_glx_get_buffer_age (CoglOnscreen *onscreen);
void
_cogl_winsys_onscreen_glx_swap_region (CoglOnscreen *onscreen,
const int *user_rectangles,
int n_rectangles,
CoglFrameInfo *info,
gpointer user_data);
void
_cogl_winsys_onscreen_glx_swap_buffers_with_damage (CoglOnscreen *onscreen,
const int *rectangles,
int n_rectangles,
CoglFrameInfo *info,
gpointer user_data);
uint32_t
_cogl_winsys_onscreen_glx_get_window_xid (CoglOnscreen *onscreen);

View file

@ -637,9 +637,6 @@ static CoglWinsysVtable _cogl_winsys_vtable =
.context_init = _cogl_winsys_context_init,
.context_deinit = _cogl_winsys_context_deinit,
.onscreen_bind = _cogl_winsys_onscreen_egl_bind,
.onscreen_swap_buffers_with_damage =
_cogl_winsys_onscreen_egl_swap_buffers_with_damage,
.onscreen_swap_region = _cogl_winsys_onscreen_egl_swap_region,
.onscreen_get_buffer_age = _cogl_winsys_onscreen_egl_get_buffer_age,
#if defined(EGL_KHR_fence_sync) || defined(EGL_KHR_reusable_sync)

View file

@ -1470,9 +1470,6 @@ static CoglWinsysVtable _cogl_winsys_vtable =
.context_deinit = _cogl_winsys_context_deinit,
.context_get_clock_time = _cogl_winsys_get_clock_time,
.onscreen_bind = _cogl_winsys_onscreen_glx_bind,
.onscreen_swap_buffers_with_damage =
_cogl_winsys_onscreen_glx_swap_buffers_with_damage,
.onscreen_swap_region = _cogl_winsys_onscreen_glx_swap_region,
.onscreen_get_buffer_age = _cogl_winsys_onscreen_glx_get_buffer_age,
.onscreen_x11_get_window_xid =
_cogl_winsys_onscreen_glx_get_window_xid,

View file

@ -107,13 +107,6 @@ typedef struct _CoglWinsysVtable
void
(*onscreen_bind) (CoglOnscreen *onscreen);
void
(*onscreen_swap_buffers_with_damage) (CoglOnscreen *onscreen,
const int *rectangles,
int n_rectangles,
CoglFrameInfo *info,
gpointer user_data);
gboolean
(*onscreen_direct_scanout) (CoglOnscreen *onscreen,
CoglScanout *scanout,
@ -130,13 +123,6 @@ typedef struct _CoglWinsysVtable
int64_t
(*context_get_clock_time) (CoglContext *context);
void
(*onscreen_swap_region) (CoglOnscreen *onscreen,
const int *rectangles,
int n_rectangles,
CoglFrameInfo *info,
gpointer user_data);
void
(*onscreen_set_resizable) (CoglOnscreen *onscreen, gboolean resizable);

View file

@ -955,7 +955,7 @@ ensure_crtc_modes (CoglOnscreen *onscreen)
meta_onscreen_native_set_crtc_mode (onscreen, renderer_gpu_data);
}
void
static void
meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen,
const int *rectangles,
int n_rectangles,
@ -979,7 +979,7 @@ meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen,
MetaGpuKms *render_gpu = onscreen_native->render_gpu;
MetaKmsDevice *render_kms_device = meta_gpu_kms_get_kms_device (render_gpu);
ClutterFrame *frame = user_data;
const CoglWinsysVtable *parent_vtable;
CoglOnscreenClass *parent_class;
gboolean egl_context_changed = FALSE;
gboolean use_modifiers;
MetaPowerSave power_save_mode;
@ -996,12 +996,12 @@ meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen,
update_secondary_gpu_state_pre_swap_buffers (onscreen);
parent_vtable = meta_get_renderer_native_parent_vtable ();
parent_vtable->onscreen_swap_buffers_with_damage (onscreen,
rectangles,
n_rectangles,
frame_info,
user_data);
parent_class = COGL_ONSCREEN_CLASS (meta_onscreen_native_parent_class);
parent_class->swap_buffers_with_damage (onscreen,
rectangles,
n_rectangles,
frame_info,
user_data);
renderer_gpu_data = meta_renderer_native_get_gpu_data (renderer_native,
render_gpu);
@ -2104,8 +2104,12 @@ meta_onscreen_native_class_init (MetaOnscreenNativeClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
CoglFramebufferClass *framebuffer_class = COGL_FRAMEBUFFER_CLASS (klass);
CoglOnscreenClass *onscreen_class = COGL_ONSCREEN_CLASS (klass);
object_class->dispose = meta_onscreen_native_dispose;
framebuffer_class->allocate = meta_onscreen_native_allocate;
onscreen_class->swap_buffers_with_damage =
meta_onscreen_native_swap_buffers_with_damage;
}

View file

@ -35,12 +35,6 @@ G_DECLARE_FINAL_TYPE (MetaOnscreenNative, meta_onscreen_native,
void meta_renderer_native_release_onscreen (CoglOnscreen *onscreen);
void meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen,
const int *rectangles,
int n_rectangles,
CoglFrameInfo *frame_info,
gpointer user_data);
gboolean meta_onscreen_native_direct_scanout (CoglOnscreen *onscreen,
CoglScanout *scanout,
CoglFrameInfo *frame_info,

View file

@ -940,10 +940,6 @@ get_native_cogl_winsys_vtable (CoglRenderer *cogl_renderer)
vtable.renderer_disconnect = meta_renderer_native_disconnect;
vtable.renderer_create_dma_buf = meta_renderer_native_create_dma_buf;
/* The KMS winsys doesn't support swap region */
vtable.onscreen_swap_region = NULL;
vtable.onscreen_swap_buffers_with_damage =
meta_onscreen_native_swap_buffers_with_damage;
vtable.onscreen_direct_scanout = meta_onscreen_native_direct_scanout;
vtable.context_get_clock_time = meta_renderer_native_get_clock_time;