> But does that mean I'll have to allocate a new AbstractRenderTarget on the
> heap
Yes. Or you could just return something already cached within the respective
Texture/Window objects to make it high load friendly.
As a side note, your suggested API makes the user believe there's no price for
switching the rendering context all the time. That could work when you
implement deferred rendering (e.g. later, call underlying system functions in a
batch per context). But such API will not work for e.g. direct OpenGL
rendering, because switching context states is considered to be expensive.
nimx lib kinda solves this like this:
let myImage = imageWithSize(x, y)
myImage.draw: # Context switch here
let ctx = getCurrentContext()
ctx.drawRect(...)
ctx.drawText(...)
... etc
# Context switches back