On Thu Nov 23 20:25:26 2023 +0000, Brendan McGrath wrote:
As an alternative, maybe I could store the `ID2D1Multithread` instead and make `ID2D1Multithread_Enter` and `ID2D1Multithread_Leave` calls in `d2d_device_context_draw`. It does add the overhead of the indirect call to `EnterCriticalSection`, but it would be insignificant compared to the `EnterCriticalSection` call itself (not to mention all the indirect ID3D11 calls that are already in `d2d_device_context_draw`). This approach has the advantage of leaving the factory implementation in `factory.c` (i.e. not leaking it in to `d2d1_private.h`) and at least removes the call to `ID2D1Factory_QueryInterface` in every draw.
I see now that changing factory field will create a larger diff, affecting every object creation method basically. Doing that we'll have to start with d2d_device I guess. For now let's go back then, and have a cs with unsafe_impl_* on context creation. You can move d2d_factory to the header, it's not a problem. I think it makes sense to have it there anyway.