High CPU usage when running animations



Hi,

consider the following example code (Vala, compile with "valac --pkg
clutter-1.0 -X -lm test.vala"):

"""
using Clutter;

void main(string[] args) {
        Clutter.init(ref args);
        var stage = new Stage();
        stage.hide.connect(Clutter.main_quit);

        var actor = new Actor();
        actor.background_color = Color.from_string("#f00");
        actor.width = 100;
        actor.height = 100;

        var animation = new Clutter.PropertyTransition("opacity");
        animation.repeat_count = -1;
        animation.auto_reverse = true;
        animation.set_interval(new Interval.with_values(typeof(int), 0, 255));
        animation.duration = 1000;
        actor.add_transition("animation", animation);

        stage.add_child(actor);

        stage.show();
        Clutter.main();
}
"""

It creates a red rectangle and loop-fades it in and out.

On GNOME Shell, i5-2400 CPU @ 3.10GHz × 4, GeForce GTX 550 Ti, nVidia
proprietary driver, running this program results in massive additional
CPU usage:

gnome-shell: 10%
Xorg: 6%
The program itself: 5%

vs. gnome-shell and Xorg sitting close to zero without the program
running.

What is going on here? Is that "normal" performance or do I have a
mistake in my code? I tested on two other machines with different
hardware and Mint/Cinnamon instead of GNOME Shell, but with similar
results. Somehow, I find it difficult to believe that fading a rectangle
in and out requires 20% of a modern CPU.

Thanks in advance & best regards
- Philipp




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]