Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions cogl/cogl/winsys/cogl-winsys-egl.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>


#ifndef EGL_KHR_create_context
Expand Down Expand Up @@ -842,6 +843,15 @@ _cogl_winsys_fence_destroy (CoglContext *context, void *fence)
}
#endif

static int64_t
_cogl_winsys_get_clock_time (CoglContext *context)
{
struct timespec ts;

clock_gettime (CLOCK_MONOTONIC, &ts);
return ts.tv_sec * G_GINT64_CONSTANT (1000000000) + ts.tv_nsec;
}

static CoglWinsysVtable _cogl_winsys_vtable =
{
.constraints = COGL_RENDERER_CONSTRAINT_USES_EGL,
Expand All @@ -863,6 +873,7 @@ static CoglWinsysVtable _cogl_winsys_vtable =
_cogl_winsys_onscreen_swap_buffers_with_damage,
.onscreen_swap_region = _cogl_winsys_onscreen_swap_region,
.onscreen_get_buffer_age = _cogl_winsys_onscreen_get_buffer_age,
.context_get_clock_time = _cogl_winsys_get_clock_time,

#if defined(EGL_KHR_fence_sync) || defined(EGL_KHR_reusable_sync)
.fence_add = _cogl_winsys_fence_add,
Expand Down
3 changes: 3 additions & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,8 @@ if have_wayland
'wayland/meta-wayland-pointer.h',
'wayland/meta-wayland-popup.c',
'wayland/meta-wayland-popup.h',
'wayland/meta-wayland-presentation-time.c',
'wayland/meta-wayland-presentation-time-private.h',
'wayland/meta-wayland-private.h',
'wayland/meta-wayland-region.c',
'wayland/meta-wayland-region.h',
Expand Down Expand Up @@ -858,6 +860,7 @@ if have_wayland
['xapp-shell', 'private', ],
['xwayland-keyboard-grab', 'unstable', 'v1', ],
['wayland-drm', 'private', ],
['presentation-time', 'stable', ],
]
if have_wayland_eglstream
wayland_eglstream_protocols_dir = wayland_eglstream_protocols_dep.get_variable(pkgconfig: 'pkgdatadir')
Expand Down
68 changes: 68 additions & 0 deletions src/wayland/meta-wayland-presentation-time-private.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* presentation-time protocol
*
* Copyright (C) 2020 Ivan Molodetskikh <yalterz@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
*/

#pragma once

#include <wayland-server.h>

#include "clutter/clutter.h"
#include "wayland/meta-wayland-types.h"

typedef struct _CoglContext CoglContext;

typedef struct _MetaWaylandPresentationFeedback
{
struct wl_list link;
struct wl_resource *resource;

MetaWaylandSurface *surface;
} MetaWaylandPresentationFeedback;

typedef struct _MetaWaylandPresentationTime
{
/*
* List of surfaces that have pending presentation-time feedbacks.
* Analogous to MetaWaylandCompositor.frame_callback_surfaces.
*/
GList *feedback_surfaces;

/*
* Feedbacks collected after painting, waiting to be delivered on
* frame completion. Since Muffin has a single frame clock, we don't
* need per-view tracking - all feedbacks go into one list.
*/
struct wl_list pending_feedbacks;

/*
* CoglContext used for converting frame timestamps from the Cogl
* clock domain to CLOCK_MONOTONIC.
*/
CoglContext *cogl_context;
} MetaWaylandPresentationTime;

void meta_wayland_presentation_time_finalize (MetaWaylandCompositor *compositor);

void meta_wayland_init_presentation_time (MetaWaylandCompositor *compositor);

void meta_wayland_presentation_feedback_discard (MetaWaylandPresentationFeedback *feedback);

void meta_wayland_surface_discard_presentation_feedback (MetaWaylandSurface *surface);

void meta_wayland_surface_state_discard_presentation_feedback (MetaWaylandSurfaceState *state);
Loading
Loading