I’m drawing multiple waveforms on a component and over that (in a children component) I paint the selected waveform that the user is playing.
Since I want to change the wavetable playing in real time, I want the painting to be fast and efficient (only repainting the active waveform on top instead of all of them would be the way to go). But afaik if a component isn’t set to opaque the component under it will be repainted (taking a good chunk of CPU when the LFO triggers constant repaintings), which is kinda confirmed by the similar CPU usage when using this aproach.
So for now I’ve tried 4 methods (all of them with setBufferedImage and attatching an openGL context to render on GPU):
- Path rendering: looks great, melts CPU
- drawVerticalLine: looks great except for waves with accentuated slopes like Saws. Plus it isn’t efficient enough.
- OpenGL (PolyLine2D): takes a good amount of CPU (Mojave/Xcode 10 mentioned problems?). Haven’t tried raw OpenGL by myself since I don’t wanna dive in yet and is giving me compiling problems in cross platforms, I discard this aproach for now.
- Pixel painting on an image: the best performance so far, but again for accentuaded slopes I need to use drawLine which makes the CPU usage high again.
Am I overcomplicating this and can be aproached by a much simpler way, or is it an usual problem where you must make some concessions?