- All Implemented Interfaces:
- ShapeRep
- Direct Known Subclasses:
- CachingEllipseRep, CachingRoundRectRep
public class CachingShapeRep
extends java.lang.Object
implements ShapeRep
An implementation of ShapeRep that attempts to cache and reuse the
mask texture that is used to render the filled/stroked geometry.
There is an artificial cap on the size of shapes that are considered
for caching, so that we do not fill up VRAM with lots of large shape
masks. The shape is considered for caching only when it is rendered
a certain number of times with unchanging transform (ignoring the
translation components) and geometry. This means that this class is
good for caching static shapes that are either completely stationary
or being translated. This class will also attempt to reuse a mask
that corresponds to a completely different shape instance as long as
the two shapes are equal and the transforms only differ by their
translation components. This means that if you have 1000 Path nodes
all with exactly the same geometry but with different translation factors,
then we will only rasterize and cache a single mask texture and reuse
it among all the Path nodes.
(Of course, the fact that we reuse the same mask texture for different
sub-pixel translation factors means we're knowingly being a bit sloppy,
so when caching is enabled you may see some dancing at the shape edges
for slowly animating translations, but otherwise will hopefully not be
too noticeable.)
The current implementation limits the size of the cache (512 pixels in
each dimension, and 4 MB in total) so that it doesn't grow without bound.
Space is granted on a first come first served basis.