Fix tearing due to bastardized OpenGL in Intel Sandy Bridge
The OpenGL GLX video backend produces tearing: To reproduce the bug, it suffices to download the teartest video [1], set the video backend to OpenGL GLX, and play the video. Every few seconds, a tearing line is clearly visible for ~0.5 seconds. Compositing is disabled and I am using full-screen mode.
I am using Debian testing. The graphics hard is the HD3000 built into my Core i5-2450M. Mesa is at version 8.0.1, the Intel Xorg driver at 2.19, the kernel at 3.6.4.
Some guessing: If I enable KWin compositing and enable the "Paint Draw" debug plugin, I can see that VLC does not issue a full-screen redraw: My screen has an aspect ratio of 16:10, while the video is 16:9, and only the 16:9 area is redrawn. I conclude that VLC does not use glXSwapBuffers on the whole full-screen window. However, on modern Intel hardware and with the proprietary NVidia drivers, that seems to be the only way to produce a tear-free playback: glXWaitVideoSync is broken[2]. mplayer2 with the OpenGL backend plays the same file completely tear-free in full-screen mode with compositing disabled. The "Paint Draw" debug plugin shows that the full screen is re-drawn for each video frame, so I assume it is doing a full-screen glXSwapBuffers.
[1] http://ompldr.org/iYXBldg-hide or https://bugs.launchpad.net/ubuntu-release-notes/+bug/600178/comments/38
[2] https://bugs.freedesktop.org/show_bug.cgi?id=37686 and https://bugs.kde.org/show_bug.cgi?id=307965