Blur effect on live scene?

Jim Graham james.graham at oracle.com
Thu Aug 13 00:15:29 UTC 2015


Hi Matthias,

On 8/10/2015 11:44 PM, Matthias Hänel wrote:
>> If we had a "snapshot to texture" mechanism then that might reduce the memory copying of the work around technique.
>
> Well, did you say there is no snapshot to texture in JavaFX? In plain OpenGL you can use FBO's (Frame Buffer Objects) to render them. This is nothing more than a snapshot. They are even sliceable and strechable.

To be clear, there is no API to directly specify "snapshot this 
Node/Group to a texture and give me a handle to it to manipulate".  As I 
said later, there is a mechanism to get Node/trees rendered into a 
texture and that is the Node cache property, but we do that behind the 
scenes, the developer doesn't get a handle to the texture in that case.

>> I'd argue that we sort of do have something like that - it is the cache flag.  If a Node is cached then we do have a copy of it in a texture and that can help make the Blur Effect work more efficiently, but there may be some additional copies between textures if everything isn't set up right.  Still, that is an avenue for someone to check to see if there isn't a better way to achieve this effect in the short term...
>
> I am not pretty sure what cache does. Probably some hasmap that holds objects and they are not instantly destroyed in the graphics RAM?

It is not a hashmap.

It is a hint to save the rendering of that node in a buffer:

https://docs.oracle.com/javase/8/javafx/api/javafx/scene/Node.html#cacheProperty

I don't like the way that this doc comment is worded as it implies that 
using it on a node that is blurred is unwise, but if the node is 
animated over even GPU acceleration of the rendering and blurring 
operations" are going to have some cost that it could save.

>  From my current point the major problem with JavaFX is still the same.
>
> 1. Has a good API
> 2. renders most of its stuff in software, hence does not run performant
> 3. Has good approaches, but the overall sight on the technology is broken somewhere.

I am not sure how you come to the conclusion that it renders most of its 
stuff in software.  It renders quite a lot in hardware.  Even the 
example here of using snapshot to optimize a blurred background - the 
rendering of the scene is done in hw.  It is only copied to main memory 
because the API requires a persistent image.  If you render that image 
to the screen it is copied back into a texture and reused from that 
texture unless we run low on vram.  There is no rendering in software 
there, only use of a heap buffer for persistent storage...

				...jim


More information about the openjfx-dev mailing list