User:Roc/WorkerCanvasProposal: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
 
Line 15: Line 15:
   
   
  WorkerCanvas implements Transferable;
  WorkerCanvas implements Transferable;
ImageBitmap implements Transferable;
   
   
  partial interface HTMLCanvasElement {
  partial interface HTMLCanvasElement {
   WorkerCanvas transferControlToWorker();
   WorkerCanvas transferControlToWorker();
};
partial interface HTMLImageElement {
  attribute (Blob or ImageBitmap)? srcObject;
  };
  };
   
   
  partial interface ImageBitmap {
  partial interface ImageBitmap {
  void transferToCanvas((HTMLCanvasElement or WorkerCanvas) canvas);
   void close();
   void close();
  };
  };
Line 30: Line 28:
== Spec changes ==
== 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.
Transferring of ImageBitmaps has to be defined. It should neuter the ImageBitmap in the sending thread. ImageBitmap.close also neuters the ImageBitmap. Neutering should set the ImageBitmap's width and height to 0.


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.
HTMLCanvasElement.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.
ImageBitmap.transferToCanvas replaces the canvas contents with the contents of the ImageBitmap, setting the canvas size to the ImageBitmap's size.
1,295

edits

Navigation menu