<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jsarava</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jsarava"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Jsarava"/>
	<updated>2026-05-09T03:57:29Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:ConvertToBlob.JPG&amp;diff=112393</id>
		<title>File:ConvertToBlob.JPG</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:ConvertToBlob.JPG&amp;diff=112393"/>
		<updated>2017-11-07T20:32:21Z</updated>

		<summary type="html">&lt;p&gt;Jsarava: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Jsarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017&amp;diff=112367</id>
		<title>CSC/ECE 517 Fall 2017</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017&amp;diff=112367"/>
		<updated>2017-11-07T19:29:48Z</updated>

		<summary type="html">&lt;p&gt;Jsarava: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Design Project Documentation'''&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E17A2 Lightweight Badging System]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E17A8. Use a profiler to identify the problems / pages that take some time to load &amp;amp; fix them]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1793. Help students find teams to join]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E17A4 Allow calibration to be part of an assignment]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E17A0 Team-based reviewing]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1793. Help students find teams to join_Team1964]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1791. Track the time that students look at the other submissions - logging improvement]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1799 Improve self-review Link peer review &amp;amp; self-review to derive grades]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1797_Timestamps_for_students_submissions]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E17A1|CSC/ECE_517_Fall_2017/E17A1 - Let experts as well as students do reviews]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/M1753_OffscreenCanvas]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/M1754_Mutation_Testing]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1794. Student-generated questions added to rubric]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E17A6. Fix account creation over web to work reasonably]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1792 OSS Visualizations for instructors]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E17A4 Allow calibration to be part of an assignment_Team34]]&lt;br /&gt;
'''Writing Assignment 2'''&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1779. Fix teammate advertisements and requests to join a team]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1773 Investigate and Fix Expertiza Production Version Runtime Exceptions.rb]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1774 Metareview fixes and improvements.rb]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1788 OSS project Maroon Heatmap fixes]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1781 Topic Management]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1745_Refactor_response_controller.rb]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1752 Refactor assignments controller]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1776_Enhance_Imports]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1756 TLD Refactor response.rb]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1772_Refactor reputation_web_service_controller.rb]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/M1753_OffscreenCanvas API]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/M1754_Mutation Testing on Servo]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1753 OSS project bidding tests]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1766_Test team functionality]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1767 Improve imports]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1786_OSS project Juniper Bookmark Enhancements]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1787_OSS project Bronze Score calculations]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1763 Fix Staggered-Deadline Assignments]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1757 Introduce a Student View for instructors]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1769_Refactor assignment_form.rb]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1754_Feature_test_of_rubric_advice]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1782 OSS Project Red Assignment Directories]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1748 Add past-due assignments to task list]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1761 Test First Development Refactor assignment.rb]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1780_OSS_Project_Teal_Email_Notification_Enhancements]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1762 Test various kinds of response-map hierarchies]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1759 ]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1749_Test First Development Refactor questionnaire_controller.rb]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1777 Coherent specification of review requirements.rb]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1771_Refactor_team.rb]]&lt;/div&gt;</summary>
		<author><name>Jsarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/M1753_OffscreenCanvas&amp;diff=112366</id>
		<title>CSC/ECE 517 Fall 2017/M1753 OffscreenCanvas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/M1753_OffscreenCanvas&amp;diff=112366"/>
		<updated>2017-11-07T19:23:03Z</updated>

		<summary type="html">&lt;p&gt;Jsarava: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The HTML specification defines a &amp;lt;canvas&amp;gt; element that use a 2D or 3D rendering context and to draw graphics. The biggest limitation of &amp;lt;canvas&amp;gt; is that all of the javascript that manipulates the &amp;lt;canvas&amp;gt; has to run on the main thread, as the UI complexity of the application increases, 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.&amp;lt;ref&amp;gt;https://www.html5rocks.com/en/tutorials/canvas/performance/&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Offscreen-canvas-project&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Background Introduction''' ==&lt;br /&gt;
'''[https://github.com/servo/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&amp;lt;ref&amp;gt;https://servo.org/&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''[https://en.wikipedia.org/wiki/Rust_(programming_language) Rust]''' 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 [https://github.com/rust-lang/rust GitHub/Git], and every commit to the source code is documented by the version control system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''The OffscreenCanvas API''' supports a canvas to be rendered off screen. The performance of a webpage can be limited by using &amp;lt;canvas&amp;gt; since all of the javascript that manipulates the &amp;lt;canvas&amp;gt; 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&amp;lt;ref&amp;gt;https://hacks.mozilla.org/2016/01/webgl-off-the-main-thread/&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== '''Project Description''' ==&lt;br /&gt;
'''Implement the OffscreenCanvas API''': Servo has an implementation of the HTML Canvas API, we need to port this API to OffscreenCanvas. This API will provide a canvas that can be rendered off screen and will be available in both the window and worker contexts. The rendering will be done in a separate thread which makes the overall rendering of the webpage quicker.&lt;br /&gt;
&lt;br /&gt;
'''Implement the OffscreenCanvasRenderingContext2D''': Servo has an implementation of the CanvasRendering2D API, we need to port this to OffscreenCanvasRenderingContext2D. This interface will be used for drawing rectangles, text, images and other objects onto the canvas element. It provides the 2D rendering context for the drawing surface of a &amp;lt;canvas&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
'''Steps:'''&lt;br /&gt;
&lt;br /&gt;
# Create the OffscreenCanvas and OffscreenCanvasRenderingContext2d interfaces.&lt;br /&gt;
# Hide the new interfaces by default&lt;br /&gt;
# Enable the existing automated tests for this feature&lt;br /&gt;
# Implement the OffscreenCanvas constructor that creates a new canvas&lt;br /&gt;
# Implement the OffscreenCanvas.getContext ignoring the WebGL requirements&lt;br /&gt;
&lt;br /&gt;
== '''Implementation''' ==&lt;br /&gt;
=== Step 1: Create Interfaces ===&lt;br /&gt;
Create the OffscreenCanvas and OffscreenCanvasRenderingContext2d interfaces with stub method implementations.&lt;br /&gt;
&lt;br /&gt;
To [http://doc.servo.org/script/dom/index.html#adding-a-new-dom-interface create] the interfaces, the following steps are to be followed : &lt;br /&gt;
&lt;br /&gt;
:1. adding the new IDL file at ''components/script/dom/webidls/OffscreenCanvas.webidl''&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/canvas.html#the-offscreencanvas-interface&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/canvas.html#the-offscreen-2d-rendering-context&amp;lt;/ref&amp;gt;; &lt;br /&gt;
 cd servo/components/script/dom/webidls&lt;br /&gt;
&lt;br /&gt;
 touch OffscreenCanvas.webidl&lt;br /&gt;
&lt;br /&gt;
 touch OffscreenCanvasRenderingContext2D.webidl&lt;br /&gt;
&lt;br /&gt;
:2. creating ''components/script/dom/OffscreenCanvas.rs'';&lt;br /&gt;
 cd servo/components/script/dom &lt;br /&gt;
&lt;br /&gt;
 touch offscreencanvas.rs&lt;br /&gt;
&lt;br /&gt;
 touch offscreencanvasrenderingcontext2d.rs&lt;br /&gt;
&lt;br /&gt;
:3. listing ''OffscreenCanvas.rs'' in ''components/script/dom/mod.rs''; &lt;br /&gt;
&lt;br /&gt;
[[File:Createoffscreencanvas.png]]&lt;br /&gt;
&lt;br /&gt;
:4. defining the DOM struct OffscreenCanvas with a ''#[dom_struct]'' attribute, a superclass or Reflector member, and other members as appropriate; &lt;br /&gt;
&lt;br /&gt;
[[File:Definedomstruct.png]]&lt;br /&gt;
&lt;br /&gt;
:5. implementing the ''dom::bindings::codegen::Bindings::OffsceenCanvasBindings::OffscreenCanvasMethods'' trait for OffscreenCanvas;&lt;br /&gt;
&lt;br /&gt;
[[File:Dombindings.png]]&lt;br /&gt;
&lt;br /&gt;
:6. adding/updating the match arm in create_element in ''components/script/dom/create.rs'' (only applicable to new types inheriting from HTMLElement)&lt;br /&gt;
&lt;br /&gt;
===Step 2: Hide newly created interfaces by default ===&lt;br /&gt;
&lt;br /&gt;
:1. Hide the new interfaces by default by adding a ''[Pref=&amp;quot;dom.offscreen_canvas.enabled&amp;quot;]'' attribute to each one and add a corresponding preference to ''resources/prefs.json''&lt;br /&gt;
::* Add the attribute in file ''OffscreenCanvas'' and ''OffscreenCanvasRendering'':&lt;br /&gt;
[[File:Attribute.png]]&lt;br /&gt;
::* Add the corresponding preference in ''prefs.json'':&lt;br /&gt;
[[File:Attribute2.png]]&lt;br /&gt;
&lt;br /&gt;
===Step 3: Enable Tests ===&lt;br /&gt;
:1. Add ''offscreen-canvas'' directory to tests folder.&lt;br /&gt;
 cd servo/tests/wpt/metadata&lt;br /&gt;
&lt;br /&gt;
 mkdir offscreen-canvas&lt;br /&gt;
&lt;br /&gt;
:2. Enable test preference for offscreen-canvas by adding ''__dir__.ini'' file to the newly created directory.&lt;br /&gt;
 cd servo/tests/wpt/metadata/offscreen-canvas&lt;br /&gt;
&lt;br /&gt;
 touch __dir__.ini&lt;br /&gt;
&lt;br /&gt;
:3. Run tests and change expected results&amp;lt;ref&amp;gt;https://github.com/servo/servo/blob/master/tests/wpt/README.md#updating-test-expectations&amp;lt;/ref&amp;gt;.&lt;br /&gt;
[[File:preds.png]]&lt;br /&gt;
&lt;br /&gt;
===Step 4: Implement OffscreenCanvas Constructor===&lt;br /&gt;
Create a new OffscreenCanvas by implementing the following Syntax: &lt;br /&gt;
 var offscreen = new OffscreenCanvas(256, 256);&lt;br /&gt;
&lt;br /&gt;
===Step 5: Implement the getContext() method for OffscreenCanvas element ===&lt;br /&gt;
Implement the ''OffscreenCanvas.getContext'' ignoring the WebGL requirements:&lt;br /&gt;
  canvas.getContext(contextType, contextAttributes);&lt;br /&gt;
&lt;br /&gt;
== '''Testing Details''' ==&lt;br /&gt;
:'''1. Building'''&lt;br /&gt;
&lt;br /&gt;
Servo is built with the Rust package manager, [https://crates.io/ Cargo]. &lt;br /&gt;
&lt;br /&gt;
The following commands are steps to built servo in development mode, please note the resulting binary is very slow.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 git clone https://github.com/jitendra29/servo.git&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 cd servo&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach build --dev&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:'''2. Testing'''&lt;br /&gt;
&lt;br /&gt;
Servo provides automated tests, adding the &amp;lt;code&amp;gt;--release&amp;lt;/code&amp;gt; flag to create an optimized build:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach build --release&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach run --release tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Notes''': &lt;br /&gt;
#We have not added any new tests to the test suite as servo follows TDD and tests were previously written for OffscreenCanvas. We are adjusting some of the test expectations for the tests to pass our implementation.&lt;br /&gt;
#Our project cannot be tested from UI since it is basically improving some javascript features (OffsereenCanvas) in servo. However you can check that it doesn't break the existing code and the browser runs correctly by running a test page on servo after performing the build as mentioned above.&lt;br /&gt;
&lt;br /&gt;
== '''Design Pattern''' ==&lt;br /&gt;
Design patterns are not applicable as our task is involved in extracting all the relevant canvas operation from already existing file and implementing a new API.&lt;br /&gt;
&lt;br /&gt;
== '''Pull Request''' ==&lt;br /&gt;
Here is our [https://github.com/servo/servo/pull/19067 pull request]. In the link you can see all code snippets changed due to implementing the above steps, as well as integration test progression information.&lt;br /&gt;
&lt;br /&gt;
== '''Future Work''' ==&lt;br /&gt;
#Extract all relevant canvas operations from CanvasRenderingContext2d into an implementation shared with OffscreenCanvasRenderingContext2d&lt;br /&gt;
#*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 &amp;lt;canvas&amp;gt; element&lt;br /&gt;
#Implement the convertToBlob API to allow testing the contents of the canvas&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/canvas.html#dom-offscreencanvas-converttoblob&amp;lt;/ref&amp;gt;&lt;br /&gt;
#Support offscreen webgl contexts in a similar fashion to the 2d context, by sharing relevant code between OffscreenCanvasRenderingContext2d and WebGLRenderingContext&lt;br /&gt;
&lt;br /&gt;
== '''References''' ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jsarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/M1753_OffscreenCanvas&amp;diff=112365</id>
		<title>CSC/ECE 517 Fall 2017/M1753 OffscreenCanvas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/M1753_OffscreenCanvas&amp;diff=112365"/>
		<updated>2017-11-07T19:21:38Z</updated>

		<summary type="html">&lt;p&gt;Jsarava: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The HTML specification defines a &amp;lt;canvas&amp;gt; element that use a 2D or 3D rendering context and to draw graphics. The biggest limitation of &amp;lt;canvas&amp;gt; is that all of the javascript that manipulates the &amp;lt;canvas&amp;gt; has to run on the main thread, as the UI complexity of the application increases, 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.&amp;lt;ref&amp;gt;https://www.html5rocks.com/en/tutorials/canvas/performance/]&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;[https://github.com/servo/servo/wiki/Offscreen-canvas-project&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Background Introduction''' ==&lt;br /&gt;
'''[https://github.com/servo/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&amp;lt;ref&amp;gt;https://servo.org/&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''[https://en.wikipedia.org/wiki/Rust_(programming_language) Rust]''' 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 [https://github.com/rust-lang/rust GitHub/Git], and every commit to the source code is documented by the version control system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''The OffscreenCanvas API''' supports a canvas to be rendered off screen. The performance of a webpage can be limited by using &amp;lt;canvas&amp;gt; since all of the javascript that manipulates the &amp;lt;canvas&amp;gt; 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&amp;lt;ref&amp;gt;https://hacks.mozilla.org/2016/01/webgl-off-the-main-thread/&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== '''Project Description''' ==&lt;br /&gt;
'''Implement the OffscreenCanvas API''': Servo has an implementation of the HTML Canvas API, we need to port this API to OffscreenCanvas. This API will provide a canvas that can be rendered off screen and will be available in both the window and worker contexts. The rendering will be done in a separate thread which makes the overall rendering of the webpage quicker.&lt;br /&gt;
&lt;br /&gt;
'''Implement the OffscreenCanvasRenderingContext2D''': Servo has an implementation of the CanvasRendering2D API, we need to port this to OffscreenCanvasRenderingContext2D. This interface will be used for drawing rectangles, text, images and other objects onto the canvas element. It provides the 2D rendering context for the drawing surface of a &amp;lt;canvas&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
'''Steps:'''&lt;br /&gt;
&lt;br /&gt;
# Create the OffscreenCanvas and OffscreenCanvasRenderingContext2d interfaces.&lt;br /&gt;
# Hide the new interfaces by default&lt;br /&gt;
# Enable the existing automated tests for this feature&lt;br /&gt;
# Implement the OffscreenCanvas constructor that creates a new canvas&lt;br /&gt;
# Implement the OffscreenCanvas.getContext ignoring the WebGL requirements&lt;br /&gt;
&lt;br /&gt;
== '''Implementation''' ==&lt;br /&gt;
=== Step 1: Create Interfaces ===&lt;br /&gt;
Create the OffscreenCanvas and OffscreenCanvasRenderingContext2d interfaces with stub method implementations.&lt;br /&gt;
&lt;br /&gt;
To [http://doc.servo.org/script/dom/index.html#adding-a-new-dom-interface create] the interfaces, the following steps are to be followed : &lt;br /&gt;
&lt;br /&gt;
:1. adding the new IDL file at ''components/script/dom/webidls/OffscreenCanvas.webidl''&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/canvas.html#the-offscreencanvas-interface&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/canvas.html#the-offscreen-2d-rendering-context&amp;lt;/ref&amp;gt;; &lt;br /&gt;
 cd servo/components/script/dom/webidls&lt;br /&gt;
&lt;br /&gt;
 touch OffscreenCanvas.webidl&lt;br /&gt;
&lt;br /&gt;
 touch OffscreenCanvasRenderingContext2D.webidl&lt;br /&gt;
&lt;br /&gt;
:2. creating ''components/script/dom/OffscreenCanvas.rs'';&lt;br /&gt;
 cd servo/components/script/dom &lt;br /&gt;
&lt;br /&gt;
 touch offscreencanvas.rs&lt;br /&gt;
&lt;br /&gt;
 touch offscreencanvasrenderingcontext2d.rs&lt;br /&gt;
&lt;br /&gt;
:3. listing ''OffscreenCanvas.rs'' in ''components/script/dom/mod.rs''; &lt;br /&gt;
&lt;br /&gt;
[[File:Createoffscreencanvas.png]]&lt;br /&gt;
&lt;br /&gt;
:4. defining the DOM struct OffscreenCanvas with a ''#[dom_struct]'' attribute, a superclass or Reflector member, and other members as appropriate; &lt;br /&gt;
&lt;br /&gt;
[[File:Definedomstruct.png]]&lt;br /&gt;
&lt;br /&gt;
:5. implementing the ''dom::bindings::codegen::Bindings::OffsceenCanvasBindings::OffscreenCanvasMethods'' trait for OffscreenCanvas;&lt;br /&gt;
&lt;br /&gt;
[[File:Dombindings.png]]&lt;br /&gt;
&lt;br /&gt;
:6. adding/updating the match arm in create_element in ''components/script/dom/create.rs'' (only applicable to new types inheriting from HTMLElement)&lt;br /&gt;
&lt;br /&gt;
===Step 2: Hide newly created interfaces by default ===&lt;br /&gt;
&lt;br /&gt;
:1. Hide the new interfaces by default by adding a ''[Pref=&amp;quot;dom.offscreen_canvas.enabled&amp;quot;]'' attribute to each one and add a corresponding preference to ''resources/prefs.json''&lt;br /&gt;
::* Add the attribute in file ''OffscreenCanvas'' and ''OffscreenCanvasRendering'':&lt;br /&gt;
[[File:Attribute.png]]&lt;br /&gt;
::* Add the corresponding preference in ''prefs.json'':&lt;br /&gt;
[[File:Attribute2.png]]&lt;br /&gt;
&lt;br /&gt;
===Step 3: Enable Tests ===&lt;br /&gt;
:1. Add ''offscreen-canvas'' directory to tests folder.&lt;br /&gt;
 cd servo/tests/wpt/metadata&lt;br /&gt;
&lt;br /&gt;
 mkdir offscreen-canvas&lt;br /&gt;
&lt;br /&gt;
:2. Enable test preference for offscreen-canvas by adding ''__dir__.ini'' file to the newly created directory.&lt;br /&gt;
 cd servo/tests/wpt/metadata/offscreen-canvas&lt;br /&gt;
&lt;br /&gt;
 touch __dir__.ini&lt;br /&gt;
&lt;br /&gt;
:3. Run tests and change expected results&amp;lt;ref&amp;gt;https://github.com/servo/servo/blob/master/tests/wpt/README.md#updating-test-expectations&amp;lt;/ref&amp;gt;.&lt;br /&gt;
[[File:preds.png]]&lt;br /&gt;
&lt;br /&gt;
===Step 4: Implement OffscreenCanvas Constructor===&lt;br /&gt;
Create a new OffscreenCanvas by implementing the following Syntax: &lt;br /&gt;
 var offscreen = new OffscreenCanvas(256, 256);&lt;br /&gt;
&lt;br /&gt;
===Step 5: Implement the getContext() method for OffscreenCanvas element ===&lt;br /&gt;
Implement the ''OffscreenCanvas.getContext'' ignoring the WebGL requirements:&lt;br /&gt;
  canvas.getContext(contextType, contextAttributes);&lt;br /&gt;
&lt;br /&gt;
== '''Testing Details''' ==&lt;br /&gt;
:'''1. Building'''&lt;br /&gt;
&lt;br /&gt;
Servo is built with the Rust package manager, [https://crates.io/ Cargo]. &lt;br /&gt;
&lt;br /&gt;
The following commands are steps to built servo in development mode, please note the resulting binary is very slow.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 git clone https://github.com/jitendra29/servo.git&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 cd servo&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach build --dev&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:'''2. Testing'''&lt;br /&gt;
&lt;br /&gt;
Servo provides automated tests, adding the &amp;lt;code&amp;gt;--release&amp;lt;/code&amp;gt; flag to create an optimized build:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach build --release&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach run --release tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Notes''': &lt;br /&gt;
#We have not added any new tests to the test suite as servo follows TDD and tests were previously written for OffscreenCanvas. We are adjusting some of the test expectations for the tests to pass our implementation.&lt;br /&gt;
#Our project cannot be tested from UI since it is basically improving some javascript features (OffsereenCanvas) in servo. However you can check that it doesn't break the existing code and the browser runs correctly by running a test page on servo after performing the build as mentioned above.&lt;br /&gt;
&lt;br /&gt;
== '''Design Pattern''' ==&lt;br /&gt;
Design patterns are not applicable as our task is involved in extracting all the relevant canvas operation from already existing file and implementing a new API.&lt;br /&gt;
&lt;br /&gt;
== '''Pull Request''' ==&lt;br /&gt;
Here is our [https://github.com/servo/servo/pull/19067 pull request]. In the link you can see all code snippets changed due to implementing the above steps, as well as integration test progression information.&lt;br /&gt;
&lt;br /&gt;
== '''Future Work''' ==&lt;br /&gt;
#Extract all relevant canvas operations from CanvasRenderingContext2d into an implementation shared with OffscreenCanvasRenderingContext2d&lt;br /&gt;
#*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 &amp;lt;canvas&amp;gt; element&lt;br /&gt;
#Implement the convertToBlob API to allow testing the contents of the canvas&amp;lt;ref&amp;gt;[https://html.spec.whatwg.org/multipage/canvas.html#dom-offscreencanvas-converttoblob]&amp;lt;/ref&amp;gt;&lt;br /&gt;
#Support offscreen webgl contexts in a similar fashion to the 2d context, by sharing relevant code between OffscreenCanvasRenderingContext2d and WebGLRenderingContext&lt;br /&gt;
&lt;br /&gt;
== '''References''' ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jsarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/M1753_OffscreenCanvas&amp;diff=112364</id>
		<title>CSC/ECE 517 Fall 2017/M1753 OffscreenCanvas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/M1753_OffscreenCanvas&amp;diff=112364"/>
		<updated>2017-11-07T19:20:21Z</updated>

		<summary type="html">&lt;p&gt;Jsarava: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The HTML specification defines a &amp;lt;canvas&amp;gt; element that use a 2D or 3D rendering context and to draw graphics. The biggest limitation of &amp;lt;canvas&amp;gt; is that all of the javascript that manipulates the &amp;lt;canvas&amp;gt; has to run on the main thread, as the UI complexity of the application increases, 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.&amp;lt;ref&amp;gt;https://www.html5rocks.com/en/tutorials/canvas/performance/]&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;[https://github.com/servo/servo/wiki/Offscreen-canvas-project&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Background Introduction''' ==&lt;br /&gt;
'''[https://github.com/servo/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&amp;lt;ref&amp;gt;https://servo.org/&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''[https://en.wikipedia.org/wiki/Rust_(programming_language) Rust]''' 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 [https://github.com/rust-lang/rust GitHub/Git], and every commit to the source code is documented by the version control system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''The OffscreenCanvas API''' supports a canvas to be rendered off screen. The performance of a webpage can be limited by using &amp;lt;canvas&amp;gt; since all of the javascript that manipulates the &amp;lt;canvas&amp;gt; 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&amp;lt;ref&amp;gt;https://hacks.mozilla.org/2016/01/webgl-off-the-main-thread/&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== '''Project Description''' ==&lt;br /&gt;
'''Implement the OffscreenCanvas API''': Servo has an implementation of the HTML Canvas API, we need to port this API to OffscreenCanvas. This API will provide a canvas that can be rendered off screen and will be available in both the window and worker contexts. The rendering will be done in a separate thread which makes the overall rendering of the webpage quicker.&lt;br /&gt;
&lt;br /&gt;
'''Implement the OffscreenCanvasRenderingContext2D''': Servo has an implementation of the CanvasRendering2D API, we need to port this to OffscreenCanvasRenderingContext2D. This interface will be used for drawing rectangles, text, images and other objects onto the canvas element. It provides the 2D rendering context for the drawing surface of a &amp;lt;canvas&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
'''Steps:'''&lt;br /&gt;
&lt;br /&gt;
# Create the OffscreenCanvas and OffscreenCanvasRenderingContext2d interfaces.&lt;br /&gt;
# Hide the new interfaces by default&lt;br /&gt;
# Enable the existing automated tests for this feature&lt;br /&gt;
# Implement the OffscreenCanvas constructor that creates a new canvas&lt;br /&gt;
# Implement the OffscreenCanvas.getContext ignoring the WebGL requirements&lt;br /&gt;
&lt;br /&gt;
== '''Implementation''' ==&lt;br /&gt;
=== Step 1: Create Interfaces ===&lt;br /&gt;
Create the OffscreenCanvas and OffscreenCanvasRenderingContext2d interfaces with stub method implementations.&lt;br /&gt;
&lt;br /&gt;
To [http://doc.servo.org/script/dom/index.html#adding-a-new-dom-interface create] the interfaces, the following steps are to be followed : &lt;br /&gt;
&lt;br /&gt;
:1. adding the new IDL file at ''components/script/dom/webidls/OffscreenCanvas.webidl''&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/canvas.html#the-offscreencanvas-interface&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/canvas.html#the-offscreen-2d-rendering-context&amp;lt;/ref&amp;gt;; &lt;br /&gt;
 cd servo/components/script/dom/webidls&lt;br /&gt;
&lt;br /&gt;
 touch OffscreenCanvas.webidl&lt;br /&gt;
&lt;br /&gt;
 touch OffscreenCanvasRenderingContext2D.webidl&lt;br /&gt;
&lt;br /&gt;
:2. creating ''components/script/dom/OffscreenCanvas.rs'';&lt;br /&gt;
 cd servo/components/script/dom &lt;br /&gt;
&lt;br /&gt;
 touch offscreencanvas.rs&lt;br /&gt;
&lt;br /&gt;
 touch offscreencanvasrenderingcontext2d.rs&lt;br /&gt;
&lt;br /&gt;
:3. listing ''OffscreenCanvas.rs'' in ''components/script/dom/mod.rs''; &lt;br /&gt;
&lt;br /&gt;
[[File:Createoffscreencanvas.png]]&lt;br /&gt;
&lt;br /&gt;
:4. defining the DOM struct OffscreenCanvas with a ''#[dom_struct]'' attribute, a superclass or Reflector member, and other members as appropriate; &lt;br /&gt;
&lt;br /&gt;
[[File:Definedomstruct.png]]&lt;br /&gt;
&lt;br /&gt;
:5. implementing the ''dom::bindings::codegen::Bindings::OffsceenCanvasBindings::OffscreenCanvasMethods'' trait for OffscreenCanvas;&lt;br /&gt;
&lt;br /&gt;
[[File:Dombindings.png]]&lt;br /&gt;
&lt;br /&gt;
:6. adding/updating the match arm in create_element in ''components/script/dom/create.rs'' (only applicable to new types inheriting from HTMLElement)&lt;br /&gt;
&lt;br /&gt;
===Step 2: Hide newly created interfaces by default ===&lt;br /&gt;
&lt;br /&gt;
:1. Hide the new interfaces by default by adding a ''[Pref=&amp;quot;dom.offscreen_canvas.enabled&amp;quot;]'' attribute to each one and add a corresponding preference to ''resources/prefs.json''&lt;br /&gt;
::* Add the attribute in file ''OffscreenCanvas'' and ''OffscreenCanvasRendering'':&lt;br /&gt;
[[File:Attribute.png]]&lt;br /&gt;
::* Add the corresponding preference in ''prefs.json'':&lt;br /&gt;
[[File:Attribute2.png]]&lt;br /&gt;
&lt;br /&gt;
===Step 3: Enable Tests ===&lt;br /&gt;
:1. Add ''offscreen-canvas'' directory to tests folder.&lt;br /&gt;
 cd servo/tests/wpt/metadata&lt;br /&gt;
&lt;br /&gt;
 mkdir offscreen-canvas&lt;br /&gt;
&lt;br /&gt;
:2. Enable test preference for offscreen-canvas by adding ''__dir__.ini'' file to the newly created directory.&lt;br /&gt;
 cd servo/tests/wpt/metadata/offscreen-canvas&lt;br /&gt;
&lt;br /&gt;
 touch __dir__.ini&lt;br /&gt;
&lt;br /&gt;
:3. Run tests and change expected results&amp;lt;ref&amp;gt;https://github.com/servo/servo/blob/master/tests/wpt/README.md#updating-test-expectations&amp;lt;/ref&amp;gt;.&lt;br /&gt;
[[File:preds.png]]&lt;br /&gt;
&lt;br /&gt;
===Step 4: Implement OffscreenCanvas Constructor===&lt;br /&gt;
Create a new OffscreenCanvas by implementing the following Syntax: &lt;br /&gt;
 var offscreen = new OffscreenCanvas(256, 256);&lt;br /&gt;
&lt;br /&gt;
===Step 5: Implement the getContext() method for OffscreenCanvas element ===&lt;br /&gt;
Implement the ''OffscreenCanvas.getContext'' ignoring the WebGL requirements:&lt;br /&gt;
  canvas.getContext(contextType, contextAttributes);&lt;br /&gt;
&lt;br /&gt;
== '''Testing Details''' ==&lt;br /&gt;
:'''1. Building'''&lt;br /&gt;
&lt;br /&gt;
Servo is built with the Rust package manager, [https://crates.io/ Cargo]. &lt;br /&gt;
&lt;br /&gt;
The following commands are steps to built servo in development mode, please note the resulting binary is very slow.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 git clone https://github.com/jitendra29/servo.git&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 cd servo&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach build --dev&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:'''2. Testing'''&lt;br /&gt;
&lt;br /&gt;
Servo provides automated tests, adding the &amp;lt;code&amp;gt;--release&amp;lt;/code&amp;gt; flag to create an optimized build:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach build --release&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach run --release tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Notes''': &lt;br /&gt;
#We have not added any new tests to the test suite as servo follows TDD and tests were previously written for OffscreenCanvas. We are adjusting some of the test expectations for the tests to pass our implementation.&lt;br /&gt;
#Our project cannot be tested from UI since it is basically improving some javascript features (OffsereenCanvas) in servo. However you can check that it doesn't break the existing code and the browser runs correctly by running a test page on servo after performing the build as mentioned above.&lt;br /&gt;
&lt;br /&gt;
== '''Design Pattern''' ==&lt;br /&gt;
Design patterns are not applicable as our task is involved in extracting all the relevant canvas operation from already existing file and implementing a new API.&lt;br /&gt;
&lt;br /&gt;
== '''Pull Request''' ==&lt;br /&gt;
Here is our [https://github.com/servo/servo/pull/19067 pull request]. In the link you can see all code snippets changed due to implementing the above steps, as well as integration test progression information.&lt;br /&gt;
&lt;br /&gt;
== '''Future Work''' ==&lt;br /&gt;
#Extract all relevant canvas operations from CanvasRenderingContext2d into an implementation shared with OffscreenCanvasRenderingContext2d&lt;br /&gt;
#*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 &amp;lt;canvas&amp;gt; element&lt;br /&gt;
#Implement the convertToBlob API to allow testing the contents of the canvas&lt;br /&gt;
#Support offscreen webgl contexts in a similar fashion to the 2d context, by sharing relevant code between OffscreenCanvasRenderingContext2d and WebGLRenderingContext&lt;br /&gt;
&lt;br /&gt;
== '''References''' ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# https://html.spec.whatwg.org/multipage/canvas.html#dom-offscreencanvas-converttoblob&amp;lt;br&amp;gt;&lt;br /&gt;
# https://www.html5rocks.com/en/tutorials/canvas/performance/][https://github.com/servo/servo/wiki/Offscreen-canvas-project&amp;lt;br&amp;gt;&lt;br /&gt;
# https://servo.org/&amp;lt;br&amp;gt;&lt;br /&gt;
# https://hacks.mozilla.org/2016/01/webgl-off-the-main-thread/&amp;lt;br&amp;gt;&lt;br /&gt;
# https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas&amp;lt;br&amp;gt;&lt;br /&gt;
# https://html.spec.whatwg.org/multipage/canvas.html#the-offscreencanvas-interface&amp;lt;br&amp;gt;&lt;br /&gt;
# https://html.spec.whatwg.org/multipage/canvas.html#the-offscreen-2d-rendering-context&amp;lt;br&amp;gt;&lt;br /&gt;
# https://github.com/servo/servo/blob/master/tests/wpt/README.md#updating-test-expectations&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jsarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/M1753_OffscreenCanvas&amp;diff=112363</id>
		<title>CSC/ECE 517 Fall 2017/M1753 OffscreenCanvas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/M1753_OffscreenCanvas&amp;diff=112363"/>
		<updated>2017-11-07T19:18:34Z</updated>

		<summary type="html">&lt;p&gt;Jsarava: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The HTML specification defines a &amp;lt;canvas&amp;gt; element that use a 2D or 3D rendering context and to draw graphics. The biggest limitation of &amp;lt;canvas&amp;gt; is that all of the javascript that manipulates the &amp;lt;canvas&amp;gt; has to run on the main thread, as the UI complexity of the application increases, 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.&amp;lt;ref&amp;gt;https://www.html5rocks.com/en/tutorials/canvas/performance/][https://github.com/servo/servo/wiki/Offscreen-canvas-project&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Background Introduction''' ==&lt;br /&gt;
'''[https://github.com/servo/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&amp;lt;ref&amp;gt;https://servo.org/&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''[https://en.wikipedia.org/wiki/Rust_(programming_language) Rust]''' 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 [https://github.com/rust-lang/rust GitHub/Git], and every commit to the source code is documented by the version control system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''The OffscreenCanvas API''' supports a canvas to be rendered off screen. The performance of a webpage can be limited by using &amp;lt;canvas&amp;gt; since all of the javascript that manipulates the &amp;lt;canvas&amp;gt; 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&amp;lt;ref&amp;gt;https://hacks.mozilla.org/2016/01/webgl-off-the-main-thread/&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== '''Project Description''' ==&lt;br /&gt;
'''Implement the OffscreenCanvas API''': Servo has an implementation of the HTML Canvas API, we need to port this API to OffscreenCanvas. This API will provide a canvas that can be rendered off screen and will be available in both the window and worker contexts. The rendering will be done in a separate thread which makes the overall rendering of the webpage quicker.&lt;br /&gt;
&lt;br /&gt;
'''Implement the OffscreenCanvasRenderingContext2D''': Servo has an implementation of the CanvasRendering2D API, we need to port this to OffscreenCanvasRenderingContext2D. This interface will be used for drawing rectangles, text, images and other objects onto the canvas element. It provides the 2D rendering context for the drawing surface of a &amp;lt;canvas&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
'''Steps:'''&lt;br /&gt;
&lt;br /&gt;
# Create the OffscreenCanvas and OffscreenCanvasRenderingContext2d interfaces.&lt;br /&gt;
# Hide the new interfaces by default&lt;br /&gt;
# Enable the existing automated tests for this feature&lt;br /&gt;
# Implement the OffscreenCanvas constructor that creates a new canvas&lt;br /&gt;
# Implement the OffscreenCanvas.getContext ignoring the WebGL requirements&lt;br /&gt;
&lt;br /&gt;
== '''Implementation''' ==&lt;br /&gt;
=== Step 1: Create Interfaces ===&lt;br /&gt;
Create the OffscreenCanvas and OffscreenCanvasRenderingContext2d interfaces with stub method implementations.&lt;br /&gt;
&lt;br /&gt;
To [http://doc.servo.org/script/dom/index.html#adding-a-new-dom-interface create] the interfaces, the following steps are to be followed : &lt;br /&gt;
&lt;br /&gt;
:1. adding the new IDL file at ''components/script/dom/webidls/OffscreenCanvas.webidl''&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/canvas.html#the-offscreencanvas-interface&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/canvas.html#the-offscreen-2d-rendering-context&amp;lt;/ref&amp;gt;; &lt;br /&gt;
 cd servo/components/script/dom/webidls&lt;br /&gt;
&lt;br /&gt;
 touch OffscreenCanvas.webidl&lt;br /&gt;
&lt;br /&gt;
 touch OffscreenCanvasRenderingContext2D.webidl&lt;br /&gt;
&lt;br /&gt;
:2. creating ''components/script/dom/OffscreenCanvas.rs'';&lt;br /&gt;
 cd servo/components/script/dom &lt;br /&gt;
&lt;br /&gt;
 touch offscreencanvas.rs&lt;br /&gt;
&lt;br /&gt;
 touch offscreencanvasrenderingcontext2d.rs&lt;br /&gt;
&lt;br /&gt;
:3. listing ''OffscreenCanvas.rs'' in ''components/script/dom/mod.rs''; &lt;br /&gt;
&lt;br /&gt;
[[File:Createoffscreencanvas.png]]&lt;br /&gt;
&lt;br /&gt;
:4. defining the DOM struct OffscreenCanvas with a ''#[dom_struct]'' attribute, a superclass or Reflector member, and other members as appropriate; &lt;br /&gt;
&lt;br /&gt;
[[File:Definedomstruct.png]]&lt;br /&gt;
&lt;br /&gt;
:5. implementing the ''dom::bindings::codegen::Bindings::OffsceenCanvasBindings::OffscreenCanvasMethods'' trait for OffscreenCanvas;&lt;br /&gt;
&lt;br /&gt;
[[File:Dombindings.png]]&lt;br /&gt;
&lt;br /&gt;
:6. adding/updating the match arm in create_element in ''components/script/dom/create.rs'' (only applicable to new types inheriting from HTMLElement)&lt;br /&gt;
&lt;br /&gt;
===Step 2: Hide newly created interfaces by default ===&lt;br /&gt;
&lt;br /&gt;
:1. Hide the new interfaces by default by adding a ''[Pref=&amp;quot;dom.offscreen_canvas.enabled&amp;quot;]'' attribute to each one and add a corresponding preference to ''resources/prefs.json''&lt;br /&gt;
::* Add the attribute in file ''OffscreenCanvas'' and ''OffscreenCanvasRendering'':&lt;br /&gt;
[[File:Attribute.png]]&lt;br /&gt;
::* Add the corresponding preference in ''prefs.json'':&lt;br /&gt;
[[File:Attribute2.png]]&lt;br /&gt;
&lt;br /&gt;
===Step 3: Enable Tests ===&lt;br /&gt;
:1. Add ''offscreen-canvas'' directory to tests folder.&lt;br /&gt;
 cd servo/tests/wpt/metadata&lt;br /&gt;
&lt;br /&gt;
 mkdir offscreen-canvas&lt;br /&gt;
&lt;br /&gt;
:2. Enable test preference for offscreen-canvas by adding ''__dir__.ini'' file to the newly created directory.&lt;br /&gt;
 cd servo/tests/wpt/metadata/offscreen-canvas&lt;br /&gt;
&lt;br /&gt;
 touch __dir__.ini&lt;br /&gt;
&lt;br /&gt;
:3. Run tests and change expected results&amp;lt;ref&amp;gt;https://github.com/servo/servo/blob/master/tests/wpt/README.md#updating-test-expectations&amp;lt;/ref&amp;gt;.&lt;br /&gt;
[[File:preds.png]]&lt;br /&gt;
&lt;br /&gt;
===Step 4: Implement OffscreenCanvas Constructor===&lt;br /&gt;
Create a new OffscreenCanvas by implementing the following Syntax: &lt;br /&gt;
 var offscreen = new OffscreenCanvas(256, 256);&lt;br /&gt;
&lt;br /&gt;
===Step 5: Implement the getContext() method for OffscreenCanvas element ===&lt;br /&gt;
Implement the ''OffscreenCanvas.getContext'' ignoring the WebGL requirements:&lt;br /&gt;
  canvas.getContext(contextType, contextAttributes);&lt;br /&gt;
&lt;br /&gt;
== '''Testing Details''' ==&lt;br /&gt;
:'''1. Building'''&lt;br /&gt;
&lt;br /&gt;
Servo is built with the Rust package manager, [https://crates.io/ Cargo]. &lt;br /&gt;
&lt;br /&gt;
The following commands are steps to built servo in development mode, please note the resulting binary is very slow.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 git clone https://github.com/jitendra29/servo.git&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 cd servo&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach build --dev&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:'''2. Testing'''&lt;br /&gt;
&lt;br /&gt;
Servo provides automated tests, adding the &amp;lt;code&amp;gt;--release&amp;lt;/code&amp;gt; flag to create an optimized build:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach build --release&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach run --release tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Notes''': &lt;br /&gt;
#We have not added any new tests to the test suite as servo follows TDD and tests were previously written for OffscreenCanvas. We are adjusting some of the test expectations for the tests to pass our implementation.&lt;br /&gt;
#Our project cannot be tested from UI since it is basically improving some javascript features (OffsereenCanvas) in servo. However you can check that it doesn't break the existing code and the browser runs correctly by running a test page on servo after performing the build as mentioned above.&lt;br /&gt;
&lt;br /&gt;
== '''Design Pattern''' ==&lt;br /&gt;
Design patterns are not applicable as our task is involved in extracting all the relevant canvas operation from already existing file and implementing a new API.&lt;br /&gt;
&lt;br /&gt;
== '''Pull Request''' ==&lt;br /&gt;
Here is our [https://github.com/servo/servo/pull/19067 pull request]. In the link you can see all code snippets changed due to implementing the above steps, as well as integration test progression information.&lt;br /&gt;
&lt;br /&gt;
== '''Future Work''' ==&lt;br /&gt;
#Extract all relevant canvas operations from CanvasRenderingContext2d into an implementation shared with OffscreenCanvasRenderingContext2d&lt;br /&gt;
#*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 &amp;lt;canvas&amp;gt; element&lt;br /&gt;
#Implement the convertToBlob API to allow testing the contents of the canvas&lt;br /&gt;
#Support offscreen webgl contexts in a similar fashion to the 2d context, by sharing relevant code between OffscreenCanvasRenderingContext2d and WebGLRenderingContext&lt;br /&gt;
&lt;br /&gt;
== '''References''' ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# https://html.spec.whatwg.org/multipage/canvas.html#dom-offscreencanvas-converttoblob&amp;lt;br&amp;gt;&lt;br /&gt;
# https://www.html5rocks.com/en/tutorials/canvas/performance/][https://github.com/servo/servo/wiki/Offscreen-canvas-project&amp;lt;br&amp;gt;&lt;br /&gt;
# https://servo.org/&amp;lt;br&amp;gt;&lt;br /&gt;
# https://hacks.mozilla.org/2016/01/webgl-off-the-main-thread/&amp;lt;br&amp;gt;&lt;br /&gt;
# https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas&amp;lt;br&amp;gt;&lt;br /&gt;
# https://html.spec.whatwg.org/multipage/canvas.html#the-offscreencanvas-interface&amp;lt;br&amp;gt;&lt;br /&gt;
# https://html.spec.whatwg.org/multipage/canvas.html#the-offscreen-2d-rendering-context&amp;lt;br&amp;gt;&lt;br /&gt;
# https://github.com/servo/servo/blob/master/tests/wpt/README.md#updating-test-expectations&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jsarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/M1753_OffscreenCanvas&amp;diff=112362</id>
		<title>CSC/ECE 517 Fall 2017/M1753 OffscreenCanvas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/M1753_OffscreenCanvas&amp;diff=112362"/>
		<updated>2017-11-07T19:18:05Z</updated>

		<summary type="html">&lt;p&gt;Jsarava: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The HTML specification defines a &amp;lt;canvas&amp;gt; element that use a 2D or 3D rendering context and to draw graphics. The biggest limitation of &amp;lt;canvas&amp;gt; is that all of the javascript that manipulates the &amp;lt;canvas&amp;gt; has to run on the main thread, as the UI complexity of the application increases, 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.&amp;lt;ref&amp;gt;https://www.html5rocks.com/en/tutorials/canvas/performance/][https://github.com/servo/servo/wiki/Offscreen-canvas-project&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Background Introduction''' ==&lt;br /&gt;
'''[https://github.com/servo/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&amp;lt;ref&amp;gt;https://servo.org/&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''[https://en.wikipedia.org/wiki/Rust_(programming_language) Rust]''' 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 [https://github.com/rust-lang/rust GitHub/Git], and every commit to the source code is documented by the version control system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''The OffscreenCanvas API''' supports a canvas to be rendered off screen. The performance of a webpage can be limited by using &amp;lt;canvas&amp;gt; since all of the javascript that manipulates the &amp;lt;canvas&amp;gt; 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&amp;lt;ref&amp;gt;https://hacks.mozilla.org/2016/01/webgl-off-the-main-thread/&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== '''Project Description''' ==&lt;br /&gt;
'''Implement the OffscreenCanvas API''': Servo has an implementation of the HTML Canvas API, we need to port this API to OffscreenCanvas. This API will provide a canvas that can be rendered off screen and will be available in both the window and worker contexts. The rendering will be done in a separate thread which makes the overall rendering of the webpage quicker.&lt;br /&gt;
&lt;br /&gt;
'''Implement the OffscreenCanvasRenderingContext2D''': Servo has an implementation of the CanvasRendering2D API, we need to port this to OffscreenCanvasRenderingContext2D. This interface will be used for drawing rectangles, text, images and other objects onto the canvas element. It provides the 2D rendering context for the drawing surface of a &amp;lt;canvas&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
'''Steps:'''&lt;br /&gt;
&lt;br /&gt;
# Create the OffscreenCanvas and OffscreenCanvasRenderingContext2d interfaces.&lt;br /&gt;
# Hide the new interfaces by default&lt;br /&gt;
# Enable the existing automated tests for this feature&lt;br /&gt;
# Implement the OffscreenCanvas constructor that creates a new canvas&lt;br /&gt;
# Implement the OffscreenCanvas.getContext ignoring the WebGL requirements&lt;br /&gt;
&lt;br /&gt;
== '''Implementation''' ==&lt;br /&gt;
=== Step 1: Create Interfaces ===&lt;br /&gt;
Create the OffscreenCanvas and OffscreenCanvasRenderingContext2d interfaces with stub method implementations.&lt;br /&gt;
&lt;br /&gt;
To [http://doc.servo.org/script/dom/index.html#adding-a-new-dom-interface create] the interfaces, the following steps are to be followed : &lt;br /&gt;
&lt;br /&gt;
:1. adding the new IDL file at ''components/script/dom/webidls/OffscreenCanvas.webidl''&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/canvas.html#the-offscreencanvas-interface&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/canvas.html#the-offscreen-2d-rendering-context&amp;lt;/ref&amp;gt;; &lt;br /&gt;
 cd servo/components/script/dom/webidls&lt;br /&gt;
&lt;br /&gt;
 touch OffscreenCanvas.webidl&lt;br /&gt;
&lt;br /&gt;
 touch OffscreenCanvasRenderingContext2D.webidl&lt;br /&gt;
&lt;br /&gt;
:2. creating ''components/script/dom/OffscreenCanvas.rs'';&lt;br /&gt;
 cd servo/components/script/dom &lt;br /&gt;
&lt;br /&gt;
 touch offscreencanvas.rs&lt;br /&gt;
&lt;br /&gt;
 touch offscreencanvasrenderingcontext2d.rs&lt;br /&gt;
&lt;br /&gt;
:3. listing ''OffscreenCanvas.rs'' in ''components/script/dom/mod.rs''; &lt;br /&gt;
&lt;br /&gt;
[[File:Createoffscreencanvas.png]]&lt;br /&gt;
&lt;br /&gt;
:4. defining the DOM struct OffscreenCanvas with a ''#[dom_struct]'' attribute, a superclass or Reflector member, and other members as appropriate; &lt;br /&gt;
&lt;br /&gt;
[[File:Definedomstruct.png]]&lt;br /&gt;
&lt;br /&gt;
:5. implementing the ''dom::bindings::codegen::Bindings::OffsceenCanvasBindings::OffscreenCanvasMethods'' trait for OffscreenCanvas;&lt;br /&gt;
&lt;br /&gt;
[[File:Dombindings.png]]&lt;br /&gt;
&lt;br /&gt;
:6. adding/updating the match arm in create_element in ''components/script/dom/create.rs'' (only applicable to new types inheriting from HTMLElement)&lt;br /&gt;
&lt;br /&gt;
===Step 2: Hide newly created interfaces by default ===&lt;br /&gt;
&lt;br /&gt;
:1. Hide the new interfaces by default by adding a ''[Pref=&amp;quot;dom.offscreen_canvas.enabled&amp;quot;]'' attribute to each one and add a corresponding preference to ''resources/prefs.json''&lt;br /&gt;
::* Add the attribute in file ''OffscreenCanvas'' and ''OffscreenCanvasRendering'':&lt;br /&gt;
[[File:Attribute.png]]&lt;br /&gt;
::* Add the corresponding preference in ''prefs.json'':&lt;br /&gt;
[[File:Attribute2.png]]&lt;br /&gt;
&lt;br /&gt;
===Step 3: Enable Tests ===&lt;br /&gt;
:1. Add ''offscreen-canvas'' directory to tests folder.&lt;br /&gt;
 cd servo/tests/wpt/metadata&lt;br /&gt;
&lt;br /&gt;
 mkdir offscreen-canvas&lt;br /&gt;
&lt;br /&gt;
:2. Enable test preference for offscreen-canvas by adding ''__dir__.ini'' file to the newly created directory.&lt;br /&gt;
 cd servo/tests/wpt/metadata/offscreen-canvas&lt;br /&gt;
&lt;br /&gt;
 touch __dir__.ini&lt;br /&gt;
&lt;br /&gt;
:3. Run tests and change expected results&amp;lt;ref&amp;gt;https://github.com/servo/servo/blob/master/tests/wpt/README.md#updating-test-expectations&amp;lt;/ref&amp;gt;.&lt;br /&gt;
[[File:preds.png]]&lt;br /&gt;
&lt;br /&gt;
===Step 4: Implement OffscreenCanvas Constructor===&lt;br /&gt;
Create a new OffscreenCanvas by implementing the following Syntax: &lt;br /&gt;
 var offscreen = new OffscreenCanvas(256, 256);&lt;br /&gt;
&lt;br /&gt;
===Step 5: Implement the getContext() method for OffscreenCanvas element ===&lt;br /&gt;
Implement the ''OffscreenCanvas.getContext'' ignoring the WebGL requirements:&lt;br /&gt;
  canvas.getContext(contextType, contextAttributes);&lt;br /&gt;
&lt;br /&gt;
== '''Testing Details''' ==&lt;br /&gt;
:'''1. Building'''&lt;br /&gt;
&lt;br /&gt;
Servo is built with the Rust package manager, [https://crates.io/ Cargo]. &lt;br /&gt;
&lt;br /&gt;
The following commands are steps to built servo in development mode, please note the resulting binary is very slow.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 git clone https://github.com/jitendra29/servo.git&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 cd servo&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach build --dev&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:'''2. Testing'''&lt;br /&gt;
&lt;br /&gt;
Servo provides automated tests, adding the &amp;lt;code&amp;gt;--release&amp;lt;/code&amp;gt; flag to create an optimized build:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach build --release&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach run --release tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Notes''': &lt;br /&gt;
#We have not added any new tests to the test suite as servo follows TDD and tests were previously written for OffscreenCanvas. We are adjusting some of the test expectations for the tests to pass our implementation.&lt;br /&gt;
#Our project cannot be tested from UI since it is basically improving some javascript features (OffsereenCanvas) in servo. However you can check that it doesn't break the existing code and the browser runs correctly by running a test page on servo after performing the build as mentioned above.&lt;br /&gt;
&lt;br /&gt;
== '''Design Pattern''' ==&lt;br /&gt;
Design patterns are not applicable as our task is involved in extracting all the relevant canvas operation from already existing file and implementing a new API.&lt;br /&gt;
&lt;br /&gt;
== '''Pull Request''' ==&lt;br /&gt;
Here is our [https://github.com/servo/servo/pull/19067 pull request]. In the link you can see all code snippets changed due to implementing the above steps, as well as integration test progression information.&lt;br /&gt;
&lt;br /&gt;
== '''Future Work''' ==&lt;br /&gt;
#Extract all relevant canvas operations from CanvasRenderingContext2d into an implementation shared with OffscreenCanvasRenderingContext2d&lt;br /&gt;
#*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 &amp;lt;canvas&amp;gt; element&lt;br /&gt;
#Implement the convertToBlob API to allow testing the contents of the canvas&lt;br /&gt;
#Support offscreen webgl contexts in a similar fashion to the 2d context, by sharing relevant code between OffscreenCanvasRenderingContext2d and WebGLRenderingContext&lt;br /&gt;
&lt;br /&gt;
== '''References''' ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# https://html.spec.whatwg.org/multipage/canvas.html#dom-offscreencanvas-converttoblob&amp;lt;br&amp;gt;&lt;br /&gt;
# https://www.html5rocks.com/en/tutorials/canvas/performance/][https://github.com/servo/servo/wiki/Offscreen-canvas-project&amp;lt;br&amp;gt;&lt;br /&gt;
# https://servo.org/&amp;lt;br&amp;gt;&lt;br /&gt;
# https://hacks.mozilla.org/2016/01/webgl-off-the-main-thread/&amp;lt;br&amp;gt;&lt;br /&gt;
# https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas&amp;lt;br&amp;gt;&lt;br /&gt;
# https://html.spec.whatwg.org/multipage/canvas.html#the-offscreencanvas-interface&amp;lt;br&amp;gt;&lt;br /&gt;
# https://html.spec.whatwg.org/multipage/canvas.html#the-offscreen-2d-rendering-context&amp;lt;br&amp;gt;&lt;br /&gt;
# https://github.com/servo/servo/blob/master/tests/wpt/README.md#updating-test-expectations&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jsarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/M1753_OffscreenCanvas&amp;diff=112361</id>
		<title>CSC/ECE 517 Fall 2017/M1753 OffscreenCanvas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/M1753_OffscreenCanvas&amp;diff=112361"/>
		<updated>2017-11-07T19:17:20Z</updated>

		<summary type="html">&lt;p&gt;Jsarava: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The HTML specification defines a &amp;lt;canvas&amp;gt; element that use a 2D or 3D rendering context and to draw graphics. The biggest limitation of &amp;lt;canvas&amp;gt; is that all of the javascript that manipulates the &amp;lt;canvas&amp;gt; has to run on the main thread, as the UI complexity of the application increases, 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.&amp;lt;ref&amp;gt;https://www.html5rocks.com/en/tutorials/canvas/performance/][https://github.com/servo/servo/wiki/Offscreen-canvas-project&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Background Introduction''' ==&lt;br /&gt;
'''[https://github.com/servo/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&amp;lt;ref&amp;gt;https://servo.org/&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''[https://en.wikipedia.org/wiki/Rust_(programming_language) Rust]''' 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 [https://github.com/rust-lang/rust GitHub/Git], and every commit to the source code is documented by the version control system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''The OffscreenCanvas API''' supports a canvas to be rendered off screen. The performance of a webpage can be limited by using &amp;lt;canvas&amp;gt; since all of the javascript that manipulates the &amp;lt;canvas&amp;gt; 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&amp;lt;ref&amp;gt;https://hacks.mozilla.org/2016/01/webgl-off-the-main-thread/&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== '''Project Description''' ==&lt;br /&gt;
'''Implement the OffscreenCanvas API''': Servo has an implementation of the HTML Canvas API, we need to port this API to OffscreenCanvas. This API will provide a canvas that can be rendered off screen and will be available in both the window and worker contexts. The rendering will be done in a separate thread which makes the overall rendering of the webpage quicker.&lt;br /&gt;
&lt;br /&gt;
'''Implement the OffscreenCanvasRenderingContext2D''': Servo has an implementation of the CanvasRendering2D API, we need to port this to OffscreenCanvasRenderingContext2D. This interface will be used for drawing rectangles, text, images and other objects onto the canvas element. It provides the 2D rendering context for the drawing surface of a &amp;lt;canvas&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
'''Steps:'''&lt;br /&gt;
&lt;br /&gt;
# Create the OffscreenCanvas and OffscreenCanvasRenderingContext2d interfaces.&lt;br /&gt;
# Hide the new interfaces by default&lt;br /&gt;
# Enable the existing automated tests for this feature&lt;br /&gt;
# Implement the OffscreenCanvas constructor that creates a new canvas&lt;br /&gt;
# Implement the OffscreenCanvas.getContext ignoring the WebGL requirements&lt;br /&gt;
&lt;br /&gt;
== '''Implementation''' ==&lt;br /&gt;
=== Step 1: Create Interfaces ===&lt;br /&gt;
Create the OffscreenCanvas and OffscreenCanvasRenderingContext2d interfaces with stub method implementations.&lt;br /&gt;
&lt;br /&gt;
To [http://doc.servo.org/script/dom/index.html#adding-a-new-dom-interface create] the interfaces, the following steps are to be followed : &lt;br /&gt;
&lt;br /&gt;
:1. adding the new IDL file at ''components/script/dom/webidls/OffscreenCanvas.webidl''&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/canvas.html#the-offscreencanvas-interface&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/canvas.html#the-offscreen-2d-rendering-context&amp;lt;/ref&amp;gt;; &lt;br /&gt;
 cd servo/components/script/dom/webidls&lt;br /&gt;
&lt;br /&gt;
 touch OffscreenCanvas.webidl&lt;br /&gt;
&lt;br /&gt;
 touch OffscreenCanvasRenderingContext2D.webidl&lt;br /&gt;
&lt;br /&gt;
:2. creating ''components/script/dom/OffscreenCanvas.rs'';&lt;br /&gt;
 cd servo/components/script/dom &lt;br /&gt;
&lt;br /&gt;
 touch offscreencanvas.rs&lt;br /&gt;
&lt;br /&gt;
 touch offscreencanvasrenderingcontext2d.rs&lt;br /&gt;
&lt;br /&gt;
:3. listing ''OffscreenCanvas.rs'' in ''components/script/dom/mod.rs''; &lt;br /&gt;
&lt;br /&gt;
[[File:Createoffscreencanvas.png]]&lt;br /&gt;
&lt;br /&gt;
:4. defining the DOM struct OffscreenCanvas with a ''#[dom_struct]'' attribute, a superclass or Reflector member, and other members as appropriate; &lt;br /&gt;
&lt;br /&gt;
[[File:Definedomstruct.png]]&lt;br /&gt;
&lt;br /&gt;
:5. implementing the ''dom::bindings::codegen::Bindings::OffsceenCanvasBindings::OffscreenCanvasMethods'' trait for OffscreenCanvas;&lt;br /&gt;
&lt;br /&gt;
[[File:Dombindings.png]]&lt;br /&gt;
&lt;br /&gt;
:6. adding/updating the match arm in create_element in ''components/script/dom/create.rs'' (only applicable to new types inheriting from HTMLElement)&lt;br /&gt;
&lt;br /&gt;
===Step 2: Hide newly created interfaces by default ===&lt;br /&gt;
&lt;br /&gt;
:1. Hide the new interfaces by default by adding a ''[Pref=&amp;quot;dom.offscreen_canvas.enabled&amp;quot;]'' attribute to each one and add a corresponding preference to ''resources/prefs.json''&lt;br /&gt;
::* Add the attribute in file ''OffscreenCanvas'' and ''OffscreenCanvasRendering'':&lt;br /&gt;
[[File:Attribute.png]]&lt;br /&gt;
::* Add the corresponding preference in ''prefs.json'':&lt;br /&gt;
[[File:Attribute2.png]]&lt;br /&gt;
&lt;br /&gt;
===Step 3: Enable Tests ===&lt;br /&gt;
:1. Add ''offscreen-canvas'' directory to tests folder.&lt;br /&gt;
 cd servo/tests/wpt/metadata&lt;br /&gt;
&lt;br /&gt;
 mkdir offscreen-canvas&lt;br /&gt;
&lt;br /&gt;
:2. Enable test preference for offscreen-canvas by adding ''__dir__.ini'' file to the newly created directory.&lt;br /&gt;
 cd servo/tests/wpt/metadata/offscreen-canvas&lt;br /&gt;
&lt;br /&gt;
 touch __dir__.ini&lt;br /&gt;
&lt;br /&gt;
:3. Run tests and change expected results&amp;lt;ref&amp;gt;https://github.com/servo/servo/blob/master/tests/wpt/README.md#updating-test-expectations&amp;lt;/ref&amp;gt;.&lt;br /&gt;
[[File:preds.png]]&lt;br /&gt;
&lt;br /&gt;
===Step 4: Implement OffscreenCanvas Constructor===&lt;br /&gt;
Create a new OffscreenCanvas by implementing the following Syntax: &lt;br /&gt;
 var offscreen = new OffscreenCanvas(256, 256);&lt;br /&gt;
&lt;br /&gt;
===Step 5: Implement the getContext() method for OffscreenCanvas element ===&lt;br /&gt;
Implement the ''OffscreenCanvas.getContext'' ignoring the WebGL requirements:&lt;br /&gt;
  canvas.getContext(contextType, contextAttributes);&lt;br /&gt;
&lt;br /&gt;
== '''Testing Details''' ==&lt;br /&gt;
:'''1. Building'''&lt;br /&gt;
&lt;br /&gt;
Servo is built with the Rust package manager, [https://crates.io/ Cargo]. &lt;br /&gt;
&lt;br /&gt;
The following commands are steps to built servo in development mode, please note the resulting binary is very slow.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 git clone https://github.com/jitendra29/servo.git&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 cd servo&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach build --dev&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:'''2. Testing'''&lt;br /&gt;
&lt;br /&gt;
Servo provides automated tests, adding the &amp;lt;code&amp;gt;--release&amp;lt;/code&amp;gt; flag to create an optimized build:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach build --release&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach run --release tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Notes''': &lt;br /&gt;
#We have not added any new tests to the test suite as servo follows TDD and tests were previously written for OffscreenCanvas. We are adjusting some of the test expectations for the tests to pass our implementation.&lt;br /&gt;
#Our project cannot be tested from UI since it is basically improving some javascript features (OffsereenCanvas) in servo. However you can check that it doesn't break the existing code and the browser runs correctly by running a test page on servo after performing the build as mentioned above.&lt;br /&gt;
&lt;br /&gt;
== '''Design Pattern''' ==&lt;br /&gt;
Design patterns are not applicable as our task is involved in extracting all the relevant canvas operation from already existing file and implementing a new API.&lt;br /&gt;
&lt;br /&gt;
== '''Pull Request''' ==&lt;br /&gt;
Here is our [https://github.com/servo/servo/pull/19067 pull request]. In the link you can see all code snippets changed due to implementing the above steps, as well as integration test progression information.&lt;br /&gt;
&lt;br /&gt;
== '''Future Work''' ==&lt;br /&gt;
#Extract all relevant canvas operations from CanvasRenderingContext2d into an implementation shared with OffscreenCanvasRenderingContext2d&lt;br /&gt;
#*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 &amp;lt;canvas&amp;gt; element&lt;br /&gt;
#Implement the convertToBlob API to allow testing the contents of the canvas&lt;br /&gt;
#Support offscreen webgl contexts in a similar fashion to the 2d context, by sharing relevant code between OffscreenCanvasRenderingContext2d and WebGLRenderingContext&lt;br /&gt;
&lt;br /&gt;
== '''References''' ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# https://html.spec.whatwg.org/multipage/canvas.html&amp;lt;br&amp;gt;&lt;br /&gt;
# dom-offscreencanvas-converttoblob&amp;lt;br&amp;gt;&lt;br /&gt;
# https://www.html5rocks.com/en/tutorials/canvas/performance/][https://github.com/servo/servo/wiki/Offscreen-canvas-project&amp;lt;br&amp;gt;&lt;br /&gt;
# https://servo.org/&amp;lt;br&amp;gt;&lt;br /&gt;
# https://hacks.mozilla.org/2016/01/webgl-off-the-main-thread/&amp;lt;br&amp;gt;&lt;br /&gt;
# https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas&amp;lt;br&amp;gt;&lt;br /&gt;
# https://html.spec.whatwg.org/multipage/canvas.html#the-offscreencanvas-interface&amp;lt;br&amp;gt;&lt;br /&gt;
# https://html.spec.whatwg.org/multipage/canvas.html#the-offscreen-2d-rendering-context&amp;lt;br&amp;gt;&lt;br /&gt;
# https://github.com/servo/servo/blob/master/tests/wpt/README.md#updating-test-expectations&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jsarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/M1753_OffscreenCanvas&amp;diff=112360</id>
		<title>CSC/ECE 517 Fall 2017/M1753 OffscreenCanvas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/M1753_OffscreenCanvas&amp;diff=112360"/>
		<updated>2017-11-07T19:16:55Z</updated>

		<summary type="html">&lt;p&gt;Jsarava: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The HTML specification defines a &amp;lt;canvas&amp;gt; element that use a 2D or 3D rendering context and to draw graphics. The biggest limitation of &amp;lt;canvas&amp;gt; is that all of the javascript that manipulates the &amp;lt;canvas&amp;gt; has to run on the main thread, as the UI complexity of the application increases, 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.&amp;lt;ref&amp;gt;https://www.html5rocks.com/en/tutorials/canvas/performance/][https://github.com/servo/servo/wiki/Offscreen-canvas-project&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Background Introduction''' ==&lt;br /&gt;
'''[https://github.com/servo/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&amp;lt;ref&amp;gt;https://servo.org/&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''[https://en.wikipedia.org/wiki/Rust_(programming_language) Rust]''' 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 [https://github.com/rust-lang/rust GitHub/Git], and every commit to the source code is documented by the version control system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''The OffscreenCanvas API''' supports a canvas to be rendered off screen. The performance of a webpage can be limited by using &amp;lt;canvas&amp;gt; since all of the javascript that manipulates the &amp;lt;canvas&amp;gt; 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&amp;lt;ref&amp;gt;https://hacks.mozilla.org/2016/01/webgl-off-the-main-thread/&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== '''Project Description''' ==&lt;br /&gt;
'''Implement the OffscreenCanvas API''': Servo has an implementation of the HTML Canvas API, we need to port this API to OffscreenCanvas. This API will provide a canvas that can be rendered off screen and will be available in both the window and worker contexts. The rendering will be done in a separate thread which makes the overall rendering of the webpage quicker.&lt;br /&gt;
&lt;br /&gt;
'''Implement the OffscreenCanvasRenderingContext2D''': Servo has an implementation of the CanvasRendering2D API, we need to port this to OffscreenCanvasRenderingContext2D. This interface will be used for drawing rectangles, text, images and other objects onto the canvas element. It provides the 2D rendering context for the drawing surface of a &amp;lt;canvas&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
'''Steps:'''&lt;br /&gt;
&lt;br /&gt;
# Create the OffscreenCanvas and OffscreenCanvasRenderingContext2d interfaces.&lt;br /&gt;
# Hide the new interfaces by default&lt;br /&gt;
# Enable the existing automated tests for this feature&lt;br /&gt;
# Implement the OffscreenCanvas constructor that creates a new canvas&lt;br /&gt;
# Implement the OffscreenCanvas.getContext ignoring the WebGL requirements&lt;br /&gt;
&lt;br /&gt;
== '''Implementation''' ==&lt;br /&gt;
=== Step 1: Create Interfaces ===&lt;br /&gt;
Create the OffscreenCanvas and OffscreenCanvasRenderingContext2d interfaces with stub method implementations.&lt;br /&gt;
&lt;br /&gt;
To [http://doc.servo.org/script/dom/index.html#adding-a-new-dom-interface create] the interfaces, the following steps are to be followed : &lt;br /&gt;
&lt;br /&gt;
:1. adding the new IDL file at ''components/script/dom/webidls/OffscreenCanvas.webidl''&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/canvas.html#the-offscreencanvas-interface&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/canvas.html#the-offscreen-2d-rendering-context&amp;lt;/ref&amp;gt;; &lt;br /&gt;
 cd servo/components/script/dom/webidls&lt;br /&gt;
&lt;br /&gt;
 touch OffscreenCanvas.webidl&lt;br /&gt;
&lt;br /&gt;
 touch OffscreenCanvasRenderingContext2D.webidl&lt;br /&gt;
&lt;br /&gt;
:2. creating ''components/script/dom/OffscreenCanvas.rs'';&lt;br /&gt;
 cd servo/components/script/dom &lt;br /&gt;
&lt;br /&gt;
 touch offscreencanvas.rs&lt;br /&gt;
&lt;br /&gt;
 touch offscreencanvasrenderingcontext2d.rs&lt;br /&gt;
&lt;br /&gt;
:3. listing ''OffscreenCanvas.rs'' in ''components/script/dom/mod.rs''; &lt;br /&gt;
&lt;br /&gt;
[[File:Createoffscreencanvas.png]]&lt;br /&gt;
&lt;br /&gt;
:4. defining the DOM struct OffscreenCanvas with a ''#[dom_struct]'' attribute, a superclass or Reflector member, and other members as appropriate; &lt;br /&gt;
&lt;br /&gt;
[[File:Definedomstruct.png]]&lt;br /&gt;
&lt;br /&gt;
:5. implementing the ''dom::bindings::codegen::Bindings::OffsceenCanvasBindings::OffscreenCanvasMethods'' trait for OffscreenCanvas;&lt;br /&gt;
&lt;br /&gt;
[[File:Dombindings.png]]&lt;br /&gt;
&lt;br /&gt;
:6. adding/updating the match arm in create_element in ''components/script/dom/create.rs'' (only applicable to new types inheriting from HTMLElement)&lt;br /&gt;
&lt;br /&gt;
===Step 2: Hide newly created interfaces by default ===&lt;br /&gt;
&lt;br /&gt;
:1. Hide the new interfaces by default by adding a ''[Pref=&amp;quot;dom.offscreen_canvas.enabled&amp;quot;]'' attribute to each one and add a corresponding preference to ''resources/prefs.json''&lt;br /&gt;
::* Add the attribute in file ''OffscreenCanvas'' and ''OffscreenCanvasRendering'':&lt;br /&gt;
[[File:Attribute.png]]&lt;br /&gt;
::* Add the corresponding preference in ''prefs.json'':&lt;br /&gt;
[[File:Attribute2.png]]&lt;br /&gt;
&lt;br /&gt;
===Step 3: Enable Tests ===&lt;br /&gt;
:1. Add ''offscreen-canvas'' directory to tests folder.&lt;br /&gt;
 cd servo/tests/wpt/metadata&lt;br /&gt;
&lt;br /&gt;
 mkdir offscreen-canvas&lt;br /&gt;
&lt;br /&gt;
:2. Enable test preference for offscreen-canvas by adding ''__dir__.ini'' file to the newly created directory.&lt;br /&gt;
 cd servo/tests/wpt/metadata/offscreen-canvas&lt;br /&gt;
&lt;br /&gt;
 touch __dir__.ini&lt;br /&gt;
&lt;br /&gt;
:3. Run tests and change expected results&amp;lt;ref&amp;gt;https://github.com/servo/servo/blob/master/tests/wpt/README.md#updating-test-expectations&amp;lt;/ref&amp;gt;.&lt;br /&gt;
[[File:preds.png]]&lt;br /&gt;
&lt;br /&gt;
===Step 4: Implement OffscreenCanvas Constructor===&lt;br /&gt;
Create a new OffscreenCanvas by implementing the following Syntax: &lt;br /&gt;
 var offscreen = new OffscreenCanvas(256, 256);&lt;br /&gt;
&lt;br /&gt;
===Step 5: Implement the getContext() method for OffscreenCanvas element ===&lt;br /&gt;
Implement the ''OffscreenCanvas.getContext'' ignoring the WebGL requirements:&lt;br /&gt;
  canvas.getContext(contextType, contextAttributes);&lt;br /&gt;
&lt;br /&gt;
== '''Testing Details''' ==&lt;br /&gt;
:'''1. Building'''&lt;br /&gt;
&lt;br /&gt;
Servo is built with the Rust package manager, [https://crates.io/ Cargo]. &lt;br /&gt;
&lt;br /&gt;
The following commands are steps to built servo in development mode, please note the resulting binary is very slow.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 git clone https://github.com/jitendra29/servo.git&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 cd servo&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach build --dev&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:'''2. Testing'''&lt;br /&gt;
&lt;br /&gt;
Servo provides automated tests, adding the &amp;lt;code&amp;gt;--release&amp;lt;/code&amp;gt; flag to create an optimized build:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach build --release&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach run --release tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Notes''': &lt;br /&gt;
#We have not added any new tests to the test suite as servo follows TDD and tests were previously written for OffscreenCanvas. We are adjusting some of the test expectations for the tests to pass our implementation.&lt;br /&gt;
#Our project cannot be tested from UI since it is basically improving some javascript features (OffsereenCanvas) in servo. However you can check that it doesn't break the existing code and the browser runs correctly by running a test page on servo after performing the build as mentioned above.&lt;br /&gt;
&lt;br /&gt;
== '''Design Pattern''' ==&lt;br /&gt;
Design patterns are not applicable as our task is involved in extracting all the relevant canvas operation from already existing file and implementing a new API.&lt;br /&gt;
&lt;br /&gt;
== '''Pull Request''' ==&lt;br /&gt;
Here is our [https://github.com/servo/servo/pull/19067 pull request]. In the link you can see all code snippets changed due to implementing the above steps, as well as integration test progression information.&lt;br /&gt;
&lt;br /&gt;
== '''Future Work''' ==&lt;br /&gt;
#Extract all relevant canvas operations from CanvasRenderingContext2d into an implementation shared with OffscreenCanvasRenderingContext2d&lt;br /&gt;
#*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 &amp;lt;canvas&amp;gt; element&lt;br /&gt;
#Implement the convertToBlob API to allow testing the contents of the canvas&lt;br /&gt;
#Support offscreen webgl contexts in a similar fashion to the 2d context, by sharing relevant code between OffscreenCanvasRenderingContext2d and WebGLRenderingContext&lt;br /&gt;
&lt;br /&gt;
== '''References''' ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
# https://html.spec.whatwg.org/multipage/canvas.html&amp;lt;br&amp;gt;&lt;br /&gt;
# dom-offscreencanvas-converttoblob&amp;lt;br&amp;gt;&lt;br /&gt;
# https://www.html5rocks.com/en/tutorials/canvas/performance/][https://github.com/servo/servo/wiki/Offscreen-canvas-project&amp;lt;br&amp;gt;&lt;br /&gt;
# https://servo.org/&amp;lt;br&amp;gt;&lt;br /&gt;
# https://hacks.mozilla.org/2016/01/webgl-off-the-main-thread/&amp;lt;br&amp;gt;&lt;br /&gt;
# https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas&amp;lt;br&amp;gt;&lt;br /&gt;
# https://html.spec.whatwg.org/multipage/canvas.html#the-offscreencanvas-interface&amp;lt;br&amp;gt;&lt;br /&gt;
# https://html.spec.whatwg.org/multipage/canvas.html#the-offscreen-2d-rendering-context&amp;lt;br&amp;gt;&lt;br /&gt;
# https://github.com/servo/servo/blob/master/tests/wpt/README.md#updating-test-expectations&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jsarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/M1753_OffscreenCanvas&amp;diff=112359</id>
		<title>CSC/ECE 517 Fall 2017/M1753 OffscreenCanvas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/M1753_OffscreenCanvas&amp;diff=112359"/>
		<updated>2017-11-07T19:14:16Z</updated>

		<summary type="html">&lt;p&gt;Jsarava: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The HTML specification defines a &amp;lt;canvas&amp;gt; element that use a 2D or 3D rendering context and to draw graphics. The biggest limitation of &amp;lt;canvas&amp;gt; is that all of the javascript that manipulates the &amp;lt;canvas&amp;gt; has to run on the main thread, as the UI complexity of the application increases, 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.&amp;lt;ref&amp;gt;https://www.html5rocks.com/en/tutorials/canvas/performance/][https://github.com/servo/servo/wiki/Offscreen-canvas-project&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Background Introduction''' ==&lt;br /&gt;
'''[https://github.com/servo/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&amp;lt;ref&amp;gt;https://servo.org/&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''[https://en.wikipedia.org/wiki/Rust_(programming_language) Rust]''' 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 [https://github.com/rust-lang/rust GitHub/Git], and every commit to the source code is documented by the version control system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''The OffscreenCanvas API''' supports a canvas to be rendered off screen. The performance of a webpage can be limited by using &amp;lt;canvas&amp;gt; since all of the javascript that manipulates the &amp;lt;canvas&amp;gt; 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&amp;lt;ref&amp;gt;https://hacks.mozilla.org/2016/01/webgl-off-the-main-thread/&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== '''Project Description''' ==&lt;br /&gt;
'''Implement the OffscreenCanvas API''': Servo has an implementation of the HTML Canvas API, we need to port this API to OffscreenCanvas. This API will provide a canvas that can be rendered off screen and will be available in both the window and worker contexts. The rendering will be done in a separate thread which makes the overall rendering of the webpage quicker.&lt;br /&gt;
&lt;br /&gt;
'''Implement the OffscreenCanvasRenderingContext2D''': Servo has an implementation of the CanvasRendering2D API, we need to port this to OffscreenCanvasRenderingContext2D. This interface will be used for drawing rectangles, text, images and other objects onto the canvas element. It provides the 2D rendering context for the drawing surface of a &amp;lt;canvas&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
'''Steps:'''&lt;br /&gt;
&lt;br /&gt;
# Create the OffscreenCanvas and OffscreenCanvasRenderingContext2d interfaces.&lt;br /&gt;
# Hide the new interfaces by default&lt;br /&gt;
# Enable the existing automated tests for this feature&lt;br /&gt;
# Implement the OffscreenCanvas constructor that creates a new canvas&lt;br /&gt;
# Implement the OffscreenCanvas.getContext ignoring the WebGL requirements&lt;br /&gt;
&lt;br /&gt;
== '''Implementation''' ==&lt;br /&gt;
=== Step 1: Create Interfaces ===&lt;br /&gt;
Create the OffscreenCanvas and OffscreenCanvasRenderingContext2d interfaces with stub method implementations.&lt;br /&gt;
&lt;br /&gt;
To [http://doc.servo.org/script/dom/index.html#adding-a-new-dom-interface create] the interfaces, the following steps are to be followed : &lt;br /&gt;
&lt;br /&gt;
:1. adding the new IDL file at ''components/script/dom/webidls/OffscreenCanvas.webidl''&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/canvas.html#the-offscreencanvas-interface&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/canvas.html#the-offscreen-2d-rendering-context&amp;lt;/ref&amp;gt;; &lt;br /&gt;
 cd servo/components/script/dom/webidls&lt;br /&gt;
&lt;br /&gt;
 touch OffscreenCanvas.webidl&lt;br /&gt;
&lt;br /&gt;
 touch OffscreenCanvasRenderingContext2D.webidl&lt;br /&gt;
&lt;br /&gt;
:2. creating ''components/script/dom/OffscreenCanvas.rs'';&lt;br /&gt;
 cd servo/components/script/dom &lt;br /&gt;
&lt;br /&gt;
 touch offscreencanvas.rs&lt;br /&gt;
&lt;br /&gt;
 touch offscreencanvasrenderingcontext2d.rs&lt;br /&gt;
&lt;br /&gt;
:3. listing ''OffscreenCanvas.rs'' in ''components/script/dom/mod.rs''; &lt;br /&gt;
&lt;br /&gt;
[[File:Createoffscreencanvas.png]]&lt;br /&gt;
&lt;br /&gt;
:4. defining the DOM struct OffscreenCanvas with a ''#[dom_struct]'' attribute, a superclass or Reflector member, and other members as appropriate; &lt;br /&gt;
&lt;br /&gt;
[[File:Definedomstruct.png]]&lt;br /&gt;
&lt;br /&gt;
:5. implementing the ''dom::bindings::codegen::Bindings::OffsceenCanvasBindings::OffscreenCanvasMethods'' trait for OffscreenCanvas;&lt;br /&gt;
&lt;br /&gt;
[[File:Dombindings.png]]&lt;br /&gt;
&lt;br /&gt;
:6. adding/updating the match arm in create_element in ''components/script/dom/create.rs'' (only applicable to new types inheriting from HTMLElement)&lt;br /&gt;
&lt;br /&gt;
===Step 2: Hide newly created interfaces by default ===&lt;br /&gt;
&lt;br /&gt;
:1. Hide the new interfaces by default by adding a ''[Pref=&amp;quot;dom.offscreen_canvas.enabled&amp;quot;]'' attribute to each one and add a corresponding preference to ''resources/prefs.json''&lt;br /&gt;
::* Add the attribute in file ''OffscreenCanvas'' and ''OffscreenCanvasRendering'':&lt;br /&gt;
[[File:Attribute.png]]&lt;br /&gt;
::* Add the corresponding preference in ''prefs.json'':&lt;br /&gt;
[[File:Attribute2.png]]&lt;br /&gt;
&lt;br /&gt;
===Step 3: Enable Tests ===&lt;br /&gt;
:1. Add ''offscreen-canvas'' directory to tests folder.&lt;br /&gt;
 cd servo/tests/wpt/metadata&lt;br /&gt;
&lt;br /&gt;
 mkdir offscreen-canvas&lt;br /&gt;
&lt;br /&gt;
:2. Enable test preference for offscreen-canvas by adding ''__dir__.ini'' file to the newly created directory.&lt;br /&gt;
 cd servo/tests/wpt/metadata/offscreen-canvas&lt;br /&gt;
&lt;br /&gt;
 touch __dir__.ini&lt;br /&gt;
&lt;br /&gt;
:3. Run tests and change expected results&amp;lt;ref&amp;gt;https://github.com/servo/servo/blob/master/tests/wpt/README.md#updating-test-expectations&amp;lt;/ref&amp;gt;.&lt;br /&gt;
[[File:preds.png]]&lt;br /&gt;
&lt;br /&gt;
===Step 4: Implement OffscreenCanvas Constructor===&lt;br /&gt;
Create a new OffscreenCanvas by implementing the following Syntax: &lt;br /&gt;
 var offscreen = new OffscreenCanvas(256, 256);&lt;br /&gt;
&lt;br /&gt;
===Step 5: Implement the getContext() method for OffscreenCanvas element ===&lt;br /&gt;
Implement the ''OffscreenCanvas.getContext'' ignoring the WebGL requirements:&lt;br /&gt;
  canvas.getContext(contextType, contextAttributes);&lt;br /&gt;
&lt;br /&gt;
== '''Testing Details''' ==&lt;br /&gt;
:'''1. Building'''&lt;br /&gt;
&lt;br /&gt;
Servo is built with the Rust package manager, [https://crates.io/ Cargo]. &lt;br /&gt;
&lt;br /&gt;
The following commands are steps to built servo in development mode, please note the resulting binary is very slow.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 git clone https://github.com/jitendra29/servo.git&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 cd servo&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach build --dev&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:'''2. Testing'''&lt;br /&gt;
&lt;br /&gt;
Servo provides automated tests, adding the &amp;lt;code&amp;gt;--release&amp;lt;/code&amp;gt; flag to create an optimized build:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach build --release&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach run --release tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Notes''': &lt;br /&gt;
#We have not added any new tests to the test suite as servo follows TDD and tests were previously written for OffscreenCanvas. We are adjusting some of the test expectations for the tests to pass our implementation.&lt;br /&gt;
#Our project cannot be tested from UI since it is basically improving some javascript features (OffsereenCanvas) in servo. However you can check that it doesn't break the existing code and the browser runs correctly by running a test page on servo after performing the build as mentioned above.&lt;br /&gt;
&lt;br /&gt;
== '''Design Pattern''' ==&lt;br /&gt;
Design patterns are not applicable as our task is involved in extracting all the relevant canvas operation from already existing file and implementing a new API.&lt;br /&gt;
&lt;br /&gt;
== '''Pull Request''' ==&lt;br /&gt;
Here is our [https://github.com/servo/servo/pull/19067 pull request]. In the link you can see all code snippets changed due to implementing the above steps, as well as integration test progression information.&lt;br /&gt;
&lt;br /&gt;
== '''Future Work''' ==&lt;br /&gt;
#Extract all relevant canvas operations from CanvasRenderingContext2d into an implementation shared with OffscreenCanvasRenderingContext2d&lt;br /&gt;
#*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 &amp;lt;canvas&amp;gt; element&lt;br /&gt;
#Implement the convertToBlob API to allow testing the contents of the canvas&lt;br /&gt;
#Support offscreen webgl contexts in a similar fashion to the 2d context, by sharing relevant code between OffscreenCanvasRenderingContext2d and WebGLRenderingContext&lt;br /&gt;
&lt;br /&gt;
== '''References''' ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
# https://html.spec.whatwg.org/multipage/canvas.html#dom-offscreencanvas-converttoblob&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jsarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/M1753_OffscreenCanvas&amp;diff=112358</id>
		<title>CSC/ECE 517 Fall 2017/M1753 OffscreenCanvas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/M1753_OffscreenCanvas&amp;diff=112358"/>
		<updated>2017-11-07T19:13:55Z</updated>

		<summary type="html">&lt;p&gt;Jsarava: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The HTML specification defines a &amp;lt;canvas&amp;gt; element that use a 2D or 3D rendering context and to draw graphics. The biggest limitation of &amp;lt;canvas&amp;gt; is that all of the javascript that manipulates the &amp;lt;canvas&amp;gt; has to run on the main thread, as the UI complexity of the application increases, 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.&amp;lt;ref&amp;gt;https://www.html5rocks.com/en/tutorials/canvas/performance/][https://github.com/servo/servo/wiki/Offscreen-canvas-project&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Background Introduction''' ==&lt;br /&gt;
'''[https://github.com/servo/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&amp;lt;ref&amp;gt;https://servo.org/&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''[https://en.wikipedia.org/wiki/Rust_(programming_language) Rust]''' 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 [https://github.com/rust-lang/rust GitHub/Git], and every commit to the source code is documented by the version control system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''The OffscreenCanvas API''' supports a canvas to be rendered off screen. The performance of a webpage can be limited by using &amp;lt;canvas&amp;gt; since all of the javascript that manipulates the &amp;lt;canvas&amp;gt; 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&amp;lt;ref&amp;gt;https://hacks.mozilla.org/2016/01/webgl-off-the-main-thread/&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== '''Project Description''' ==&lt;br /&gt;
'''Implement the OffscreenCanvas API''': Servo has an implementation of the HTML Canvas API, we need to port this API to OffscreenCanvas. This API will provide a canvas that can be rendered off screen and will be available in both the window and worker contexts. The rendering will be done in a separate thread which makes the overall rendering of the webpage quicker.&lt;br /&gt;
&lt;br /&gt;
'''Implement the OffscreenCanvasRenderingContext2D''': Servo has an implementation of the CanvasRendering2D API, we need to port this to OffscreenCanvasRenderingContext2D. This interface will be used for drawing rectangles, text, images and other objects onto the canvas element. It provides the 2D rendering context for the drawing surface of a &amp;lt;canvas&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
'''Steps:'''&lt;br /&gt;
&lt;br /&gt;
# Create the OffscreenCanvas and OffscreenCanvasRenderingContext2d interfaces.&lt;br /&gt;
# Hide the new interfaces by default&lt;br /&gt;
# Enable the existing automated tests for this feature&lt;br /&gt;
# Implement the OffscreenCanvas constructor that creates a new canvas&lt;br /&gt;
# Implement the OffscreenCanvas.getContext ignoring the WebGL requirements&lt;br /&gt;
&lt;br /&gt;
== '''Implementation''' ==&lt;br /&gt;
=== Step 1: Create Interfaces ===&lt;br /&gt;
Create the OffscreenCanvas and OffscreenCanvasRenderingContext2d interfaces with stub method implementations.&lt;br /&gt;
&lt;br /&gt;
To [http://doc.servo.org/script/dom/index.html#adding-a-new-dom-interface create] the interfaces, the following steps are to be followed : &lt;br /&gt;
&lt;br /&gt;
:1. adding the new IDL file at ''components/script/dom/webidls/OffscreenCanvas.webidl''&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/canvas.html#the-offscreencanvas-interface&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/canvas.html#the-offscreen-2d-rendering-context&amp;lt;/ref&amp;gt;; &lt;br /&gt;
 cd servo/components/script/dom/webidls&lt;br /&gt;
&lt;br /&gt;
 touch OffscreenCanvas.webidl&lt;br /&gt;
&lt;br /&gt;
 touch OffscreenCanvasRenderingContext2D.webidl&lt;br /&gt;
&lt;br /&gt;
:2. creating ''components/script/dom/OffscreenCanvas.rs'';&lt;br /&gt;
 cd servo/components/script/dom &lt;br /&gt;
&lt;br /&gt;
 touch offscreencanvas.rs&lt;br /&gt;
&lt;br /&gt;
 touch offscreencanvasrenderingcontext2d.rs&lt;br /&gt;
&lt;br /&gt;
:3. listing ''OffscreenCanvas.rs'' in ''components/script/dom/mod.rs''; &lt;br /&gt;
&lt;br /&gt;
[[File:Createoffscreencanvas.png]]&lt;br /&gt;
&lt;br /&gt;
:4. defining the DOM struct OffscreenCanvas with a ''#[dom_struct]'' attribute, a superclass or Reflector member, and other members as appropriate; &lt;br /&gt;
&lt;br /&gt;
[[File:Definedomstruct.png]]&lt;br /&gt;
&lt;br /&gt;
:5. implementing the ''dom::bindings::codegen::Bindings::OffsceenCanvasBindings::OffscreenCanvasMethods'' trait for OffscreenCanvas;&lt;br /&gt;
&lt;br /&gt;
[[File:Dombindings.png]]&lt;br /&gt;
&lt;br /&gt;
:6. adding/updating the match arm in create_element in ''components/script/dom/create.rs'' (only applicable to new types inheriting from HTMLElement)&lt;br /&gt;
&lt;br /&gt;
===Step 2: Hide newly created interfaces by default ===&lt;br /&gt;
&lt;br /&gt;
:1. Hide the new interfaces by default by adding a ''[Pref=&amp;quot;dom.offscreen_canvas.enabled&amp;quot;]'' attribute to each one and add a corresponding preference to ''resources/prefs.json''&lt;br /&gt;
::* Add the attribute in file ''OffscreenCanvas'' and ''OffscreenCanvasRendering'':&lt;br /&gt;
[[File:Attribute.png]]&lt;br /&gt;
::* Add the corresponding preference in ''prefs.json'':&lt;br /&gt;
[[File:Attribute2.png]]&lt;br /&gt;
&lt;br /&gt;
===Step 3: Enable Tests ===&lt;br /&gt;
:1. Add ''offscreen-canvas'' directory to tests folder.&lt;br /&gt;
 cd servo/tests/wpt/metadata&lt;br /&gt;
&lt;br /&gt;
 mkdir offscreen-canvas&lt;br /&gt;
&lt;br /&gt;
:2. Enable test preference for offscreen-canvas by adding ''__dir__.ini'' file to the newly created directory.&lt;br /&gt;
 cd servo/tests/wpt/metadata/offscreen-canvas&lt;br /&gt;
&lt;br /&gt;
 touch __dir__.ini&lt;br /&gt;
&lt;br /&gt;
:3. Run tests and change expected results&amp;lt;ref&amp;gt;https://github.com/servo/servo/blob/master/tests/wpt/README.md#updating-test-expectations&amp;lt;/ref&amp;gt;.&lt;br /&gt;
[[File:preds.png]]&lt;br /&gt;
&lt;br /&gt;
===Step 4: Implement OffscreenCanvas Constructor===&lt;br /&gt;
Create a new OffscreenCanvas by implementing the following Syntax: &lt;br /&gt;
 var offscreen = new OffscreenCanvas(256, 256);&lt;br /&gt;
&lt;br /&gt;
===Step 5: Implement the getContext() method for OffscreenCanvas element ===&lt;br /&gt;
Implement the ''OffscreenCanvas.getContext'' ignoring the WebGL requirements:&lt;br /&gt;
  canvas.getContext(contextType, contextAttributes);&lt;br /&gt;
&lt;br /&gt;
== '''Testing Details''' ==&lt;br /&gt;
:'''1. Building'''&lt;br /&gt;
&lt;br /&gt;
Servo is built with the Rust package manager, [https://crates.io/ Cargo]. &lt;br /&gt;
&lt;br /&gt;
The following commands are steps to built servo in development mode, please note the resulting binary is very slow.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 git clone https://github.com/jitendra29/servo.git&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 cd servo&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach build --dev&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:'''2. Testing'''&lt;br /&gt;
&lt;br /&gt;
Servo provides automated tests, adding the &amp;lt;code&amp;gt;--release&amp;lt;/code&amp;gt; flag to create an optimized build:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach build --release&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach run --release tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Notes''': &lt;br /&gt;
#We have not added any new tests to the test suite as servo follows TDD and tests were previously written for OffscreenCanvas. We are adjusting some of the test expectations for the tests to pass our implementation.&lt;br /&gt;
#Our project cannot be tested from UI since it is basically improving some javascript features (OffsereenCanvas) in servo. However you can check that it doesn't break the existing code and the browser runs correctly by running a test page on servo after performing the build as mentioned above.&lt;br /&gt;
&lt;br /&gt;
== '''Design Pattern''' ==&lt;br /&gt;
Design patterns are not applicable as our task is involved in extracting all the relevant canvas operation from already existing file and implementing a new API.&lt;br /&gt;
&lt;br /&gt;
== '''Pull Request''' ==&lt;br /&gt;
Here is our [https://github.com/servo/servo/pull/19067 pull request]. In the link you can see all code snippets changed due to implementing the above steps, as well as integration test progression information.&lt;br /&gt;
&lt;br /&gt;
== '''Future Work''' ==&lt;br /&gt;
#Extract all relevant canvas operations from CanvasRenderingContext2d into an implementation shared with OffscreenCanvasRenderingContext2d&lt;br /&gt;
#*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 &amp;lt;canvas&amp;gt; element&lt;br /&gt;
#Implement the convertToBlob API to allow testing the contents of the canvas&lt;br /&gt;
#Support offscreen webgl contexts in a similar fashion to the 2d context, by sharing relevant code between OffscreenCanvasRenderingContext2d and WebGLRenderingContext&lt;br /&gt;
&lt;br /&gt;
== '''References''' ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
# https://html.spec.whatwg.org/multipage/canvas.html#dom-offscreencanvas-converttoblob&amp;lt;/br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jsarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/M1753_OffscreenCanvas&amp;diff=112357</id>
		<title>CSC/ECE 517 Fall 2017/M1753 OffscreenCanvas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/M1753_OffscreenCanvas&amp;diff=112357"/>
		<updated>2017-11-07T19:13:14Z</updated>

		<summary type="html">&lt;p&gt;Jsarava: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The HTML specification defines a &amp;lt;canvas&amp;gt; element that use a 2D or 3D rendering context and to draw graphics. The biggest limitation of &amp;lt;canvas&amp;gt; is that all of the javascript that manipulates the &amp;lt;canvas&amp;gt; has to run on the main thread, as the UI complexity of the application increases, 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.&amp;lt;ref&amp;gt;https://www.html5rocks.com/en/tutorials/canvas/performance/][https://github.com/servo/servo/wiki/Offscreen-canvas-project&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Background Introduction''' ==&lt;br /&gt;
'''[https://github.com/servo/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&amp;lt;ref&amp;gt;https://servo.org/&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''[https://en.wikipedia.org/wiki/Rust_(programming_language) Rust]''' 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 [https://github.com/rust-lang/rust GitHub/Git], and every commit to the source code is documented by the version control system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''The OffscreenCanvas API''' supports a canvas to be rendered off screen. The performance of a webpage can be limited by using &amp;lt;canvas&amp;gt; since all of the javascript that manipulates the &amp;lt;canvas&amp;gt; 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&amp;lt;ref&amp;gt;https://hacks.mozilla.org/2016/01/webgl-off-the-main-thread/&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== '''Project Description''' ==&lt;br /&gt;
'''Implement the OffscreenCanvas API''': Servo has an implementation of the HTML Canvas API, we need to port this API to OffscreenCanvas. This API will provide a canvas that can be rendered off screen and will be available in both the window and worker contexts. The rendering will be done in a separate thread which makes the overall rendering of the webpage quicker.&lt;br /&gt;
&lt;br /&gt;
'''Implement the OffscreenCanvasRenderingContext2D''': Servo has an implementation of the CanvasRendering2D API, we need to port this to OffscreenCanvasRenderingContext2D. This interface will be used for drawing rectangles, text, images and other objects onto the canvas element. It provides the 2D rendering context for the drawing surface of a &amp;lt;canvas&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
'''Steps:'''&lt;br /&gt;
&lt;br /&gt;
# Create the OffscreenCanvas and OffscreenCanvasRenderingContext2d interfaces.&lt;br /&gt;
# Hide the new interfaces by default&lt;br /&gt;
# Enable the existing automated tests for this feature&lt;br /&gt;
# Implement the OffscreenCanvas constructor that creates a new canvas&lt;br /&gt;
# Implement the OffscreenCanvas.getContext ignoring the WebGL requirements&lt;br /&gt;
&lt;br /&gt;
== '''Implementation''' ==&lt;br /&gt;
=== Step 1: Create Interfaces ===&lt;br /&gt;
Create the OffscreenCanvas and OffscreenCanvasRenderingContext2d interfaces with stub method implementations.&lt;br /&gt;
&lt;br /&gt;
To [http://doc.servo.org/script/dom/index.html#adding-a-new-dom-interface create] the interfaces, the following steps are to be followed : &lt;br /&gt;
&lt;br /&gt;
:1. adding the new IDL file at ''components/script/dom/webidls/OffscreenCanvas.webidl''&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/canvas.html#the-offscreencanvas-interface&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/canvas.html#the-offscreen-2d-rendering-context&amp;lt;/ref&amp;gt;; &lt;br /&gt;
 cd servo/components/script/dom/webidls&lt;br /&gt;
&lt;br /&gt;
 touch OffscreenCanvas.webidl&lt;br /&gt;
&lt;br /&gt;
 touch OffscreenCanvasRenderingContext2D.webidl&lt;br /&gt;
&lt;br /&gt;
:2. creating ''components/script/dom/OffscreenCanvas.rs'';&lt;br /&gt;
 cd servo/components/script/dom &lt;br /&gt;
&lt;br /&gt;
 touch offscreencanvas.rs&lt;br /&gt;
&lt;br /&gt;
 touch offscreencanvasrenderingcontext2d.rs&lt;br /&gt;
&lt;br /&gt;
:3. listing ''OffscreenCanvas.rs'' in ''components/script/dom/mod.rs''; &lt;br /&gt;
&lt;br /&gt;
[[File:Createoffscreencanvas.png]]&lt;br /&gt;
&lt;br /&gt;
:4. defining the DOM struct OffscreenCanvas with a ''#[dom_struct]'' attribute, a superclass or Reflector member, and other members as appropriate; &lt;br /&gt;
&lt;br /&gt;
[[File:Definedomstruct.png]]&lt;br /&gt;
&lt;br /&gt;
:5. implementing the ''dom::bindings::codegen::Bindings::OffsceenCanvasBindings::OffscreenCanvasMethods'' trait for OffscreenCanvas;&lt;br /&gt;
&lt;br /&gt;
[[File:Dombindings.png]]&lt;br /&gt;
&lt;br /&gt;
:6. adding/updating the match arm in create_element in ''components/script/dom/create.rs'' (only applicable to new types inheriting from HTMLElement)&lt;br /&gt;
&lt;br /&gt;
===Step 2: Hide newly created interfaces by default ===&lt;br /&gt;
&lt;br /&gt;
:1. Hide the new interfaces by default by adding a ''[Pref=&amp;quot;dom.offscreen_canvas.enabled&amp;quot;]'' attribute to each one and add a corresponding preference to ''resources/prefs.json''&lt;br /&gt;
::* Add the attribute in file ''OffscreenCanvas'' and ''OffscreenCanvasRendering'':&lt;br /&gt;
[[File:Attribute.png]]&lt;br /&gt;
::* Add the corresponding preference in ''prefs.json'':&lt;br /&gt;
[[File:Attribute2.png]]&lt;br /&gt;
&lt;br /&gt;
===Step 3: Enable Tests ===&lt;br /&gt;
:1. Add ''offscreen-canvas'' directory to tests folder.&lt;br /&gt;
 cd servo/tests/wpt/metadata&lt;br /&gt;
&lt;br /&gt;
 mkdir offscreen-canvas&lt;br /&gt;
&lt;br /&gt;
:2. Enable test preference for offscreen-canvas by adding ''__dir__.ini'' file to the newly created directory.&lt;br /&gt;
 cd servo/tests/wpt/metadata/offscreen-canvas&lt;br /&gt;
&lt;br /&gt;
 touch __dir__.ini&lt;br /&gt;
&lt;br /&gt;
:3. Run tests and change expected results&amp;lt;ref&amp;gt;https://github.com/servo/servo/blob/master/tests/wpt/README.md#updating-test-expectations&amp;lt;/ref&amp;gt;.&lt;br /&gt;
[[File:preds.png]]&lt;br /&gt;
&lt;br /&gt;
===Step 4: Implement OffscreenCanvas Constructor===&lt;br /&gt;
Create a new OffscreenCanvas by implementing the following Syntax: &lt;br /&gt;
 var offscreen = new OffscreenCanvas(256, 256);&lt;br /&gt;
&lt;br /&gt;
===Step 5: Implement the getContext() method for OffscreenCanvas element ===&lt;br /&gt;
Implement the ''OffscreenCanvas.getContext'' ignoring the WebGL requirements:&lt;br /&gt;
  canvas.getContext(contextType, contextAttributes);&lt;br /&gt;
&lt;br /&gt;
== '''Testing Details''' ==&lt;br /&gt;
:'''1. Building'''&lt;br /&gt;
&lt;br /&gt;
Servo is built with the Rust package manager, [https://crates.io/ Cargo]. &lt;br /&gt;
&lt;br /&gt;
The following commands are steps to built servo in development mode, please note the resulting binary is very slow.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 git clone https://github.com/jitendra29/servo.git&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 cd servo&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach build --dev&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:'''2. Testing'''&lt;br /&gt;
&lt;br /&gt;
Servo provides automated tests, adding the &amp;lt;code&amp;gt;--release&amp;lt;/code&amp;gt; flag to create an optimized build:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach build --release&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach run --release tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Notes''': &lt;br /&gt;
#We have not added any new tests to the test suite as servo follows TDD and tests were previously written for OffscreenCanvas. We are adjusting some of the test expectations for the tests to pass our implementation.&lt;br /&gt;
#Our project cannot be tested from UI since it is basically improving some javascript features (OffsereenCanvas) in servo. However you can check that it doesn't break the existing code and the browser runs correctly by running a test page on servo after performing the build as mentioned above.&lt;br /&gt;
&lt;br /&gt;
== '''Design Pattern''' ==&lt;br /&gt;
Design patterns are not applicable as our task is involved in extracting all the relevant canvas operation from already existing file and implementing a new API.&lt;br /&gt;
&lt;br /&gt;
== '''Pull Request''' ==&lt;br /&gt;
Here is our [https://github.com/servo/servo/pull/19067 pull request]. In the link you can see all code snippets changed due to implementing the above steps, as well as integration test progression information.&lt;br /&gt;
&lt;br /&gt;
== '''Future Work''' ==&lt;br /&gt;
#Extract all relevant canvas operations from CanvasRenderingContext2d into an implementation shared with OffscreenCanvasRenderingContext2d&lt;br /&gt;
#*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 &amp;lt;canvas&amp;gt; element&lt;br /&gt;
#Implement the convertToBlob API to allow testing the contents of the canvas&lt;br /&gt;
#Support offscreen webgl contexts in a similar fashion to the 2d context, by sharing relevant code between OffscreenCanvasRenderingContext2d and WebGLRenderingContext&lt;br /&gt;
&lt;br /&gt;
== '''References''' ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
1.    https://html.spec.whatwg.org/multipage/canvas.html#dom-offscreencanvas-converttoblob&amp;lt;/br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jsarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/M1753_OffscreenCanvas&amp;diff=112355</id>
		<title>CSC/ECE 517 Fall 2017/M1753 OffscreenCanvas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/M1753_OffscreenCanvas&amp;diff=112355"/>
		<updated>2017-11-07T19:10:21Z</updated>

		<summary type="html">&lt;p&gt;Jsarava: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The HTML specification defines a &amp;lt;canvas&amp;gt; element that use a 2D or 3D rendering context and to draw graphics. The biggest limitation of &amp;lt;canvas&amp;gt; is that all of the javascript that manipulates the &amp;lt;canvas&amp;gt; has to run on the main thread, as the UI complexity of the application increases, 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.&amp;lt;ref&amp;gt;https://www.html5rocks.com/en/tutorials/canvas/performance/][https://github.com/servo/servo/wiki/Offscreen-canvas-project&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Background Introduction''' ==&lt;br /&gt;
'''[https://github.com/servo/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&amp;lt;ref&amp;gt;https://servo.org/&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''[https://en.wikipedia.org/wiki/Rust_(programming_language) Rust]''' 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 [https://github.com/rust-lang/rust GitHub/Git], and every commit to the source code is documented by the version control system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''The OffscreenCanvas API''' supports a canvas to be rendered off screen. The performance of a webpage can be limited by using &amp;lt;canvas&amp;gt; since all of the javascript that manipulates the &amp;lt;canvas&amp;gt; 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&amp;lt;ref&amp;gt;https://hacks.mozilla.org/2016/01/webgl-off-the-main-thread/&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== '''Project Description''' ==&lt;br /&gt;
'''Implement the OffscreenCanvas API''': Servo has an implementation of the HTML Canvas API, we need to port this API to OffscreenCanvas. This API will provide a canvas that can be rendered off screen and will be available in both the window and worker contexts. The rendering will be done in a separate thread which makes the overall rendering of the webpage quicker.&lt;br /&gt;
&lt;br /&gt;
'''Implement the OffscreenCanvasRenderingContext2D''': Servo has an implementation of the CanvasRendering2D API, we need to port this to OffscreenCanvasRenderingContext2D. This interface will be used for drawing rectangles, text, images and other objects onto the canvas element. It provides the 2D rendering context for the drawing surface of a &amp;lt;canvas&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
'''Steps:'''&lt;br /&gt;
&lt;br /&gt;
# Create the OffscreenCanvas and OffscreenCanvasRenderingContext2d interfaces.&lt;br /&gt;
# Hide the new interfaces by default&lt;br /&gt;
# Enable the existing automated tests for this feature&lt;br /&gt;
# Implement the OffscreenCanvas constructor that creates a new canvas&lt;br /&gt;
# Implement the OffscreenCanvas.getContext ignoring the WebGL requirements&lt;br /&gt;
&lt;br /&gt;
== '''Implementation''' ==&lt;br /&gt;
=== Step 1: Create Interfaces ===&lt;br /&gt;
Create the OffscreenCanvas and OffscreenCanvasRenderingContext2d interfaces with stub method implementations.&lt;br /&gt;
&lt;br /&gt;
To [http://doc.servo.org/script/dom/index.html#adding-a-new-dom-interface create] the interfaces, the following steps are to be followed : &lt;br /&gt;
&lt;br /&gt;
:1. adding the new IDL file at ''components/script/dom/webidls/OffscreenCanvas.webidl''&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/canvas.html#the-offscreencanvas-interface&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/canvas.html#the-offscreen-2d-rendering-context&amp;lt;/ref&amp;gt;; &lt;br /&gt;
 cd servo/components/script/dom/webidls&lt;br /&gt;
&lt;br /&gt;
 touch OffscreenCanvas.webidl&lt;br /&gt;
&lt;br /&gt;
 touch OffscreenCanvasRenderingContext2D.webidl&lt;br /&gt;
&lt;br /&gt;
:2. creating ''components/script/dom/OffscreenCanvas.rs'';&lt;br /&gt;
 cd servo/components/script/dom &lt;br /&gt;
&lt;br /&gt;
 touch offscreencanvas.rs&lt;br /&gt;
&lt;br /&gt;
 touch offscreencanvasrenderingcontext2d.rs&lt;br /&gt;
&lt;br /&gt;
:3. listing ''OffscreenCanvas.rs'' in ''components/script/dom/mod.rs''; &lt;br /&gt;
&lt;br /&gt;
[[File:Createoffscreencanvas.png]]&lt;br /&gt;
&lt;br /&gt;
:4. defining the DOM struct OffscreenCanvas with a ''#[dom_struct]'' attribute, a superclass or Reflector member, and other members as appropriate; &lt;br /&gt;
&lt;br /&gt;
[[File:Definedomstruct.png]]&lt;br /&gt;
&lt;br /&gt;
:5. implementing the ''dom::bindings::codegen::Bindings::OffsceenCanvasBindings::OffscreenCanvasMethods'' trait for OffscreenCanvas;&lt;br /&gt;
&lt;br /&gt;
[[File:Dombindings.png]]&lt;br /&gt;
&lt;br /&gt;
:6. adding/updating the match arm in create_element in ''components/script/dom/create.rs'' (only applicable to new types inheriting from HTMLElement)&lt;br /&gt;
&lt;br /&gt;
===Step 2: Hide newly created interfaces by default ===&lt;br /&gt;
&lt;br /&gt;
:1. Hide the new interfaces by default by adding a ''[Pref=&amp;quot;dom.offscreen_canvas.enabled&amp;quot;]'' attribute to each one and add a corresponding preference to ''resources/prefs.json''&lt;br /&gt;
::* Add the attribute in file ''OffscreenCanvas'' and ''OffscreenCanvasRendering'':&lt;br /&gt;
[[File:Attribute.png]]&lt;br /&gt;
::* Add the corresponding preference in ''prefs.json'':&lt;br /&gt;
[[File:Attribute2.png]]&lt;br /&gt;
&lt;br /&gt;
===Step 3: Enable Tests ===&lt;br /&gt;
:1. Add ''offscreen-canvas'' directory to tests folder.&lt;br /&gt;
 cd servo/tests/wpt/metadata&lt;br /&gt;
&lt;br /&gt;
 mkdir offscreen-canvas&lt;br /&gt;
&lt;br /&gt;
:2. Enable test preference for offscreen-canvas by adding ''__dir__.ini'' file to the newly created directory.&lt;br /&gt;
 cd servo/tests/wpt/metadata/offscreen-canvas&lt;br /&gt;
&lt;br /&gt;
 touch __dir__.ini&lt;br /&gt;
&lt;br /&gt;
:3. Run tests and change expected results&amp;lt;ref&amp;gt;https://github.com/servo/servo/blob/master/tests/wpt/README.md#updating-test-expectations&amp;lt;/ref&amp;gt;.&lt;br /&gt;
[[File:preds.png]]&lt;br /&gt;
&lt;br /&gt;
===Step 4: Implement OffscreenCanvas Constructor===&lt;br /&gt;
Create a new OffscreenCanvas by implementing the following Syntax: &lt;br /&gt;
 var offscreen = new OffscreenCanvas(256, 256);&lt;br /&gt;
&lt;br /&gt;
===Step 5: Implement the getContext() method for OffscreenCanvas element ===&lt;br /&gt;
Implement the ''OffscreenCanvas.getContext'' ignoring the WebGL requirements:&lt;br /&gt;
  canvas.getContext(contextType, contextAttributes);&lt;br /&gt;
&lt;br /&gt;
== '''Testing Details''' ==&lt;br /&gt;
:'''1. Building'''&lt;br /&gt;
&lt;br /&gt;
Servo is built with the Rust package manager, [https://crates.io/ Cargo]. &lt;br /&gt;
&lt;br /&gt;
The following commands are steps to built servo in development mode, please note the resulting binary is very slow.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 git clone https://github.com/jitendra29/servo.git&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 cd servo&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach build --dev&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:'''2. Testing'''&lt;br /&gt;
&lt;br /&gt;
Servo provides automated tests, adding the &amp;lt;code&amp;gt;--release&amp;lt;/code&amp;gt; flag to create an optimized build:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach build --release&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach run --release tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Notes''': &lt;br /&gt;
#We have not added any new tests to the test suite as servo follows TDD and tests were previously written for OffscreenCanvas. We are adjusting some of the test expectations for the tests to pass our implementation.&lt;br /&gt;
#Our project cannot be tested from UI since it is basically improving some javascript features (OffsereenCanvas) in servo. However you can check that it doesn't break the existing code and the browser runs correctly by running a test page on servo after performing the build as mentioned above.&lt;br /&gt;
&lt;br /&gt;
== '''Design Pattern''' ==&lt;br /&gt;
Design patterns are not applicable as our task is involved in extracting all the relevant canvas operation from already existing file and implementing a new API.&lt;br /&gt;
&lt;br /&gt;
== '''Pull Request''' ==&lt;br /&gt;
Here is our [https://github.com/servo/servo/pull/19067 pull request]. In the link you can see all code snippets changed due to implementing the above steps, as well as integration test progression information.&lt;br /&gt;
&lt;br /&gt;
== '''Future Work''' ==&lt;br /&gt;
#Extract all relevant canvas operations from CanvasRenderingContext2d into an implementation shared with OffscreenCanvasRenderingContext2d&lt;br /&gt;
#*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 &amp;lt;canvas&amp;gt; element&lt;br /&gt;
#Implement the convertToBlob API to allow testing the contents of the canvas&lt;br /&gt;
#Support offscreen webgl contexts in a similar fashion to the 2d context, by sharing relevant code between OffscreenCanvasRenderingContext2d and WebGLRenderingContext&lt;br /&gt;
&lt;br /&gt;
== '''References''' ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jsarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/M1753_OffscreenCanvas&amp;diff=112354</id>
		<title>CSC/ECE 517 Fall 2017/M1753 OffscreenCanvas</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/M1753_OffscreenCanvas&amp;diff=112354"/>
		<updated>2017-11-07T19:03:16Z</updated>

		<summary type="html">&lt;p&gt;Jsarava: Created page with &amp;quot;The HTML specification defines a &amp;lt;canvas&amp;gt; element that use a 2D or 3D rendering context and to draw graphics. The biggest limitation of &amp;lt;canvas&amp;gt; is that all of the javascript tha...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The HTML specification defines a &amp;lt;canvas&amp;gt; element that use a 2D or 3D rendering context and to draw graphics. The biggest limitation of &amp;lt;canvas&amp;gt; is that all of the javascript that manipulates the &amp;lt;canvas&amp;gt; has to run on the main thread, as the UI complexity of the application increases, 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.&amp;lt;ref&amp;gt;https://www.html5rocks.com/en/tutorials/canvas/performance/][https://github.com/servo/servo/wiki/Offscreen-canvas-project&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Background Introduction''' ==&lt;br /&gt;
'''[https://github.com/servo/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&amp;lt;ref&amp;gt;https://servo.org/&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''[https://en.wikipedia.org/wiki/Rust_(programming_language) Rust]''' 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 [https://github.com/rust-lang/rust GitHub/Git], and every commit to the source code is documented by the version control system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''The OffscreenCanvas API''' supports a canvas to be rendered off screen. The performance of a webpage can be limited by using &amp;lt;canvas&amp;gt; since all of the javascript that manipulates the &amp;lt;canvas&amp;gt; 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&amp;lt;ref&amp;gt;https://hacks.mozilla.org/2016/01/webgl-off-the-main-thread/&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== '''Project Description''' ==&lt;br /&gt;
'''Implement the OffscreenCanvas API''': Servo has an implementation of the HTML Canvas API, we need to port this API to OffscreenCanvas. This API will provide a canvas that can be rendered off screen and will be available in both the window and worker contexts. The rendering will be done in a separate thread which makes the overall rendering of the webpage quicker.&lt;br /&gt;
&lt;br /&gt;
'''Implement the OffscreenCanvasRenderingContext2D''': Servo has an implementation of the CanvasRendering2D API, we need to port this to OffscreenCanvasRenderingContext2D. This interface will be used for drawing rectangles, text, images and other objects onto the canvas element. It provides the 2D rendering context for the drawing surface of a &amp;lt;canvas&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
'''Steps:'''&lt;br /&gt;
&lt;br /&gt;
# Create the OffscreenCanvas and OffscreenCanvasRenderingContext2d interfaces.&lt;br /&gt;
# Hide the new interfaces by default&lt;br /&gt;
# Enable the existing automated tests for this feature&lt;br /&gt;
# Implement the OffscreenCanvas constructor that creates a new canvas&lt;br /&gt;
# Implement the OffscreenCanvas.getContext ignoring the WebGL requirements&lt;br /&gt;
&lt;br /&gt;
== '''Implementation''' ==&lt;br /&gt;
=== Step 1: Create Interfaces ===&lt;br /&gt;
Create the OffscreenCanvas and OffscreenCanvasRenderingContext2d interfaces with stub method implementations.&lt;br /&gt;
&lt;br /&gt;
To [http://doc.servo.org/script/dom/index.html#adding-a-new-dom-interface create] the interfaces, the following steps are to be followed : &lt;br /&gt;
&lt;br /&gt;
:1. adding the new IDL file at ''components/script/dom/webidls/OffscreenCanvas.webidl''&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/canvas.html#the-offscreencanvas-interface&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/canvas.html#the-offscreen-2d-rendering-context&amp;lt;/ref&amp;gt;; &lt;br /&gt;
 cd servo/components/script/dom/webidls&lt;br /&gt;
&lt;br /&gt;
 touch OffscreenCanvas.webidl&lt;br /&gt;
&lt;br /&gt;
 touch OffscreenCanvasRenderingContext2D.webidl&lt;br /&gt;
&lt;br /&gt;
:2. creating ''components/script/dom/OffscreenCanvas.rs'';&lt;br /&gt;
 cd servo/components/script/dom &lt;br /&gt;
&lt;br /&gt;
 touch offscreencanvas.rs&lt;br /&gt;
&lt;br /&gt;
 touch offscreencanvasrenderingcontext2d.rs&lt;br /&gt;
&lt;br /&gt;
:3. listing ''OffscreenCanvas.rs'' in ''components/script/dom/mod.rs''; &lt;br /&gt;
&lt;br /&gt;
[[File:Createoffscreencanvas.png]]&lt;br /&gt;
&lt;br /&gt;
:4. defining the DOM struct OffscreenCanvas with a ''#[dom_struct]'' attribute, a superclass or Reflector member, and other members as appropriate; &lt;br /&gt;
&lt;br /&gt;
[[File:Definedomstruct.png]]&lt;br /&gt;
&lt;br /&gt;
:5. implementing the ''dom::bindings::codegen::Bindings::OffsceenCanvasBindings::OffscreenCanvasMethods'' trait for OffscreenCanvas;&lt;br /&gt;
&lt;br /&gt;
[[File:Dombindings.png]]&lt;br /&gt;
&lt;br /&gt;
:6. adding/updating the match arm in create_element in ''components/script/dom/create.rs'' (only applicable to new types inheriting from HTMLElement)&lt;br /&gt;
&lt;br /&gt;
===Step 2: Hide newly created interfaces by default ===&lt;br /&gt;
&lt;br /&gt;
:1. Hide the new interfaces by default by adding a ''[Pref=&amp;quot;dom.offscreen_canvas.enabled&amp;quot;]'' attribute to each one and add a corresponding preference to ''resources/prefs.json''&lt;br /&gt;
::* Add the attribute in file ''OffscreenCanvas'' and ''OffscreenCanvasRendering'':&lt;br /&gt;
[[File:Attribute.png]]&lt;br /&gt;
::* Add the corresponding preference in ''prefs.json'':&lt;br /&gt;
[[File:Attribute2.png]]&lt;br /&gt;
&lt;br /&gt;
===Step 3: Enable Tests ===&lt;br /&gt;
:1. Add ''offscreen-canvas'' directory to tests folder.&lt;br /&gt;
 cd servo/tests/wpt/metadata&lt;br /&gt;
&lt;br /&gt;
 mkdir offscreen-canvas&lt;br /&gt;
&lt;br /&gt;
:2. Enable test preference for offscreen-canvas by adding ''__dir__.ini'' file to the newly created directory.&lt;br /&gt;
 cd servo/tests/wpt/metadata/offscreen-canvas&lt;br /&gt;
&lt;br /&gt;
 touch __dir__.ini&lt;br /&gt;
&lt;br /&gt;
:3. Run tests and change expected results&amp;lt;ref&amp;gt;https://github.com/servo/servo/blob/master/tests/wpt/README.md#updating-test-expectations&amp;lt;/ref&amp;gt;.&lt;br /&gt;
[[File:preds.png]]&lt;br /&gt;
&lt;br /&gt;
===Step 4: Implement OffscreenCanvas Constructor===&lt;br /&gt;
Create a new OffscreenCanvas by implementing the following Syntax: &lt;br /&gt;
 var offscreen = new OffscreenCanvas(256, 256);&lt;br /&gt;
&lt;br /&gt;
===Step 5: Implement the getContext() method for OffscreenCanvas element ===&lt;br /&gt;
Implement the ''OffscreenCanvas.getContext'' ignoring the WebGL requirements:&lt;br /&gt;
  canvas.getContext(contextType, contextAttributes);&lt;br /&gt;
&lt;br /&gt;
== '''Testing Details''' ==&lt;br /&gt;
:'''1. Building'''&lt;br /&gt;
&lt;br /&gt;
Servo is built with the Rust package manager, [https://crates.io/ Cargo]. &lt;br /&gt;
&lt;br /&gt;
The following commands are steps to built servo in development mode, please note the resulting binary is very slow.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 git clone https://github.com/jitendra29/servo.git&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 cd servo&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach build --dev&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:'''2. Testing'''&lt;br /&gt;
&lt;br /&gt;
Servo provides automated tests, adding the &amp;lt;code&amp;gt;--release&amp;lt;/code&amp;gt; flag to create an optimized build:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach build --release&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach run --release tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Notes''': &lt;br /&gt;
#We have not added any new tests to the test suite as servo follows TDD and tests were previously written for OffscreenCanvas. We are adjusting some of the test expectations for the tests to pass our implementation.&lt;br /&gt;
#Our project cannot be tested from UI since it is basically improving some javascript features (OffsereenCanvas) in servo. However you can check that it doesn't break the existing code and the browser runs correctly by running a test page on servo after performing the build as mentioned above.&lt;br /&gt;
&lt;br /&gt;
== '''Pull Request''' ==&lt;br /&gt;
Here is our [https://github.com/servo/servo/pull/19067 pull request]. In the link you can see all code snippets changed due to implementing the above steps, as well as integration test progression information.&lt;br /&gt;
&lt;br /&gt;
== '''Future Work''' ==&lt;br /&gt;
#Extract all relevant canvas operations from CanvasRenderingContext2d into an implementation shared with OffscreenCanvasRenderingContext2d&lt;br /&gt;
#*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 &amp;lt;canvas&amp;gt; element&lt;br /&gt;
#Implement the convertToBlob API to allow testing the contents of the canvas&lt;br /&gt;
#Support offscreen webgl contexts in a similar fashion to the 2d context, by sharing relevant code between OffscreenCanvasRenderingContext2d and WebGLRenderingContext&lt;br /&gt;
&lt;br /&gt;
== '''References''' ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jsarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017&amp;diff=112350</id>
		<title>CSC/ECE 517 Fall 2017</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017&amp;diff=112350"/>
		<updated>2017-11-07T18:46:57Z</updated>

		<summary type="html">&lt;p&gt;Jsarava: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Design Project Documentation'''&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E17A2 Lightweight Badging System]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E17A8. Use a profiler to identify the problems / pages that take some time to load &amp;amp; fix them]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1793. Help students find teams to join]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E17A4 Allow calibration to be part of an assignment]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E17A0 Team-based reviewing]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1793. Help students find teams to join_Team1964]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1791. Track the time that students look at the other submissions - logging improvement]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1799 Improve self-review Link peer review &amp;amp; self-review to derive grades]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1797_Timestamps_for_students_submissions]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E17A1|CSC/ECE_517_Fall_2017/E17A1 - Let experts as well as students do reviews]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/M1754_Mutation_Testing]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1794. Student-generated questions added to rubric]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E17A6. Fix account creation over web to work reasonably]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1792 OSS Visualizations for instructors]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E17A4 Allow calibration to be part of an assignment_Team34]]&lt;br /&gt;
'''Writing Assignment 2'''&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1779. Fix teammate advertisements and requests to join a team]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1773 Investigate and Fix Expertiza Production Version Runtime Exceptions.rb]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1774 Metareview fixes and improvements.rb]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1788 OSS project Maroon Heatmap fixes]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1781 Topic Management]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1745_Refactor_response_controller.rb]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1752 Refactor assignments controller]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1776_Enhance_Imports]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1756 TLD Refactor response.rb]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1772_Refactor reputation_web_service_controller.rb]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/M1753_OffscreenCanvas API]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/M1754_Mutation Testing on Servo]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1753 OSS project bidding tests]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1766_Test team functionality]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1767 Improve imports]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1786_OSS project Juniper Bookmark Enhancements]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1787_OSS project Bronze Score calculations]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1763 Fix Staggered-Deadline Assignments]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1757 Introduce a Student View for instructors]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1769_Refactor assignment_form.rb]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1754_Feature_test_of_rubric_advice]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1782 OSS Project Red Assignment Directories]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1748 Add past-due assignments to task list]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1761 Test First Development Refactor assignment.rb]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1780_OSS_Project_Teal_Email_Notification_Enhancements]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1762 Test various kinds of response-map hierarchies]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1759 ]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2017/E1749_Test First Development Refactor questionnaire_controller.rb]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1777 Coherent specification of review requirements.rb]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2017/E1771_Refactor_team.rb]]&lt;/div&gt;</summary>
		<author><name>Jsarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/M1753_OffscreenCanvas_API&amp;diff=111776</id>
		<title>CSC/ECE 517 Fall 2017/M1753 OffscreenCanvas API</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/M1753_OffscreenCanvas_API&amp;diff=111776"/>
		<updated>2017-11-04T18:55:12Z</updated>

		<summary type="html">&lt;p&gt;Jsarava: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The HTML specification defines a &amp;lt;canvas&amp;gt; element that use a 2D or 3D rendering context and to draw graphics. The biggest limitation of &amp;lt;canvas&amp;gt; is that all of the javascript that manipulates the &amp;lt;canvas&amp;gt; has to run on the main thread, as the UI complexity of the application increases, 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.&amp;lt;ref&amp;gt;https://www.html5rocks.com/en/tutorials/canvas/performance/][https://github.com/servo/servo/wiki/Offscreen-canvas-project&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Background Introduction''' ==&lt;br /&gt;
'''[https://github.com/servo/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&amp;lt;ref&amp;gt;https://servo.org/&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''[https://en.wikipedia.org/wiki/Rust_(programming_language) Rust]''' 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 [https://github.com/rust-lang/rust GitHub/Git], and every commit to the source code is documented by the version control system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''The OffscreenCanvas API''' supports a canvas to be rendered off screen. The performance of a webpage can be limited by using &amp;lt;canvas&amp;gt; since all of the javascript that manipulates the &amp;lt;canvas&amp;gt; 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&amp;lt;ref&amp;gt;https://hacks.mozilla.org/2016/01/webgl-off-the-main-thread/&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== '''Project Description''' ==&lt;br /&gt;
'''Implement the OffscreenCanvas API''': Servo has an implementation of the HTML Canvas API, we need to port this API to OffscreenCanvas. This API will provide a canvas that can be rendered off screen and will be available in both the window and worker contexts. The rendering will be done in a separate thread which makes the overall rendering of the webpage quicker.&lt;br /&gt;
&lt;br /&gt;
'''Implement the OffscreenCanvasRenderingContext2D''': Servo has an implementation of the CanvasRendering2D API, we need to port this to OffscreenCanvasRenderingContext2D. This interface will be used for drawing rectangles, text, images and other objects onto the canvas element. It provides the 2D rendering context for the drawing surface of a &amp;lt;canvas&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
'''Steps:'''&lt;br /&gt;
&lt;br /&gt;
# Create the OffscreenCanvas and OffscreenCanvasRenderingContext2d interfaces.&lt;br /&gt;
# Hide the new interfaces by default&lt;br /&gt;
# Enable the existing automated tests for this feature&lt;br /&gt;
# Implement the OffscreenCanvas constructor that creates a new canvas&lt;br /&gt;
# Implement the OffscreenCanvas.getContext ignoring the WebGL requirements&lt;br /&gt;
&lt;br /&gt;
== '''Implementation''' ==&lt;br /&gt;
=== Step 1: Create Interfaces ===&lt;br /&gt;
Create the OffscreenCanvas and OffscreenCanvasRenderingContext2d interfaces with stub method implementations.&lt;br /&gt;
&lt;br /&gt;
To [http://doc.servo.org/script/dom/index.html#adding-a-new-dom-interface create] the interfaces, the following steps are to be followed : &lt;br /&gt;
&lt;br /&gt;
:1. adding the new IDL file at ''components/script/dom/webidls/OffscreenCanvas.webidl''&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/canvas.html#the-offscreencanvas-interface&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/canvas.html#the-offscreen-2d-rendering-context&amp;lt;/ref&amp;gt;; &lt;br /&gt;
 cd servo/components/script/dom/webidls&lt;br /&gt;
&lt;br /&gt;
 touch OffscreenCanvas.webidl&lt;br /&gt;
&lt;br /&gt;
 touch OffscreenCanvasRenderingContext2D.webidl&lt;br /&gt;
&lt;br /&gt;
:2. creating ''components/script/dom/OffscreenCanvas.rs'';&lt;br /&gt;
 cd servo/components/script/dom &lt;br /&gt;
&lt;br /&gt;
 touch offscreencanvas.rs&lt;br /&gt;
&lt;br /&gt;
 touch offscreencanvasrenderingcontext2d.rs&lt;br /&gt;
&lt;br /&gt;
:3. listing ''OffscreenCanvas.rs'' in ''components/script/dom/mod.rs''; &lt;br /&gt;
&lt;br /&gt;
[[File:Createoffscreencanvas.png]]&lt;br /&gt;
&lt;br /&gt;
:4. defining the DOM struct OffscreenCanvas with a ''#[dom_struct]'' attribute, a superclass or Reflector member, and other members as appropriate; &lt;br /&gt;
&lt;br /&gt;
[[File:Definedomstruct.png]]&lt;br /&gt;
&lt;br /&gt;
:5. implementing the ''dom::bindings::codegen::Bindings::OffsceenCanvasBindings::OffscreenCanvasMethods'' trait for OffscreenCanvas;&lt;br /&gt;
&lt;br /&gt;
[[File:Dombindings.png]]&lt;br /&gt;
&lt;br /&gt;
:6. adding/updating the match arm in create_element in ''components/script/dom/create.rs'' (only applicable to new types inheriting from HTMLElement)&lt;br /&gt;
&lt;br /&gt;
===Step 2: Hide newly created interfaces by default ===&lt;br /&gt;
&lt;br /&gt;
:1. Hide the new interfaces by default by adding a ''[Pref=&amp;quot;dom.offscreen_canvas.enabled&amp;quot;]'' attribute to each one and add a corresponding preference to ''resources/prefs.json''&lt;br /&gt;
::* Add the attribute in file ''OffscreenCanvas'' and ''OffscreenCanvasRendering'':&lt;br /&gt;
[[File:Attribute.png]]&lt;br /&gt;
::* Add the corresponding preference in ''prefs.json'':&lt;br /&gt;
[[File:Attribute2.png]]&lt;br /&gt;
&lt;br /&gt;
===Step 3: Enable Tests ===&lt;br /&gt;
:1. Add ''offscreen-canvas'' directory to tests folder.&lt;br /&gt;
 cd servo/tests/wpt/metadata&lt;br /&gt;
&lt;br /&gt;
 mkdir offscreen-canvas&lt;br /&gt;
&lt;br /&gt;
:2. Enable test preference for offscreen-canvas by adding ''__dir__.ini'' file to the newly created directory.&lt;br /&gt;
 cd servo/tests/wpt/metadata/offscreen-canvas&lt;br /&gt;
&lt;br /&gt;
 touch __dir__.ini&lt;br /&gt;
&lt;br /&gt;
:3. Run tests and change expected results&amp;lt;ref&amp;gt;https://github.com/servo/servo/blob/master/tests/wpt/README.md#updating-test-expectations&amp;lt;/ref&amp;gt;.&lt;br /&gt;
[[File:preds.png]]&lt;br /&gt;
&lt;br /&gt;
===Step 4: Implement OffscreenCanvas Constructor===&lt;br /&gt;
Create a new OffscreenCanvas by implementing the following Syntax: &lt;br /&gt;
 var offscreen = new OffscreenCanvas(256, 256);&lt;br /&gt;
&lt;br /&gt;
===Step 5: Implement the getContext() method for OffscreenCanvas element ===&lt;br /&gt;
Implement the ''OffscreenCanvas.getContext'' ignoring the WebGL requirements:&lt;br /&gt;
  canvas.getContext(contextType, contextAttributes);&lt;br /&gt;
&lt;br /&gt;
== '''Testing Details''' ==&lt;br /&gt;
:'''1. Building'''&lt;br /&gt;
&lt;br /&gt;
Servo is built with the Rust package manager, [https://crates.io/ Cargo]. &lt;br /&gt;
&lt;br /&gt;
The following commands are steps to built servo in development mode, please note the resulting binary is very slow.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 git clone https://github.com/jitendra29/servo.git&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 cd servo&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach build --dev&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:'''2. Testing'''&lt;br /&gt;
&lt;br /&gt;
Servo provides automated tests, adding the &amp;lt;code&amp;gt;--release&amp;lt;/code&amp;gt; flag to create an optimized build:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach build --release&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach run --release tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Notes''': &lt;br /&gt;
#We have not added any new tests to the test suite as servo follows TDD and tests were previously written for OffscreenCanvas. We are adjusting some of the test expectations for the tests to pass our implementation.&lt;br /&gt;
#Our project cannot be tested from UI since it is basically improving some javascript features (OffsereenCanvas) in servo. However you can check that it doesn't break the existing code and the browser runs correctly by running a test page on servo after performing the build as mentioned above.&lt;br /&gt;
&lt;br /&gt;
== '''Pull Request''' ==&lt;br /&gt;
Here is our [https://github.com/servo/servo/pull/19067 pull request]. In the link you can see all code snippets changed due to implementing the above steps, as well as integration test progression information.&lt;br /&gt;
&lt;br /&gt;
== '''Future Work''' ==&lt;br /&gt;
#Extract all relevant canvas operations from CanvasRenderingContext2d into an implementation shared with OffscreenCanvasRenderingContext2d&lt;br /&gt;
#*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 &amp;lt;canvas&amp;gt; element&lt;br /&gt;
#Implement the convertToBlob API to allow testing the contents of the canvas&lt;br /&gt;
#Support offscreen webgl contexts in a similar fashion to the 2d context, by sharing relevant code between OffscreenCanvasRenderingContext2d and WebGLRenderingContext&lt;br /&gt;
&lt;br /&gt;
== '''References''' ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jsarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/M1753_OffscreenCanvas_API&amp;diff=110050</id>
		<title>CSC/ECE 517 Fall 2017/M1753 OffscreenCanvas API</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/M1753_OffscreenCanvas_API&amp;diff=110050"/>
		<updated>2017-10-27T18:59:57Z</updated>

		<summary type="html">&lt;p&gt;Jsarava: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The HTML specification defines a &amp;lt;canvas&amp;gt; element that use a 2D or 3D rendering context and to draw graphics. The biggest limitation of &amp;lt;canvas&amp;gt; is that all of the javascript that manipulates the &amp;lt;canvas&amp;gt; has to run on the main thread, as the UI complexity of the application increases, 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.&amp;lt;ref&amp;gt;https://www.html5rocks.com/en/tutorials/canvas/performance/][https://github.com/servo/servo/wiki/Offscreen-canvas-project&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== '''Background Introduction''' ==&lt;br /&gt;
'''[https://github.com/servo/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&amp;lt;ref&amp;gt;https://servo.org/&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''[https://en.wikipedia.org/wiki/Rust_(programming_language) Rust]''' 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 [https://github.com/rust-lang/rust GitHub/Git], and every commit to the source code is documented by the version control system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''The OffscreenCanvas API''' supports a canvas to be rendered off screen. The performance of a webpage can be limited by using &amp;lt;canvas&amp;gt; since all of the javascript that manipulates the &amp;lt;canvas&amp;gt; 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&amp;lt;ref&amp;gt;https://hacks.mozilla.org/2016/01/webgl-off-the-main-thread/&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== '''Project Description''' ==&lt;br /&gt;
'''Implement the OffscreenCanvas API''': Servo has an implementation of the HTML Canvas API, we need to port this API to OffscreenCanvas. This API will provide a canvas that can be rendered off screen and will be available in both the window and worker contexts. The rendering will be done in a separate thread which makes the overall rendering of the webpage quicker.&lt;br /&gt;
&lt;br /&gt;
'''Implement the OffscreenCanvasRenderingContext2D''': Servo has an implementation of the CanvasRendering2D API, we need to port this to OffscreenCanvasRenderingContext2D. This interface will be used for drawing rectangles, text, images and other objects onto the canvas element. It provides the 2D rendering context for the drawing surface of a &amp;lt;canvas&amp;gt; element.&lt;br /&gt;
&lt;br /&gt;
'''Steps:'''&lt;br /&gt;
&lt;br /&gt;
# Create the OffscreenCanvas and OffscreenCanvasRenderingContext2d interfaces.&lt;br /&gt;
# Hide the new interfaces by default&lt;br /&gt;
# Enable the existing automated tests for this feature&lt;br /&gt;
# Implement the OffscreenCanvas constructor that creates a new canvas&lt;br /&gt;
# Implement the OffscreenCanvas.getContext ignoring the WebGL requirements&lt;br /&gt;
&lt;br /&gt;
== '''Implementation''' ==&lt;br /&gt;
=== Create Interfaces ===&lt;br /&gt;
Create the OffscreenCanvas and OffscreenCanvasRenderingContext2d interfaces with stub method implementations.&lt;br /&gt;
&lt;br /&gt;
To [http://doc.servo.org/script/dom/index.html#adding-a-new-dom-interface create] the interfaces, the following steps are to be followed : &lt;br /&gt;
&lt;br /&gt;
# adding the new IDL file at ''components/script/dom/webidls/OffscreenCanvas.webidl''&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/canvas.html#the-offscreencanvas-interface&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/canvas.html#the-offscreen-2d-rendering-context&amp;lt;/ref&amp;gt;; &amp;lt;br&amp;gt;&amp;lt;code&amp;gt; cd servo/components/script/dom/webidls &amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;touch OffscreenCanvas.webidl &amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt; touch OffscreenCanvasRenderingContext2D.webidl &amp;lt;/code&amp;gt;&lt;br /&gt;
# creating ''components/script/dom/OffscreenCanvas.rs'';&amp;lt;br&amp;gt;&amp;lt;code&amp;gt; cd servo/components/script/dom &amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;touch offscreencanvas.rs&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt; offscreencanvasrenderingcontext2d.rs &amp;lt;/code&amp;gt;&lt;br /&gt;
# listing ''OffscreenCanvas.rs'' in ''components/script/dom/mod.rs''; [[File:Createoffscreencanvas.png]]&lt;br /&gt;
# defining the DOM struct OffscreenCanvas with a ''#[dom_struct]'' attribute, a superclass or Reflector member, and other members as appropriate; [[File:Definedomstruct.png]]&lt;br /&gt;
# implementing the ''dom::bindings::codegen::Bindings::OffsceenCanvasBindings::OffscreenCanvasMethods'' trait for OffscreenCanvas;[[File:Dombindings.png]]&lt;br /&gt;
# adding/updating the match arm in create_element in ''components/script/dom/create.rs'' (only applicable to new types inheriting from HTMLElement)&lt;br /&gt;
&lt;br /&gt;
=== Hide newly created interfaces by default ===&lt;br /&gt;
&lt;br /&gt;
# Hide the new interfaces by default by adding a ''[Pref=&amp;quot;dom.offscreen_canvas.enabled&amp;quot;]'' attribute to each one and add a corresponding preference to ''resources/prefs.json''&lt;br /&gt;
&lt;br /&gt;
=== Enable Tests ===&lt;br /&gt;
# Add ''offscreen-canvas'' directory to tests folder.&lt;br /&gt;
# Enable test preference for offscreen-canvas by adding ''__dir__.ini'' file to the newly created directory.&lt;br /&gt;
# Run tests and change expected results&amp;lt;ref&amp;gt;https://github.com/servo/servo/blob/master/tests/wpt/README.md#updating-test-expectations&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===  Implement OffscreenCanvas Constructor===&lt;br /&gt;
Create a new OffscreenCanvas by implementing the following Syntax: &lt;br /&gt;
 var offscreen = new OffscreenCanvas(256, 256);&lt;br /&gt;
&lt;br /&gt;
=== Implement the getContext() method for OffscreenCanvas element ===&lt;br /&gt;
Implement the ''OffscreenCanvas.getContext'' ignoring the WebGL requirements:&lt;br /&gt;
  canvas.getContext(contextType, contextAttributes);&lt;br /&gt;
&lt;br /&gt;
== '''Testing Details''' ==&lt;br /&gt;
* '''Building'''&lt;br /&gt;
&lt;br /&gt;
Servo is built with the Rust package manager, [https://crates.io/ Cargo]. &lt;br /&gt;
&lt;br /&gt;
The following commands are steps to built servo in development mode, please note the resulting binary is very slow.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 git clone https://github.com/jitendra29/servo.git&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 cd servo&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach build --dev&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Testing'''&lt;br /&gt;
&lt;br /&gt;
Servo provides automated tests, adding the &amp;lt;code&amp;gt;--release&amp;lt;/code&amp;gt; flag to create an optimized build:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach build --release&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach run --release tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Notes''': &lt;br /&gt;
#We have not added any new tests to the test suite as servo follows TDD and tests were previously written for OffscreenCanvas. We are adjusting some of the test expectations for the tests to pass our implementation.&lt;br /&gt;
#Our project cannot be tested from UI since it is basically improving some javascript features (OffsereenCanvas) in servo. However you can check that it doesn't break the existing code and the browser runs correctly by running a test page on servo after performing the build as mentioned above.&lt;br /&gt;
&lt;br /&gt;
== '''Pull Request''' ==&lt;br /&gt;
&lt;br /&gt;
== '''Future Work''' ==&lt;br /&gt;
#Extract all relevant canvas operations from CanvasRenderingContext2d into an implementation shared with OffscreenCanvasRenderingContext2d&lt;br /&gt;
#*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 &amp;lt;canvas&amp;gt; element&lt;br /&gt;
#Implement the convertToBlob API to allow testing the contents of the canvas&lt;br /&gt;
#Support offscreen webgl contexts in a similar fashion to the 2d context, by sharing relevant code between OffscreenCanvasRenderingContext2d and WebGLRenderingContext&lt;br /&gt;
&lt;br /&gt;
== '''References''' ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jsarava</name></author>
	</entry>
</feed>