-
Enhancement
-
Resolution: Won't Fix
-
P4
-
fx1.0.1
Demos like SmokeParticles may load the same image many many times, if they have code
like this:
public class Particle extends CustomNode {
override function create(): Node {
return ImageView {
transforms: [
Translate{ x : bind x, y : bind y } ]
image :
Image { url: "{__DIR__}resources/texture.png" }
opacity: bind timer / 100
};
}
This is not an unusual pattern in FX.
It means however that for every new particle we're forced to
reload the image. This happens gazillion times per second.
So, two solutions:
1. fix the demo (for sure)
2. introduce a weak hash of loaded resources in JavaFX so that
we don't reload the same resource many times
We may need to differentiate between images loaded with no scaling, and those with scaling.
Caching those loaded w/o scaling is simpler.
like this:
public class Particle extends CustomNode {
override function create(): Node {
return ImageView {
transforms: [
Translate{ x : bind x, y : bind y } ]
image :
Image { url: "{__DIR__}resources/texture.png" }
opacity: bind timer / 100
};
}
This is not an unusual pattern in FX.
It means however that for every new particle we're forced to
reload the image. This happens gazillion times per second.
So, two solutions:
1. fix the demo (for sure)
2. introduce a weak hash of loaded resources in JavaFX so that
we don't reload the same resource many times
We may need to differentiate between images loaded with no scaling, and those with scaling.
Caching those loaded w/o scaling is simpler.