It’s always reassuring when the banned fork is the one holding the performance seminar. At this point JUCE should probably send Yup a thank-you card and a legal disclaimer.
This example calls repaint from paint which is considered bad practise FWIW.
componentPainted call legend.repaint(); A timer should be use for this use case.
CG tolerates it and AppKit paces drawRect to the refresh, so the loop costs at most one frame per refresh. I Will do the same.
Thanks for the report.
Sure, as I said it’s a vibe-coded example to show that you don’t need a whole new renderer to fix your problem. You just need to use the existing API correctly.
3 whole milliseconds?! My example takes 0.1ms if you use the API correctly ![]()
Setting SetBufferedToImage on all the component is just a non sense to me, but feel free to keep this solution.
@Kunitoki do you have the source for your retrace stuff ? Would be interresting to do the same in Juce to compare the difference with Rive. Thanks !
Why? I provided the demo to prove it solves this kind of problem. Why would you choose to write a whole new renderer instead of setting a handful of flags?
Because if you have hundreds of components, settings SetBufferedToImage on all of them is just nonsense. Feel free to disagree. Maybe this new renderer is not for you but that doesn’t make it useless.
Why is it nonsense?
Because it’s a workaround for CoreGraphics, not a fix. It’s like saying a bandage is a good fix. Maybe this is your opinion but not mine.
well your example is not even comparable with a complex UI nearly animating from top left to bottom right, with hundreds of nested components, shaders, gradients, text, post processing effects.
It’s a solution. Not a workaround.
It can be still helpful in certain scenarios, especially if you have complex backgrounds that you want them rendered once, and you just change an overlay (or the opposite), or you want to apply shading
It animates from top left to bottom right on osx. That’s the whole point.
You can add more components if you like to see the impact.
you are not animating the center, just animating a strip on the left and a strip on the right it’s not an indication of what i’m talking about. what happen if each of your center rects are animating gradient coloring ? let me know how that goes
On OSX you are. That was the point that was previously being discussed.
Because you changed the subject from what we were talking about in this thread.
The performance will be worse, obviously. OP’s Metal renderer performs much better than the CoreGraphics renderer. But the demo I provided gets 10,000 FPS on my machine if you use the API correctly and that’s all I was trying to point out - it’s much easier to set a few flags to optimise for CoreGraphics than it is to write an entirely new renderer.
i’m done here
If you use the API correctly? So now we have to write some algorithm to decide, frame by frame, if a component should be buffered to image or not?
Can you imagine writing this kind of advice to any web-developer? Oh, the composer inside Chrome repaints stuff unnecessarily, why don’t you buffer the stuff in between to images and back when you want to animate them?
You are arguing AGAINST improving matters and FOR workarounds NOBODY should have to make.
The area between two dirty rects should never been re-painted. No tricks/workaround should be necessary.
Where did I say you should do that? You just call setBufferedToImage() on components that are expensive to draw and that don’t frequently change.
Yes you need to use those APIs correctly too. E.g. don’t use a <canvas> for complex drawing if you can use SVG, and don’t use SVG if you can use CSS. Don’t use JS for responsive image assets, use <picture> etc. Same goes for game engines - Unreal Engine doesn’t magiclly make every game run at 120 FPS on a 4k monitor. You have to use the API correctly to get the best performance for your particular project.
I’m not arguing against anything. A Metal renderer in JUCE would be fantastic, it’s just not likely to happen any time soon. In the meantime there are existing solutions to the problem. Call them workarounds if you like, but they’ll allow you to ship an update to your users today instead of in 3 years.
