I tried to implement animated transitions between different screens in my application in the following way:
- Take a snapshot of the component on the screen before the transition
- Take a snapshot of the new component
- Start a timer
- While the timer is running, do the animation effect step by step in each timer callback e.g. by fading out the old image and moving it from the screen while fading in the new image and moving it onto the screen. After that trigger a repaint.
- Stop the timer and display the new component, when the transition is complete.
That works in general, but the problem with that solution is the performance and here especially with Linux.
I use a Timer that fires every 30 milliseconds, what gives me a frame rate of about 33 per second and that is the minimum to get a smooth effect for the user. If now the drawing of the two images in between two timer callbacks lasts longer than 30 milliseconds, in Windows sometimes two timer callbacks happen without a repaint in between. With that the animation is not so smooth any more, but not really broken.
In Linux always a timer callback and then the repaint is done, but if the next timer callback comes immediatly after the repaint (because the repaint lasts that long), the screen is not redisplayed completely any more, which really breaks the animation. Is there anything that can be done in Linux so that the screen is fully redisplayed, even if the next timer callback comes immediately?
Or the other way round: the drawing of two images (1024*768) with alpha effects into a Graphics lasts about 20 milliseconds. When I try to add rescaling effects, you easily need more than 30 milliseconds and that breaks my animation. The “Graphics::drawImage” seems to be to slow to do such things!?! Is there a better way to that with Juce?