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

Re: [Public WebGL] getContext multiple context language



On Sat, Jan 23, 2010 at 1:45 AM, Vladimir Vukicevic
<vladimir@mozilla.com> wrote:
> Here's the language for getContext() -- let me know of any suggestions
> before I send it off to hixie:

A general note: the W3C's version of HTML5 currently splits the 2d
context into a separate document (http://dev.w3.org/html5/2dcontext/),
so the text around getContext is different to the WHATWG's integrated
version. I think that's probably not a problem here, though - Hixie
can sort out the exact wording, given the desired behaviour.

> object getContext(in DOMString contextId, in optional object attributes)

Perhaps this could use "in any... attributes" to be consistent with
toDataURL, with the interpretation of the attributes (number and type)
left entirely to the spec that defines behaviour for the given
contextId.

> 'contextId' must be a string naming a canvas rendering context to be
> returned.  This specification only defines one context, with the name "2d".
> If getContext() is called with that exact string for its 'contextId'
> argument, then the UA must return a reference to an object implementing
> CanvasRenderingContext2D.

This conflicts with the requirement later that it can return null,
e.g. if someone called getContext('3d') earlier.

> If getContext() is called multiple times on the same canvas with the same
> context ID, it must return the same resulting context object provided that
> the attributes are identical to all previous requests for that context ID.
> If the attributes are not identical, getContext() must raise an
> INVALID_STATE_ERR exception.

What does this mean? E.g. which of the following are errors:

  var a = { x: 1 }, b = { x : 1 }; // a != b
  c.getContext('example', a);
  c.getContext('example', b);

  var a = { x: 1 };
  c.getContext('example', a);
  a.x = 2;
  c.getContext('example', a);

  var a = { get x() { return Math.random(); } };
  c.getContext('example', a);
  c.getContext('example', a);

I don't see how it's possible to define a sensible notion of
"identical" for arbitrary JS objects. Maybe it'd be fine to simply
ignore attributes for all but the first call - that should be simple
to define and to implement interoperably, and I don't imagine this
would be a common or hard-to-debug authoring error. (Browsers could
emit warnings in their error consoles anyway, saying they're ignoring
the changed attributes, if it turns out to be a common mistake.)

> If getContext() is called with a context ID different from the context IDs
> given to any previous successful calls to getContext(), it may either return
> a new canvas context that can be used simultaneously with all previously
> obtained contexts, or return null to indicate that the newly requested
> context cannot be used with the previously obtained contexts.

What is a successful call? If getContext returns null because it
doesn't support simultaneous rendering, is that a successful call?

> If multiple rendering contexts are active, they all render to the same
> canvas; they are not layered or otherwise isolated.  Changes made to the
> canvas with one context must be immediately visible to any other active
> contexts on the canvas.

The first two mentions of "canvas" should be "bitmap", to make it
clear they're really talking about the bitmap that's associated with
the canvas.

> It is up to the implementation to manage
> synchronization issues associated with rendering with different contexts to
> the same canvas.

I assume the original spec's paragraphs on vendorname-context and on
returning null for unrecognised contexts should still be included
here.

>
> - Vlad
>

-- 
Philip Taylor
excors@gmail.com

-----------------------------------------------------------
You are currently subscribe to public_webgl@khronos.org.
To unsubscribe, send an email to majordomo@khronos.org with
the following command in the body of your email: