linebender / piet

An abstraction for 2D graphics.
Apache License 2.0
1.23k stars 95 forks source link

`piet_common` with winit #545

Open DasLixou opened 1 year ago

DasLixou commented 1 year ago

Hello! I wonder if there is an easy way to make piet_common work with winit. Thanks :D

xStrom commented 1 year ago

Not easily, no. It may become easier in the future, because I imagine the work needed to make it easier is similar that would be needed to use Piet with glazier. That work is not scheduled currently though. We need someone to step up and make it happen.

bitec0de commented 1 year ago

@DasLixou I tried getting this to work using the pixels crate, but it seems very inefficient, around 25ms per full screen frame in release mode with the Druid custom widget example graphics (I couldn't work out how to avoid creating a new BitmapTarget for every frame due to lifetime issues with Winit's 'static event_loop.run closure). Here's the attempt.

@xStrom How much work would be needed getting Piet to work with Glazier again? Would there be guidance? I'd like it to happen too, Vello doesn't work on my machine.

Edit: this seems to be the commit where Glazier removed all references to Piet, so I guess the process would be to go through that and copy all the platform specific code about presenting to a window into Piet?

notgull commented 1 year ago

Apologies for the shameless plug, but I'm currently working on a Piet implementation called theo that should be able to be integrated with winit in a fairly straightforwards way. The only thing that really needs to be done before release are minor fixes to text rendering; contributions are welcome.

Ideally, piet-common would just expose an API that takes a HasRawWindowHandle or otherwise. Not sure how difficult this would be.