diff options
Diffstat (limited to 'vcl/source/bitmap/BitmapScaleSuperFilter.cxx')
-rw-r--r-- | vcl/source/bitmap/BitmapScaleSuperFilter.cxx | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/vcl/source/bitmap/BitmapScaleSuperFilter.cxx b/vcl/source/bitmap/BitmapScaleSuperFilter.cxx index eb081281b56d..14b18e9f7a02 100644 --- a/vcl/source/bitmap/BitmapScaleSuperFilter.cxx +++ b/vcl/source/bitmap/BitmapScaleSuperFilter.cxx @@ -26,6 +26,7 @@ #include <algorithm> #include <memory> +#include <svdata.hxx> #include <sal/log.hxx> namespace { @@ -935,6 +936,7 @@ BitmapScaleSuperFilter::~BitmapScaleSuperFilter() BitmapEx BitmapScaleSuperFilter::execute(BitmapEx const& rBitmap) const { Bitmap aBitmap(rBitmap.GetBitmap()); + SalBitmap* pKey = aBitmap.ImplGetSalBitmap().get(); bool bRet = false; @@ -954,6 +956,16 @@ BitmapEx BitmapScaleSuperFilter::execute(BitmapEx const& rBitmap) const if (nDstW <= 1 || nDstH <= 1) return BitmapEx(); + // check cache for a previously scaled version of this + ImplSVData* pSVData = ImplGetSVData(); + auto& rCache = pSVData->maGDIData.maScaleCache; + auto aFind = rCache.find(pKey); + if (aFind != rCache.end()) + { + if (aFind->second.GetSizePixel().Width() == nDstW && aFind->second.GetSizePixel().Height() == nDstH) + return aFind->second; + } + { Bitmap::ScopedReadAccess pReadAccess(aBitmap); @@ -1077,7 +1089,9 @@ BitmapEx BitmapScaleSuperFilter::execute(BitmapEx const& rBitmap) const { tools::Rectangle aRect(Point(0, 0), Point(nDstW, nDstH)); aBitmap.Crop(aRect); - return BitmapEx(aBitmap); + BitmapEx aRet(aBitmap); + rCache.insert(std::make_pair(pKey, aRet)); + return aRet; } return BitmapEx(); |