CtrlCore: Improved Image cache behaviour in Win32

git-svn-id: svn://ultimatepp.org/upp/trunk@12788 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2019-02-23 15:28:18 +00:00
parent 508ddd6d97
commit 31affcdb46
2 changed files with 10 additions and 0 deletions

View file

@ -339,6 +339,12 @@ void SystemDraw::SysDrawImageOp(int x, int y, const Image& img, const Rect& src,
LLOG("SysDrawImageOp " << img.GetSerialId() << ' ' << img.GetSize());
ImageSysDataMaker m;
static LRUCache<ImageSysData, int64> cache;
static int Rsz;
Rsz += img.GetLength();
if(Rsz > 200 * 200) { // we do not want to do this for each small image painted...
Rsz = 0;
cache.Remove([](const ImageSysData& object) { return object.img.GetRefCount() == 1; });
}
LLOG("SysImage cache pixels " << cache.GetSize() << ", count " << cache.GetCount());
Size sz = Ctrl::GetPrimaryScreenArea().GetSize();
m.img = IsPrinter() && GetDeviceCaps(GetHandle(), NUMCOLORS) == 2 ? Dither(img, 360) : img; // If printer does not support color, dither

View file

@ -253,6 +253,10 @@ public:
char info[24];
};
explicit Image(const Init& init);
// required by system image cache managemenent
int GetRefCount() const { return data->refcount; }
};
Image Premultiply(const Image& img);