Double buffer
For this pattern, we need to imagine a photocopier being operated by an artist. The artist has been commissioned to deliver at least two copies of every picture they draw, so they think smart and use a photocopier to copy their work. To save time moving artwork from the easel to the copier, they simply put their canvas straight onto the scanner. They then paint as fast as they can and hit Copy at the same time. What follows is a race where the artist needs to paint each line fast enough to stay ahead of the scanning head. If they are successful, the artwork and the copy will look the same with no extra time taken. More than likely, the scanning head will get in front of the artist, which will result in a picture up until the point where the artist fell behind and a blank copy after that point. This is known as frame tearing, the issue we are trying to solve. Frame tearing occurs when the frame buffer, our example artist’s canvas, has not been fully updated by the...