Implement CGContext
CGContext is a drawing canvas. We can use it to render fonts, convert 32bit PNGs to 8bit Alpha maps etc.
Implementation
The easiest method available to us is to make CGContext a thin wrapper over SDLSurface - both have similar initialisers, properties, and methods. And a SDLSurface can be easily converted to a CGImage (as can a CGContext). If we need more advanced drawing capabilities (rounded circles etc) we can use (lib) Cairo to draw on the SDLSurface internally.
This work has been done in Cacao: https://github.com/PureSwift/Cacao. @colemancda has indicated to us that it'd be fine to use the implementation he implemented using Cairo, we "just" need to build Cairo for Android and adapt his internal UIKit code to match our structures.
The actual code is here: https://github.com/PureSwift/Silica CoreGraphics is actually one of the really solid parts of the Cacao project. You need the get Cairo compiling via the SwiftPM or an Android binary.
Alternatively, you can use skia for 2D. It is pretty close to CGContext from my experience.
Great, how to you use C++ Skia from Swift? Is there a wrapper library somewhere? I would love to use Skia and Swift on Linux and Android.
Yea, for some features it will require writing a thin layer to make C APIs. :) Some APIs are available as C.