W3C home > Mailing lists > Public > public-html@w3.org > September 2012

RE: [Canvas] proposal for supportsContext

From: Frank Olivier <Frank.Olivier@microsoft.com>
Date: Tue, 11 Sep 2012 17:14:25 +0000
To: Dean Jackson <dino@apple.com>, Travis Leithead <travis.leithead@microsoft.com>
CC: Robin Berjon <robin@w3.org>, "public-html@w3.org" <public-html@w3.org>
Message-ID: <91175A762AB48840AF1473514B26B47552CDE018@TK5EX14MBXC261.redmond.corp.microsoft.com>
Why not (internally) defer context creation until the author calls a method that needs an actual context?

(This would be somewhat similar to deferring creation of your media engine & codecs until the author calls video.play() )


-----Original Message-----
From: Dean Jackson [mailto:dino@apple.com] 
Sent: Tuesday, September 11, 2012 9:48 AM
To: Travis Leithead
Cc: Robin Berjon; public-html@w3.org
Subject: Re: [Canvas] proposal for supportsContext


On Sep 11, 2012, at 9:37 AM, Travis Leithead <travis.leithead@microsoft.com> wrote:

> Hmm. Seems like this still incurs the cost of spinning up a context. 
> Never mind :(

This is similar to what we'd originally proposed doing, which is hiding (returning undefined or null) WebGLRenderingContext when we do not support WebGL. We can do it, but it's slightly ugly.

The main complaint about all this is that users still need to create the context in order to know for sure it is possible, and therefore will create the context no matter what helper functions we provide.

Dean

> 
>> -----Original Message-----
>> From: Travis Leithead
>> Sent: Tuesday, September 11, 2012 9:12 AM
>> To: 'Robin Berjon'; Dean Jackson
>> Cc: public-html@w3.org
>> Subject: RE: [Canvas] proposal for supportsContext
>> 
>> On the other hand, you could change the way that the 3d context is 
>> obtained from the canvas element, to better allow feature detection...
>> 
>> if (canvas.context3d) {
>>   ...
>> }
>> 
>> ??
>> 
>>> -----Original Message-----
>>> From: Robin Berjon [mailto:robin@w3.org]
>>> Sent: Tuesday, September 11, 2012 1:41 AM
>>> To: Dean Jackson
>>> Cc: public-html@w3.org
>>> Subject: Re: [Canvas] proposal for supportsContext
>>> 
>>> Hi Dean,
>>> 
>>> On 10/09/2012 20:11 , Dean Jackson wrote:
>>>> I propose adding a new method to HTMLCanvasElement:
>>>> 
>>>> interface HTMLCanvasElement : HTMLElement {
>>>>   boolean supportsContext(DOMString contextId, any... arguments); 
>>>> };
>>>> 
>>>> supportsContext takes the same parameters as getContext, and simply
>>> returns
>>>> true if the corresponding call to getContext would have returned a
>> valid
>>>> context, false otherwise.
>>> 
>>> I like it. My only concern is about why this would work when
>>> hasFeature() failed so miserably. I guess that it covers a 
>>> sufficiently limited set that it will be done right.
>>> 
>>> --
>>> Robin Berjon - http://berjon.com/ - @robinberjon
>>> 
> 
> 
Received on Tuesday, 11 September 2012 17:15:02 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 September 2012 17:15:03 GMT