Qt's QPainter can actually serialize draw calls into SVG; I used that to make "SVG screenshots" of Qt apps from time to time. The resulting fidelity lacks some polish, and when the app buffers any rendering through pixmaps it has no choice but to embed raster data for those elements into the SVG which then can't scale, but it's a cute little trick nonetheless.
Compare with: <a href="http://en.wikipedia.org/wiki/Display_postscript" rel="nofollow">http://en.wikipedia.org/wiki/Display_postscript</a> pioneered for NeXT; a derivative is used by MacOS X.
Text cache: <a href="https://webcache.googleusercontent.com/search?q=cache%3Ahttps%3A%2F%2Fwww.joachim-breitner.de%2Fblog%2Farchives%2F494-Better-PDF-screenshots-with-gtk-3.html" rel="nofollow">https://webcache.googleusercontent.com/search?q=cache%3Ahttp...</a>
I remember this used to be possible in the classic MacOS (System 7, technically it wasn't called "MacOS" back then). The native PICT image format was just QuickDraw graphics API calls serialized to a binary file, so there was a screenshot program that would simply record the API calls made, and save them to a PICT file.