Smooth animations under XFree86

Billy Biggs <> Mon Apr 7 09:21:11 ADT 2003, Fri Apr 11 16:07:55 ADT 2003


I have been watching the news alot lately, and quite enjoy the scrolling headlines along the bottom of CNN, al-jazeera, MSNBC, and other news networks, so I decided to write a news ticker application for Linux.

The primary goal of the stock ticker application was smoothness of display. There are alot of news sources to choose from, and alot of news occurs in a day, so the text must move rapidly, but also be legible. Artifacts to avoid are flicker, tearing and judder.


In many applications, the output is drawn multi-pass. For example, one way to draw a frame is to first clear the window to the background colour, then draw the text in the new position on the cleared image. If multiple passes are performed directly on the visible part of the framebuffer, then a race occurs where the user may see the image in an intermediate state of drawing. We call this 'flicker'.

Tearing or shearing

Tearing occurs when a window is being updated as the video card is sending it out to the display. Since writing to video memory is faster than the speed at which the image is sent to the display, a user might see images where half is the old frame, and the other half is the new frame.

To avoid tearing, we have to know what methods we have of controlling how data is written to the framebuffer.

I have a Matrox G400 and a display running at 75hz. The modeline in use is:

135.00 1280 1296 1440 1688 1024 1025 1028 1066 +hsync +vsync

I wrote a program to time how long the refresh takes, and how long is spent in the blanking. My timings show that it takes 13.3ms for each refresh (and one tenth of a millisecond for the gun to return to the top of the screen). The active area on each scanline is:

1280/1688 = 76%

And the vertical active area is of size:

1024/1066 = 96%

So, this means that for 9.7ms out of every 13ms, something is being drawn that we can see.


Judder is stuttery motion caused when each frame of the animation fails to be displayed for the same amount of time on the display device. This is where refresh rate information, as well as synchronization to the display, is most important.

Prior work

There have been many headline applications for linux.

  1. ticker is a console-based news ticker. It outputs using slang. Drawing is handled by the terminal application, or by the console in which it is run. This method exhibits flicker inside xterm on my display, as slang clear the text screen and redraws at its new position.
  2. GKrellM Newsticker is a plugin for the popular GKrellM monitoring application that displays news.
  3. gtik was a stock ticker application that used gdk_draw_rectangle to clear the region, gdk_draw_string to render the text, and then gtk_widget_draw to update the image. It is currently an applet shipped with GNOME2.
  4. Tclticker is a simple stock ticker application which simply repaints the screen using the standard tcl calls. On my machine, it flickers badly as it redraws.

Furthermore, there has been some work on smooth animations and judder reduction under Linux.


The process is as follows:

  1. wait for the retrace
  2. generate our frame
  3. queue a request to page flip or show on the next retrace

X shared memory images (MIT-SHM)

Xv shared memory images (XVIDEO)

OpenGL textures

OpenGL glDrawPixels

Refresh sync with the NVIDIA binary driver

Refresh sync with DRM ioctl

Icon  Name                    Last modified      Size  Description
[DIR] Parent Directory - [   ] headlines-0.2.tar.gz 16-Apr-2003 06:56 200K