Skip to content

Offscreen canvas project

Josh Matthews edited this page Sep 24, 2018 · 6 revisions

Implement OffscreenCanvas API

Background information: The HTML specification defines a <canvas> element that can use a 2d or 3d rendering context. A new specification was recently developed that defines a canvas that can be used without being associated with an in-page canvas element, allowing for more efficient rendering.

Tracking issue: https://github.com/servo/servo/issues/14627 (please ask questions here)

Initial steps:

  • email the mozilla.dev.servo mailing list (be sure to subscribe to it first!) introducing your group and asking any necessary questions
  • create the OffscreenCanvas and OffscreenCanvasRenderingContext2d interfaces with stub method implementations
    • hide the new interfaces by default by adding a [Pref="dom.offscreen_canvas.enabled"] attribute to each one and add a corresponding preference to resources/prefs.json
  • enable the existing automated tests for this feature by adding the offscreen-canvas directory to tests/wpt/include.ini
  • implement the OffscreenCanvas constructor that creates a new canvas
  • implement the OffscreenCanvas.getContext ignoring the WebGL requirements, using HTMLCanvasElement.getContext for inspiration

Subsequent steps:

  • extract all relevant canvas operations from CanvasRenderingContext2d into an implementation shared with OffscreenCanvasRenderingContext2d
    • create a trait that abstracts away any operation that currently uses self.canvas in the 2d canvas rendering context, since the offscreen canvas rendering context has no associated <canvas> element
  • implement the convertToBlob API to allow testing the contents of the canvas
  • support offscreen webgl contexts in a similar fashion to the 2d context, by sharing relevant code between OffscreenCanvasRenderingContext2d and WebGLRenderingContext
Clone this wiki locally