The vriffle vectorized ebook reader

Monday morning I was curious how fast you could render a GUI on the CPU, so I elicited a demo from Claude Opus 5.5. Hundreds of frames per second, it turns out. Here’s a demonstration ebook reader application for amd64 Linux with X-Windows under the GPLv3. Download vriffle v7 source code or the retroactively numbered v1, when it was called Riffle.

The context here is that Ben Schaaf on the orange website was concerned about “pegging the CPU while scrolling” on “a 4k120hz display” if you tried to render your GUI on the CPU instead of the GPU.

I didn’t think CPU rendering would need to peg the CPU while scrolling, so I created vriffle. It’s an ebook reader with some gratuitous eye candy, here seen displaying the Project Gutenberg version of Newton’s “Opticks”, which it can do on one core of my laptop at about 200 frames per second. On the Xeon where Claude initially tested it, it can spew out pixels about 60% faster than memcpy(), but on my Ryzen 5 3500U, it’s unfortunately about 55% slower than memcpy(), which I hope I can fix.

Some things on display in the above images:

So you can page through a document at hundreds of frames per second. Or 60fps on my laptop’s LCD, using about 15% of one core.

There are a couple of things I think are new here, which are perhaps not coincidentally the two things that compromise its output quality:

  1. To reduce the size of the SDF representation while permitting efficient vectorized resampling on the CPU, each one-byte sample of the SDF is accompanied by a second byte encoding the gradient angle at that point, which turns out to give better interpolations than bilinearly interpolating the SDF!
  2. To speed up compositing, it’s using vectorized bytewise minimum to composite the antialiased dark letterforms onto the light background. This is not only twice as fast as standard α-blending, it yields LCD-subpixel-antialiased results for free.

I tried recording a video of it several times, but unfortunately OBS couldn’t keep up with 60fps 1920×1080 video with text dynamically shrinking and growing and reflowing, and it was showing jank in the video that wasn’t present on my screen.