Home » Developing U++ » U++ Developers corner » Optimizing DrawImage across platforms
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend [message #53630 is a reply to message #53621] |
Thu, 16 April 2020 21:08   |
Tom1
Messages: 1303 Registered: March 2007
|
Ultimate Contributor |
|
|
Hi Mirek,
Thank you very much for solving this issue for me! 
I did some further tuning of the render/paint structure using the new ViewDraw and ended up with a nice target update time of 60-150 micro seconds on both Windows and Linux GTK3 with the following code:
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
class Testcase5 : public TopWindow {
public:
typedef Testcase5 CLASSNAME;
Rect loc;
ImageBuffer map;
Testcase5(){
loc.SetNull();
}
void Paint(Draw &w){
int64 t0=usecs();
SetSurface(w,Rect(map.GetSize()),map,map.GetSize(),Point(0,0));
loc.SetNull();
int64 t1=usecs();
Title(Format("Paint took %lld us",t1-t0));
}
void Layout(){
Size sz=GetSize();
map.Create(sz);
BufferPainter bp(map);
bp.RectPath(Rect(sz));
bp.Fill(Pointf(0,0),Green(),Pointf(sz.cx-1,sz.cy-1),Yellow());
bp.Move(0,0).Line(Pointf(sz.cx-1,sz.cy-1)).Stroke(1,Black());
bp.Move(0,sz.cy-1).Line(Pointf(sz.cx-1,0)).Stroke(1,Black());
}
void MouseMove(Point p, dword keyflags){
int64 t0=usecs();
Rect area;
area.SetNull();
if(!loc.IsNullInstance()) area.Union(loc);
loc.Set(p.x-16,p.y-16,p.x+16,p.y+16);
area.Union(loc);
area.Inflate(2);
area.Intersect(Rect(GetSize()));
ImageBuffer sb(area.GetSize());
for(int y=0;y<area.Height();y++) memcpy(sb[y],&map[y+area.top][area.left],sizeof(RGBA)*area.Width());
BufferPainter sbp(sb);
sbp.Translate(loc.left-area.left,loc.top-area.top);
sbp.Move(0,0).Line(31,31);
sbp.Move(0,31).Line(31,0);
sbp.Stroke(5,Black());
ViewDraw draw(this,area);
SetSurface(draw,area.GetSize(),sb,sb.GetSize(),Point(0,0));
int64 t1=usecs();
Title(Format("Move took %lld us",t1-t0));
}
};
GUI_APP_MAIN
{
Testcase5().Sizeable().MaximizeBox().MinimizeBox().Run();
}
I do not need support for this feature in Mac, but what worries me is the potential deprecation of ViewDraw... Is there a real risk that you would drop ViewDraw entirely? As you can see from running the example above, an optimized Paint (as above, drawing a readily rendered ImageBuffer with SetSurface()) of the entire view on a 4K screen takes something like 6-12 ms, the small update with ViewDraw runs at around just 1 % of that time. (That's the difference between success and failure for my task.)
How would similar code and its performance look with what you refer to as 'Refresh and optimized Paint'?
Thanks and best regards,
Tom
|
|
|
 |
|
Optimizing DrawImage across platforms
By: Tom1 on Wed, 15 April 2020 09:52
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: mirek on Wed, 15 April 2020 14:35
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: Tom1 on Wed, 15 April 2020 15:15
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: mirek on Wed, 15 April 2020 22:21
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: Tom1 on Thu, 16 April 2020 21:08
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: Tom1 on Thu, 16 April 2020 22:06
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: mirek on Fri, 17 April 2020 00:41
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: Tom1 on Fri, 17 April 2020 13:20
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: mirek on Fri, 17 April 2020 13:38
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: Tom1 on Fri, 17 April 2020 14:36
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: Tom1 on Fri, 17 April 2020 17:00
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: Tom1 on Sat, 18 April 2020 14:05
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: mirek on Sat, 18 April 2020 15:06
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: Tom1 on Sat, 18 April 2020 16:43
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: mirek on Sat, 18 April 2020 17:12
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: Tom1 on Sat, 18 April 2020 17:27
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: mirek on Sat, 18 April 2020 18:21
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: Tom1 on Sat, 18 April 2020 16:57
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: mirek on Sat, 18 April 2020 16:48
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: Tom1 on Sat, 18 April 2020 17:05
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: Tom1 on Sat, 18 April 2020 19:21
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: mirek on Sun, 19 April 2020 14:28
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: Tom1 on Sun, 19 April 2020 22:37
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: mirek on Mon, 20 April 2020 10:31
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: mirek on Mon, 20 April 2020 11:13
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: Tom1 on Mon, 20 April 2020 12:57
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: mirek on Mon, 20 April 2020 13:13
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: Tom1 on Mon, 20 April 2020 14:11
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: mirek on Mon, 20 April 2020 15:11
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: Tom1 on Mon, 20 April 2020 15:25
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: Tom1 on Mon, 20 April 2020 15:34
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: mirek on Mon, 20 April 2020 17:55
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: Tom1 on Mon, 20 April 2020 20:37
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: Tom1 on Mon, 20 April 2020 20:59
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: mirek on Tue, 21 April 2020 16:20
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: Tom1 on Tue, 21 April 2020 18:03
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: mirek on Tue, 21 April 2020 18:28
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: Tom1 on Tue, 21 April 2020 19:25
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: Didier on Tue, 21 April 2020 22:19
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: mirek on Wed, 22 April 2020 17:57
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: Tom1 on Wed, 22 April 2020 14:08
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: mirek on Fri, 24 April 2020 17:19
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: Tom1 on Fri, 24 April 2020 22:43
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: mirek on Sat, 25 April 2020 15:58
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: Tom1 on Sun, 26 April 2020 11:49
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: mirek on Tue, 28 April 2020 09:30
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: mirek on Tue, 12 May 2020 15:35
|
 |
|
Re: MILESTONE: gtk3 replaces gtk2 as default linux backend
By: Tom1 on Wed, 13 May 2020 09:44
|
Goto Forum:
Current Time: Fri Jun 06 19:21:48 CEST 2025
Total time taken to generate the page: 0.05439 seconds
|