Skip to content

Commit

Permalink
Cached uncached font lookup.
Browse files Browse the repository at this point in the history
  • Loading branch information
DeanWookey committed Jan 17, 2019
1 parent 7af755e commit e12f00f
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1546,19 +1546,27 @@ private CalculatedValue getCachedFont(final Styleable styleable) {
// there is a parent helper and a cacheContainer,
} else {

Set<PseudoClass>[] transitionStates = parentHelper.getTransitionStates(parent);
StyleCacheEntry.Key parentCacheEntryKey = new StyleCacheEntry.Key(transitionStates, Font.getDefault());
CacheContainer parentCacheContainer = parentHelper.cacheContainer;
if ( parentCacheContainer != null
&& parentCacheContainer.fontSizeCache != null
&& parentCacheContainer.fontSizeCache.isEmpty() == false) {

Set<PseudoClass>[] transitionStates = parentHelper.getTransitionStates(parent);
StyleCacheEntry.Key parentCacheEntryKey = new StyleCacheEntry.Key(transitionStates, Font.getDefault());
cachedFont = parentCacheContainer.fontSizeCache.get(parentCacheEntryKey);
}

if (cachedFont == null) {
StyleMap smap = parentHelper.getStyleMap(parent);
cachedFont = parentHelper.lookupFont(parent, "-fx-font", smap, null);

if (parentCacheContainer != null) {
//The same caching as transitionToState()
CalculatedValue toCache = cachedFont;
if (toCache == SKIP) toCache = getCachedFont(parent.getStyleableParent());
if (toCache == null) toCache = new CalculatedValue(Font.getDefault(), null, false);
parentCacheContainer.fontSizeCache.put(parentCacheEntryKey,toCache);
}
}
}

Expand Down

0 comments on commit e12f00f

Please sign in to comment.