Tuesday, December 17, 2019

Six days of work to display a cat photo

It took me less than three full days to get a working proof of concept for Linux. I thought that was a long time to get something working. I'm going on day seven of experimenting on Mac, and I still don't have a raw pixel array drawing to the screen. I might make a breakthrough in one more day, or it might take another week. With the wild inconsistency in the search results I've found, I can't really say for sure.

I made some adjustments to my Linux proof of concept to better simulate actual usage, since rendering to the pixel array and drawing to the screen will happen on separate threads, and as a result, drawing to the screen doesn't have to wait on rendering to finish. I removed the continual re-clearing of the pixel array and replaced it with just a memcpy call, and the result was a jump from ~300 fps to ~1300 fps on VM. I wasn't able to test this change on actual hardware due to technical problems with the shared Linux machines, but I expect to get performance similar to the existing Windows raster surface.

I decided to focus on NSImage over CGImage for drawing on Mac because the recommendations I've found for drawing images aren't definitive one way or the other, but from my own testing I've found NSImage to be easier to get close to a working state. More specifically, I can get an NSImage object created at all, but I haven't been able to get a CGImage to work at all.

Kai showed me how to change some build settings in Xcode near the end of the day today and thanks to that, I was finally able to get at least something to draw to the screen, but given that it was a JPEG photo of a cat that was loaded from a file, it's still a far cry from real-time BLIT drawing of raw pixel data. I'm getting close, though. Or at least I think I am. If I can find the reason that an image loaded from a file will draw but an image created at runtime won't, I should be able to finally finish dancing the Mac BLIT Mambo without too much trouble, but that's a pretty big 'if'. Progress has been slow on this task, but I am still making progress.

No comments:

Post a Comment