The Shape of Everything
A website mostly about Mac stuff, written by August "Gus" Mueller
» Acorn
» Retrobatch
» Mastodon
» Micro.blog
» Instagram
» Github
» Maybe Pizza?
» Archives
» Feed
» Micro feed
September 25, 2013

I've added a new class to my FMMicroPaintPlus code (as described previously) named "FMIOSurfaceAccumulator". It's basically a clone of CIImageAccumulator which is backed by an IOSurface. This class could be handy if you want the flexibility of an IOSurface (such as handing it off to OpenCL) but need fast incremental updates to the image like CIImageAccumulator does.

It does it's magic by using CGLTexImageIOSurface2D, which is a neat little function which tells OpenGL to use an IOSurface as a texture. When calling setImage:dirtyRect: the class uses a CIContext which it setup with OpenGL + drawImage:inRect:fromRect:, which is a way faster than using render:toIOSurface:bounds:colorSpace:.

Then later on (.00024 microseconds) when you need a CIImage you can create it one of two ways— either with a texture reference or the original IOSurface (and depending on your OS release, one way works better than the other).