Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

html

canvas

gwt

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

like image 297
user291701 Avatar asked Aug 02 '12 12:08

user291701


2 Answers

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/

like image 119
Simon Sarris Avatar answered Nov 16 '22 03:11

Simon Sarris


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.

like image 4
Kim Lavoie Avatar answered Nov 16 '22 05:11

Kim Lavoie