From 31fd4c5654595a4763e492e4ec26f66ca3a8a405 Mon Sep 17 00:00:00 2001 From: marha Date: Mon, 4 Nov 2013 12:08:23 +0100 Subject: libxtrans fontconfig mesa xserver pixman xkbcomp git update 4 nov 2013 xserver commit 33c85beed521c9db140cadd8c5aa9992398ee1fe xkbcomp commit e3e6e938535532bfad175c1635256ab7fb3ac943 pixman commit 8cbc7da4e525c96a8e089e4c1baee75dc8315218 libxtrans commit 1fb0fd555a16dd8fce4abc6d3fd22b315f46762a fontconfig commit 767108aa1327cf0156dfc6f024dbc8fb783ae067 mesa commit 2f896627175384fd5943f21804700a155ba4e8a0 --- xorg-server/present/present_fake.c | 140 +++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 xorg-server/present/present_fake.c (limited to 'xorg-server/present/present_fake.c') diff --git a/xorg-server/present/present_fake.c b/xorg-server/present/present_fake.c new file mode 100644 index 000000000..a67759254 --- /dev/null +++ b/xorg-server/present/present_fake.c @@ -0,0 +1,140 @@ +/* + * Copyright © 2013 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include "present_priv.h" +#include "list.h" + +static struct xorg_list fake_vblank_queue; + +typedef struct present_fake_vblank { + struct xorg_list list; + uint64_t event_id; + OsTimerPtr timer; + ScreenPtr screen; +} present_fake_vblank_rec, *present_fake_vblank_ptr; + +int +present_fake_get_ust_msc(ScreenPtr screen, uint64_t *ust, uint64_t *msc) +{ + present_screen_priv_ptr screen_priv = present_screen_priv(screen); + + *ust = GetTimeInMicros(); + *msc = *ust / screen_priv->fake_interval; + return Success; +} + +static void +present_fake_notify(ScreenPtr screen, uint64_t event_id) +{ + uint64_t ust, msc; + + present_fake_get_ust_msc(screen, &ust, &msc); + present_event_notify(event_id, ust, msc); +} + +static CARD32 +present_fake_do_timer(OsTimerPtr timer, + CARD32 time, + pointer arg) +{ + present_fake_vblank_ptr fake_vblank = arg; + + present_fake_notify(fake_vblank->screen, fake_vblank->event_id); + xorg_list_del(&fake_vblank->list); + free(fake_vblank); + return 0; +} + +void +present_fake_abort_vblank(ScreenPtr screen, uint64_t event_id, uint64_t msc) +{ + present_fake_vblank_ptr fake_vblank, tmp; + + xorg_list_for_each_entry_safe(fake_vblank, tmp, &fake_vblank_queue, list) { + if (fake_vblank->event_id == event_id) { + TimerCancel(fake_vblank->timer); + xorg_list_del(&fake_vblank->list); + free (fake_vblank); + break; + } + } +} + +int +present_fake_queue_vblank(ScreenPtr screen, + uint64_t event_id, + uint64_t msc) +{ + present_screen_priv_ptr screen_priv = present_screen_priv(screen); + uint64_t ust = msc * screen_priv->fake_interval; + uint64_t now = GetTimeInMicros(); + INT32 delay = ((int64_t) (ust - now)) / 1000; + present_fake_vblank_ptr fake_vblank; + + if (delay <= 0) { + present_fake_notify(screen, event_id); + return Success; + } + + fake_vblank = calloc (1, sizeof (present_fake_vblank_rec)); + if (!fake_vblank) + return BadAlloc; + + fake_vblank->screen = screen; + fake_vblank->event_id = event_id; + fake_vblank->timer = TimerSet(NULL, 0, delay, present_fake_do_timer, fake_vblank); + if (!fake_vblank->timer) { + free(fake_vblank); + return BadAlloc; + } + + xorg_list_add(&fake_vblank->list, &fake_vblank_queue); + + return Success; +} + +void +present_fake_screen_init(ScreenPtr screen) +{ + present_screen_priv_ptr screen_priv = present_screen_priv(screen); + + /* For screens with hardware vblank support, the fake code + * will be used for off-screen windows and while screens are blanked, + * in which case we want a slow interval here + * + * Otherwise, pretend that the screen runs at 60Hz + */ + if (screen_priv->info && screen_priv->info->get_crtc) + screen_priv->fake_interval = 1000000; + else + screen_priv->fake_interval = 16667; +} + +void +present_fake_queue_init(void) +{ + xorg_list_init(&fake_vblank_queue); +} -- cgit v1.2.3