Reinstate some caching for vector images with small enough dimensions.

A dimension of 400 largest size x or y should cover all common caching cases for SVG icons and web app elements,
but not caching large vector rasters that would exhaust the cache.
Final solution for #757.
This commit is contained in:
Pale Moon
2017-06-28 21:44:36 +02:00
committed by Roy Tam
parent 5b6de5f6cd
commit 19738af3c0
+9 -11
View File
@@ -837,21 +837,21 @@ VectorImage::CreateSurfaceAndShow(const SVGDrawingParameters& aParams)
nsRefPtr<gfxDrawable> svgDrawable =
new gfxCallbackDrawable(cb, ThebesIntSize(aParams.size));
// We take an early exit here without using the surface cache, because for
// vector images this can cause bad perf issues if large sizes are scaled
// repeatedly (a rather common scenario) that can quickly exhaust the
// cache.
return Show(svgDrawable, aParams);
// We take an early exit without using the surface cache if
// x or y > maxDimension, because for vector images this can cause bad perf
// issues if large sizes are scaled repeatedly (a rather common scenario)
// that can quickly exhaust the cache.
uint32_t maxDimension = 400;
// ***** Reference: Surface cache code if needed in the future ***** //
// e.g. if we want to use the cache for specific (small) sizes
#if 0
bool bypassCache = bool(aParams.flags & FLAG_BYPASS_SURFACE_CACHE) ||
// Refuse to cache animated images:
// XXX(seth): We may remove this restriction in bug 922893.
mHaveAnimations ||
// The image is too big to fit in the cache:
!SurfaceCache::CanHold(aParams.size);
!SurfaceCache::CanHold(aParams.size) ||
// Image x or y is larger than our cache cap:
aParams.size.width > maxDimension ||
aParams.size.height > maxDimension;
if (bypassCache)
return Show(svgDrawable, aParams);
@@ -886,8 +886,6 @@ VectorImage::CreateSurfaceAndShow(const SVGDrawingParameters& aParams)
nsRefPtr<gfxDrawable> drawable =
new gfxSurfaceDrawable(surface, ThebesIntSize(aParams.size));
Show(drawable, aParams);
#endif
// ***** End Reference: Surface cache code ***** //
}