Feature: #7: VSync

- Add VSync feature. 3 possible VSync methods available: "sw" (software,
  not too reliable, but at least you have something to fallback to),
  "drm" (using DRM_IOCTL_WAIT_VBLANK, should work only on DRI drivers),
  "opengl" (using SGI_swap_control extension OpenGL, might work on more
  drivers than the DRM method). "sw" and "opengl" are briefly tested,
  "drm" received utterly no test (because I use the nVidia binary blob).
  They are enabled with "--vsync sw" / "--vsync drm" / "--vsync opengl".

- Add --refresh-rate to let user specify a refresh rate for software
  VSync, in case the automatic refresh rate detection does not work
  well.

- Seemingly the automatic refresh rate detection using X RandR in
  software VSync detects refresh rate incorrectly. Need further investigation.

- Fix a few bugs in fading timing.

- Add a workaround for client window detection on Fluxbox, as Fluxbox
  (incorrectly?) sets the override-redirect flag upon all frame
  windows.

- Software VSync adds dependency on librt (a part of glibc) for
  nanosecond-level timing functions, and libXrandr for automatic refresh
  rate detection; DRM VSync adds dependency on libdrm to use its drm.h,
  but does not link to libdrm; OpenGL VSync adds dependency on libGL.

- Print timing information on DEBUG_REPAINT.
This commit is contained in:
Richard Grenville
2012-10-08 10:20:01 +08:00
parent 1306b1591f
commit b59e592588
6 changed files with 654 additions and 50 deletions

View File

@ -12,7 +12,7 @@ set(CMAKE_C_FLAGS_DEBUG "-ggdb")
set(CMAKE_C_FLAGS_RELEASE "-O2 -march=native")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -march=native -ggdb")
add_definitions("-Wall")
add_definitions("-Wall" "-std=c99")
# == Options ==
@ -31,9 +31,23 @@ if (CONFIG_LIBCONFIG)
add_definitions("-DCONFIG_LIBCONFIG")
endif ()
option(CONFIG_VSYNC_DRM "Enable DRM VSync support" ON)
if (CONFIG_VSYNC_DRM)
add_definitions("-DCONFIG_VSYNC_DRM")
endif ()
option(CONFIG_VSYNC_OPENGL "Enable OpenGL VSync support" ON)
if (CONFIG_VSYNC_OPENGL)
add_definitions("-DCONFIG_VSYNC_OPENGL")
endif ()
# == Find libraries ==
target_link_libraries(compton "-lm")
target_link_libraries(compton "-lm" "-lrt")
if (CONFIG_VSYNC_OPENGL)
target_link_libraries(compton "-lGL")
endif ()
include(FindPkgConfig)
@ -53,6 +67,7 @@ X11LIB_CHK(Xdamage)
X11LIB_CHK(Xext)
X11LIB_CHK(Xfixes)
X11LIB_CHK(Xrender)
X11LIB_CHK(Xrandr)
# --- Find libpcre ---
if (CONFIG_REGEX_PCRE)