present: Move timings adjustment in common part of flip mode API
To reduce future code duplication refactor timings adjustment out as a separate function. Signed-off-by: Roman Gilg <subdiff@gmail.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
This commit is contained in:
parent
84112a1d0b
commit
6a338b5959
|
@ -27,6 +27,17 @@
|
||||||
#include "present_priv.h"
|
#include "present_priv.h"
|
||||||
#include <gcstruct.h>
|
#include <gcstruct.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns:
|
||||||
|
* TRUE if the first MSC value is equal to or after the second one
|
||||||
|
* FALSE if the first MSC value is before the second one
|
||||||
|
*/
|
||||||
|
static Bool
|
||||||
|
msc_is_equal_or_after(uint64_t test, uint64_t reference)
|
||||||
|
{
|
||||||
|
return (int64_t)(test - reference) >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copies the update region from a pixmap to the target drawable
|
* Copies the update region from a pixmap to the target drawable
|
||||||
*/
|
*/
|
||||||
|
@ -118,6 +129,33 @@ present_can_window_flip(WindowPtr window)
|
||||||
return screen_priv->can_window_flip(window);
|
return screen_priv->can_window_flip(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
present_adjust_timings(uint32_t options,
|
||||||
|
uint64_t *crtc_msc,
|
||||||
|
uint64_t *target_msc,
|
||||||
|
uint64_t divisor,
|
||||||
|
uint64_t remainder)
|
||||||
|
{
|
||||||
|
/* Adjust target_msc to match modulus
|
||||||
|
*/
|
||||||
|
if (msc_is_equal_or_after(*crtc_msc, *target_msc)) {
|
||||||
|
if (divisor != 0) {
|
||||||
|
*target_msc = *crtc_msc - (*crtc_msc % divisor) + remainder;
|
||||||
|
if (options & PresentOptionAsync) {
|
||||||
|
if (msc_is_after(*crtc_msc, *target_msc))
|
||||||
|
*target_msc += divisor;
|
||||||
|
} else {
|
||||||
|
if (msc_is_equal_or_after(*crtc_msc, *target_msc))
|
||||||
|
*target_msc += divisor;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
*target_msc = *crtc_msc;
|
||||||
|
if (!(options & PresentOptionAsync))
|
||||||
|
(*target_msc)++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
present_pixmap(WindowPtr window,
|
present_pixmap(WindowPtr window,
|
||||||
PixmapPtr pixmap,
|
PixmapPtr pixmap,
|
||||||
|
|
|
@ -239,6 +239,13 @@ present_set_tree_pixmap(WindowPtr window,
|
||||||
PixmapPtr expected,
|
PixmapPtr expected,
|
||||||
PixmapPtr pixmap);
|
PixmapPtr pixmap);
|
||||||
|
|
||||||
|
void
|
||||||
|
present_adjust_timings(uint32_t options,
|
||||||
|
uint64_t *crtc_msc,
|
||||||
|
uint64_t *target_msc,
|
||||||
|
uint64_t divisor,
|
||||||
|
uint64_t remainder);
|
||||||
|
|
||||||
int
|
int
|
||||||
present_pixmap(WindowPtr window,
|
present_pixmap(WindowPtr window,
|
||||||
PixmapPtr pixmap,
|
PixmapPtr pixmap,
|
||||||
|
|
|
@ -46,17 +46,6 @@ static struct xorg_list present_flip_queue;
|
||||||
static void
|
static void
|
||||||
present_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc);
|
present_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc);
|
||||||
|
|
||||||
/*
|
|
||||||
* Returns:
|
|
||||||
* TRUE if the first MSC value is equal to or after the second one
|
|
||||||
* FALSE if the first MSC value is before the second one
|
|
||||||
*/
|
|
||||||
static Bool
|
|
||||||
msc_is_equal_or_after(uint64_t test, uint64_t reference)
|
|
||||||
{
|
|
||||||
return (int64_t)(test - reference) >= 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
present_scmd_create_event_id(present_vblank_ptr vblank)
|
present_scmd_create_event_id(present_vblank_ptr vblank)
|
||||||
{
|
{
|
||||||
|
@ -714,24 +703,11 @@ present_scmd_pixmap(WindowPtr window,
|
||||||
window_priv->msc = crtc_msc;
|
window_priv->msc = crtc_msc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Adjust target_msc to match modulus
|
present_adjust_timings(options,
|
||||||
*/
|
&crtc_msc,
|
||||||
if (msc_is_equal_or_after(crtc_msc, target_msc)) {
|
&target_msc,
|
||||||
if (divisor != 0) {
|
divisor,
|
||||||
target_msc = crtc_msc - (crtc_msc % divisor) + remainder;
|
remainder);
|
||||||
if (options & PresentOptionAsync) {
|
|
||||||
if (msc_is_after(crtc_msc, target_msc))
|
|
||||||
target_msc += divisor;
|
|
||||||
} else {
|
|
||||||
if (msc_is_equal_or_after(crtc_msc, target_msc))
|
|
||||||
target_msc += divisor;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
target_msc = crtc_msc;
|
|
||||||
if (!(options & PresentOptionAsync))
|
|
||||||
target_msc++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Look for a matching presentation already on the list and
|
* Look for a matching presentation already on the list and
|
||||||
|
|
Loading…
Reference in New Issue