Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous messageGo to previous message
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

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: git
Next Topic: integer->String conversion optimised
Goto Forum:
  


Current Time: Sun May 12 00:17:03 CEST 2024

Total time taken to generate the page: 0.02578 seconds