Draw: In Win32, DrawImage with Color now using CachedSetColorKeepAlpha instead of emulation when drawing

This commit is contained in:
Mirek Fidler 2026-04-09 10:15:11 +02:00
parent 162c3cf2e7
commit 21cceb0031
3 changed files with 33 additions and 1 deletions

View file

@ -305,11 +305,14 @@ struct ImageSysDataMaker : LRUCache<ImageSysData, int64>::Maker {
virtual int Make(ImageSysData& object) const { object.Init(img); return (int)img.GetLength(); }
};
void SystemDraw::SysDrawImageOp(int x, int y, const Image& img, const Rect& src, Color color)
void SystemDraw::SysDrawImageOp(int x, int y, const Image& _img, const Rect& src, Color color)
{
LLOG("SysDrawImageOp " << img.GetSerialId() << ' ' << img.GetSize());
GuiLock __;
Image img = _img;
if(img.GetLength() == 0)
return;
@ -324,6 +327,11 @@ void SystemDraw::SysDrawImageOp(int x, int y, const Image& img, const Rect& src,
SetSurface(*this, x, y, sz.cx, sz.cy, ~img);
return;
}
if(!IsNull(color)) { // avoid SW emulation
img = CachedSetColorKeepAlpha(img, color);
color = Null;
}
ImageSysDataMaker m;
static LRUCache<ImageSysData, int64> cache;

View file

@ -0,0 +1,9 @@
uses
CtrlLib;
file
main.cpp;
mainconfig
"" = "GUI";

View file

@ -0,0 +1,15 @@
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
struct MyApp : TopWindow {
void Paint(Draw& w) override {
w.DrawRect(GetSize(), White());
w.DrawImage(100, 100, CtrlImg::undo(), Red());
}
};
GUI_APP_MAIN
{
MyApp().Run();
}