-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Offscreen canvas project
Josh Matthews edited this page Sep 24, 2018
·
6 revisions
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 toresources/prefs.json
- hide the new interfaces by default by adding a
- enable the existing automated tests for this feature by adding the
offscreen-canvas
directory totests/wpt/include.ini
- add a
__dir__.ini
file totests/wpt/metadata/offscreen-canvas
which enables the new preference, then run the tests in that directory and update the expected test results.
- add a
- 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
- create a trait that abstracts away any operation that currently uses
- 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