Hi All,
I draw a 5 point amplifier envelope onto a bitmap (just as a shaded old style LCD background) using
4 quatrilaterals and some small circles arround its points to pick up and move the points
by mouse.
[attachment=0]env.JPG[/attachment]
That works pretty well but I noticed quiet a huge CPU usage when points get moved,
either by mouse or by incoming Midi data. I am talking about up to 20% CPU usage in release mode
for a 10cm x 4cm component which is too much from my point of you?!
I’ve searched the forum for performance optimization and all of those optimizations are helpful but
don’t get performance down dramatically.
I am drawing onto an opaque component using the below code:
[code]void JK_Envelope::paint (Graphics& g)
{
_bufferedImage = Image (Image::RGB, getWidth(), getHeight(), Image::NativeImage);
Graphics imG (_bufferedImage);
imG.drawImageAt(backgroundPic, 0, 0);
Path env;
for (int i = 0; i < envPoints.size() - 2; i = i + 2)
env.addQuadrilateral(envPoints[i + 1]->getX(),
envPoints[i + 1]->getY(),
envPoints[i + 0]->getX(),
envPoints[i + 0]->getY(),
envPoints[i + 2]->getX(),
envPoints[i + 2]->getY(),
envPoints[i + 3]->getX(),
envPoints[i + 3]->getY());
imG.setColour($findColour($LookAndFeel->EN_Colour));
imG.fillPath(env);
for (int i = 1; i < envPoints.size(); i = i + 2)
{
imG.setTiledImageFill(backgroundPic, 0, 0, 1.0f);
imG.fillRoundedRectangle(envPoints[i]->getX() - 5.0f,
envPoints[i]->getY() - 5.0f,
10.0f, 10.0f, 5.0f);
imG.setColour($findColour($LookAndFeel->EN_Colour));
imG.drawRoundedRectangle(envPoints[i]->getX() - 5.0f,
envPoints[i]->getY() - 5.0f,
10.0f, 10.0f, 5.0f, 1.0f);
}
g.drawImageAt (_bufferedImage, 0, 0);
}[/code]
If I now attach a Listener to each point then the CPU usage gets up to 30% when points are moving.
So I guess I can do some more optimizations to my envelope code to get a decent usage but
here I need some ideas. I noticed that broadcaster/listener always have an impact to performance which
might be one reason why Jules has changed UI update code in the demo plugin from Broadcaster/Listener to
timer. So what else could I do instead?
There is another UI code in my plugin that need some optimization but may I can pull out information for that
from your input…
i am also open for a easier way to draw such an envelope 
Thank you!
Joerg
