From 19738af3c0ee9dee0488c8041fdbac979dfbccdb Mon Sep 17 00:00:00 2001 From: Pale Moon Date: Wed, 28 Jun 2017 21:44:36 +0200 Subject: [PATCH] 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. --- image/src/VectorImage.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/image/src/VectorImage.cpp b/image/src/VectorImage.cpp index 40b50ec735..8054d9e9b0 100644 --- a/image/src/VectorImage.cpp +++ b/image/src/VectorImage.cpp @@ -837,21 +837,21 @@ VectorImage::CreateSurfaceAndShow(const SVGDrawingParameters& aParams) nsRefPtr 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 drawable = new gfxSurfaceDrawable(surface, ThebesIntSize(aParams.size)); Show(drawable, aParams); -#endif -// ***** End Reference: Surface cache code ***** // }