JDK-8098087 : Implement Region image based caching
  • Type: Enhancement
  • Component: javafx
  • Sub-Component: graphics
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2012-07-17
  • Updated: 2015-06-12
  • Resolved: 2012-09-10
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.
JDK 8
8Fixed
Related Reports
Blocks :  
Relates :  
Relates :  
Description
Presently, we draw all region code as a series of fills, strokes, images, and / or paths.

With the NimbusLookAndFeel, we also took this approach. We had to however optimize this in order to get the performance of, say, MetalLookAndFeel. We did this by maintaining a cache which we would render the equivalent of a Region into (given some state) at some smallish size (say, 19x9 or whatnot, depending on the insets and radii of the region). We then would subsequently render this region using 9-square image stretching techniques on all subsequent usages.

In reality we have very few unique region drawing combinations, and could fit them all within a 256x256 texture (probably).

In addition, paths such as arrows and such could be rendered once and reused thereafter, whereas at the moment we are constantly uploading texture masks for those paths.

We need to implement an image cache and 9-square image scaling for regions. With Nimbus we had a maximum cache size, where upon we would throw out the least-recently-used cache'd images when we faced overflow (or maybe we just cleared the whole thing and started rebuilding again -- should check to see what technique we actually used to handle overflow).
Comments
Can not verify performance improvement Tweak
11-02-2014

I have implemented this with RT-22429. The approach I took was to let height be the dependent variable, and width independent. Meaning, if you have a region of a single height but varying width, then the cached image is used with 3-patch instead of 9-patch. An additional requirement is that if there is a gradient applied, it must run strictly vertical. I can add more robust support (such as using 9-patch if only solid fills are used, or determining horizontal vs. vertical gradients and stretching in the independent axis, or doing something more clever with stretching gradients by some factor in the dependent direction, or ...). But for now it is implemented and has a positive impact on performance (2.5x for several tests including check box toggle test and button test). It can be refined through further JIRAs.
10-09-2012