One of the tricks for video playback is to use a green screen, more technically known as color-keying or chroma-keying. The media player program didn’t render the video pixels to the screen. Rather, it followed this recipe: Draw solid green where you want the video to go. Render the video pixels to a graphics surface shared with the graphics card. Tell the graphics card that whenever it sees a green pixel about to be written to the screen, it should substitute a pixel from that shared graphics surface. Surface 🏖️ ↓ → Graphics card → 🏖️ Desktop Monitor There are a few advantages to this approach. One is that the shared graphics surface need not have the same pixel format as the user’s main display. Therefore, you can specify that the shared graphics surface have a pixel format that matches that of the video, avoiding the need to do any pixel format conversions. Another is that you can update the content without having to go through a full paint cycle. You just update the shared graphics surface, and the results are on the screen at the next frame. This lets you update the video at 60 frames per second from a background thread, which works even if the UI thread is busy or sluggish. You can do even better if you create two shared graphics surfaces. The first one holds the contents of the video frame you want the user to see right now. And the second one is where you create the contents of the video frame you want the user to see next. And then at the vertical blank, you tell the video card to switch to the second shared graphics surface (known as “flipping”), and the entire screen updates at once with no tearing. While the second surface is on the screen, you can render the next frame to the first surface, and then flip again at the next vertical blank. Repeat this process for each frame of the video. A media player program of this era typically negotiated with the graphics card (via DirectDraw) to get one of these magic graphic surfaces and configure it to use it as r...
First seen: 2025-10-18 20:58
Last seen: 2025-10-19 17:01