On Mon, 9 Jun 2025 21:23:47 GMT, Phil Race <p...@openjdk.org> wrote:

> > > Multi-threaded access in the sense of the not being used concurrently by 
> > > different threads ? What FFM means is that the thread that creates the 
> > > Arena is the only thread ever allowed to use the Arena or any memory 
> > > allocated by it. I don't quite see how you guarantee a static field of a 
> > > class is never accessed by another thread. And all it takes is for some 
> > > other thread to have initialize the class and boom
> > > And how in fact is Marlin ensuring only one thread is ever used to run 
> > > Marlin ? I didn't think it did anything of the kind. Is this just a case 
> > > of the FX thread always runs it ?
> > 
> > 
> > The QuantumRenderer thread uses Marlin during rendering and the JavaFX 
> > application thread uses it during picking.
> > @bourgesl can provide a more complete answer, but from what I see, all 
> > accesses to OffHeapArray are done via an instance of the RendererContext 
> > class. Marlin ensures that a RendererContext instance is created and 
> > accessed on the same thread by using thread local state and using the 
> > rendering context for the thread in question (or creating it if it is the 
> > first time). See 
> > [DMarlinRenderingEngine::getRendererContext](https://github.com/openjdk/jfx/blob/b22ed6d202f7bb3765fa402a748d455f6316f7c9/modules/javafx.graphics/src/main/java/com/sun/marlin/DMarlinRenderingEngine.java#L254).
> 
> I'd looked at that but it was not obvious. And it definitely is not obvious 
> that it will be the same thread that initialises the 
> MaskMarlinAlphaConsumer.java class

Yes, I see what you are saying. The `ALPHA_MASK_XXX` arrays are static fields 
of `MaskMarlinAlphaConsumer`, and the renderer context class has an instance 
field of `MaskMarlinAlphaConsumer`. So it does seem possible that 
`MaskMarlinAlphaConsumer` could be initialized by a thread other than the prism 
renderer thread. Hmmm.

-------------

PR Comment: https://git.openjdk.org/jfx/pull/1814#issuecomment-2957097495

Reply via email to