user291701
user291701

Reputation: 39731

Do we need to implement double buffering ourselves with <canvas>?

I'm starting to use Canvas (with GWT), do we need to implement double buffering ourselves? Wondering if somehow the browsers instead implement this for us already.

Thanks

Upvotes: 11

Views: 5135

Answers (2)

Kim Lavoie
Kim Lavoie

Reputation: 41

I know it's quite an old thread, but I wanted to point out that the Fiddle in Simon Sarris answer seems wrong. When I tried it on Google Chrome, I inserted an alert statement between lines 10 and 11 (just before the loop) and the square had disappeared, just to reappear after I closed the alert window. It seems that the loop is not executed correctly. Maybe javascript optimized it out. Anyway, it seems to me that no double buffering is done. Correct me if I'm wrong.

Upvotes: 4

Simon Sarris
Simon Sarris

Reputation: 63872

You absolutely do not need to implement double buffering yourself and doing so would be a waste of time and performance.

Lucky for us every canvas implementation implements it behind-the-scenes for you.

Here's a simple example of it in action: http://jsfiddle.net/HYVLj/

Upvotes: 13

Related Questions