diff options
author | Richard Grenville <pyxlcy@gmail.com> | 2012-10-26 11:12:28 +0800 |
---|---|---|
committer | Richard Grenville <pyxlcy@gmail.com> | 2012-10-26 11:28:38 +0800 |
commit | 399df7aef871f7db8ab3adbe3eee6b0f5af99989 (patch) | |
tree | 18772787f0a33a4efe8a7cc9b02b70bcad973b1c /compton.h | |
parent | c1471ff16a88f5383450fa6715124b465f379727 (diff) | |
download | tdebase-399df7aef871f7db8ab3adbe3eee6b0f5af99989.tar.gz tdebase-399df7aef871f7db8ab3adbe3eee6b0f5af99989.zip |
Bug fix #7: Correct a possible issue in VSync
- I realized I might have fundamentally misunderstood VSync. This commit
tries to fix the possible problem, or at least move the tearing line
close to the top of the screen.
- Software VSync is replaced by --sw-opti (software optimization), as
I guess it isn't possible at all to do VSync without driver support.
- Add "vsync" and "sw-opti" as configuration file options.
Diffstat (limited to 'compton.h')
-rw-r--r-- | compton.h | 32 |
1 files changed, 24 insertions, 8 deletions
@@ -111,7 +111,7 @@ extern struct timeval time_start; #define WINDOW_ARGB 2 #define FADE_DELTA_TOLERANCE 0.2 -#define VSYNC_SW_TOLERANCE 1000 +#define SW_OPTI_TOLERANCE 1000 #define NS_PER_SEC 1000000000L #define US_PER_SEC 1000000L @@ -286,7 +286,6 @@ typedef struct _win { typedef enum _vsync_t { VSYNC_NONE, - VSYNC_SW, VSYNC_DRM, VSYNC_OPENGL, } vsync_t; @@ -313,9 +312,11 @@ typedef struct _options { /// Whether to work under synchronized mode for debugging. Bool synchronize; - // VSync + // VSync and software optimization /// User-specified refresh rate. int refresh_rate; + /// Whether to enable refresh-rate-based software optimization. + Bool sw_opti; /// VSync method to use; vsync_t vsync; /// Whether to enable double buffer. @@ -620,6 +621,21 @@ timespec_subtract(struct timespec *result, } /** + * Get current time in struct timespec. + * + * Note its starting time is unspecified. + */ +static inline struct timespec +get_time_timespec(void) { + struct timespec tm = { 0 }; + + clock_gettime(CLOCK_MONOTONIC, &tm); + + // Return a time of all 0 if the call fails + return tm; +} + +/** * Print time passed since program starts execution. * * Used for debugging. @@ -1136,10 +1152,10 @@ static void update_refresh_rate(Display *dpy); static Bool -vsync_sw_init(void); +sw_opti_init(void); -static struct timespec -vsync_sw_ntimeout(int timeout); +static int +evpoll(struct pollfd *fd, int timeout); static Bool vsync_drm_init(void); @@ -1157,8 +1173,8 @@ static void vsync_opengl_wait(void); #endif -static Bool -vsync_wait(Display *dpy, struct pollfd *fd, int timeout); +static void +vsync_wait(void); static void init_alpha_picts(Display *dpy); |