|
|
Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » Font and Image rendering slow
Font and Image rendering slow [message #59968] |
Wed, 28 June 2023 17:36  |
devilsclaw
Messages: 72 Registered: August 2022
|
Member |
|
|
So I have been porting a app that I created in java to U++.
When I render a image with DrawImage and have 108 instances of it on the screen it is way slower then in java. So I decided to manually draw what the image is with line and rectangle since its a simple image and its performance was on par with java.
The item I am drawing also has text and with the text enable it renders much slower than java also.
So it seems that both the text and image rasterizer are highly inefficient at least compared to java.
|
|
|
|
Re: Font and Image rendering slow [message #59970 is a reply to message #59968] |
Thu, 29 June 2023 04:57   |
devilsclaw
Messages: 72 Registered: August 2022
|
Member |
|
|
Currently the image is an element of the the object and is in the paint member of that object, which I currently no longer use the image and just manually draw what the image looks like during the paint which has increase performance greatly. The being said I don't know how to cache an image so that would be useful in the future. so if you could explain how or give an example.
But that does not solve the Font problem since that is different for the 108 items and it has a similar slow down.
If I click and hold on the object it allows me to move it on the screen which of course causes a repaint/refresh and its performance it much lower than the java version.
[Updated on: Thu, 29 June 2023 05:20] Report message to a moderator
|
|
|
Re: Font and Image rendering slow [message #59971 is a reply to message #59970] |
Thu, 29 June 2023 07:43   |
Oblivion
Messages: 1202 Registered: August 2007
|
Senior Contributor |
|
|
Hello devilsclaw
Quote:Currently the image is an element of the the object and is in the paint member of that object, which I currently no longer use the image and just manually draw what the image looks like during the paint which has increase performance greatly. The being said I don't know how to cache an image so that would be useful in the future. so if you could explain how or give an example.
But that does not solve the Font problem since that is different for the 108 items and it has a similar slow down.
If I click and hold on the object it allows me to move it on the screen which of course causes a repaint/refresh and its performance it much lower than the java version.
Image tutorials (check 6 for image caching)
If you can provide a bare minimum U++ example code (preferably in Java too) that replicates the problem we can look into it.
Also platform/OS/hardware information and specs would be very useful.
Best regards,
Oblivion.
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Thu, 29 June 2023 08:10] Report message to a moderator
|
|
|
|
|
Re: Font and Image rendering slow [message #59979 is a reply to message #59968] |
Thu, 29 June 2023 23:28   |
devilsclaw
Messages: 72 Registered: August 2022
|
Member |
|
|
The java project is too big to upload here since it has everything except the JRE and JDK to build it.
So here is a link:
http://devilsclaws.net/downloads/javademo.zip
in the fatjar directory there is either the jar file or a window exe.
This is a netbeans project so if you want to compile it with that you can I also have script directories that let you build but you will still need to open it in netbeans at least once on your system so it can get the java pathing correct.
You can scroll with the mouse wheel and shift+scroll does the other scroll axis.
The icons are clipped to only drawing what is visible also but there is like 1089 total there. only about 108 on screen at a time on a 1920x1080 resolution.
I will be working on the U++ version tomorrow.
[Updated on: Thu, 29 June 2023 23:31] Report message to a moderator
|
|
|
|
|
Re: Font and Image rendering slow [message #59987 is a reply to message #59986] |
Sat, 01 July 2023 21:40   |
Oblivion
Messages: 1202 Registered: August 2007
|
Senior Contributor |
|
|
Hi,
Thanks for the code.
Yesterday I have looked into the Java code and it seems fine and works well.
A quick tour through its U++ counterpart (I will dive deep, later), and here's some "odd" things (for U++ land, of course) I've seen so far (All understandable, as Upp can sometimes look alien even to regular C++ developers):
1) You seem to have duplicated code that is already in Upp: (Rectf, Sizef, Pointf, their operators, etc.)
2) Mixing std::string with Upp code: Not inherently bad, it is possible and sometimes necessary but Upp::String is more optimized and has a lot of optimized functionality you can utilize. Rule of thumb: Use Upp::String with Upp infrastructure whenever possible. Convert to Std only for glue code.
3) You are using BufferPainter, which is a pdf/print quality (subpixel) 2d graphics library for U++. It is great for a lot of things, but it is also very CPU-intesinve.It does not (AFAIK) utilize GPU's 2D hardware acceleration. But it can take advantage of multithreading. Try the below code, and you'll see the difference:
4) (post-post:) You also seem to use iterators a lot. Avoid them where possible. Upp's containers are designed to work with indices. In a wide range of use-cases they are lot faster & easier to use.
void frm_main::Paint(Draw& w) {
Size sz = GetSize();
ImageBuffer ib(scroll.GetViewSize());
BufferPainter sw(ib, MODE_ANTIALIASED);
sw.Co(); // Enable MT.
sw.Clear(White());
_icons_paint(sw, scroll.Get().x, scroll.Get().y, render_everything);
sw.Finish(); // Join.
w.DrawImage(0, 0, ib);
}
Now, of course the above code doesn't really fix the problem.
I am going study your code and try to come up with a diagnosis at least.
Best regards,
Oblivion
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Sat, 01 July 2023 21:43] Report message to a moderator
|
|
|
Re: Font and Image rendering slow [message #59988 is a reply to message #59968] |
Sat, 01 July 2023 21:49   |
devilsclaw
Messages: 72 Registered: August 2022
|
Member |
|
|
The replicated code is actually to make the code work more like java and I also have a hard time with cx and cy as width and height.
I also have more standard C++ code in the project then U++ since I am only using U++ for the UI elements.
I will look to see where the code only needs U++ and where C++ STD is needed and try to optimize it.
One of the reasons I used that Draw function is due to sub-pixel bleeding looking bad in integer based drawing. So I use sub pixels to make it look clean.
indices I think I might do that for code standardization to make the code work similar in all areas and maybe for deleting or its just me being used to C++ STD since it does not make it easy to delete element with out iterators. I will look to see what I can do to clean that up.
I will try you example today. Thanks.
[Updated on: Sat, 01 July 2023 21:52] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Fri Apr 25 17:55:31 CEST 2025
Total time taken to generate the page: 0.00687 seconds
|
|
|