Home » Community » U++ community news and announcements » gtk rendering improvements, BufferPainter::PaintOnceHint
Re: gtk rendering improvements, BufferPainter::PaintOnceHint [message #57175 is a reply to message #57172] |
Fri, 04 June 2021 13:25 |
Tom1
Messages: 1213 Registered: March 2007
|
Senior Contributor |
|
|
Hi Mirek,
I did some testing of SetSurface on Linux/Gtk and noticed that it does not work well when using only a part of a larger image. Offset does not seem to work at all there. On Windows, it works very well and can update a 4k screen at 40-50 FPS with SetSurface and 13 FPS with DrawImage. On Linux I get 11-12 FPS for DrawImage.
Please try this testcase:
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
class ResponsiveDrag : public TopWindow {
public:
Image im;
Point offset;
ResponsiveDrag(){
Sizeable().MaximizeBox().MinimizeBox();
Maximize();
offset=Point(0,0);
leftdown=false;
}
virtual void Paint(Draw &w){
static int64 last;
int64 now=usecs();
double fps=1000000/(now-last);
last=now;
// In Windows SetSurface is about 3x faster than Drawimage on 4k UHD screen
// However, in Gtk SetSurface fails to display the image correctly
// and offset is not taken into account at all
SetSurface(w,Rect(GetSize()),~im,im.GetSize(),offset); // Only works on Windows
// w.DrawImage(Rect(GetSize()),im,Rect(offset,GetSize())); // Works on both Linux and Windows
w.DrawText(10,10,Format("FPS = %.1f",fps));
}
virtual void Layout(){
Size sz(GetSize()*3);
ImageBuffer ib(sz);
BufferPainter p(ib);
p.Clear(SColorPaper());
for(int i=0;i<50;i++){
p.Move(Random(sz.cx),Random(sz.cy));
p.Line(Random(sz.cx),Random(sz.cy));
p.Stroke(3,SColorText());
}
im=ib;
offset=Point(GetSize());
Refresh();
}
bool leftdown;
Point leftdownp;
virtual void LeftDown(Point p, dword keyflags){
SetCapture();
leftdown=true;
leftdownp=p;
}
virtual void LeftUp(Point p, dword keyflags){
ReleaseCapture();
leftdown=false;
offset=Point(GetSize());
Refresh();
}
virtual void MouseMove(Point p, dword keyflags){
if(leftdown){
offset=Point(GetSize())+leftdownp-p;
Refresh();
}
}
};
GUI_APP_MAIN
{
ResponsiveDrag().Run();
}
Best regards,
Tom
Update: PaintOnceHint() almost doubles the DrawImage() FPS on Linux/Gtk to about 20 FPS. On Windows PaintOnceHint() does not have any effect on DrawImage() performance.
[Updated on: Fri, 04 June 2021 14:01] Report message to a moderator
|
|
|
|
|
gtk rendering improvements, BufferPainter::PaintOnceHint
By: mirek on Thu, 03 June 2021 11:33
|
|
|
Re: gtk rendering improvements, BufferPainter::PaintOnceHint
By: Tom1 on Thu, 03 June 2021 16:01
|
|
|
Re: gtk rendering improvements, BufferPainter::PaintOnceHint
By: Tom1 on Fri, 04 June 2021 13:25
|
|
|
Re: gtk rendering improvements, BufferPainter::PaintOnceHint
By: mirek on Fri, 04 June 2021 14:55
|
|
|
Re: gtk rendering improvements, BufferPainter::PaintOnceHint
By: Tom1 on Fri, 04 June 2021 16:20
|
|
|
Re: gtk rendering improvements, BufferPainter::PaintOnceHint
By: mirek on Fri, 04 June 2021 17:55
|
|
|
Re: gtk rendering improvements, BufferPainter::PaintOnceHint
By: Tom1 on Mon, 07 June 2021 12:27
|
|
|
Re: gtk rendering improvements, BufferPainter::PaintOnceHint
|
Goto Forum:
Current Time: Sun May 12 00:17:03 CEST 2024
Total time taken to generate the page: 0.02578 seconds
|