JDK-8090484 : Need API to detect Render thread
  • Type: Enhancement
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: 8
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2013-02-19
  • Updated: 2018-09-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Blocks :  
Blocks :  
Description
With printing, rendering methods can be called on any thread. Sometimes they need to know whether they run on Render thread or not, e.g. to access accelerated textures safely. A new method similar to Toolkit.isFxUserThread() would help.
Comments
In this case I'll need to propagate Graphics object down the call chain into methods that don't currently accept Graphics. This will likely work but not in a clean way.
21-02-2013

That's not how I've been handling it elsewhere. I check if the Graphics is a PrinterGraphics and get a new texture from the 2D pipeline, use it and drop it afterwards. I don't touch the one that would be used on screen.
21-02-2013

Then what's needed is just a way to detect whether current thread is Render thread or not. I'll remove the reference to "Printer thread" from the summary. While printing images and canvases (which are backed by accelerated textures), I need to copy those texture into J2DTextures. Accelerated textures should be accessed from Render thread only, so I need to know whether I can call readPixels() directly or need to submit a render job.
21-02-2013

I need to understand the requirement better since there is no "Printer Thread". Printing can happen on any user/application created thread so long as the node isn't attached to a Scene/Stage. In fact there isn't even a requirement that Page 1 and Page 2 print on the same thread, so long as they are completely serialised - something that's enforced on PrinterJob by Java synchronization.
20-02-2013

Needed for WebEngine printing.
19-02-2013