음악, 삶, 개발

Juce Drawing 최적화 (CPU 사용량 줄이기) 본문

개발 공부/Juce 공부방

Juce Drawing 최적화 (CPU 사용량 줄이기)

Lee_____ 2020. 10. 12. 12:53

이 부분에 대해, 추가적인 연구가 필요한데

일단 Nathan 과 Peter 가 얘기해준 부분을 남겨놓는다.

추후 공부하면서 이 포스팅은 다시 업데이트 하는걸로.


Nathan

Quick tip that my be helpful to you.
If you set JUCE_ENABLE_REPAINT_DEBUGGING to enabled in the projucer under the juce_gui_basics module,

then you can see when areas of the screen are being redrawn.
I have found that using a child component for drawing ui elements means that it will only redraw the part of the parent component where the child has moved rather than redrawing the entire component.
This cut cpu usage in half.
I wonder if you make the transport line as a child component and,

move that then your juce example should be much lighter.

I have also been using setRepaintOnMouseActivity(false) and calling repaint() only when I want to.
Also setOpaque(true) and setPaintingIsUnclipped(true) have helped a bit too.

I expect, when you get there, using the openGL renderer rather than the cpu renderer for this sort of thing may give some performance improvement.


Peter

It’s more efficient to fill a 1 px wide rectangle.

(For vertical and horizontal lines)

Doing it as a separate component could also work esp. if you set setBufferedToImage true.

You can also get some improvement by setting the component opaque

That way it isn’t drawing the background behind it. 

it’s also fine in this case to not worry about the atomic

You can just read the double if it’s only for drawing.  (b/c worst case is a momentary graphics glitch)