[PATCH 07/19] present: Move timings adjustment in common part of flip mode API
Roman Gilg
subdiff at gmail.com
Mon Jan 29 13:34:05 UTC 2018
To reduce future code duplication refactor timings adjustment out
as a separate function.
Signed-off-by: Roman Gilg <subdiff at gmail.com>
---
present/present.c | 38 ++++++++++++++++++++++++++++++++++++++
present/present_priv.h | 7 +++++++
present/present_scmd.c | 34 +++++-----------------------------
3 files changed, 50 insertions(+), 29 deletions(-)
diff --git a/present/present.c b/present/present.c
index f8146fa..505d3ea 100644
--- a/present/present.c
+++ b/present/present.c
@@ -28,6 +28,17 @@
#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
*/
void
@@ -74,6 +85,33 @@ present_pixmap_idle(PixmapPtr pixmap, WindowPtr window, CARD32 serial, struct pr
}
}
+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
present_pixmap(WindowPtr window,
PixmapPtr pixmap,
diff --git a/present/present_priv.h b/present/present_priv.h
index 92cc1ba..2c32457 100644
--- a/present/present_priv.h
+++ b/present/present_priv.h
@@ -228,6 +228,13 @@ present_copy_region(DrawablePtr drawable,
void
present_pixmap_idle(PixmapPtr pixmap, WindowPtr window, CARD32 serial, struct present_fence *present_fence);
+void
+present_adjust_timings(uint32_t options,
+ uint64_t *crtc_msc,
+ uint64_t *target_msc,
+ uint64_t divisor,
+ uint64_t remainder);
+
int
present_pixmap(WindowPtr window,
PixmapPtr pixmap,
diff --git a/present/present_scmd.c b/present/present_scmd.c
index e414b3b..3146ecb 100644
--- a/present/present_scmd.c
+++ b/present/present_scmd.c
@@ -46,17 +46,6 @@ static struct xorg_list present_flip_queue;
static void
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
present_scmd_create_event_id(present_vblank_ptr vblank)
{
@@ -700,24 +689,11 @@ present_scmd_pixmap(WindowPtr window,
window_priv->msc = crtc_msc;
}
- /* 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++;
- }
- }
+ present_adjust_timings(options,
+ &crtc_msc,
+ &target_msc,
+ divisor,
+ remainder);
/*
* Look for a matching presentation already on the list and
--
2.7.4
More information about the xorg-devel
mailing list