CSC/ECE 517 Fall 2017/M1753 OffscreenCanvas API: Difference between revisions
No edit summary |
|||
Line 2: | Line 2: | ||
== '''Background Introduction''' == | == '''Background Introduction''' == | ||
'''Servo[https://github.com/servo/servo]''' is a modern web browser engine designed to maximize the benefits of multi-core-based parallel processing. Written in the Rust language, servo was aimed for the application on Android and ARM processors, but now its applicable scope has expanded to Linux, Mac OS X, Windows, Android and Firefox OS (also known as Gonk) and other operating systems[https://servo.org/]. | '''Servo[https://github.com/servo/servo]''' is a modern web browser engine designed to maximize the benefits of multi-core-based parallel processing. Parallelism is undoubtedly the highlight feature of the servo, besides other characteristics like GPU rendering, embedding, modularity and memory safety are also stressed. Written in the Rust language, servo was aimed for the application on Android and ARM processors, but now its applicable scope has expanded to Linux, Mac OS X, Windows, Android and Firefox OS (also known as Gonk) and other operating systems[https://servo.org/]. | ||
'''Rust[https://en.wikipedia.org/wiki/Rust_(programming_language)]''' is a programming language that emphasizes security, concurrency and | '''Rust[https://en.wikipedia.org/wiki/Rust_(programming_language)]''' is a programming language that emphasizes security, concurrency and speed. The three keywords, safety, control of memory layout, and concurrency are the core features of rust, and also the primary factors that distinguish rust from other programming languages. Rust performs most of its memory management and security checks at compile time, which makes it possible to predict the time and space requirements of the program and be embedded into low-level code , such as device driver and operating system.Rust is developed on GitHub/Git [https://github.com/rust-lang/rust], and every commit to the source code is documented by the version control system. | ||
Revision as of 20:35, 26 October 2017
The HTML specification defines a <canvas> element that use a 2D or 3D rendering context and draw graphics. The biggest limitation of <canvas> is that all of the javascript that manipulates the <canvas> has to run on the main thread, as the applications we build increase in complexity, developers inadvertently hit the performance wall. 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. The OffscreenCanvas API achieves pre-rendering that using a separate off-screen canvas to render temporary image, and then rendering the off-screen canvas back to the main thread.[1][2]
Background Introduction
Servo[3] is a modern web browser engine designed to maximize the benefits of multi-core-based parallel processing. Parallelism is undoubtedly the highlight feature of the servo, besides other characteristics like GPU rendering, embedding, modularity and memory safety are also stressed. Written in the Rust language, servo was aimed for the application on Android and ARM processors, but now its applicable scope has expanded to Linux, Mac OS X, Windows, Android and Firefox OS (also known as Gonk) and other operating systems[4].
Rust[5] is a programming language that emphasizes security, concurrency and speed. The three keywords, safety, control of memory layout, and concurrency are the core features of rust, and also the primary factors that distinguish rust from other programming languages. Rust performs most of its memory management and security checks at compile time, which makes it possible to predict the time and space requirements of the program and be embedded into low-level code , such as device driver and operating system.Rust is developed on GitHub/Git [6], and every commit to the source code is documented by the version control system.
The OffscreenCanvas API supports a canvas to be rendered off screen. The performance of a webpage can be limited by using <canvas> since all of the javascript that manipulates the <canvas> has to run on the main thread, situation is not optimistic when the canvas operations are complex. The OffscreenCanvas API provides a way to interact with the same canvas APIs but in a different thread. This allows rendering to progress no matter what is going on in the main thread [7].
Project Description
Implement the OffscreenCanvas API: Servo has an implementation of the HTML Canvas API. Our project is to implement the OffscreenCanvas API which provides a canvas that can be rendered off screen and is available in both the window and worker contexts.
Steps
- Create the OffscreenCanvas and OffscreenCanvasRenderingContext2d interfaces.
- Hide the new interfaces by default
- Enable the existing automated tests for this feature
- Implement the OffscreenCanvas constructor that creates a new canvas
- Implement the OffscreenCanvas.getContext ignoring the WebGL requirements
Implementation
Create Interfaces
Create the OffscreenCanvas and OffscreenCanvasRenderingContext2d interfaces with stub method implementations.
To add the interfaces, the following steps are to be followed: * adding the new IDL file at components/script/dom/webidls/Foo.webidl; * creating components/script/dom/foo.rs; * listing foo.rs in components/script/dom/mod.rs; * defining the DOM struct Foo with a #[dom_struct] attribute, a superclass or Reflector member, and other members as appropriate; * implementing the dom::bindings::codegen::Bindings::FooBindings::FooMethods trait for Foo; * adding/updating the match arm in create_element in components/script/dom/create.rs (only applicable to new types inheriting from HTMLElement)
Hide newly created interfaces by default: * Add corresponding attribute to the interface file as well as resources/prefs.json
Enable Tests: