I built a demo app to show my problem in another thread.
Just extract the rar to juce\extras and then build and run. It has a slider in a window. When you drag the slider it repaint the main component with simple lines and colors. When dragging it you can check the CPU usage. It’s about 40% for me.
Copy the project to the same position of a old juce library (before low level graphics change). Rebuild the project and run. Drag the slider and watch the CPU, it’s about 15% for me.
This might be because you’re drawing vertical lines with drawLine rather than fillRect or drawVerticalLine. I think the old code had an optimisation that detected that and used a faster draw method, but the new stuff might not do that.
Anyway, it’s always best to never call drawLine unless you really do need an angled line.
[quote=“jules”]This might be because you’re drawing vertical lines with drawLine rather than fillRect or drawVerticalLine. I think the old code had an optimisation that detected that and used a faster draw method, but the new stuff might not do that.
Anyway, it’s always best to never call drawLine unless you really do need an angled line.[/quote]
Yes. You’re just making heavy use of the one graphics operation that is much slower in the new version - long vertical lines. Everything else is as fast as it used to be, but those now have to be rendered as rectangles so they can be correctly clipped to complex clipping regions, whereas in the old version they were done as a special case.
TBH I don’t know how I could possibly optimise them, and if you weren’t filling the screen with them you wouldn’t have noticed the difference. But if you’re drawing a screenful of repeating patterns like that, it’s probably much quicker to fill it with an image brush anyway.
[quote=“jules”]Yes. You’re just making heavy use of the one graphics operation that is much slower in the new version - long vertical lines. Everything else is as fast as it used to be, but those now have to be rendered as rectangles so they can be correctly clipped to complex clipping regions, whereas in the old version they were done as a special case.
TBH I don’t know how I could possibly optimise them, and if you weren’t filling the screen with them you wouldn’t have noticed the difference. But if you’re drawing a screenful of repeating patterns like that, it’s probably much quicker to fill it with an image brush anyway.[/quote]
[quote=“jules”]Yes. You’re just making heavy use of the one graphics operation that is much slower in the new version - long vertical lines. Everything else is as fast as it used to be, but those now have to be rendered as rectangles so they can be correctly clipped to complex clipping regions, whereas in the old version they were done as a special case.
TBH I don’t know how I could possibly optimise them, and if you weren’t filling the screen with them you wouldn’t have noticed the difference. But if you’re drawing a screenful of repeating patterns like that, it’s probably much quicker to fill it with an image brush anyway.[/quote]
I mean is it possible for me to replace the slow new drawverticalline code with the fast old drawverticalline. Is that part of code very compact? or it won’t work with other juce components after replace?