DirectXOffscreenContext to allow drawing into offscreen texture (#1016)
Needed to run benchmarks without vsync interference.
The code extracted from Direct3DSwingRedrawer with minimal changes.
- implementation for other API will be added when it is needed (Metal is
considered later)
- there are no plans to make commonMain abstraction in `skiko` as it is
not needed at the moment
## Testing
- manually in benchmarks with this code:
```
@OptIn(ExperimentalSkikoApi::class)
class DirectXGraphicsContext() : DesktopGraphicsContext {
private val context = DirectXOffscreenContext()
private var texture: DirectXOffscreenContext.Texture? = null
override fun surface(width: Int, height: Int): Surface {
texture?.close()
texture = context.Texture(width, height)
return Surface.makeFromBackendRenderTarget(
context.directContext,
texture!!.backendRenderTarget,
SurfaceOrigin.TOP_LEFT,
SurfaceColorFormat.BGRA_8888,
ColorSpace.sRGB,
SurfaceProps(pixelGeometry = PixelGeometry.UNKNOWN)
) ?: throw IllegalStateException("Can't create Surface")
}
override suspend fun awaitGPUCompletion() {
texture?.waitForCompletion()
}
override fun close() {
texture?.close()
context.close()
}
}
interface DesktopGraphicsContext : GraphicsContext, AutoCloseable
```
- new test for SkiaSwingLayer
- new test for DirectXOffscreenContext
Showing