A user account is required in order to edit this wiki, but we've had to disable public user registrations due to spam.

To request an account, ask an autoconfirmed user on Chat (such as one of these permanent autoconfirmed members).

WorkerCanvas

From WHATWG Wiki
Revision as of 21:41, 22 October 2013 by Roc (talk | contribs) (Created page with "== WebIDL == [Constructor(unsigned long width, unsigned long height)] interface WorkerCanvas { attribute unsigned long width; attribute unsigned long height; Rende...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

WebIDL

[Constructor(unsigned long width, unsigned long height)]
interface WorkerCanvas {
  attribute unsigned long width;
  attribute unsigned long height;
  RenderingContext? getContext(DOMString contextId, any... arguments); 
  void toBlob(FileCallback? _callback, optional DOMString type, any... arguments);
  ImageBitmap transferToImageBitmap();
};

partial interface RenderingContext {
  void commit();
};

WorkerCanvas implements Transferable;

partial interface HTMLCanvasElement {
  WorkerCanvas transferControlToWorker();
};

partial interface HTMLImageElement {
  attribute (Blob or ImageBitmap)? srcObject;
};

partial interface ImageBitmap {
  void close();
};

Spec changes

Structured clone of ImageBitmaps has to be defined; since they're immutable, it's straightforward. The implementation can share the underlying buffer data across threads. An ImageBitmap can also be implemented as the result of deferred rendering of a list of drawing commands.

transferControlToWorker behaves like transferControlToProxy in the current WHATWG spec. WorkerCanvas is Transferable, but transfer fails if transferred other than from the main thread to a worker. All its methods throw if not called on a worker, or if it's neutered.

HTMLImageElement.srcObject behaves like HTMLMediaElement.srcObject: if non-null, it takes precedence over the "src" attribute and renders the contents of the Blob (as a decoded image) or the ImageBitmap.