mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
Draw: In Win32, DrawImage with Color now using CachedSetColorKeepAlpha instead of emulation when drawing
This commit is contained in:
parent
162c3cf2e7
commit
21cceb0031
3 changed files with 33 additions and 1 deletions
|
|
@ -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;
|
||||
|
|
|
|||
9
upptst/DrawImageColor/DrawImageColor.upp
Normal file
9
upptst/DrawImageColor/DrawImageColor.upp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
uses
|
||||
CtrlLib;
|
||||
|
||||
file
|
||||
main.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "GUI";
|
||||
|
||||
15
upptst/DrawImageColor/main.cpp
Normal file
15
upptst/DrawImageColor/main.cpp
Normal 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();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue