mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
CtrlCore: ImageWin32 optimisations
git-svn-id: svn://ultimatepp.org/upp/trunk@14343 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
0e2401c338
commit
84334c3407
3 changed files with 18 additions and 17 deletions
|
|
@ -115,7 +115,7 @@ void HexDumpData(Stream& s, const void *ptr, int size, bool adr, int maxsize) {
|
|||
sprintf(h, "%+6d 0x%08X%08X ", a, (int)(aa >> 32), (int)aa);
|
||||
s.Put(h);
|
||||
#else
|
||||
sprintf(h, "%+6d 0x%08X ", a, a + dword(ptr));
|
||||
sprintf(h, "%+6d 0x%08X ", a, int(a + dword(ptr)));
|
||||
s.Put(h);
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ void operator delete[](void *ptr, const std::nothrow_t&) noexcept { UPP::Memory
|
|||
|
||||
#if defined(PLATFORM_WIN32) && defined(COMPILER_CLANG)
|
||||
// this is temporary fix before llvm-mingw fixes weak references
|
||||
void __attribute__((__noreturn__)) std::__throw_bad_alloc (void) { throw bad_alloc(); }
|
||||
// void __attribute__((__noreturn__)) std::__throw_bad_alloc (void) { throw bad_alloc(); }
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -186,7 +186,6 @@ struct ImageSysData {
|
|||
HBITMAP hmask;
|
||||
HBITMAP himg;
|
||||
RGBA *section;
|
||||
int paintcount;
|
||||
|
||||
void Init(const Image& img);
|
||||
void CreateHBMP(HDC dc, const RGBA *data);
|
||||
|
|
@ -199,7 +198,6 @@ void ImageSysData::Init(const Image& _img)
|
|||
{
|
||||
img = _img;
|
||||
hbmp = hmask = himg = NULL;
|
||||
paintcount = 0;
|
||||
LLOG("ImageSysData::Init " << img.GetSerialId() << " " << img.GetSize());
|
||||
}
|
||||
|
||||
|
|
@ -254,17 +252,6 @@ void ImageSysData::Paint(SystemDraw& w, int x, int y, const Rect& src, Color c)
|
|||
if(sr.IsEmpty())
|
||||
return;
|
||||
|
||||
int kind = img.GetKindNoScan();
|
||||
if(kind == IMAGE_OPAQUE && !IsNull(c)) {
|
||||
w.DrawRect(x, y, sz.cx, sz.cy, c);
|
||||
return;
|
||||
}
|
||||
if(kind == IMAGE_OPAQUE && (GetDeviceCaps(dc, RASTERCAPS) & RC_DIBTODEV)) {
|
||||
LTIMING("Image Opaque direct set");
|
||||
SetSurface(w, x, y, sz.cx, sz.cy, ~img);
|
||||
paintcount++;
|
||||
return;
|
||||
}
|
||||
if(fnAlphaBlend() && IsNull(c) && !ImageFallBack &&
|
||||
!(w.IsPrinter() && (GetDeviceCaps(dc, SHADEBLENDCAPS) & (SB_PIXEL_ALPHA|SB_PREMULT_ALPHA)) !=
|
||||
(SB_PIXEL_ALPHA|SB_PREMULT_ALPHA))) {
|
||||
|
|
@ -312,10 +299,24 @@ struct ImageSysDataMaker : LRUCache<ImageSysData, int64>::Maker {
|
|||
|
||||
void SystemDraw::SysDrawImageOp(int x, int y, const Image& img, const Rect& src, Color color)
|
||||
{
|
||||
LLOG("SysDrawImageOp " << img.GetSerialId() << ' ' << img.GetSize());
|
||||
|
||||
GuiLock __;
|
||||
if(img.GetLength() == 0)
|
||||
return;
|
||||
LLOG("SysDrawImageOp " << img.GetSerialId() << ' ' << img.GetSize());
|
||||
|
||||
Size sz = img.GetSize();
|
||||
int kind = img.GetKindNoScan();
|
||||
if(kind == IMAGE_OPAQUE && !IsNull(color)) {
|
||||
DrawRect(x, y, sz.cx, sz.cy, color);
|
||||
return;
|
||||
}
|
||||
if(kind == IMAGE_OPAQUE && (!IsPrinter() || (GetDeviceCaps(GetHandle(), RASTERCAPS) & RC_DIBTODEV))) {
|
||||
LTIMING("Image Opaque direct set");
|
||||
SetSurface(*this, x, y, sz.cx, sz.cy, ~img);
|
||||
return;
|
||||
}
|
||||
|
||||
ImageSysDataMaker m;
|
||||
static LRUCache<ImageSysData, int64> cache;
|
||||
static int Rsz;
|
||||
|
|
@ -325,7 +326,7 @@ void SystemDraw::SysDrawImageOp(int x, int y, const Image& img, const Rect& src,
|
|||
cache.Remove([](const ImageSysData& object) { return object.img.GetRefCount() == 1; });
|
||||
}
|
||||
LLOG("SysImage cache pixels " << cache.GetSize() << ", count " << cache.GetCount());
|
||||
Size sz = Ctrl::GetPrimaryScreenArea().GetSize();
|
||||
sz = Ctrl::GetVirtualScreenArea().GetSize();
|
||||
m.img = IsPrinter() && GetDeviceCaps(GetHandle(), NUMCOLORS) == 2 ? Dither(img, 360) : img; // If printer does not support color, dither
|
||||
cache.Get(m).Paint(*this, x, y, src, color);
|
||||
cache.Shrink(4 * sz.cx * sz.cy, IsWinNT() ? 1000 : 100);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue