[whatwg] Canvas size and double buffering.

Simon Fraser smfr at me.com
Wed Feb 3 08:50:52 PST 2010

On Feb 3, 2010, at 7:59 AM, Boris Zbarsky wrote:

> On 2/3/10 9:05 AM, Tim Hutt wrote:
>> 1. You can only set the size exactly in pixels. It is very hard to get
>> a resizable canvas that fills the page. You *can* set the size in CSS,
>> but it doesn't work very well (e.g. using left,right-margin: auto; to
>> centre the canvas doesn't work. Also it scales the canvas rather than
>> resizes it.
> That's right, because resizing the canvas (as in, changing the number of pixels in the backing store) involves clearing it at the moment.  Your proposal would mean that if the user changes the window size your canvas will immediately get cleared.  Is that what you're after?  If not, how do you envision the backing-store resize being performed?

Canvas drawing should have been callback-based from the start. Maybe we can retrofit this by having a way the author can specify that the canvas backing store resizes with the element, and firing an event when the backing store size changes.

>> 2. There doesn't appear to be any kind of double buffering capability.
>> This is pretty critical for animations where you might need to clear
>> the canvas and then draw stuff. You currently get flickering if you
>> try.
> You do?  Under what circumstances?  At least in Gecko, run-to-completion means that while you script is running the canvas won't be painted. What UAs are you seeing flicker in, and under what circumstances?

Same with WebKit. As long as you clear and redraw at the same time, there should not be flicker.


More information about the whatwg mailing list