I just have done a test with an Image that gets zoomed and rotated via a Timer that should repeat every 10ms.
I did this test first in my own framework (with AGG used for drawing stuff), then in JUCE. Although the drawing speed of JUCE is good for the transformation (as seen in the milliseconds display in the top left corner), it seems that there’s a problem somewhere else, because the JUCE version of the small demo app is significantly slower than the one using my own framework.
Files at: http://www.2shared.com/file/unKdA0xg/timerProblem.html
Please check out the files - both versions were compiled using VC2008 (Release). The rotation/zoom code for both is identical, so that cannot be the problem.
It’s obvious that the Timer is not firing at 10ms anymore when the CPU gets used a lot because of the painting (but it should still be firing much faster than what it is, considering the time to draw the image is about 20ms!).
Maybe the Timer gets slowed down to some additional big overhead in JUCE for preparing the Graphics stuff and finally blitting it back to the window surface?
In any case, it would be worth to know what’s going on!
Here’s the main code:
[code]class MainComponent:public Component, public Timer
{
public:
MainComponent()
{
setSize(100,100);
mouseX=mouseY=0;
setOpaque(true);
angle=0.0;
startTimer(10);
PNGImageFormat png;
image=png.loadFrom(File("image.png"));
image2=png.loadFrom(File("image2.png"));
}
double angle;
void timerCallback()
{
angle+=0.01;
if (angle>(2.0*3.1415)) angle=0.0;
repaint();
}
void paint(Graphics &g)
{
g.fillAll(Colours::black);
g.setImageResamplingQuality(Graphics::lowResamplingQuality);
double t1=Time::getMillisecondCounterHiRes();
AffineTransform t;
double zoom=1.0+sin(angle)*0.25;
double a=-3.1415*0.5 + sin(angle)*0.25;
t=t.rotated(a);
t=t.scaled(zoom, zoom);
t=t.translated((float)mouseX, (float)mouseY);
g.drawImageTransformed(image2, t);
double t2=Time::getMillisecondCounterHiRes();
g.setColour(Colours::white);
g.drawText(String(t2-t1), 10, 10, 100, 12, Justification::centredLeft, false);
}
void mouseMove(const MouseEvent &e)
{
mouseX=e.x;
mouseY=e.y;
repaint();
}
int mouseX, mouseY;
Image image, image2;
};[/code]