<?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=Aagrawa5</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=Aagrawa5"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Aagrawa5"/>
	<updated>2026-06-03T20:18:23Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=92526</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=92526"/>
		<updated>2014-12-04T23:23:22Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* Setup of Development Environment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Background Information &amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_M1455_asa&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Servo currently depends on a lot of C libraries for image decoding. We wish to evaluate switching some of these to new Rust libraries. This project involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
====Setup of Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/ankit3005/servo&lt;br /&gt;
cd servo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ensure that modified dependencies point to right sources&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./mach update-cargo -p freetype-rs&lt;br /&gt;
./mach update-cargo -p image&lt;br /&gt;
./mach update-cargo -p freetype-rs --precise 753496406098651c83cdaf63db9f75dc42da17c7&lt;br /&gt;
./mach update-cargo -p image --precise 3a398831adb22f1200cb68682e446ede187d23b9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run basic tests to ensure build success.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The scope of our project is limited to changing the libraries used in the image decoding task shown above.&lt;br /&gt;
&lt;br /&gt;
== Requirement analysis ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Servo currently depends on a lot of C libraries, because Rust equivalents for these libraries did not exist when the project started. Our project is to evaluate switching some of these to new Rust libraries that have since been created. It involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Initial step&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_M1455_asa initial step], implemented for the OSS project involved:&lt;br /&gt;
# Building Servo.&lt;br /&gt;
# Adding [http://doc.servo.org/util/time/fn.time.html timing code] to the image decoding implementation in the net crate.&lt;br /&gt;
# Rebuilding Servo.&lt;br /&gt;
# Reporting numbers for different kinds of images (i.e. PNG, JPEG, GIF).&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;b&amp;gt;Final Requirements&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our final project requirements are to:&lt;br /&gt;
* Build Servo and add code that reports (via the println! macro) the time required to decode images into displayable pixels.&lt;br /&gt;
* Add image decoding timing to the profiler.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/freetype-rs freetype-rs] library to replace [https://github.com/servo/rust-freetype rust-freetype] in Servo, rewriting necessary code.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3369&amp;lt;/ref&amp;gt; For this, we are to use [http://doc.crates.io/ Cargo], the dependency manager for Servo.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/image rust-image] library to replace the [https://github.com/servo/rust-stb-image rust-stb-image] and [https://github.com/nothings/stb stb-image] libraries and rewrite the &amp;lt;code&amp;gt;load_from_memory&amp;lt;/code&amp;gt; function which uses these libraries.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3368&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Report the timing differences for loading PNGs and non-PNGs on the same benchmarks. For this step, we are to consider profiling the result and optimizing the hotspots in rust-image.&lt;br /&gt;
&lt;br /&gt;
== Implementation of the Final Requirements ==&lt;br /&gt;
&lt;br /&gt;
1. Add Image Decoding time to the Profiler&lt;br /&gt;
To profile the time required by the load_from_memory to decode an image, we make a call to the profiler which outputs the time taken to decode on the console. To enable the profiler to do so, the following files were changed:&lt;br /&gt;
*image_cache_task.rs&lt;br /&gt;
*lib.rs&lt;br /&gt;
*time.rs&lt;br /&gt;
To invoke the profiler, we added a category under which to group the timings and passed a TimeProfilerChan (ie. a channel for communicating with the profiler task) to the ImageCacheTask::new method. On successfully building and running servo, we get the following image timings by profiler on the console:&lt;br /&gt;
&amp;lt;pre&amp;gt; ./mach run -p 1 https://optipng.sourceforge.net/pngtech/img/lena.html &amp;lt;/pre&amp;gt;&lt;br /&gt;
[[File:Profiler.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Imported the freetype-rs library to replace rust-freetype in Servo.&lt;br /&gt;
We replaced the currently used rust-freetype library with the freetype-rs library. To enable proper functioning of servo after importing the new library, following files were modified in the repository [https://github.com/PistonDevelopers/freetype-rs PistonDevelopers/freetype-rs]:&lt;br /&gt;
*Cargo.toml &lt;br /&gt;
*src/ffi.rs&lt;br /&gt;
*src/lib.rs&lt;br /&gt;
*src/lib.rs&lt;br /&gt;
*src/library.rs&lt;br /&gt;
*src/tt_os2.rs&lt;br /&gt;
These changes were committed and have been pulled by PistonDevelopers. Check the changes on [https://github.com/PistonDevelopers/freetype-rs/pull/70 pull request] for more info.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Imported the rust-image library to replace the rust-stb-image and stb-image libraries and rewrite the load_from_memory function which uses these libraries.&lt;br /&gt;
In order to import the new library we modified the following files files in the repository [https://github.com/ankit3005/servo]:&lt;br /&gt;
*Cargo.toml &lt;br /&gt;
*components/net/lib.rs&lt;br /&gt;
*components/net/image_cache_task.rs&lt;br /&gt;
*components/net/image/base.rs&lt;br /&gt;
*components/net/image/holder.rs&lt;br /&gt;
*components/gfx/render_context.rs&lt;br /&gt;
*components/gfx/lib.rs&lt;br /&gt;
*components/gfx/Cargo.toml&lt;br /&gt;
*components/gfx/display_list/mod.rs&lt;br /&gt;
*components/layout/display_list_builder.rs&lt;br /&gt;
*components/layout/lib.rs&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Reported the timing differences for loading PNGs and non-PNGs on the same benchmarks.&lt;br /&gt;
Once the new image library was imported , passed in several test images to record the decoding timing for different images.&lt;br /&gt;
The timing was compared with the decoding time for images by passing in the same images to the servo build containing the C image library. The results can be seen in the Test-Cases section below.&lt;br /&gt;
&lt;br /&gt;
== Data and component design &amp;lt;ref&amp;gt;http://www.rust-ci.org/PistonDevelopers/piston/doc/image/index.html&amp;lt;/ref&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
===Data Design===&lt;br /&gt;
The system entities that the project deals with is present in the image crate.&lt;br /&gt;
&lt;br /&gt;
The structs and enums used to represent images are as below :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Structures&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ImageBuf&lt;br /&gt;
|An Image whose pixels are contained within a vector&lt;br /&gt;
|-&lt;br /&gt;
|Luma&lt;br /&gt;
|A type to hold a grayscale pixel&lt;br /&gt;
|-&lt;br /&gt;
|LumaA&lt;br /&gt;
|A type to hold a grayscale pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|MutPixels&lt;br /&gt;
|Mutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Pixels&lt;br /&gt;
|Immutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Rgb&lt;br /&gt;
|A type to hold an RGB pixel&lt;br /&gt;
|-&lt;br /&gt;
|Rgba&lt;br /&gt;
|A type to hold an RGB pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|SubImage&lt;br /&gt;
|A View into another image&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Enums&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ColorType&lt;br /&gt;
|An enumeration over supported color types and their bit depths&lt;br /&gt;
|-&lt;br /&gt;
|DynamicImage&lt;br /&gt;
|A Dynamic Image&lt;br /&gt;
|-&lt;br /&gt;
|FilterType&lt;br /&gt;
|Available Sampling Filters&lt;br /&gt;
|-&lt;br /&gt;
|ImageError&lt;br /&gt;
|An enumeration of Image Errors&lt;br /&gt;
|-&lt;br /&gt;
|ImageFormat&lt;br /&gt;
|An enumeration of supported image formats. Not all formats support both encoding and decoding.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Component Design===&lt;br /&gt;
&lt;br /&gt;
Rust image : It is an image processing library. This crate provides basic imaging processing functions and methods for converting to and from image formats.&lt;br /&gt;
All image processing functions provided operate on types that implement the GenericImage trait and return an ImageBuf. The details of other modules and  traits included are :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Modules&amp;lt;ref&amp;gt;http://doc.rust-lang.org/guide.html#crates-and-modules&amp;lt;/ref&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|gif&lt;br /&gt;
|Decoding of GIF Images&lt;br /&gt;
|-&lt;br /&gt;
|imageops&lt;br /&gt;
|Image Processing Functions&lt;br /&gt;
|-&lt;br /&gt;
|jpeg&lt;br /&gt;
|Decoding and Encoding of JPEG Images&lt;br /&gt;
|-&lt;br /&gt;
|png&lt;br /&gt;
|Decoding and Encoding of PNG Images&lt;br /&gt;
|-&lt;br /&gt;
|ppm&lt;br /&gt;
|Encoding of portable pixmap Images&lt;br /&gt;
|-&lt;br /&gt;
|webp&lt;br /&gt;
|Decoding of Webp Images&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Traits&amp;lt;ref&amp;gt;http://rustbyexample.com/trait.html&amp;lt;/ref&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|GenericImage&lt;br /&gt;
|A trait for manipulating images.&lt;br /&gt;
|-&lt;br /&gt;
|ImageDecoder&lt;br /&gt;
|The trait that all decoders implement&lt;br /&gt;
|-&lt;br /&gt;
|MutableRefImage&lt;br /&gt;
|A trait for images that allow providing mutable references to pixels.&lt;br /&gt;
|-&lt;br /&gt;
|Pixel&lt;br /&gt;
|A trait that all pixels implement.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Functions&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|load&lt;br /&gt;
|Create a new image from a Reader&lt;br /&gt;
|-&lt;br /&gt;
|load_from_memory&lt;br /&gt;
|Create a new image from a byte slice&lt;br /&gt;
|-&lt;br /&gt;
|open&lt;br /&gt;
|Open the image located at the path specified. The image's format is determined from the path's file extension&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
&lt;br /&gt;
We are adhering to the following design principles for our implementation:&lt;br /&gt;
&lt;br /&gt;
'''Open-Closed Principle'''&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Open/closed_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Although our task is to evaluate replacing C libraries with Rust libraries, we won't actually be modifying any existing functionality.&lt;br /&gt;
&lt;br /&gt;
'''Interface Segregation Principle'''&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Interface_segregation_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The existing code is currently using the ''rust-freetype'' library for rendering fonts on the browser. We will be replacing this with the ''freetype-rs'' library, which divides the functionality offered by the former into smaller libraries which can be individually implemented instead of calling the entire library.&lt;br /&gt;
&lt;br /&gt;
== Design Pattern==&lt;br /&gt;
&lt;br /&gt;
We have implemented the Adapter Pattern in our Project:&lt;br /&gt;
&lt;br /&gt;
When we updated the image library, the function load_from_memory() in base.rs had to be updated since the return from the updated function accepts a different set of parameters.&lt;br /&gt;
We implemented the Adapter pattern as a wrapper function over the new load_from_memory() function which performs the below functions:&lt;br /&gt;
1. Based on the file extension generate the ImageFormat Enum.&lt;br /&gt;
2. The return of the new function is a Result&amp;lt;DynamicImage&amp;gt;. This needs to be converted into a DynamicImage struct.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pub fn load_from_memory(buffer: &amp;amp;[u8],ext: &amp;amp;str) -&amp;gt; Option&amp;lt;DynamicImage&amp;gt; {&lt;br /&gt;
    if buffer.len() == 0 {&lt;br /&gt;
        return None;&lt;br /&gt;
    }&lt;br /&gt;
   else {&lt;br /&gt;
        //Retrieve the ImageFormat enum to be passed into the updated function&lt;br /&gt;
        let image_type: Option&amp;lt; servo_image::ImageFormat &amp;gt; = get_format(ext);&lt;br /&gt;
	if image_type == None&lt;br /&gt;
	{&lt;br /&gt;
	panic!(&amp;quot;Image format not supported!&amp;quot;);&lt;br /&gt;
	}&lt;br /&gt;
	else{&lt;br /&gt;
        let new_image_type: servo_image::ImageFormat = image_type.unwrap();&lt;br /&gt;
        &lt;br /&gt;
        //The updated function returns a Result&amp;lt;DynamicImage&amp;gt;&lt;br /&gt;
        //below code resolves it to be returned by the wrapper function&lt;br /&gt;
	let result = servo_image::load_from_memory(buffer,new_image_type);&lt;br /&gt;
	if result.is_ok() {&lt;br /&gt;
  	    let v = result.unwrap();&lt;br /&gt;
  	    return Some(v);&lt;br /&gt;
	}&lt;br /&gt;
	else  {	&lt;br /&gt;
	    return None;&lt;br /&gt;
	}		&lt;br /&gt;
   }&lt;br /&gt;
   }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Flowchart describing Project Implementation==&lt;br /&gt;
[[File:Flowchart_final_M1455.JPG]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
&lt;br /&gt;
===Class Diagram===&lt;br /&gt;
[[File:Class_diagram_M1455.JPG]]&lt;br /&gt;
&lt;br /&gt;
== Test Cases ==&lt;br /&gt;
&lt;br /&gt;
The project does not plan to add new functionality. &lt;br /&gt;
The test-cases we propose to run are will ensure that tasks that could be performed with the older C libraries can be executed.&lt;br /&gt;
&lt;br /&gt;
The following test cases are proposed.&lt;br /&gt;
&lt;br /&gt;
1. The initial step test case includes printing the decoding time for various image formates and has been included in the wiki: [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_M1455_asa initial step]&lt;br /&gt;
&lt;br /&gt;
2. The profiler is meant to capture the image decoding time take by the load_from_memory function. The profiler is run using the following command which gives the decoding time for the image passed as an argument:&lt;br /&gt;
&amp;lt;pre&amp;gt;./mach run -p 1 https://optipng.sourceforge.net/pngtech/img/lena.html&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
3. After replacing the rust-freetype library by the freetype-rs library, we have tested that it works as expected by passing a webpage url and checking that the text renders correctly.&lt;br /&gt;
&amp;lt;pre&amp;gt;./mach run http://simple.wikipedia.org/wiki/Main_Page&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. After replacing the rust-stb-image and stb-image libraries with rust-image library and rewriting the load_from_memory function, we tested the the imports worked as expected by passing in different formats of images as urls and rendering them. &lt;br /&gt;
&amp;lt;pre&amp;gt; ./mach run https://www.http://optipng.sourceforge.net/pngtech/img/lena.png&amp;lt;/pre&amp;gt;&lt;br /&gt;
Below you can see the image being rendered after importing the new rust image library: &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;[[File:lenaRenderedCorrectly.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As you can see the image is being rendered as intended. &lt;br /&gt;
Note: This was previously broken due to a bug in our code. We had used the wrong enum type while decoding images that resulted in distorted images. This was fixed by the following [https://github.com/ankit3005/servo/commit/dfa0b92b21144c01223db78d8570aa5ac890922c commit].&lt;br /&gt;
&lt;br /&gt;
5. Our test cases include reporting the timing differences for loading PNGs and non-PNG images. The following report has been made with respect to the same:&lt;br /&gt;
{| class=&amp;quot;wikitable sortable mw-collapsible&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Image Source&lt;br /&gt;
!Resolution&lt;br /&gt;
!New library decode timing (in ms)&lt;br /&gt;
!Old library decode timing (in ms)&lt;br /&gt;
|-&lt;br /&gt;
|http://meesoft.logicnet.dk/Analyzer/help/Lenna.jpg&lt;br /&gt;
|256X256&lt;br /&gt;
|40.3814&lt;br /&gt;
|45.002006&lt;br /&gt;
|-&lt;br /&gt;
|http://peps.redprince.net/peps/tiger-Q300.png&lt;br /&gt;
|290X300&lt;br /&gt;
|78.0789&lt;br /&gt;
|29.636256&lt;br /&gt;
|-&lt;br /&gt;
|http://www.codeproject.com/KB/GDI-plus/ImageProcessing2/grayscale.jpg&lt;br /&gt;
|332X300&lt;br /&gt;
|106.7289&lt;br /&gt;
|64.298119&lt;br /&gt;
|-&lt;br /&gt;
|http://www.ampsoft.net/webdesign-l/img/JPEG-sample-landscape-standard.jpg&lt;br /&gt;
|300X200&lt;br /&gt;
|88.852&lt;br /&gt;
|42.395043&lt;br /&gt;
|-&lt;br /&gt;
|http://andreas.com/pixs/ping-sample.gif&lt;br /&gt;
|682X310&lt;br /&gt;
|106.9462&lt;br /&gt;
|124.54975&lt;br /&gt;
|-&lt;br /&gt;
|http://www.cs.cmu.edu/~chuck/lennapg/len_top.jpg&lt;br /&gt;
|400X225&lt;br /&gt;
|118.0558&lt;br /&gt;
|62.443986&lt;br /&gt;
|-&lt;br /&gt;
|http://www.roman10.net/wp-content/uploads/2011/08/sample_thumb.jpg&lt;br /&gt;
|484X316&lt;br /&gt;
|175.0287&lt;br /&gt;
|99.462362&lt;br /&gt;
|-&lt;br /&gt;
|http://www.kksou.com/php-gtk2/gif/sample6.png&lt;br /&gt;
|480X240&lt;br /&gt;
|223.9521&lt;br /&gt;
|44.864687&lt;br /&gt;
|-&lt;br /&gt;
|http://imagej.nih.gov/ij/images/lena.jpg&lt;br /&gt;
|512X512&lt;br /&gt;
|257.5638&lt;br /&gt;
|165.242363&lt;br /&gt;
|-&lt;br /&gt;
|http://people.sc.fsu.edu/~jburkardt/data/png/lena.png&lt;br /&gt;
|512X512&lt;br /&gt;
|397.7005&lt;br /&gt;
|88.834362&lt;br /&gt;
|-&lt;br /&gt;
|http://24.media.tumblr.com/tumblr_m97zes5x3k1rezf8ro1_500.jpg&lt;br /&gt;
|500X375&lt;br /&gt;
|312.1556&lt;br /&gt;
|129.003554&lt;br /&gt;
|-&lt;br /&gt;
|http://urlnextdoor.com/ai/design-layout/images/sample-png.png&lt;br /&gt;
|200X200&lt;br /&gt;
|152.053&lt;br /&gt;
|20.885724&lt;br /&gt;
|-&lt;br /&gt;
|https://cdn2.iconfinder.com/data/icons/free-3d-printer-icon-set/512/3d_objects.png&lt;br /&gt;
|512X512&lt;br /&gt;
|550.5805&lt;br /&gt;
|78.025999&lt;br /&gt;
|-&lt;br /&gt;
|http://www.samontab.com/web/wp-content/uploads/2012/06/lena3.png&lt;br /&gt;
|512X512&lt;br /&gt;
|811.8095&lt;br /&gt;
|97.916758&lt;br /&gt;
|-&lt;br /&gt;
|http://www.math.uga.edu/~mjlai/images/LenaRecovered.jpg&lt;br /&gt;
|1200X900&lt;br /&gt;
|909.2834&lt;br /&gt;
|662.842394&lt;br /&gt;
|-&lt;br /&gt;
|https://chadaphone.files.wordpress.com/2013/10/face_detection.png&lt;br /&gt;
|640X480&lt;br /&gt;
|942.4558&lt;br /&gt;
|113.816885&lt;br /&gt;
|-&lt;br /&gt;
|https://www.drupal.org/files/issues/sample_7.png&lt;br /&gt;
|800X600&lt;br /&gt;
|708.9273&lt;br /&gt;
|157.806566&lt;br /&gt;
|-&lt;br /&gt;
|http://optipng.sourceforge.net/pngtech/img/lena.png&lt;br /&gt;
|512X512&lt;br /&gt;
|924.4648&lt;br /&gt;
|95.02457&lt;br /&gt;
|-&lt;br /&gt;
|http://www.ultrasync.net/dee/warehouse_the_odd_stage/lena2_before_1024.png&lt;br /&gt;
|1024X1024&lt;br /&gt;
|1507.7304&lt;br /&gt;
|326.962991&lt;br /&gt;
|-&lt;br /&gt;
|http://menehune.opt.wfu.edu/CSC365_665/Proj1/Gif/lena.gif&lt;br /&gt;
|256X256&lt;br /&gt;
|2466.9467&lt;br /&gt;
|40.845023&lt;br /&gt;
|-&lt;br /&gt;
|http://www.openbsd.org/art/puffy/ppuf1000X907.gif&lt;br /&gt;
|1000x907&lt;br /&gt;
|56338.6327&lt;br /&gt;
|615.134272&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Video ==&lt;br /&gt;
A walkthrough of our entire project is available on this link: [https://www.youtube.com/watch?v=rq8MvpR1JyI Final Project Walkthrough]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_M1455_asa Initial Step Details]&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=92525</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=92525"/>
		<updated>2014-12-04T22:43:34Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* Test Cases */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Background Information &amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_M1455_asa&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Servo currently depends on a lot of C libraries for image decoding. We wish to evaluate switching some of these to new Rust libraries. This project involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
====Setup of Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ensure that modified dependencies point to right sources&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./mach update-cargo -p freetype-rs&lt;br /&gt;
./mach update-cargo -p image&lt;br /&gt;
./mach update-cargo -p freetype-rs --precise 753496406098651c83cdaf63db9f75dc42da17c7&lt;br /&gt;
./mach update-cargo -p image --precise 3a398831adb22f1200cb68682e446ede187d23b9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run basic tests to ensure build success.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The scope of our project is limited to changing the libraries used in the image decoding task shown above.&lt;br /&gt;
&lt;br /&gt;
== Requirement analysis ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Servo currently depends on a lot of C libraries, because Rust equivalents for these libraries did not exist when the project started. Our project is to evaluate switching some of these to new Rust libraries that have since been created. It involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Initial step&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_M1455_asa initial step], implemented for the OSS project involved:&lt;br /&gt;
# Building Servo.&lt;br /&gt;
# Adding [http://doc.servo.org/util/time/fn.time.html timing code] to the image decoding implementation in the net crate.&lt;br /&gt;
# Rebuilding Servo.&lt;br /&gt;
# Reporting numbers for different kinds of images (i.e. PNG, JPEG, GIF).&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;b&amp;gt;Final Requirements&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our final project requirements are to:&lt;br /&gt;
* Build Servo and add code that reports (via the println! macro) the time required to decode images into displayable pixels.&lt;br /&gt;
* Add image decoding timing to the profiler.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/freetype-rs freetype-rs] library to replace [https://github.com/servo/rust-freetype rust-freetype] in Servo, rewriting necessary code.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3369&amp;lt;/ref&amp;gt; For this, we are to use [http://doc.crates.io/ Cargo], the dependency manager for Servo.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/image rust-image] library to replace the [https://github.com/servo/rust-stb-image rust-stb-image] and [https://github.com/nothings/stb stb-image] libraries and rewrite the &amp;lt;code&amp;gt;load_from_memory&amp;lt;/code&amp;gt; function which uses these libraries.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3368&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Report the timing differences for loading PNGs and non-PNGs on the same benchmarks. For this step, we are to consider profiling the result and optimizing the hotspots in rust-image.&lt;br /&gt;
&lt;br /&gt;
== Implementation of the Final Requirements ==&lt;br /&gt;
&lt;br /&gt;
1. Add Image Decoding time to the Profiler&lt;br /&gt;
To profile the time required by the load_from_memory to decode an image, we make a call to the profiler which outputs the time taken to decode on the console. To enable the profiler to do so, the following files were changed:&lt;br /&gt;
*image_cache_task.rs&lt;br /&gt;
*lib.rs&lt;br /&gt;
*time.rs&lt;br /&gt;
To invoke the profiler, we added a category under which to group the timings and passed a TimeProfilerChan (ie. a channel for communicating with the profiler task) to the ImageCacheTask::new method. On successfully building and running servo, we get the following image timings by profiler on the console:&lt;br /&gt;
&amp;lt;pre&amp;gt; ./mach run -p 1 https://optipng.sourceforge.net/pngtech/img/lena.html &amp;lt;/pre&amp;gt;&lt;br /&gt;
[[File:Profiler.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Imported the freetype-rs library to replace rust-freetype in Servo.&lt;br /&gt;
We replaced the currently used rust-freetype library with the freetype-rs library. To enable proper functioning of servo after importing the new library, following files were modified in the repository [https://github.com/PistonDevelopers/freetype-rs PistonDevelopers/freetype-rs]:&lt;br /&gt;
*Cargo.toml &lt;br /&gt;
*src/ffi.rs&lt;br /&gt;
*src/lib.rs&lt;br /&gt;
*src/lib.rs&lt;br /&gt;
*src/library.rs&lt;br /&gt;
*src/tt_os2.rs&lt;br /&gt;
These changes were committed and have been pulled by PistonDevelopers. Check the changes on [https://github.com/PistonDevelopers/freetype-rs/pull/70 pull request] for more info.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Imported the rust-image library to replace the rust-stb-image and stb-image libraries and rewrite the load_from_memory function which uses these libraries.&lt;br /&gt;
In order to import the new library we modified the following files files in the repository [https://github.com/ankit3005/servo]:&lt;br /&gt;
*Cargo.toml &lt;br /&gt;
*components/net/lib.rs&lt;br /&gt;
*components/net/image_cache_task.rs&lt;br /&gt;
*components/net/image/base.rs&lt;br /&gt;
*components/net/image/holder.rs&lt;br /&gt;
*components/gfx/render_context.rs&lt;br /&gt;
*components/gfx/lib.rs&lt;br /&gt;
*components/gfx/Cargo.toml&lt;br /&gt;
*components/gfx/display_list/mod.rs&lt;br /&gt;
*components/layout/display_list_builder.rs&lt;br /&gt;
*components/layout/lib.rs&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Reported the timing differences for loading PNGs and non-PNGs on the same benchmarks.&lt;br /&gt;
Once the new image library was imported , passed in several test images to record the decoding timing for different images.&lt;br /&gt;
The timing was compared with the decoding time for images by passing in the same images to the servo build containing the C image library. The results can be seen in the Test-Cases section below.&lt;br /&gt;
&lt;br /&gt;
== Data and component design &amp;lt;ref&amp;gt;http://www.rust-ci.org/PistonDevelopers/piston/doc/image/index.html&amp;lt;/ref&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
===Data Design===&lt;br /&gt;
The system entities that the project deals with is present in the image crate.&lt;br /&gt;
&lt;br /&gt;
The structs and enums used to represent images are as below :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Structures&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ImageBuf&lt;br /&gt;
|An Image whose pixels are contained within a vector&lt;br /&gt;
|-&lt;br /&gt;
|Luma&lt;br /&gt;
|A type to hold a grayscale pixel&lt;br /&gt;
|-&lt;br /&gt;
|LumaA&lt;br /&gt;
|A type to hold a grayscale pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|MutPixels&lt;br /&gt;
|Mutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Pixels&lt;br /&gt;
|Immutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Rgb&lt;br /&gt;
|A type to hold an RGB pixel&lt;br /&gt;
|-&lt;br /&gt;
|Rgba&lt;br /&gt;
|A type to hold an RGB pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|SubImage&lt;br /&gt;
|A View into another image&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Enums&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ColorType&lt;br /&gt;
|An enumeration over supported color types and their bit depths&lt;br /&gt;
|-&lt;br /&gt;
|DynamicImage&lt;br /&gt;
|A Dynamic Image&lt;br /&gt;
|-&lt;br /&gt;
|FilterType&lt;br /&gt;
|Available Sampling Filters&lt;br /&gt;
|-&lt;br /&gt;
|ImageError&lt;br /&gt;
|An enumeration of Image Errors&lt;br /&gt;
|-&lt;br /&gt;
|ImageFormat&lt;br /&gt;
|An enumeration of supported image formats. Not all formats support both encoding and decoding.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Component Design===&lt;br /&gt;
&lt;br /&gt;
Rust image : It is an image processing library. This crate provides basic imaging processing functions and methods for converting to and from image formats.&lt;br /&gt;
All image processing functions provided operate on types that implement the GenericImage trait and return an ImageBuf. The details of other modules and  traits included are :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Modules&amp;lt;ref&amp;gt;http://doc.rust-lang.org/guide.html#crates-and-modules&amp;lt;/ref&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|gif&lt;br /&gt;
|Decoding of GIF Images&lt;br /&gt;
|-&lt;br /&gt;
|imageops&lt;br /&gt;
|Image Processing Functions&lt;br /&gt;
|-&lt;br /&gt;
|jpeg&lt;br /&gt;
|Decoding and Encoding of JPEG Images&lt;br /&gt;
|-&lt;br /&gt;
|png&lt;br /&gt;
|Decoding and Encoding of PNG Images&lt;br /&gt;
|-&lt;br /&gt;
|ppm&lt;br /&gt;
|Encoding of portable pixmap Images&lt;br /&gt;
|-&lt;br /&gt;
|webp&lt;br /&gt;
|Decoding of Webp Images&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Traits&amp;lt;ref&amp;gt;http://rustbyexample.com/trait.html&amp;lt;/ref&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|GenericImage&lt;br /&gt;
|A trait for manipulating images.&lt;br /&gt;
|-&lt;br /&gt;
|ImageDecoder&lt;br /&gt;
|The trait that all decoders implement&lt;br /&gt;
|-&lt;br /&gt;
|MutableRefImage&lt;br /&gt;
|A trait for images that allow providing mutable references to pixels.&lt;br /&gt;
|-&lt;br /&gt;
|Pixel&lt;br /&gt;
|A trait that all pixels implement.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Functions&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|load&lt;br /&gt;
|Create a new image from a Reader&lt;br /&gt;
|-&lt;br /&gt;
|load_from_memory&lt;br /&gt;
|Create a new image from a byte slice&lt;br /&gt;
|-&lt;br /&gt;
|open&lt;br /&gt;
|Open the image located at the path specified. The image's format is determined from the path's file extension&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
&lt;br /&gt;
We are adhering to the following design principles for our implementation:&lt;br /&gt;
&lt;br /&gt;
'''Open-Closed Principle'''&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Open/closed_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Although our task is to evaluate replacing C libraries with Rust libraries, we won't actually be modifying any existing functionality.&lt;br /&gt;
&lt;br /&gt;
'''Interface Segregation Principle'''&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Interface_segregation_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The existing code is currently using the ''rust-freetype'' library for rendering fonts on the browser. We will be replacing this with the ''freetype-rs'' library, which divides the functionality offered by the former into smaller libraries which can be individually implemented instead of calling the entire library.&lt;br /&gt;
&lt;br /&gt;
== Design Pattern==&lt;br /&gt;
&lt;br /&gt;
We have implemented the Adapter Pattern in our Project:&lt;br /&gt;
&lt;br /&gt;
When we updated the image library, the function load_from_memory() in base.rs had to be updated since the return from the updated function accepts a different set of parameters.&lt;br /&gt;
We implemented the Adapter pattern as a wrapper function over the new load_from_memory() function which performs the below functions:&lt;br /&gt;
1. Based on the file extension generate the ImageFormat Enum.&lt;br /&gt;
2. The return of the new function is a Result&amp;lt;DynamicImage&amp;gt;. This needs to be converted into a DynamicImage struct.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pub fn load_from_memory(buffer: &amp;amp;[u8],ext: &amp;amp;str) -&amp;gt; Option&amp;lt;DynamicImage&amp;gt; {&lt;br /&gt;
    if buffer.len() == 0 {&lt;br /&gt;
        return None;&lt;br /&gt;
    }&lt;br /&gt;
   else {&lt;br /&gt;
        //Retrieve the ImageFormat enum to be passed into the updated function&lt;br /&gt;
        let image_type: Option&amp;lt; servo_image::ImageFormat &amp;gt; = get_format(ext);&lt;br /&gt;
	if image_type == None&lt;br /&gt;
	{&lt;br /&gt;
	panic!(&amp;quot;Image format not supported!&amp;quot;);&lt;br /&gt;
	}&lt;br /&gt;
	else{&lt;br /&gt;
        let new_image_type: servo_image::ImageFormat = image_type.unwrap();&lt;br /&gt;
        &lt;br /&gt;
        //The updated function returns a Result&amp;lt;DynamicImage&amp;gt;&lt;br /&gt;
        //below code resolves it to be returned by the wrapper function&lt;br /&gt;
	let result = servo_image::load_from_memory(buffer,new_image_type);&lt;br /&gt;
	if result.is_ok() {&lt;br /&gt;
  	    let v = result.unwrap();&lt;br /&gt;
  	    return Some(v);&lt;br /&gt;
	}&lt;br /&gt;
	else  {	&lt;br /&gt;
	    return None;&lt;br /&gt;
	}		&lt;br /&gt;
   }&lt;br /&gt;
   }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Flowchart describing Project Implementation==&lt;br /&gt;
[[File:Flowchart_final_M1455.JPG]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
&lt;br /&gt;
===Class Diagram===&lt;br /&gt;
[[File:Class_diagram_M1455.JPG]]&lt;br /&gt;
&lt;br /&gt;
== Test Cases ==&lt;br /&gt;
&lt;br /&gt;
The project does not plan to add new functionality. &lt;br /&gt;
The test-cases we propose to run are will ensure that tasks that could be performed with the older C libraries can be executed.&lt;br /&gt;
&lt;br /&gt;
The following test cases are proposed.&lt;br /&gt;
&lt;br /&gt;
1. The initial step test case includes printing the decoding time for various image formates and has been included in the wiki: [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_M1455_asa initial step]&lt;br /&gt;
&lt;br /&gt;
2. The profiler is meant to capture the image decoding time take by the load_from_memory function. The profiler is run using the following command which gives the decoding time for the image passed as an argument:&lt;br /&gt;
&amp;lt;pre&amp;gt;./mach run -p 1 https://optipng.sourceforge.net/pngtech/img/lena.html&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
3. After replacing the rust-freetype library by the freetype-rs library, we have tested that it works as expected by passing a webpage url and checking that the text renders correctly.&lt;br /&gt;
&amp;lt;pre&amp;gt;./mach run http://simple.wikipedia.org/wiki/Main_Page&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. After replacing the rust-stb-image and stb-image libraries with rust-image library and rewriting the load_from_memory function, we tested the the imports worked as expected by passing in different formats of images as urls and rendering them. &lt;br /&gt;
&amp;lt;pre&amp;gt; ./mach run https://www.http://optipng.sourceforge.net/pngtech/img/lena.png&amp;lt;/pre&amp;gt;&lt;br /&gt;
Below you can see the image being rendered after importing the new rust image library: &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;[[File:lenaRenderedCorrectly.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As you can see the image is being rendered as intended. &lt;br /&gt;
Note: This was previously broken due to a bug in our code. We had used the wrong enum type while decoding images that resulted in distorted images. This was fixed by the following [https://github.com/ankit3005/servo/commit/dfa0b92b21144c01223db78d8570aa5ac890922c commit].&lt;br /&gt;
&lt;br /&gt;
5. Our test cases include reporting the timing differences for loading PNGs and non-PNG images. The following report has been made with respect to the same:&lt;br /&gt;
{| class=&amp;quot;wikitable sortable mw-collapsible&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Image Source&lt;br /&gt;
!Resolution&lt;br /&gt;
!New library decode timing (in ms)&lt;br /&gt;
!Old library decode timing (in ms)&lt;br /&gt;
|-&lt;br /&gt;
|http://meesoft.logicnet.dk/Analyzer/help/Lenna.jpg&lt;br /&gt;
|256X256&lt;br /&gt;
|40.3814&lt;br /&gt;
|45.002006&lt;br /&gt;
|-&lt;br /&gt;
|http://peps.redprince.net/peps/tiger-Q300.png&lt;br /&gt;
|290X300&lt;br /&gt;
|78.0789&lt;br /&gt;
|29.636256&lt;br /&gt;
|-&lt;br /&gt;
|http://www.codeproject.com/KB/GDI-plus/ImageProcessing2/grayscale.jpg&lt;br /&gt;
|332X300&lt;br /&gt;
|106.7289&lt;br /&gt;
|64.298119&lt;br /&gt;
|-&lt;br /&gt;
|http://www.ampsoft.net/webdesign-l/img/JPEG-sample-landscape-standard.jpg&lt;br /&gt;
|300X200&lt;br /&gt;
|88.852&lt;br /&gt;
|42.395043&lt;br /&gt;
|-&lt;br /&gt;
|http://andreas.com/pixs/ping-sample.gif&lt;br /&gt;
|682X310&lt;br /&gt;
|106.9462&lt;br /&gt;
|124.54975&lt;br /&gt;
|-&lt;br /&gt;
|http://www.cs.cmu.edu/~chuck/lennapg/len_top.jpg&lt;br /&gt;
|400X225&lt;br /&gt;
|118.0558&lt;br /&gt;
|62.443986&lt;br /&gt;
|-&lt;br /&gt;
|http://www.roman10.net/wp-content/uploads/2011/08/sample_thumb.jpg&lt;br /&gt;
|484X316&lt;br /&gt;
|175.0287&lt;br /&gt;
|99.462362&lt;br /&gt;
|-&lt;br /&gt;
|http://www.kksou.com/php-gtk2/gif/sample6.png&lt;br /&gt;
|480X240&lt;br /&gt;
|223.9521&lt;br /&gt;
|44.864687&lt;br /&gt;
|-&lt;br /&gt;
|http://imagej.nih.gov/ij/images/lena.jpg&lt;br /&gt;
|512X512&lt;br /&gt;
|257.5638&lt;br /&gt;
|165.242363&lt;br /&gt;
|-&lt;br /&gt;
|http://people.sc.fsu.edu/~jburkardt/data/png/lena.png&lt;br /&gt;
|512X512&lt;br /&gt;
|397.7005&lt;br /&gt;
|88.834362&lt;br /&gt;
|-&lt;br /&gt;
|http://24.media.tumblr.com/tumblr_m97zes5x3k1rezf8ro1_500.jpg&lt;br /&gt;
|500X375&lt;br /&gt;
|312.1556&lt;br /&gt;
|129.003554&lt;br /&gt;
|-&lt;br /&gt;
|http://urlnextdoor.com/ai/design-layout/images/sample-png.png&lt;br /&gt;
|200X200&lt;br /&gt;
|152.053&lt;br /&gt;
|20.885724&lt;br /&gt;
|-&lt;br /&gt;
|https://cdn2.iconfinder.com/data/icons/free-3d-printer-icon-set/512/3d_objects.png&lt;br /&gt;
|512X512&lt;br /&gt;
|550.5805&lt;br /&gt;
|78.025999&lt;br /&gt;
|-&lt;br /&gt;
|http://www.samontab.com/web/wp-content/uploads/2012/06/lena3.png&lt;br /&gt;
|512X512&lt;br /&gt;
|811.8095&lt;br /&gt;
|97.916758&lt;br /&gt;
|-&lt;br /&gt;
|http://www.math.uga.edu/~mjlai/images/LenaRecovered.jpg&lt;br /&gt;
|1200X900&lt;br /&gt;
|909.2834&lt;br /&gt;
|662.842394&lt;br /&gt;
|-&lt;br /&gt;
|https://chadaphone.files.wordpress.com/2013/10/face_detection.png&lt;br /&gt;
|640X480&lt;br /&gt;
|942.4558&lt;br /&gt;
|113.816885&lt;br /&gt;
|-&lt;br /&gt;
|https://www.drupal.org/files/issues/sample_7.png&lt;br /&gt;
|800X600&lt;br /&gt;
|708.9273&lt;br /&gt;
|157.806566&lt;br /&gt;
|-&lt;br /&gt;
|http://optipng.sourceforge.net/pngtech/img/lena.png&lt;br /&gt;
|512X512&lt;br /&gt;
|924.4648&lt;br /&gt;
|95.02457&lt;br /&gt;
|-&lt;br /&gt;
|http://www.ultrasync.net/dee/warehouse_the_odd_stage/lena2_before_1024.png&lt;br /&gt;
|1024X1024&lt;br /&gt;
|1507.7304&lt;br /&gt;
|326.962991&lt;br /&gt;
|-&lt;br /&gt;
|http://menehune.opt.wfu.edu/CSC365_665/Proj1/Gif/lena.gif&lt;br /&gt;
|256X256&lt;br /&gt;
|2466.9467&lt;br /&gt;
|40.845023&lt;br /&gt;
|-&lt;br /&gt;
|http://www.openbsd.org/art/puffy/ppuf1000X907.gif&lt;br /&gt;
|1000x907&lt;br /&gt;
|56338.6327&lt;br /&gt;
|615.134272&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Video ==&lt;br /&gt;
A walkthrough of our entire project is available on this link: [https://www.youtube.com/watch?v=rq8MvpR1JyI Final Project Walkthrough]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_M1455_asa Initial Step Details]&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:LenaRenderedCorrectly.png&amp;diff=92524</id>
		<title>File:LenaRenderedCorrectly.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:LenaRenderedCorrectly.png&amp;diff=92524"/>
		<updated>2014-12-04T22:42:27Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: uploaded a new version of &amp;amp;quot;File:LenaRenderedCorrectly.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:LenaRenderedCorrectly.png&amp;diff=92523</id>
		<title>File:LenaRenderedCorrectly.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:LenaRenderedCorrectly.png&amp;diff=92523"/>
		<updated>2014-12-04T22:41:56Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: uploaded a new version of &amp;amp;quot;File:LenaRenderedCorrectly.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:LenaRenderedCorrectly.png&amp;diff=92522</id>
		<title>File:LenaRenderedCorrectly.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:LenaRenderedCorrectly.png&amp;diff=92522"/>
		<updated>2014-12-04T22:41:31Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: uploaded a new version of &amp;amp;quot;File:LenaRenderedCorrectly.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:LenaRenderedCorrectly.png&amp;diff=92521</id>
		<title>File:LenaRenderedCorrectly.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:LenaRenderedCorrectly.png&amp;diff=92521"/>
		<updated>2014-12-04T22:40:45Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=92520</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=92520"/>
		<updated>2014-12-04T22:40:30Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* Test Cases */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Background Information &amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_M1455_asa&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Servo currently depends on a lot of C libraries for image decoding. We wish to evaluate switching some of these to new Rust libraries. This project involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
====Setup of Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ensure that modified dependencies point to right sources&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./mach update-cargo -p freetype-rs&lt;br /&gt;
./mach update-cargo -p image&lt;br /&gt;
./mach update-cargo -p freetype-rs --precise 753496406098651c83cdaf63db9f75dc42da17c7&lt;br /&gt;
./mach update-cargo -p image --precise 3a398831adb22f1200cb68682e446ede187d23b9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run basic tests to ensure build success.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The scope of our project is limited to changing the libraries used in the image decoding task shown above.&lt;br /&gt;
&lt;br /&gt;
== Requirement analysis ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Servo currently depends on a lot of C libraries, because Rust equivalents for these libraries did not exist when the project started. Our project is to evaluate switching some of these to new Rust libraries that have since been created. It involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Initial step&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_M1455_asa initial step], implemented for the OSS project involved:&lt;br /&gt;
# Building Servo.&lt;br /&gt;
# Adding [http://doc.servo.org/util/time/fn.time.html timing code] to the image decoding implementation in the net crate.&lt;br /&gt;
# Rebuilding Servo.&lt;br /&gt;
# Reporting numbers for different kinds of images (i.e. PNG, JPEG, GIF).&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;b&amp;gt;Final Requirements&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our final project requirements are to:&lt;br /&gt;
* Build Servo and add code that reports (via the println! macro) the time required to decode images into displayable pixels.&lt;br /&gt;
* Add image decoding timing to the profiler.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/freetype-rs freetype-rs] library to replace [https://github.com/servo/rust-freetype rust-freetype] in Servo, rewriting necessary code.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3369&amp;lt;/ref&amp;gt; For this, we are to use [http://doc.crates.io/ Cargo], the dependency manager for Servo.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/image rust-image] library to replace the [https://github.com/servo/rust-stb-image rust-stb-image] and [https://github.com/nothings/stb stb-image] libraries and rewrite the &amp;lt;code&amp;gt;load_from_memory&amp;lt;/code&amp;gt; function which uses these libraries.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3368&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Report the timing differences for loading PNGs and non-PNGs on the same benchmarks. For this step, we are to consider profiling the result and optimizing the hotspots in rust-image.&lt;br /&gt;
&lt;br /&gt;
== Implementation of the Final Requirements ==&lt;br /&gt;
&lt;br /&gt;
1. Add Image Decoding time to the Profiler&lt;br /&gt;
To profile the time required by the load_from_memory to decode an image, we make a call to the profiler which outputs the time taken to decode on the console. To enable the profiler to do so, the following files were changed:&lt;br /&gt;
*image_cache_task.rs&lt;br /&gt;
*lib.rs&lt;br /&gt;
*time.rs&lt;br /&gt;
To invoke the profiler, we added a category under which to group the timings and passed a TimeProfilerChan (ie. a channel for communicating with the profiler task) to the ImageCacheTask::new method. On successfully building and running servo, we get the following image timings by profiler on the console:&lt;br /&gt;
&amp;lt;pre&amp;gt; ./mach run -p 1 https://optipng.sourceforge.net/pngtech/img/lena.html &amp;lt;/pre&amp;gt;&lt;br /&gt;
[[File:Profiler.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Imported the freetype-rs library to replace rust-freetype in Servo.&lt;br /&gt;
We replaced the currently used rust-freetype library with the freetype-rs library. To enable proper functioning of servo after importing the new library, following files were modified in the repository [https://github.com/PistonDevelopers/freetype-rs PistonDevelopers/freetype-rs]:&lt;br /&gt;
*Cargo.toml &lt;br /&gt;
*src/ffi.rs&lt;br /&gt;
*src/lib.rs&lt;br /&gt;
*src/lib.rs&lt;br /&gt;
*src/library.rs&lt;br /&gt;
*src/tt_os2.rs&lt;br /&gt;
These changes were committed and have been pulled by PistonDevelopers. Check the changes on [https://github.com/PistonDevelopers/freetype-rs/pull/70 pull request] for more info.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Imported the rust-image library to replace the rust-stb-image and stb-image libraries and rewrite the load_from_memory function which uses these libraries.&lt;br /&gt;
In order to import the new library we modified the following files files in the repository [https://github.com/ankit3005/servo]:&lt;br /&gt;
*Cargo.toml &lt;br /&gt;
*components/net/lib.rs&lt;br /&gt;
*components/net/image_cache_task.rs&lt;br /&gt;
*components/net/image/base.rs&lt;br /&gt;
*components/net/image/holder.rs&lt;br /&gt;
*components/gfx/render_context.rs&lt;br /&gt;
*components/gfx/lib.rs&lt;br /&gt;
*components/gfx/Cargo.toml&lt;br /&gt;
*components/gfx/display_list/mod.rs&lt;br /&gt;
*components/layout/display_list_builder.rs&lt;br /&gt;
*components/layout/lib.rs&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Reported the timing differences for loading PNGs and non-PNGs on the same benchmarks.&lt;br /&gt;
Once the new image library was imported , passed in several test images to record the decoding timing for different images.&lt;br /&gt;
The timing was compared with the decoding time for images by passing in the same images to the servo build containing the C image library. The results can be seen in the Test-Cases section below.&lt;br /&gt;
&lt;br /&gt;
== Data and component design &amp;lt;ref&amp;gt;http://www.rust-ci.org/PistonDevelopers/piston/doc/image/index.html&amp;lt;/ref&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
===Data Design===&lt;br /&gt;
The system entities that the project deals with is present in the image crate.&lt;br /&gt;
&lt;br /&gt;
The structs and enums used to represent images are as below :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Structures&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ImageBuf&lt;br /&gt;
|An Image whose pixels are contained within a vector&lt;br /&gt;
|-&lt;br /&gt;
|Luma&lt;br /&gt;
|A type to hold a grayscale pixel&lt;br /&gt;
|-&lt;br /&gt;
|LumaA&lt;br /&gt;
|A type to hold a grayscale pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|MutPixels&lt;br /&gt;
|Mutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Pixels&lt;br /&gt;
|Immutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Rgb&lt;br /&gt;
|A type to hold an RGB pixel&lt;br /&gt;
|-&lt;br /&gt;
|Rgba&lt;br /&gt;
|A type to hold an RGB pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|SubImage&lt;br /&gt;
|A View into another image&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Enums&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ColorType&lt;br /&gt;
|An enumeration over supported color types and their bit depths&lt;br /&gt;
|-&lt;br /&gt;
|DynamicImage&lt;br /&gt;
|A Dynamic Image&lt;br /&gt;
|-&lt;br /&gt;
|FilterType&lt;br /&gt;
|Available Sampling Filters&lt;br /&gt;
|-&lt;br /&gt;
|ImageError&lt;br /&gt;
|An enumeration of Image Errors&lt;br /&gt;
|-&lt;br /&gt;
|ImageFormat&lt;br /&gt;
|An enumeration of supported image formats. Not all formats support both encoding and decoding.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Component Design===&lt;br /&gt;
&lt;br /&gt;
Rust image : It is an image processing library. This crate provides basic imaging processing functions and methods for converting to and from image formats.&lt;br /&gt;
All image processing functions provided operate on types that implement the GenericImage trait and return an ImageBuf. The details of other modules and  traits included are :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Modules&amp;lt;ref&amp;gt;http://doc.rust-lang.org/guide.html#crates-and-modules&amp;lt;/ref&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|gif&lt;br /&gt;
|Decoding of GIF Images&lt;br /&gt;
|-&lt;br /&gt;
|imageops&lt;br /&gt;
|Image Processing Functions&lt;br /&gt;
|-&lt;br /&gt;
|jpeg&lt;br /&gt;
|Decoding and Encoding of JPEG Images&lt;br /&gt;
|-&lt;br /&gt;
|png&lt;br /&gt;
|Decoding and Encoding of PNG Images&lt;br /&gt;
|-&lt;br /&gt;
|ppm&lt;br /&gt;
|Encoding of portable pixmap Images&lt;br /&gt;
|-&lt;br /&gt;
|webp&lt;br /&gt;
|Decoding of Webp Images&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Traits&amp;lt;ref&amp;gt;http://rustbyexample.com/trait.html&amp;lt;/ref&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|GenericImage&lt;br /&gt;
|A trait for manipulating images.&lt;br /&gt;
|-&lt;br /&gt;
|ImageDecoder&lt;br /&gt;
|The trait that all decoders implement&lt;br /&gt;
|-&lt;br /&gt;
|MutableRefImage&lt;br /&gt;
|A trait for images that allow providing mutable references to pixels.&lt;br /&gt;
|-&lt;br /&gt;
|Pixel&lt;br /&gt;
|A trait that all pixels implement.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Functions&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|load&lt;br /&gt;
|Create a new image from a Reader&lt;br /&gt;
|-&lt;br /&gt;
|load_from_memory&lt;br /&gt;
|Create a new image from a byte slice&lt;br /&gt;
|-&lt;br /&gt;
|open&lt;br /&gt;
|Open the image located at the path specified. The image's format is determined from the path's file extension&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
&lt;br /&gt;
We are adhering to the following design principles for our implementation:&lt;br /&gt;
&lt;br /&gt;
'''Open-Closed Principle'''&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Open/closed_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Although our task is to evaluate replacing C libraries with Rust libraries, we won't actually be modifying any existing functionality.&lt;br /&gt;
&lt;br /&gt;
'''Interface Segregation Principle'''&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Interface_segregation_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The existing code is currently using the ''rust-freetype'' library for rendering fonts on the browser. We will be replacing this with the ''freetype-rs'' library, which divides the functionality offered by the former into smaller libraries which can be individually implemented instead of calling the entire library.&lt;br /&gt;
&lt;br /&gt;
== Design Pattern==&lt;br /&gt;
&lt;br /&gt;
We have implemented the Adapter Pattern in our Project:&lt;br /&gt;
&lt;br /&gt;
When we updated the image library, the function load_from_memory() in base.rs had to be updated since the return from the updated function accepts a different set of parameters.&lt;br /&gt;
We implemented the Adapter pattern as a wrapper function over the new load_from_memory() function which performs the below functions:&lt;br /&gt;
1. Based on the file extension generate the ImageFormat Enum.&lt;br /&gt;
2. The return of the new function is a Result&amp;lt;DynamicImage&amp;gt;. This needs to be converted into a DynamicImage struct.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pub fn load_from_memory(buffer: &amp;amp;[u8],ext: &amp;amp;str) -&amp;gt; Option&amp;lt;DynamicImage&amp;gt; {&lt;br /&gt;
    if buffer.len() == 0 {&lt;br /&gt;
        return None;&lt;br /&gt;
    }&lt;br /&gt;
   else {&lt;br /&gt;
        //Retrieve the ImageFormat enum to be passed into the updated function&lt;br /&gt;
        let image_type: Option&amp;lt; servo_image::ImageFormat &amp;gt; = get_format(ext);&lt;br /&gt;
	if image_type == None&lt;br /&gt;
	{&lt;br /&gt;
	panic!(&amp;quot;Image format not supported!&amp;quot;);&lt;br /&gt;
	}&lt;br /&gt;
	else{&lt;br /&gt;
        let new_image_type: servo_image::ImageFormat = image_type.unwrap();&lt;br /&gt;
        &lt;br /&gt;
        //The updated function returns a Result&amp;lt;DynamicImage&amp;gt;&lt;br /&gt;
        //below code resolves it to be returned by the wrapper function&lt;br /&gt;
	let result = servo_image::load_from_memory(buffer,new_image_type);&lt;br /&gt;
	if result.is_ok() {&lt;br /&gt;
  	    let v = result.unwrap();&lt;br /&gt;
  	    return Some(v);&lt;br /&gt;
	}&lt;br /&gt;
	else  {	&lt;br /&gt;
	    return None;&lt;br /&gt;
	}		&lt;br /&gt;
   }&lt;br /&gt;
   }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Flowchart describing Project Implementation==&lt;br /&gt;
[[File:Flowchart_final_M1455.JPG]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
&lt;br /&gt;
===Class Diagram===&lt;br /&gt;
[[File:Class_diagram_M1455.JPG]]&lt;br /&gt;
&lt;br /&gt;
== Test Cases ==&lt;br /&gt;
&lt;br /&gt;
The project does not plan to add new functionality. &lt;br /&gt;
The test-cases we propose to run are will ensure that tasks that could be performed with the older C libraries can be executed.&lt;br /&gt;
&lt;br /&gt;
The following test cases are proposed.&lt;br /&gt;
&lt;br /&gt;
1. The initial step test case includes printing the decoding time for various image formates and has been included in the wiki: [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_M1455_asa initial step]&lt;br /&gt;
&lt;br /&gt;
2. The profiler is meant to capture the image decoding time take by the load_from_memory function. The profiler is run using the following command which gives the decoding time for the image passed as an argument:&lt;br /&gt;
&amp;lt;pre&amp;gt;./mach run -p 1 https://optipng.sourceforge.net/pngtech/img/lena.html&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
3. After replacing the rust-freetype library by the freetype-rs library, we have tested that it works as expected by passing a webpage url and checking that the text renders correctly.&lt;br /&gt;
&amp;lt;pre&amp;gt;./mach run http://simple.wikipedia.org/wiki/Main_Page&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. After replacing the rust-stb-image and stb-image libraries with rust-image library and rewriting the load_from_memory function, we tested the the imports worked as expected by passing in different formats of images as urls and rendering them. &lt;br /&gt;
&amp;lt;pre&amp;gt; ./mach run https://www.http://optipng.sourceforge.net/pngtech/img/lena.png&amp;lt;/pre&amp;gt;&lt;br /&gt;
Below you can see the image being rendered after importing the new rust image library: &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;[[File:lenaRenderedCorrectly.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As you can see the image is being rendered as intended. &lt;br /&gt;
Note: This was previously broken due to a bug in our code. We had used the wrong enum type while decoding images that resulted in distorted images. This was fixed by the following [commit https://github.com/ankit3005/servo/commit/dfa0b92b21144c01223db78d8570aa5ac890922c].&lt;br /&gt;
&lt;br /&gt;
5. Our test cases include reporting the timing differences for loading PNGs and non-PNG images. The following report has been made with respect to the same:&lt;br /&gt;
{| class=&amp;quot;wikitable sortable mw-collapsible&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Image Source&lt;br /&gt;
!Resolution&lt;br /&gt;
!New library decode timing (in ms)&lt;br /&gt;
!Old library decode timing (in ms)&lt;br /&gt;
|-&lt;br /&gt;
|http://meesoft.logicnet.dk/Analyzer/help/Lenna.jpg&lt;br /&gt;
|256X256&lt;br /&gt;
|40.3814&lt;br /&gt;
|45.002006&lt;br /&gt;
|-&lt;br /&gt;
|http://peps.redprince.net/peps/tiger-Q300.png&lt;br /&gt;
|290X300&lt;br /&gt;
|78.0789&lt;br /&gt;
|29.636256&lt;br /&gt;
|-&lt;br /&gt;
|http://www.codeproject.com/KB/GDI-plus/ImageProcessing2/grayscale.jpg&lt;br /&gt;
|332X300&lt;br /&gt;
|106.7289&lt;br /&gt;
|64.298119&lt;br /&gt;
|-&lt;br /&gt;
|http://www.ampsoft.net/webdesign-l/img/JPEG-sample-landscape-standard.jpg&lt;br /&gt;
|300X200&lt;br /&gt;
|88.852&lt;br /&gt;
|42.395043&lt;br /&gt;
|-&lt;br /&gt;
|http://andreas.com/pixs/ping-sample.gif&lt;br /&gt;
|682X310&lt;br /&gt;
|106.9462&lt;br /&gt;
|124.54975&lt;br /&gt;
|-&lt;br /&gt;
|http://www.cs.cmu.edu/~chuck/lennapg/len_top.jpg&lt;br /&gt;
|400X225&lt;br /&gt;
|118.0558&lt;br /&gt;
|62.443986&lt;br /&gt;
|-&lt;br /&gt;
|http://www.roman10.net/wp-content/uploads/2011/08/sample_thumb.jpg&lt;br /&gt;
|484X316&lt;br /&gt;
|175.0287&lt;br /&gt;
|99.462362&lt;br /&gt;
|-&lt;br /&gt;
|http://www.kksou.com/php-gtk2/gif/sample6.png&lt;br /&gt;
|480X240&lt;br /&gt;
|223.9521&lt;br /&gt;
|44.864687&lt;br /&gt;
|-&lt;br /&gt;
|http://imagej.nih.gov/ij/images/lena.jpg&lt;br /&gt;
|512X512&lt;br /&gt;
|257.5638&lt;br /&gt;
|165.242363&lt;br /&gt;
|-&lt;br /&gt;
|http://people.sc.fsu.edu/~jburkardt/data/png/lena.png&lt;br /&gt;
|512X512&lt;br /&gt;
|397.7005&lt;br /&gt;
|88.834362&lt;br /&gt;
|-&lt;br /&gt;
|http://24.media.tumblr.com/tumblr_m97zes5x3k1rezf8ro1_500.jpg&lt;br /&gt;
|500X375&lt;br /&gt;
|312.1556&lt;br /&gt;
|129.003554&lt;br /&gt;
|-&lt;br /&gt;
|http://urlnextdoor.com/ai/design-layout/images/sample-png.png&lt;br /&gt;
|200X200&lt;br /&gt;
|152.053&lt;br /&gt;
|20.885724&lt;br /&gt;
|-&lt;br /&gt;
|https://cdn2.iconfinder.com/data/icons/free-3d-printer-icon-set/512/3d_objects.png&lt;br /&gt;
|512X512&lt;br /&gt;
|550.5805&lt;br /&gt;
|78.025999&lt;br /&gt;
|-&lt;br /&gt;
|http://www.samontab.com/web/wp-content/uploads/2012/06/lena3.png&lt;br /&gt;
|512X512&lt;br /&gt;
|811.8095&lt;br /&gt;
|97.916758&lt;br /&gt;
|-&lt;br /&gt;
|http://www.math.uga.edu/~mjlai/images/LenaRecovered.jpg&lt;br /&gt;
|1200X900&lt;br /&gt;
|909.2834&lt;br /&gt;
|662.842394&lt;br /&gt;
|-&lt;br /&gt;
|https://chadaphone.files.wordpress.com/2013/10/face_detection.png&lt;br /&gt;
|640X480&lt;br /&gt;
|942.4558&lt;br /&gt;
|113.816885&lt;br /&gt;
|-&lt;br /&gt;
|https://www.drupal.org/files/issues/sample_7.png&lt;br /&gt;
|800X600&lt;br /&gt;
|708.9273&lt;br /&gt;
|157.806566&lt;br /&gt;
|-&lt;br /&gt;
|http://optipng.sourceforge.net/pngtech/img/lena.png&lt;br /&gt;
|512X512&lt;br /&gt;
|924.4648&lt;br /&gt;
|95.02457&lt;br /&gt;
|-&lt;br /&gt;
|http://www.ultrasync.net/dee/warehouse_the_odd_stage/lena2_before_1024.png&lt;br /&gt;
|1024X1024&lt;br /&gt;
|1507.7304&lt;br /&gt;
|326.962991&lt;br /&gt;
|-&lt;br /&gt;
|http://menehune.opt.wfu.edu/CSC365_665/Proj1/Gif/lena.gif&lt;br /&gt;
|256X256&lt;br /&gt;
|2466.9467&lt;br /&gt;
|40.845023&lt;br /&gt;
|-&lt;br /&gt;
|http://www.openbsd.org/art/puffy/ppuf1000X907.gif&lt;br /&gt;
|1000x907&lt;br /&gt;
|56338.6327&lt;br /&gt;
|615.134272&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Video ==&lt;br /&gt;
A walkthrough of our entire project is available on this link: [https://www.youtube.com/watch?v=rq8MvpR1JyI Final Project Walkthrough]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_M1455_asa Initial Step Details]&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=92519</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=92519"/>
		<updated>2014-12-04T22:35:26Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* Test Cases */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Background Information &amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_M1455_asa&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Servo currently depends on a lot of C libraries for image decoding. We wish to evaluate switching some of these to new Rust libraries. This project involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
====Setup of Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ensure that modified dependencies point to right sources&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./mach update-cargo -p freetype-rs&lt;br /&gt;
./mach update-cargo -p image&lt;br /&gt;
./mach update-cargo -p freetype-rs --precise 753496406098651c83cdaf63db9f75dc42da17c7&lt;br /&gt;
./mach update-cargo -p image --precise 3a398831adb22f1200cb68682e446ede187d23b9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run basic tests to ensure build success.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The scope of our project is limited to changing the libraries used in the image decoding task shown above.&lt;br /&gt;
&lt;br /&gt;
== Requirement analysis ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Servo currently depends on a lot of C libraries, because Rust equivalents for these libraries did not exist when the project started. Our project is to evaluate switching some of these to new Rust libraries that have since been created. It involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Initial step&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_M1455_asa initial step], implemented for the OSS project involved:&lt;br /&gt;
# Building Servo.&lt;br /&gt;
# Adding [http://doc.servo.org/util/time/fn.time.html timing code] to the image decoding implementation in the net crate.&lt;br /&gt;
# Rebuilding Servo.&lt;br /&gt;
# Reporting numbers for different kinds of images (i.e. PNG, JPEG, GIF).&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;b&amp;gt;Final Requirements&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our final project requirements are to:&lt;br /&gt;
* Build Servo and add code that reports (via the println! macro) the time required to decode images into displayable pixels.&lt;br /&gt;
* Add image decoding timing to the profiler.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/freetype-rs freetype-rs] library to replace [https://github.com/servo/rust-freetype rust-freetype] in Servo, rewriting necessary code.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3369&amp;lt;/ref&amp;gt; For this, we are to use [http://doc.crates.io/ Cargo], the dependency manager for Servo.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/image rust-image] library to replace the [https://github.com/servo/rust-stb-image rust-stb-image] and [https://github.com/nothings/stb stb-image] libraries and rewrite the &amp;lt;code&amp;gt;load_from_memory&amp;lt;/code&amp;gt; function which uses these libraries.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3368&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Report the timing differences for loading PNGs and non-PNGs on the same benchmarks. For this step, we are to consider profiling the result and optimizing the hotspots in rust-image.&lt;br /&gt;
&lt;br /&gt;
== Implementation of the Final Requirements ==&lt;br /&gt;
&lt;br /&gt;
1. Add Image Decoding time to the Profiler&lt;br /&gt;
To profile the time required by the load_from_memory to decode an image, we make a call to the profiler which outputs the time taken to decode on the console. To enable the profiler to do so, the following files were changed:&lt;br /&gt;
*image_cache_task.rs&lt;br /&gt;
*lib.rs&lt;br /&gt;
*time.rs&lt;br /&gt;
To invoke the profiler, we added a category under which to group the timings and passed a TimeProfilerChan (ie. a channel for communicating with the profiler task) to the ImageCacheTask::new method. On successfully building and running servo, we get the following image timings by profiler on the console:&lt;br /&gt;
&amp;lt;pre&amp;gt; ./mach run -p 1 https://optipng.sourceforge.net/pngtech/img/lena.html &amp;lt;/pre&amp;gt;&lt;br /&gt;
[[File:Profiler.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Imported the freetype-rs library to replace rust-freetype in Servo.&lt;br /&gt;
We replaced the currently used rust-freetype library with the freetype-rs library. To enable proper functioning of servo after importing the new library, following files were modified in the repository [https://github.com/PistonDevelopers/freetype-rs PistonDevelopers/freetype-rs]:&lt;br /&gt;
*Cargo.toml &lt;br /&gt;
*src/ffi.rs&lt;br /&gt;
*src/lib.rs&lt;br /&gt;
*src/lib.rs&lt;br /&gt;
*src/library.rs&lt;br /&gt;
*src/tt_os2.rs&lt;br /&gt;
These changes were committed and have been pulled by PistonDevelopers. Check the changes on [https://github.com/PistonDevelopers/freetype-rs/pull/70 pull request] for more info.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Imported the rust-image library to replace the rust-stb-image and stb-image libraries and rewrite the load_from_memory function which uses these libraries.&lt;br /&gt;
In order to import the new library we modified the following files files in the repository [https://github.com/ankit3005/servo]:&lt;br /&gt;
*Cargo.toml &lt;br /&gt;
*components/net/lib.rs&lt;br /&gt;
*components/net/image_cache_task.rs&lt;br /&gt;
*components/net/image/base.rs&lt;br /&gt;
*components/net/image/holder.rs&lt;br /&gt;
*components/gfx/render_context.rs&lt;br /&gt;
*components/gfx/lib.rs&lt;br /&gt;
*components/gfx/Cargo.toml&lt;br /&gt;
*components/gfx/display_list/mod.rs&lt;br /&gt;
*components/layout/display_list_builder.rs&lt;br /&gt;
*components/layout/lib.rs&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Reported the timing differences for loading PNGs and non-PNGs on the same benchmarks.&lt;br /&gt;
Once the new image library was imported , passed in several test images to record the decoding timing for different images.&lt;br /&gt;
The timing was compared with the decoding time for images by passing in the same images to the servo build containing the C image library. The results can be seen in the Test-Cases section below.&lt;br /&gt;
&lt;br /&gt;
== Data and component design &amp;lt;ref&amp;gt;http://www.rust-ci.org/PistonDevelopers/piston/doc/image/index.html&amp;lt;/ref&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
===Data Design===&lt;br /&gt;
The system entities that the project deals with is present in the image crate.&lt;br /&gt;
&lt;br /&gt;
The structs and enums used to represent images are as below :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Structures&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ImageBuf&lt;br /&gt;
|An Image whose pixels are contained within a vector&lt;br /&gt;
|-&lt;br /&gt;
|Luma&lt;br /&gt;
|A type to hold a grayscale pixel&lt;br /&gt;
|-&lt;br /&gt;
|LumaA&lt;br /&gt;
|A type to hold a grayscale pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|MutPixels&lt;br /&gt;
|Mutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Pixels&lt;br /&gt;
|Immutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Rgb&lt;br /&gt;
|A type to hold an RGB pixel&lt;br /&gt;
|-&lt;br /&gt;
|Rgba&lt;br /&gt;
|A type to hold an RGB pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|SubImage&lt;br /&gt;
|A View into another image&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Enums&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ColorType&lt;br /&gt;
|An enumeration over supported color types and their bit depths&lt;br /&gt;
|-&lt;br /&gt;
|DynamicImage&lt;br /&gt;
|A Dynamic Image&lt;br /&gt;
|-&lt;br /&gt;
|FilterType&lt;br /&gt;
|Available Sampling Filters&lt;br /&gt;
|-&lt;br /&gt;
|ImageError&lt;br /&gt;
|An enumeration of Image Errors&lt;br /&gt;
|-&lt;br /&gt;
|ImageFormat&lt;br /&gt;
|An enumeration of supported image formats. Not all formats support both encoding and decoding.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Component Design===&lt;br /&gt;
&lt;br /&gt;
Rust image : It is an image processing library. This crate provides basic imaging processing functions and methods for converting to and from image formats.&lt;br /&gt;
All image processing functions provided operate on types that implement the GenericImage trait and return an ImageBuf. The details of other modules and  traits included are :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Modules&amp;lt;ref&amp;gt;http://doc.rust-lang.org/guide.html#crates-and-modules&amp;lt;/ref&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|gif&lt;br /&gt;
|Decoding of GIF Images&lt;br /&gt;
|-&lt;br /&gt;
|imageops&lt;br /&gt;
|Image Processing Functions&lt;br /&gt;
|-&lt;br /&gt;
|jpeg&lt;br /&gt;
|Decoding and Encoding of JPEG Images&lt;br /&gt;
|-&lt;br /&gt;
|png&lt;br /&gt;
|Decoding and Encoding of PNG Images&lt;br /&gt;
|-&lt;br /&gt;
|ppm&lt;br /&gt;
|Encoding of portable pixmap Images&lt;br /&gt;
|-&lt;br /&gt;
|webp&lt;br /&gt;
|Decoding of Webp Images&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Traits&amp;lt;ref&amp;gt;http://rustbyexample.com/trait.html&amp;lt;/ref&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|GenericImage&lt;br /&gt;
|A trait for manipulating images.&lt;br /&gt;
|-&lt;br /&gt;
|ImageDecoder&lt;br /&gt;
|The trait that all decoders implement&lt;br /&gt;
|-&lt;br /&gt;
|MutableRefImage&lt;br /&gt;
|A trait for images that allow providing mutable references to pixels.&lt;br /&gt;
|-&lt;br /&gt;
|Pixel&lt;br /&gt;
|A trait that all pixels implement.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Functions&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|load&lt;br /&gt;
|Create a new image from a Reader&lt;br /&gt;
|-&lt;br /&gt;
|load_from_memory&lt;br /&gt;
|Create a new image from a byte slice&lt;br /&gt;
|-&lt;br /&gt;
|open&lt;br /&gt;
|Open the image located at the path specified. The image's format is determined from the path's file extension&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
&lt;br /&gt;
We are adhering to the following design principles for our implementation:&lt;br /&gt;
&lt;br /&gt;
'''Open-Closed Principle'''&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Open/closed_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Although our task is to evaluate replacing C libraries with Rust libraries, we won't actually be modifying any existing functionality.&lt;br /&gt;
&lt;br /&gt;
'''Interface Segregation Principle'''&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Interface_segregation_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The existing code is currently using the ''rust-freetype'' library for rendering fonts on the browser. We will be replacing this with the ''freetype-rs'' library, which divides the functionality offered by the former into smaller libraries which can be individually implemented instead of calling the entire library.&lt;br /&gt;
&lt;br /&gt;
== Design Pattern==&lt;br /&gt;
&lt;br /&gt;
We have implemented the Adapter Pattern in our Project:&lt;br /&gt;
&lt;br /&gt;
When we updated the image library, the function load_from_memory() in base.rs had to be updated since the return from the updated function accepts a different set of parameters.&lt;br /&gt;
We implemented the Adapter pattern as a wrapper function over the new load_from_memory() function which performs the below functions:&lt;br /&gt;
1. Based on the file extension generate the ImageFormat Enum.&lt;br /&gt;
2. The return of the new function is a Result&amp;lt;DynamicImage&amp;gt;. This needs to be converted into a DynamicImage struct.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pub fn load_from_memory(buffer: &amp;amp;[u8],ext: &amp;amp;str) -&amp;gt; Option&amp;lt;DynamicImage&amp;gt; {&lt;br /&gt;
    if buffer.len() == 0 {&lt;br /&gt;
        return None;&lt;br /&gt;
    }&lt;br /&gt;
   else {&lt;br /&gt;
        //Retrieve the ImageFormat enum to be passed into the updated function&lt;br /&gt;
        let image_type: Option&amp;lt; servo_image::ImageFormat &amp;gt; = get_format(ext);&lt;br /&gt;
	if image_type == None&lt;br /&gt;
	{&lt;br /&gt;
	panic!(&amp;quot;Image format not supported!&amp;quot;);&lt;br /&gt;
	}&lt;br /&gt;
	else{&lt;br /&gt;
        let new_image_type: servo_image::ImageFormat = image_type.unwrap();&lt;br /&gt;
        &lt;br /&gt;
        //The updated function returns a Result&amp;lt;DynamicImage&amp;gt;&lt;br /&gt;
        //below code resolves it to be returned by the wrapper function&lt;br /&gt;
	let result = servo_image::load_from_memory(buffer,new_image_type);&lt;br /&gt;
	if result.is_ok() {&lt;br /&gt;
  	    let v = result.unwrap();&lt;br /&gt;
  	    return Some(v);&lt;br /&gt;
	}&lt;br /&gt;
	else  {	&lt;br /&gt;
	    return None;&lt;br /&gt;
	}		&lt;br /&gt;
   }&lt;br /&gt;
   }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Flowchart describing Project Implementation==&lt;br /&gt;
[[File:Flowchart_final_M1455.JPG]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
&lt;br /&gt;
===Class Diagram===&lt;br /&gt;
[[File:Class_diagram_M1455.JPG]]&lt;br /&gt;
&lt;br /&gt;
== Test Cases ==&lt;br /&gt;
&lt;br /&gt;
The project does not plan to add new functionality. &lt;br /&gt;
The test-cases we propose to run are will ensure that tasks that could be performed with the older C libraries can be executed.&lt;br /&gt;
&lt;br /&gt;
The following test cases are proposed.&lt;br /&gt;
&lt;br /&gt;
1. The initial step test case includes printing the decoding time for various image formates and has been included in the wiki: [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_M1455_asa initial step]&lt;br /&gt;
&lt;br /&gt;
2. The profiler is meant to capture the image decoding time take by the load_from_memory function. The profiler is run using the following command which gives the decoding time for the image passed as an argument:&lt;br /&gt;
&amp;lt;pre&amp;gt;./mach run -p 1 https://optipng.sourceforge.net/pngtech/img/lena.html&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
3. After replacing the rust-freetype library by the freetype-rs library, we have tested that it works as expected by passing a webpage url and checking that the text renders correctly.&lt;br /&gt;
&amp;lt;pre&amp;gt;./mach run http://simple.wikipedia.org/wiki/Main_Page&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. After replacing the rust-stb-image and stb-image libraries with rust-image library and rewriting the load_from_memory function, we tested the the imports worked as expected by passing in different formats of images as urls and rendering them. &lt;br /&gt;
&amp;lt;pre&amp;gt; ./mach run https://www.http://optipng.sourceforge.net/pngtech/img/lena.png&amp;lt;/pre&amp;gt;&lt;br /&gt;
Below you can see the image being rendered after importing the new rust image library: &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;[[File:M1455newcrop.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As you can see the image is not being rendered as intended. It is suspected to be a bud in the rust image library developed by the PistonDevelopers. We have been asked by servo representatives to raise an issue with the developers of the rust image library.&lt;br /&gt;
&lt;br /&gt;
5. Our test cases include reporting the timing differences for loading PNGs and non-PNG images. The following report has been made with respect to the same:&lt;br /&gt;
{| class=&amp;quot;wikitable sortable mw-collapsible&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Image Source&lt;br /&gt;
!Resolution&lt;br /&gt;
!New library decode timing (in ms)&lt;br /&gt;
!Old library decode timing (in ms)&lt;br /&gt;
|-&lt;br /&gt;
|http://meesoft.logicnet.dk/Analyzer/help/Lenna.jpg&lt;br /&gt;
|256X256&lt;br /&gt;
|40.3814&lt;br /&gt;
|45.002006&lt;br /&gt;
|-&lt;br /&gt;
|http://peps.redprince.net/peps/tiger-Q300.png&lt;br /&gt;
|290X300&lt;br /&gt;
|78.0789&lt;br /&gt;
|29.636256&lt;br /&gt;
|-&lt;br /&gt;
|http://www.codeproject.com/KB/GDI-plus/ImageProcessing2/grayscale.jpg&lt;br /&gt;
|332X300&lt;br /&gt;
|106.7289&lt;br /&gt;
|64.298119&lt;br /&gt;
|-&lt;br /&gt;
|http://www.ampsoft.net/webdesign-l/img/JPEG-sample-landscape-standard.jpg&lt;br /&gt;
|300X200&lt;br /&gt;
|88.852&lt;br /&gt;
|42.395043&lt;br /&gt;
|-&lt;br /&gt;
|http://andreas.com/pixs/ping-sample.gif&lt;br /&gt;
|682X310&lt;br /&gt;
|106.9462&lt;br /&gt;
|124.54975&lt;br /&gt;
|-&lt;br /&gt;
|http://www.cs.cmu.edu/~chuck/lennapg/len_top.jpg&lt;br /&gt;
|400X225&lt;br /&gt;
|118.0558&lt;br /&gt;
|62.443986&lt;br /&gt;
|-&lt;br /&gt;
|http://www.roman10.net/wp-content/uploads/2011/08/sample_thumb.jpg&lt;br /&gt;
|484X316&lt;br /&gt;
|175.0287&lt;br /&gt;
|99.462362&lt;br /&gt;
|-&lt;br /&gt;
|http://www.kksou.com/php-gtk2/gif/sample6.png&lt;br /&gt;
|480X240&lt;br /&gt;
|223.9521&lt;br /&gt;
|44.864687&lt;br /&gt;
|-&lt;br /&gt;
|http://imagej.nih.gov/ij/images/lena.jpg&lt;br /&gt;
|512X512&lt;br /&gt;
|257.5638&lt;br /&gt;
|165.242363&lt;br /&gt;
|-&lt;br /&gt;
|http://people.sc.fsu.edu/~jburkardt/data/png/lena.png&lt;br /&gt;
|512X512&lt;br /&gt;
|397.7005&lt;br /&gt;
|88.834362&lt;br /&gt;
|-&lt;br /&gt;
|http://24.media.tumblr.com/tumblr_m97zes5x3k1rezf8ro1_500.jpg&lt;br /&gt;
|500X375&lt;br /&gt;
|312.1556&lt;br /&gt;
|129.003554&lt;br /&gt;
|-&lt;br /&gt;
|http://urlnextdoor.com/ai/design-layout/images/sample-png.png&lt;br /&gt;
|200X200&lt;br /&gt;
|152.053&lt;br /&gt;
|20.885724&lt;br /&gt;
|-&lt;br /&gt;
|https://cdn2.iconfinder.com/data/icons/free-3d-printer-icon-set/512/3d_objects.png&lt;br /&gt;
|512X512&lt;br /&gt;
|550.5805&lt;br /&gt;
|78.025999&lt;br /&gt;
|-&lt;br /&gt;
|http://www.samontab.com/web/wp-content/uploads/2012/06/lena3.png&lt;br /&gt;
|512X512&lt;br /&gt;
|811.8095&lt;br /&gt;
|97.916758&lt;br /&gt;
|-&lt;br /&gt;
|http://www.math.uga.edu/~mjlai/images/LenaRecovered.jpg&lt;br /&gt;
|1200X900&lt;br /&gt;
|909.2834&lt;br /&gt;
|662.842394&lt;br /&gt;
|-&lt;br /&gt;
|https://chadaphone.files.wordpress.com/2013/10/face_detection.png&lt;br /&gt;
|640X480&lt;br /&gt;
|942.4558&lt;br /&gt;
|113.816885&lt;br /&gt;
|-&lt;br /&gt;
|https://www.drupal.org/files/issues/sample_7.png&lt;br /&gt;
|800X600&lt;br /&gt;
|708.9273&lt;br /&gt;
|157.806566&lt;br /&gt;
|-&lt;br /&gt;
|http://optipng.sourceforge.net/pngtech/img/lena.png&lt;br /&gt;
|512X512&lt;br /&gt;
|924.4648&lt;br /&gt;
|95.02457&lt;br /&gt;
|-&lt;br /&gt;
|http://www.ultrasync.net/dee/warehouse_the_odd_stage/lena2_before_1024.png&lt;br /&gt;
|1024X1024&lt;br /&gt;
|1507.7304&lt;br /&gt;
|326.962991&lt;br /&gt;
|-&lt;br /&gt;
|http://menehune.opt.wfu.edu/CSC365_665/Proj1/Gif/lena.gif&lt;br /&gt;
|256X256&lt;br /&gt;
|2466.9467&lt;br /&gt;
|40.845023&lt;br /&gt;
|-&lt;br /&gt;
|http://www.openbsd.org/art/puffy/ppuf1000X907.gif&lt;br /&gt;
|1000x907&lt;br /&gt;
|56338.6327&lt;br /&gt;
|615.134272&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Video ==&lt;br /&gt;
A walkthrough of our entire project is available on this link: [https://www.youtube.com/watch?v=rq8MvpR1JyI Final Project Walkthrough]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_M1455_asa Initial Step Details]&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=92518</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=92518"/>
		<updated>2014-12-04T16:45:56Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* Setup of Development Environment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Background Information &amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_M1455_asa&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Servo currently depends on a lot of C libraries for image decoding. We wish to evaluate switching some of these to new Rust libraries. This project involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
====Setup of Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ensure that modified dependencies point to right sources&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./mach update-cargo -p freetype-rs&lt;br /&gt;
./mach update-cargo -p image&lt;br /&gt;
./mach update-cargo -p freetype-rs --precise 753496406098651c83cdaf63db9f75dc42da17c7&lt;br /&gt;
./mach update-cargo -p image --precise 3a398831adb22f1200cb68682e446ede187d23b9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run basic tests to ensure build success.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The scope of our project is limited to changing the libraries used in the image decoding task shown above.&lt;br /&gt;
&lt;br /&gt;
== Requirement analysis ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Servo currently depends on a lot of C libraries, because Rust equivalents for these libraries did not exist when the project started. Our project is to evaluate switching some of these to new Rust libraries that have since been created. It involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Initial step&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_M1455_asa initial step], implemented for the OSS project involved:&lt;br /&gt;
# Building Servo.&lt;br /&gt;
# Adding [http://doc.servo.org/util/time/fn.time.html timing code] to the image decoding implementation in the net crate.&lt;br /&gt;
# Rebuilding Servo.&lt;br /&gt;
# Reporting numbers for different kinds of images (i.e. PNG, JPEG, GIF).&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;b&amp;gt;Final Requirements&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our final project requirements are to:&lt;br /&gt;
* Build Servo and add code that reports (via the println! macro) the time required to decode images into displayable pixels.&lt;br /&gt;
* Add image decoding timing to the profiler.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/freetype-rs freetype-rs] library to replace [https://github.com/servo/rust-freetype rust-freetype] in Servo, rewriting necessary code.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3369&amp;lt;/ref&amp;gt; For this, we are to use [http://doc.crates.io/ Cargo], the dependency manager for Servo.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/image rust-image] library to replace the [https://github.com/servo/rust-stb-image rust-stb-image] and [https://github.com/nothings/stb stb-image] libraries and rewrite the &amp;lt;code&amp;gt;load_from_memory&amp;lt;/code&amp;gt; function which uses these libraries.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3368&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Report the timing differences for loading PNGs and non-PNGs on the same benchmarks. For this step, we are to consider profiling the result and optimizing the hotspots in rust-image.&lt;br /&gt;
&lt;br /&gt;
== Implementation of the Final Requirements ==&lt;br /&gt;
&lt;br /&gt;
1. Add Image Decoding time to the Profiler&lt;br /&gt;
To profile the time required by the load_from_memory to decode an image, we make a call to the profiler which outputs the time taken to decode on the console. To enable the profiler to do so, the following files were changed:&lt;br /&gt;
*image_cache_task.rs&lt;br /&gt;
*lib.rs&lt;br /&gt;
*time.rs&lt;br /&gt;
To invoke the profiler, we added a category under which to group the timings and passed a TimeProfilerChan (ie. a channel for communicating with the profiler task) to the ImageCacheTask::new method. On successfully building and running servo, we get the following image timings by profiler on the console:&lt;br /&gt;
&amp;lt;pre&amp;gt; ./mach run -p 1 https://optipng.sourceforge.net/pngtech/img/lena.html &amp;lt;/pre&amp;gt;&lt;br /&gt;
[[File:Profiler.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Imported the freetype-rs library to replace rust-freetype in Servo.&lt;br /&gt;
We replaced the currently used rust-freetype library with the freetype-rs library. To enable proper functioning of servo after importing the new library, following files were modified in the repository [https://github.com/PistonDevelopers/freetype-rs PistonDevelopers/freetype-rs]:&lt;br /&gt;
*Cargo.toml &lt;br /&gt;
*src/ffi.rs&lt;br /&gt;
*src/lib.rs&lt;br /&gt;
*src/lib.rs&lt;br /&gt;
*src/library.rs&lt;br /&gt;
*src/tt_os2.rs&lt;br /&gt;
These changes were committed and have been pulled by PistonDevelopers. Check the changes on [https://github.com/PistonDevelopers/freetype-rs/pull/70 pull request] for more info.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Imported the rust-image library to replace the rust-stb-image and stb-image libraries and rewrite the load_from_memory function which uses these libraries.&lt;br /&gt;
In order to import the new library we modified the following files files in the repository [https://github.com/ankit3005/servo]:&lt;br /&gt;
*Cargo.toml &lt;br /&gt;
*components/net/lib.rs&lt;br /&gt;
*components/net/image_cache_task.rs&lt;br /&gt;
*components/net/image/base.rs&lt;br /&gt;
*components/net/image/holder.rs&lt;br /&gt;
*components/gfx/render_context.rs&lt;br /&gt;
*components/gfx/lib.rs&lt;br /&gt;
*components/gfx/Cargo.toml&lt;br /&gt;
*components/gfx/display_list/mod.rs&lt;br /&gt;
*components/layout/display_list_builder.rs&lt;br /&gt;
*components/layout/lib.rs&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Reported the timing differences for loading PNGs and non-PNGs on the same benchmarks.&lt;br /&gt;
Once the new image library was imported , passed in several test images to record the decoding timing for different images.&lt;br /&gt;
The timing was compared with the decoding time for images by passing in the same images to the servo build containing the C image library. The results can be seen in the Test-Cases section below.&lt;br /&gt;
&lt;br /&gt;
== Data and component design &amp;lt;ref&amp;gt;http://www.rust-ci.org/PistonDevelopers/piston/doc/image/index.html&amp;lt;/ref&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
===Data Design===&lt;br /&gt;
The system entities that the project deals with is present in the image crate.&lt;br /&gt;
&lt;br /&gt;
The structs and enums used to represent images are as below :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Structures&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ImageBuf&lt;br /&gt;
|An Image whose pixels are contained within a vector&lt;br /&gt;
|-&lt;br /&gt;
|Luma&lt;br /&gt;
|A type to hold a grayscale pixel&lt;br /&gt;
|-&lt;br /&gt;
|LumaA&lt;br /&gt;
|A type to hold a grayscale pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|MutPixels&lt;br /&gt;
|Mutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Pixels&lt;br /&gt;
|Immutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Rgb&lt;br /&gt;
|A type to hold an RGB pixel&lt;br /&gt;
|-&lt;br /&gt;
|Rgba&lt;br /&gt;
|A type to hold an RGB pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|SubImage&lt;br /&gt;
|A View into another image&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Enums&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ColorType&lt;br /&gt;
|An enumeration over supported color types and their bit depths&lt;br /&gt;
|-&lt;br /&gt;
|DynamicImage&lt;br /&gt;
|A Dynamic Image&lt;br /&gt;
|-&lt;br /&gt;
|FilterType&lt;br /&gt;
|Available Sampling Filters&lt;br /&gt;
|-&lt;br /&gt;
|ImageError&lt;br /&gt;
|An enumeration of Image Errors&lt;br /&gt;
|-&lt;br /&gt;
|ImageFormat&lt;br /&gt;
|An enumeration of supported image formats. Not all formats support both encoding and decoding.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Component Design===&lt;br /&gt;
&lt;br /&gt;
Rust image : It is an image processing library. This crate provides basic imaging processing functions and methods for converting to and from image formats.&lt;br /&gt;
All image processing functions provided operate on types that implement the GenericImage trait and return an ImageBuf. The details of other modules and  traits included are :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Modules&amp;lt;ref&amp;gt;http://doc.rust-lang.org/guide.html#crates-and-modules&amp;lt;/ref&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|gif&lt;br /&gt;
|Decoding of GIF Images&lt;br /&gt;
|-&lt;br /&gt;
|imageops&lt;br /&gt;
|Image Processing Functions&lt;br /&gt;
|-&lt;br /&gt;
|jpeg&lt;br /&gt;
|Decoding and Encoding of JPEG Images&lt;br /&gt;
|-&lt;br /&gt;
|png&lt;br /&gt;
|Decoding and Encoding of PNG Images&lt;br /&gt;
|-&lt;br /&gt;
|ppm&lt;br /&gt;
|Encoding of portable pixmap Images&lt;br /&gt;
|-&lt;br /&gt;
|webp&lt;br /&gt;
|Decoding of Webp Images&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Traits&amp;lt;ref&amp;gt;http://rustbyexample.com/trait.html&amp;lt;/ref&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|GenericImage&lt;br /&gt;
|A trait for manipulating images.&lt;br /&gt;
|-&lt;br /&gt;
|ImageDecoder&lt;br /&gt;
|The trait that all decoders implement&lt;br /&gt;
|-&lt;br /&gt;
|MutableRefImage&lt;br /&gt;
|A trait for images that allow providing mutable references to pixels.&lt;br /&gt;
|-&lt;br /&gt;
|Pixel&lt;br /&gt;
|A trait that all pixels implement.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Functions&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|load&lt;br /&gt;
|Create a new image from a Reader&lt;br /&gt;
|-&lt;br /&gt;
|load_from_memory&lt;br /&gt;
|Create a new image from a byte slice&lt;br /&gt;
|-&lt;br /&gt;
|open&lt;br /&gt;
|Open the image located at the path specified. The image's format is determined from the path's file extension&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
&lt;br /&gt;
We are adhering to the following design principles for our implementation:&lt;br /&gt;
&lt;br /&gt;
'''Open-Closed Principle'''&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Open/closed_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Although our task is to evaluate replacing C libraries with Rust libraries, we won't actually be modifying any existing functionality.&lt;br /&gt;
&lt;br /&gt;
'''Interface Segregation Principle'''&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Interface_segregation_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The existing code is currently using the ''rust-freetype'' library for rendering fonts on the browser. We will be replacing this with the ''freetype-rs'' library, which divides the functionality offered by the former into smaller libraries which can be individually implemented instead of calling the entire library.&lt;br /&gt;
&lt;br /&gt;
== Design Pattern==&lt;br /&gt;
&lt;br /&gt;
We have implemented the Adapter Pattern in our Project:&lt;br /&gt;
&lt;br /&gt;
When we updated the image library, the function load_from_memory() in base.rs had to be updated since the return from the updated function accepts a different set of parameters.&lt;br /&gt;
We implemented the Adapter pattern as a wrapper function over the new load_from_memory() function which performs the below functions:&lt;br /&gt;
1. Based on the file extension generate the ImageFormat Enum.&lt;br /&gt;
2. The return of the new function is a Result&amp;lt;DynamicImage&amp;gt;. This needs to be converted into a DynamicImage struct.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pub fn load_from_memory(buffer: &amp;amp;[u8],ext: &amp;amp;str) -&amp;gt; Option&amp;lt;DynamicImage&amp;gt; {&lt;br /&gt;
    if buffer.len() == 0 {&lt;br /&gt;
        return None;&lt;br /&gt;
    }&lt;br /&gt;
   else {&lt;br /&gt;
        //Retrieve the ImageFormat enum to be passed into the updated function&lt;br /&gt;
        let image_type: Option&amp;lt; servo_image::ImageFormat &amp;gt; = get_format(ext);&lt;br /&gt;
	if image_type == None&lt;br /&gt;
	{&lt;br /&gt;
	panic!(&amp;quot;Image format not supported!&amp;quot;);&lt;br /&gt;
	}&lt;br /&gt;
	else{&lt;br /&gt;
        let new_image_type: servo_image::ImageFormat = image_type.unwrap();&lt;br /&gt;
        &lt;br /&gt;
        //The updated function returns a Result&amp;lt;DynamicImage&amp;gt;&lt;br /&gt;
        //below code resolves it to be returned by the wrapper function&lt;br /&gt;
	let result = servo_image::load_from_memory(buffer,new_image_type);&lt;br /&gt;
	if result.is_ok() {&lt;br /&gt;
  	    let v = result.unwrap();&lt;br /&gt;
  	    return Some(v);&lt;br /&gt;
	}&lt;br /&gt;
	else  {	&lt;br /&gt;
	    return None;&lt;br /&gt;
	}		&lt;br /&gt;
   }&lt;br /&gt;
   }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Flowchart describing Project Implementation==&lt;br /&gt;
[[File:Flowchart_final_M1455.JPG]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
&lt;br /&gt;
===Class Diagram===&lt;br /&gt;
[[File:Class_diagram_M1455.JPG]]&lt;br /&gt;
&lt;br /&gt;
== Test Cases ==&lt;br /&gt;
&lt;br /&gt;
The project does not plan to add new functionality. &lt;br /&gt;
The test-cases we propose to run are will ensure that tasks that could be performed with the older C libraries can be executed.&lt;br /&gt;
&lt;br /&gt;
The following test cases are proposed.&lt;br /&gt;
&lt;br /&gt;
1. The initial step test case includes printing the decoding time for various image formates and has been included in the wiki: [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_M1455_asa initial step]&lt;br /&gt;
&lt;br /&gt;
2. The profiler is meant to capture the image decoding time take by the load_from_memory function. The profiler is run using the following command which gives the decoding time for the image passed as an argument:&lt;br /&gt;
&amp;lt;pre&amp;gt;./mach run -p 1 https://optipng.sourceforge.net/pngtech/img/lena.html&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
3. After replacing the rust-freetype library by the freetype-rs library, we have tested that it works as expected by passing a webpage url and checking that the text renders correctly.&lt;br /&gt;
&amp;lt;pre&amp;gt;./mach run http://simple.wikipedia.org/wiki/Main_Page&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. After replacing the rust-stb-image and stb-image libraries with rust-image library and rewriting the load_from_memory function, we tested the the imports worked as expected by passing in different formats of images as urls and rendering them. &lt;br /&gt;
&amp;lt;pre&amp;gt; ./mach run https://www.http://optipng.sourceforge.net/pngtech/img/lena.png&amp;lt;/pre&amp;gt;&lt;br /&gt;
Below you can see the image being rendered after importing the new rust image library: &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;[[File:M1455newcrop.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see the image is not being rendered as intended. It is suspected to be a bud in the rust image library developed by the PistonDevelopers. We have been asked by servo representatives to raise an issue with the developers of the rust image library.&lt;br /&gt;
&lt;br /&gt;
5. Our test cases include reporting the timing differences for loading PNGs and non-PNG images. The following report has been made with respect to the same:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[File:Report001.PNG]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Video ==&lt;br /&gt;
A walkthrough of our entire project is available on this link: [https://www.youtube.com/watch?v=rq8MvpR1JyI Final Project Walkthrough]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_M1455_asa Initial Step Details]&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=92517</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=92517"/>
		<updated>2014-12-04T16:44:06Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* Setup of Development Environment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Background Information &amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_M1455_asa&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Servo currently depends on a lot of C libraries for image decoding. We wish to evaluate switching some of these to new Rust libraries. This project involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
====Setup of Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ensure that modified dependencies point to right sources&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./mach update-cargo -p freetype-rs --precise 753496406098651c83cdaf63db9f75dc42da17c7&lt;br /&gt;
./mach update-cargo -p image --precise 3a398831adb22f1200cb68682e446ede187d23b9&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build and run basic tests to ensure build success.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The scope of our project is limited to changing the libraries used in the image decoding task shown above.&lt;br /&gt;
&lt;br /&gt;
== Requirement analysis ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Servo currently depends on a lot of C libraries, because Rust equivalents for these libraries did not exist when the project started. Our project is to evaluate switching some of these to new Rust libraries that have since been created. It involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Initial step&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_M1455_asa initial step], implemented for the OSS project involved:&lt;br /&gt;
# Building Servo.&lt;br /&gt;
# Adding [http://doc.servo.org/util/time/fn.time.html timing code] to the image decoding implementation in the net crate.&lt;br /&gt;
# Rebuilding Servo.&lt;br /&gt;
# Reporting numbers for different kinds of images (i.e. PNG, JPEG, GIF).&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;b&amp;gt;Final Requirements&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our final project requirements are to:&lt;br /&gt;
* Build Servo and add code that reports (via the println! macro) the time required to decode images into displayable pixels.&lt;br /&gt;
* Add image decoding timing to the profiler.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/freetype-rs freetype-rs] library to replace [https://github.com/servo/rust-freetype rust-freetype] in Servo, rewriting necessary code.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3369&amp;lt;/ref&amp;gt; For this, we are to use [http://doc.crates.io/ Cargo], the dependency manager for Servo.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/image rust-image] library to replace the [https://github.com/servo/rust-stb-image rust-stb-image] and [https://github.com/nothings/stb stb-image] libraries and rewrite the &amp;lt;code&amp;gt;load_from_memory&amp;lt;/code&amp;gt; function which uses these libraries.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3368&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Report the timing differences for loading PNGs and non-PNGs on the same benchmarks. For this step, we are to consider profiling the result and optimizing the hotspots in rust-image.&lt;br /&gt;
&lt;br /&gt;
== Implementation of the Final Requirements ==&lt;br /&gt;
&lt;br /&gt;
1. Add Image Decoding time to the Profiler&lt;br /&gt;
To profile the time required by the load_from_memory to decode an image, we make a call to the profiler which outputs the time taken to decode on the console. To enable the profiler to do so, the following files were changed:&lt;br /&gt;
*image_cache_task.rs&lt;br /&gt;
*lib.rs&lt;br /&gt;
*time.rs&lt;br /&gt;
To invoke the profiler, we added a category under which to group the timings and passed a TimeProfilerChan (ie. a channel for communicating with the profiler task) to the ImageCacheTask::new method. On successfully building and running servo, we get the following image timings by profiler on the console:&lt;br /&gt;
&amp;lt;pre&amp;gt; ./mach run -p 1 https://optipng.sourceforge.net/pngtech/img/lena.html &amp;lt;/pre&amp;gt;&lt;br /&gt;
[[File:Profiler.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Imported the freetype-rs library to replace rust-freetype in Servo.&lt;br /&gt;
We replaced the currently used rust-freetype library with the freetype-rs library. To enable proper functioning of servo after importing the new library, following files were modified in the repository [https://github.com/PistonDevelopers/freetype-rs PistonDevelopers/freetype-rs]:&lt;br /&gt;
*Cargo.toml &lt;br /&gt;
*src/ffi.rs&lt;br /&gt;
*src/lib.rs&lt;br /&gt;
*src/lib.rs&lt;br /&gt;
*src/library.rs&lt;br /&gt;
*src/tt_os2.rs&lt;br /&gt;
These changes were committed and have been pulled by PistonDevelopers. Check the changes on [https://github.com/PistonDevelopers/freetype-rs/pull/70 pull request] for more info.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Imported the rust-image library to replace the rust-stb-image and stb-image libraries and rewrite the load_from_memory function which uses these libraries.&lt;br /&gt;
In order to import the new library we modified the following files files in the repository [https://github.com/ankit3005/servo]:&lt;br /&gt;
*Cargo.toml &lt;br /&gt;
*components/net/lib.rs&lt;br /&gt;
*components/net/image_cache_task.rs&lt;br /&gt;
*components/net/image/base.rs&lt;br /&gt;
*components/net/image/holder.rs&lt;br /&gt;
*components/gfx/render_context.rs&lt;br /&gt;
*components/gfx/lib.rs&lt;br /&gt;
*components/gfx/Cargo.toml&lt;br /&gt;
*components/gfx/display_list/mod.rs&lt;br /&gt;
*components/layout/display_list_builder.rs&lt;br /&gt;
*components/layout/lib.rs&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Reported the timing differences for loading PNGs and non-PNGs on the same benchmarks.&lt;br /&gt;
Once the new image library was imported , passed in several test images to record the decoding timing for different images.&lt;br /&gt;
The timing was compared with the decoding time for images by passing in the same images to the servo build containing the C image library. The results can be seen in the Test-Cases section below.&lt;br /&gt;
&lt;br /&gt;
== Data and component design &amp;lt;ref&amp;gt;http://www.rust-ci.org/PistonDevelopers/piston/doc/image/index.html&amp;lt;/ref&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
===Data Design===&lt;br /&gt;
The system entities that the project deals with is present in the image crate.&lt;br /&gt;
&lt;br /&gt;
The structs and enums used to represent images are as below :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Structures&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ImageBuf&lt;br /&gt;
|An Image whose pixels are contained within a vector&lt;br /&gt;
|-&lt;br /&gt;
|Luma&lt;br /&gt;
|A type to hold a grayscale pixel&lt;br /&gt;
|-&lt;br /&gt;
|LumaA&lt;br /&gt;
|A type to hold a grayscale pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|MutPixels&lt;br /&gt;
|Mutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Pixels&lt;br /&gt;
|Immutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Rgb&lt;br /&gt;
|A type to hold an RGB pixel&lt;br /&gt;
|-&lt;br /&gt;
|Rgba&lt;br /&gt;
|A type to hold an RGB pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|SubImage&lt;br /&gt;
|A View into another image&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Enums&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ColorType&lt;br /&gt;
|An enumeration over supported color types and their bit depths&lt;br /&gt;
|-&lt;br /&gt;
|DynamicImage&lt;br /&gt;
|A Dynamic Image&lt;br /&gt;
|-&lt;br /&gt;
|FilterType&lt;br /&gt;
|Available Sampling Filters&lt;br /&gt;
|-&lt;br /&gt;
|ImageError&lt;br /&gt;
|An enumeration of Image Errors&lt;br /&gt;
|-&lt;br /&gt;
|ImageFormat&lt;br /&gt;
|An enumeration of supported image formats. Not all formats support both encoding and decoding.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Component Design===&lt;br /&gt;
&lt;br /&gt;
Rust image : It is an image processing library. This crate provides basic imaging processing functions and methods for converting to and from image formats.&lt;br /&gt;
All image processing functions provided operate on types that implement the GenericImage trait and return an ImageBuf. The details of other modules and  traits included are :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Modules&amp;lt;ref&amp;gt;http://doc.rust-lang.org/guide.html#crates-and-modules&amp;lt;/ref&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|gif&lt;br /&gt;
|Decoding of GIF Images&lt;br /&gt;
|-&lt;br /&gt;
|imageops&lt;br /&gt;
|Image Processing Functions&lt;br /&gt;
|-&lt;br /&gt;
|jpeg&lt;br /&gt;
|Decoding and Encoding of JPEG Images&lt;br /&gt;
|-&lt;br /&gt;
|png&lt;br /&gt;
|Decoding and Encoding of PNG Images&lt;br /&gt;
|-&lt;br /&gt;
|ppm&lt;br /&gt;
|Encoding of portable pixmap Images&lt;br /&gt;
|-&lt;br /&gt;
|webp&lt;br /&gt;
|Decoding of Webp Images&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Traits&amp;lt;ref&amp;gt;http://rustbyexample.com/trait.html&amp;lt;/ref&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|GenericImage&lt;br /&gt;
|A trait for manipulating images.&lt;br /&gt;
|-&lt;br /&gt;
|ImageDecoder&lt;br /&gt;
|The trait that all decoders implement&lt;br /&gt;
|-&lt;br /&gt;
|MutableRefImage&lt;br /&gt;
|A trait for images that allow providing mutable references to pixels.&lt;br /&gt;
|-&lt;br /&gt;
|Pixel&lt;br /&gt;
|A trait that all pixels implement.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Functions&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|load&lt;br /&gt;
|Create a new image from a Reader&lt;br /&gt;
|-&lt;br /&gt;
|load_from_memory&lt;br /&gt;
|Create a new image from a byte slice&lt;br /&gt;
|-&lt;br /&gt;
|open&lt;br /&gt;
|Open the image located at the path specified. The image's format is determined from the path's file extension&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
&lt;br /&gt;
We are adhering to the following design principles for our implementation:&lt;br /&gt;
&lt;br /&gt;
'''Open-Closed Principle'''&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Open/closed_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Although our task is to evaluate replacing C libraries with Rust libraries, we won't actually be modifying any existing functionality.&lt;br /&gt;
&lt;br /&gt;
'''Interface Segregation Principle'''&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Interface_segregation_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The existing code is currently using the ''rust-freetype'' library for rendering fonts on the browser. We will be replacing this with the ''freetype-rs'' library, which divides the functionality offered by the former into smaller libraries which can be individually implemented instead of calling the entire library.&lt;br /&gt;
&lt;br /&gt;
== Design Pattern==&lt;br /&gt;
&lt;br /&gt;
We have implemented the Adapter Pattern in our Project:&lt;br /&gt;
&lt;br /&gt;
When we updated the image library, the function load_from_memory() in base.rs had to be updated since the return from the updated function accepts a different set of parameters.&lt;br /&gt;
We implemented the Adapter pattern as a wrapper function over the new load_from_memory() function which performs the below functions:&lt;br /&gt;
1. Based on the file extension generate the ImageFormat Enum.&lt;br /&gt;
2. The return of the new function is a Result&amp;lt;DynamicImage&amp;gt;. This needs to be converted into a DynamicImage struct.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pub fn load_from_memory(buffer: &amp;amp;[u8],ext: &amp;amp;str) -&amp;gt; Option&amp;lt;DynamicImage&amp;gt; {&lt;br /&gt;
    if buffer.len() == 0 {&lt;br /&gt;
        return None;&lt;br /&gt;
    }&lt;br /&gt;
   else {&lt;br /&gt;
        //Retrieve the ImageFormat enum to be passed into the updated function&lt;br /&gt;
        let image_type: Option&amp;lt; servo_image::ImageFormat &amp;gt; = get_format(ext);&lt;br /&gt;
	if image_type == None&lt;br /&gt;
	{&lt;br /&gt;
	panic!(&amp;quot;Image format not supported!&amp;quot;);&lt;br /&gt;
	}&lt;br /&gt;
	else{&lt;br /&gt;
        let new_image_type: servo_image::ImageFormat = image_type.unwrap();&lt;br /&gt;
        &lt;br /&gt;
        //The updated function returns a Result&amp;lt;DynamicImage&amp;gt;&lt;br /&gt;
        //below code resolves it to be returned by the wrapper function&lt;br /&gt;
	let result = servo_image::load_from_memory(buffer,new_image_type);&lt;br /&gt;
	if result.is_ok() {&lt;br /&gt;
  	    let v = result.unwrap();&lt;br /&gt;
  	    return Some(v);&lt;br /&gt;
	}&lt;br /&gt;
	else  {	&lt;br /&gt;
	    return None;&lt;br /&gt;
	}		&lt;br /&gt;
   }&lt;br /&gt;
   }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Flowchart describing Project Implementation==&lt;br /&gt;
[[File:Flowchart_final_M1455.JPG]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
&lt;br /&gt;
===Class Diagram===&lt;br /&gt;
[[File:Class_diagram_M1455.JPG]]&lt;br /&gt;
&lt;br /&gt;
== Test Cases ==&lt;br /&gt;
&lt;br /&gt;
The project does not plan to add new functionality. &lt;br /&gt;
The test-cases we propose to run are will ensure that tasks that could be performed with the older C libraries can be executed.&lt;br /&gt;
&lt;br /&gt;
The following test cases are proposed.&lt;br /&gt;
&lt;br /&gt;
1. The initial step test case includes printing the decoding time for various image formates and has been included in the wiki: [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_M1455_asa initial step]&lt;br /&gt;
&lt;br /&gt;
2. The profiler is meant to capture the image decoding time take by the load_from_memory function. The profiler is run using the following command which gives the decoding time for the image passed as an argument:&lt;br /&gt;
&amp;lt;pre&amp;gt;./mach run -p 1 https://optipng.sourceforge.net/pngtech/img/lena.html&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
3. After replacing the rust-freetype library by the freetype-rs library, we have tested that it works as expected by passing a webpage url and checking that the text renders correctly.&lt;br /&gt;
&amp;lt;pre&amp;gt;./mach run http://simple.wikipedia.org/wiki/Main_Page&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. After replacing the rust-stb-image and stb-image libraries with rust-image library and rewriting the load_from_memory function, we tested the the imports worked as expected by passing in different formats of images as urls and rendering them. &lt;br /&gt;
&amp;lt;pre&amp;gt; ./mach run https://www.http://optipng.sourceforge.net/pngtech/img/lena.png&amp;lt;/pre&amp;gt;&lt;br /&gt;
Below you can see the image being rendered after importing the new rust image library: &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;[[File:M1455newcrop.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see the image is not being rendered as intended. It is suspected to be a bud in the rust image library developed by the PistonDevelopers. We have been asked by servo representatives to raise an issue with the developers of the rust image library.&lt;br /&gt;
&lt;br /&gt;
5. Our test cases include reporting the timing differences for loading PNGs and non-PNG images. The following report has been made with respect to the same:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[[File:Report001.PNG]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Video ==&lt;br /&gt;
A walkthrough of our entire project is available on this link: [https://www.youtube.com/watch?v=rq8MvpR1JyI Final Project Walkthrough]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_M1455_asa Initial Step Details]&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=92108</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=92108"/>
		<updated>2014-11-13T19:12:47Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* Requirement analysis */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Background Information &amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_M1455_asa&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Servo currently depends on a lot of C libraries for image decoding. We wish to evaluate switching some of these to new Rust libraries. This project involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
====Setup of Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone and build servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The scope of our project is limited to changing the libraries used in the image decoding task shown above.&lt;br /&gt;
&lt;br /&gt;
== Requirement analysis ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Servo currently depends on a lot of C libraries, because Rust equivalents for these libraries did not exist when the project started. Our project is to evaluate switching some of these to new Rust libraries that have since been created. It involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Initial step&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our [http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_M1455_asa initial step], implemented for the OSS project involved:&lt;br /&gt;
# Building Servo.&lt;br /&gt;
# Adding [http://doc.servo.org/util/time/fn.time.html timing code] to the image decoding implementation in the net crate.&lt;br /&gt;
# Rebuilding Servo.&lt;br /&gt;
# Reporting numbers for different kinds of images (i.e. PNG, JPEG, GIF).&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;b&amp;gt;Final Requirements&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our final project requirements are to:&lt;br /&gt;
* Build Servo and add code that reports (via the println! macro) the time required to decode images into displayable pixels.&lt;br /&gt;
* Add image decoding timing to the profiler.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/freetype-rs freetype-rs] library to replace [https://github.com/servo/rust-freetype rust-freetype] in Servo, rewriting necessary code.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3369&amp;lt;/ref&amp;gt; For this, we are to use [http://doc.crates.io/ Cargo], the dependency manager for Servo.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/image rust-image] library to replace the [https://github.com/servo/rust-stb-image rust-stb-image] and [https://github.com/nothings/stb stb-image] libraries and rewrite the &amp;lt;code&amp;gt;load_from_memory&amp;lt;/code&amp;gt; function which uses these libraries.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3368&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Report the timing differences for loading PNGs and non-PNGs on the same benchmarks. For this step, we are to consider profiling the result and optimizing the hotspots in rust-image.&lt;br /&gt;
&lt;br /&gt;
== Data and component design &amp;lt;ref&amp;gt;http://www.rust-ci.org/PistonDevelopers/piston/doc/image/index.html&amp;lt;/ref&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
===Data Design===&lt;br /&gt;
The system entities that the project deals with is present in the image crate.&lt;br /&gt;
&lt;br /&gt;
The structs and enums used to represent images are as below :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Structures&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ImageBuf&lt;br /&gt;
|An Image whose pixels are contained within a vector&lt;br /&gt;
|-&lt;br /&gt;
|Luma&lt;br /&gt;
|A type to hold a grayscale pixel&lt;br /&gt;
|-&lt;br /&gt;
|LumaA&lt;br /&gt;
|A type to hold a grayscale pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|MutPixels&lt;br /&gt;
|Mutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Pixels&lt;br /&gt;
|Immutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Rgb&lt;br /&gt;
|A type to hold an RGB pixel&lt;br /&gt;
|-&lt;br /&gt;
|Rgba&lt;br /&gt;
|A type to hold an RGB pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|SubImage&lt;br /&gt;
|A View into another image&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Enums&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ColorType&lt;br /&gt;
|An enumeration over supported color types and their bit depths&lt;br /&gt;
|-&lt;br /&gt;
|DynamicImage&lt;br /&gt;
|A Dynamic Image&lt;br /&gt;
|-&lt;br /&gt;
|FilterType&lt;br /&gt;
|Available Sampling Filters&lt;br /&gt;
|-&lt;br /&gt;
|ImageError&lt;br /&gt;
|An enumeration of Image Errors&lt;br /&gt;
|-&lt;br /&gt;
|ImageFormat&lt;br /&gt;
|An enumeration of supported image formats. Not all formats support both encoding and decoding.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Component Design===&lt;br /&gt;
&lt;br /&gt;
Rust image : It is an image processing library. This crate provides basic imaging processing functions and methods for converting to and from image formats.&lt;br /&gt;
All image processing functions provided operate on types that implement the GenericImage trait and return an ImageBuf. The details of other modules and  traits included are :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Modules&amp;lt;ref&amp;gt;http://doc.rust-lang.org/guide.html#crates-and-modules&amp;lt;/ref&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|gif&lt;br /&gt;
|Decoding of GIF Images&lt;br /&gt;
|-&lt;br /&gt;
|imageops&lt;br /&gt;
|Image Processing Functions&lt;br /&gt;
|-&lt;br /&gt;
|jpeg&lt;br /&gt;
|Decoding and Encoding of JPEG Images&lt;br /&gt;
|-&lt;br /&gt;
|png&lt;br /&gt;
|Decoding and Encoding of PNG Images&lt;br /&gt;
|-&lt;br /&gt;
|ppm&lt;br /&gt;
|Encoding of portable pixmap Images&lt;br /&gt;
|-&lt;br /&gt;
|webp&lt;br /&gt;
|Decoding of Webp Images&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Traits&amp;lt;ref&amp;gt;http://rustbyexample.com/trait.html&amp;lt;/ref&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|GenericImage&lt;br /&gt;
|A trait for manipulating images.&lt;br /&gt;
|-&lt;br /&gt;
|ImageDecoder&lt;br /&gt;
|The trait that all decoders implement&lt;br /&gt;
|-&lt;br /&gt;
|MutableRefImage&lt;br /&gt;
|A trait for images that allow providing mutable references to pixels.&lt;br /&gt;
|-&lt;br /&gt;
|Pixel&lt;br /&gt;
|A trait that all pixels implement.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Functions&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|load&lt;br /&gt;
|Create a new image from a Reader&lt;br /&gt;
|-&lt;br /&gt;
|load_from_memory&lt;br /&gt;
|Create a new image from a byte slice&lt;br /&gt;
|-&lt;br /&gt;
|open&lt;br /&gt;
|Open the image located at the path specified. The image's format is determined from the path's file extension&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
&lt;br /&gt;
We are adhering to the following design principles for our implementation:&lt;br /&gt;
&lt;br /&gt;
'''Open-Closed Principle'''&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Open/closed_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Although our task is to evaluate replacing C libraries with Rust libraries, we won't actually be modifying any existing functionality.&lt;br /&gt;
&lt;br /&gt;
'''Interface Segregation Principle'''&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Interface_segregation_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The existing code is currently using the ''rust-freetype'' library for rendering fonts on the browser. We will be replacing this with the ''freetype-rs'' library, which divides the functionality offered by the former into smaller libraries which can be individually implemented instead of calling the entire library.&lt;br /&gt;
&lt;br /&gt;
==Flowchart describing Project Implementation==&lt;br /&gt;
[[File:Flowchart_final_M1455.JPG]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
&lt;br /&gt;
===Class Diagram===&lt;br /&gt;
[[File:Class_diagram_M1455.JPG]]&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
The project does not plan to add new functionality. &lt;br /&gt;
The test-cases we propose to run are will ensure that tasks that could be performed with the older C libraries can be executed.&lt;br /&gt;
&lt;br /&gt;
The following test cases are proposed.&lt;br /&gt;
&lt;br /&gt;
# Render different webpages with different fonts. Ensure the text renders correctly&lt;br /&gt;
# Render images of different formats (png, jpeg, bmp, gif) of different resolutions. Ensure that the images are rendered correctly.&lt;br /&gt;
# Record time taken to render and compare against time taken by the older libraries, for both image and text.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_M1455_asa Initial Step Details]&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=92107</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=92107"/>
		<updated>2014-11-13T19:11:28Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* Design Principles */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Background Information &amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_M1455_asa&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Servo currently depends on a lot of C libraries for image decoding. We wish to evaluate switching some of these to new Rust libraries. This project involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
====Setup of Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone and build servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The scope of our project is limited to changing the libraries used in the image decoding task shown above.&lt;br /&gt;
&lt;br /&gt;
== Requirement analysis ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Servo currently depends on a lot of C libraries, because Rust equivalents for these libraries did not exist when the project started. Our project is to evaluate switching some of these to new Rust libraries that have since been created. It involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Initial step&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our initial step, implemented for the OSS project involved:&lt;br /&gt;
# Building Servo.&lt;br /&gt;
# Adding [http://doc.servo.org/util/time/fn.time.html timing code] to the image decoding implementation in the net crate.&lt;br /&gt;
# Rebuilding Servo.&lt;br /&gt;
# Reporting numbers for different kinds of images (i.e. PNG, JPEG, GIF).&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;b&amp;gt;Final Requirements&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our final project requirements are to:&lt;br /&gt;
* Build Servo and add code that reports (via the println! macro) the time required to decode images into displayable pixels.&lt;br /&gt;
* Add image decoding timing to the profiler.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/freetype-rs freetype-rs] library to replace [https://github.com/servo/rust-freetype rust-freetype] in Servo, rewriting necessary code.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3369&amp;lt;/ref&amp;gt; For this, we are to use [http://doc.crates.io/ Cargo], the dependency manager for Servo.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/image rust-image] library to replace the [https://github.com/servo/rust-stb-image rust-stb-image] and [https://github.com/nothings/stb stb-image] libraries and rewrite the &amp;lt;code&amp;gt;load_from_memory&amp;lt;/code&amp;gt; function which uses these libraries.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3368&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Report the timing differences for loading PNGs and non-PNGs on the same benchmarks. For this step, we are to consider profiling the result and optimizing the hotspots in rust-image.&lt;br /&gt;
&lt;br /&gt;
== Data and component design &amp;lt;ref&amp;gt;http://www.rust-ci.org/PistonDevelopers/piston/doc/image/index.html&amp;lt;/ref&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
===Data Design===&lt;br /&gt;
The system entities that the project deals with is present in the image crate.&lt;br /&gt;
&lt;br /&gt;
The structs and enums used to represent images are as below :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Structures&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ImageBuf&lt;br /&gt;
|An Image whose pixels are contained within a vector&lt;br /&gt;
|-&lt;br /&gt;
|Luma&lt;br /&gt;
|A type to hold a grayscale pixel&lt;br /&gt;
|-&lt;br /&gt;
|LumaA&lt;br /&gt;
|A type to hold a grayscale pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|MutPixels&lt;br /&gt;
|Mutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Pixels&lt;br /&gt;
|Immutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Rgb&lt;br /&gt;
|A type to hold an RGB pixel&lt;br /&gt;
|-&lt;br /&gt;
|Rgba&lt;br /&gt;
|A type to hold an RGB pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|SubImage&lt;br /&gt;
|A View into another image&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Enums&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ColorType&lt;br /&gt;
|An enumeration over supported color types and their bit depths&lt;br /&gt;
|-&lt;br /&gt;
|DynamicImage&lt;br /&gt;
|A Dynamic Image&lt;br /&gt;
|-&lt;br /&gt;
|FilterType&lt;br /&gt;
|Available Sampling Filters&lt;br /&gt;
|-&lt;br /&gt;
|ImageError&lt;br /&gt;
|An enumeration of Image Errors&lt;br /&gt;
|-&lt;br /&gt;
|ImageFormat&lt;br /&gt;
|An enumeration of supported image formats. Not all formats support both encoding and decoding.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Component Design===&lt;br /&gt;
&lt;br /&gt;
Rust image : It is an image processing library. This crate provides basic imaging processing functions and methods for converting to and from image formats.&lt;br /&gt;
All image processing functions provided operate on types that implement the GenericImage trait and return an ImageBuf. The details of other modules and  traits included are :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Modules&amp;lt;ref&amp;gt;http://doc.rust-lang.org/guide.html#crates-and-modules&amp;lt;/ref&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|gif&lt;br /&gt;
|Decoding of GIF Images&lt;br /&gt;
|-&lt;br /&gt;
|imageops&lt;br /&gt;
|Image Processing Functions&lt;br /&gt;
|-&lt;br /&gt;
|jpeg&lt;br /&gt;
|Decoding and Encoding of JPEG Images&lt;br /&gt;
|-&lt;br /&gt;
|png&lt;br /&gt;
|Decoding and Encoding of PNG Images&lt;br /&gt;
|-&lt;br /&gt;
|ppm&lt;br /&gt;
|Encoding of portable pixmap Images&lt;br /&gt;
|-&lt;br /&gt;
|webp&lt;br /&gt;
|Decoding of Webp Images&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Traits&amp;lt;ref&amp;gt;http://rustbyexample.com/trait.html&amp;lt;/ref&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|GenericImage&lt;br /&gt;
|A trait for manipulating images.&lt;br /&gt;
|-&lt;br /&gt;
|ImageDecoder&lt;br /&gt;
|The trait that all decoders implement&lt;br /&gt;
|-&lt;br /&gt;
|MutableRefImage&lt;br /&gt;
|A trait for images that allow providing mutable references to pixels.&lt;br /&gt;
|-&lt;br /&gt;
|Pixel&lt;br /&gt;
|A trait that all pixels implement.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Functions&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|load&lt;br /&gt;
|Create a new image from a Reader&lt;br /&gt;
|-&lt;br /&gt;
|load_from_memory&lt;br /&gt;
|Create a new image from a byte slice&lt;br /&gt;
|-&lt;br /&gt;
|open&lt;br /&gt;
|Open the image located at the path specified. The image's format is determined from the path's file extension&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
&lt;br /&gt;
We are adhering to the following design principles for our implementation:&lt;br /&gt;
&lt;br /&gt;
'''Open-Closed Principle'''&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Open/closed_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Although our task is to evaluate replacing C libraries with Rust libraries, we won't actually be modifying any existing functionality.&lt;br /&gt;
&lt;br /&gt;
'''Interface Segregation Principle'''&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Interface_segregation_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The existing code is currently using the ''rust-freetype'' library for rendering fonts on the browser. We will be replacing this with the ''freetype-rs'' library, which divides the functionality offered by the former into smaller libraries which can be individually implemented instead of calling the entire library.&lt;br /&gt;
&lt;br /&gt;
==Flowchart describing Project Implementation==&lt;br /&gt;
[[File:Flowchart_final_M1455.JPG]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
&lt;br /&gt;
===Class Diagram===&lt;br /&gt;
[[File:Class_diagram_M1455.JPG]]&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
The project does not plan to add new functionality. &lt;br /&gt;
The test-cases we propose to run are will ensure that tasks that could be performed with the older C libraries can be executed.&lt;br /&gt;
&lt;br /&gt;
The following test cases are proposed.&lt;br /&gt;
&lt;br /&gt;
# Render different webpages with different fonts. Ensure the text renders correctly&lt;br /&gt;
# Render images of different formats (png, jpeg, bmp, gif) of different resolutions. Ensure that the images are rendered correctly.&lt;br /&gt;
# Record time taken to render and compare against time taken by the older libraries, for both image and text.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_M1455_asa Initial Step Details]&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014&amp;diff=91828</id>
		<title>CSC/ECE 517 Fall 2014</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014&amp;diff=91828"/>
		<updated>2014-11-11T23:47:20Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;*[[CSC/ECE_517_Fall_2014/sample_page]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1a 22 as]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 19 mx]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 3 zq]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 4 lf]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 4 wl]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a a7 ch]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 25 rs]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 25 jf]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 8 os]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 8 sn]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 15 gs]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 10 hu]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 20 kv]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 21 as]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 24 sa]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 26 sn]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 6 rl]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 2 ss]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 16 av]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 1 rm]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 1 sj]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 23 ss]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 20 rn]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 22 sp]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/oss M1454 rss]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 26 gn]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 13 va]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 9 aa]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 9 kn]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 11 ap]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 25 ks]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 7 kz]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1a_6_bn]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1a 10 zz]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1a 16 va]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1a F1415 rv]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1a_3_cp]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1b 26 sa]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1b_28_cg]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1b 29 ry]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1b 30 cs]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1b_33_jy]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1b_27_js]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/oss E1453 syy]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/oss E1463 vpd]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/oss E1465 oak]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/oss_M1456_kdv]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/oss_M1453_sst]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/oss_E1456_akk]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/oss_M1455_asa]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/oss_E1458_sst]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/oss_E1457_ags]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/OSS_E1466_gjf]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/oss_M1452_jns]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/oss_E1462_nms]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/OSS_S1455_ajp]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/OSS_S1454_ccc]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/OSS_E1450_cxm]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/OSS_E1455_skn]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/OSS_M1450_vda]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/OSS_E1467_rsv]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/OSS_E1464_vnn]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/OSS_M1451_ahs]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/OSS_E1451_las]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/OSS_E1461_knn]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/oss_E1460_aua]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/oss_E1459_jjr]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/final_E1472_gjfz]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/final_design_doc_M1451_hsss]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/final_E1471_asuv]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/final_E1475_nrnn]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/final_design_doc_M1450_navr]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/final_M1455_yaaa]]&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_ayaa&amp;diff=91826</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 ayaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_ayaa&amp;diff=91826"/>
		<updated>2014-11-11T23:46:56Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: moved CSC/ECE 517 Fall 2014/final M1455 ayaa to CSC/ECE 517 Fall 2014/final M1455 yaaa&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[CSC/ECE 517 Fall 2014/final M1455 yaaa]]&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91825</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91825"/>
		<updated>2014-11-11T23:46:56Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: moved CSC/ECE 517 Fall 2014/final M1455 ayaa to CSC/ECE 517 Fall 2014/final M1455 yaaa&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Background Information &amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_M1455_asa&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Servo currently depends on a lot of C libraries for image decoding. We wish to evaluate switching some of these to new Rust libraries. This project involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
====Setup of Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone and build servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The scope of our project is limited to changing the libraries used in the image decoding task shown above.&lt;br /&gt;
&lt;br /&gt;
== Requirement analysis ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Servo currently depends on a lot of C libraries, because Rust equivalents for these libraries did not exist when the project started. Our project is to evaluate switching some of these to new Rust libraries that have since been created. It involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Initial step&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our initial step, implemented for the OSS project involved:&lt;br /&gt;
# Building Servo.&lt;br /&gt;
# Adding [http://doc.servo.org/util/time/fn.time.html timing code] to the image decoding implementation in the net crate.&lt;br /&gt;
# Rebuilding Servo.&lt;br /&gt;
# Reporting numbers for different kinds of images (i.e. PNG, JPEG, GIF).&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;b&amp;gt;Final Requirements&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our final project requirements are to:&lt;br /&gt;
* Build Servo and add code that reports (via the println! macro) the time required to decode images into displayable pixels.&lt;br /&gt;
* Add image decoding timing to the profiler.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/freetype-rs freetype-rs] library to replace [https://github.com/servo/rust-freetype rust-freetype] in Servo, rewriting necessary code.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3369&amp;lt;/ref&amp;gt; For this, we are to use [http://doc.crates.io/ Cargo], the dependency manager for Servo.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/image rust-image] library to replace the [https://github.com/servo/rust-stb-image rust-stb-image] and [https://github.com/nothings/stb stb-image] libraries and rewrite the &amp;lt;code&amp;gt;load_from_memory&amp;lt;/code&amp;gt; function which uses these libraries.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3368&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Report the timing differences for loading PNGs and non-PNGs on the same benchmarks. For this step, we are to consider profiling the result and optimizing the hotspots in rust-image.&lt;br /&gt;
&lt;br /&gt;
== Data and component design &amp;lt;ref&amp;gt;http://www.rust-ci.org/PistonDevelopers/piston/doc/image/index.html&amp;lt;/ref&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
===Data Design===&lt;br /&gt;
The system entities that the project deals with is present in the image crate.&lt;br /&gt;
&lt;br /&gt;
The structs and enums used to represent images are as below :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Structures&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ImageBuf&lt;br /&gt;
|An Image whose pixels are contained within a vector&lt;br /&gt;
|-&lt;br /&gt;
|Luma&lt;br /&gt;
|A type to hold a grayscale pixel&lt;br /&gt;
|-&lt;br /&gt;
|LumaA&lt;br /&gt;
|A type to hold a grayscale pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|MutPixels&lt;br /&gt;
|Mutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Pixels&lt;br /&gt;
|Immutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Rgb&lt;br /&gt;
|A type to hold an RGB pixel&lt;br /&gt;
|-&lt;br /&gt;
|Rgba&lt;br /&gt;
|A type to hold an RGB pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|SubImage&lt;br /&gt;
|A View into another image&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Enums&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ColorType&lt;br /&gt;
|An enumeration over supported color types and their bit depths&lt;br /&gt;
|-&lt;br /&gt;
|DynamicImage&lt;br /&gt;
|A Dynamic Image&lt;br /&gt;
|-&lt;br /&gt;
|FilterType&lt;br /&gt;
|Available Sampling Filters&lt;br /&gt;
|-&lt;br /&gt;
|ImageError&lt;br /&gt;
|An enumeration of Image Errors&lt;br /&gt;
|-&lt;br /&gt;
|ImageFormat&lt;br /&gt;
|An enumeration of supported image formats. Not all formats support both encoding and decoding.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Component Design===&lt;br /&gt;
&lt;br /&gt;
Rust image : It is an image processing library. This crate provides basic imaging processing functions and methods for converting to and from image formats.&lt;br /&gt;
All image processing functions provided operate on types that implement the GenericImage trait and return an ImageBuf. The details of other modules and  traits included are :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Modules&amp;lt;ref&amp;gt;http://doc.rust-lang.org/guide.html#crates-and-modules&amp;lt;/ref&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|gif&lt;br /&gt;
|Decoding of GIF Images&lt;br /&gt;
|-&lt;br /&gt;
|imageops&lt;br /&gt;
|Image Processing Functions&lt;br /&gt;
|-&lt;br /&gt;
|jpeg&lt;br /&gt;
|Decoding and Encoding of JPEG Images&lt;br /&gt;
|-&lt;br /&gt;
|png&lt;br /&gt;
|Decoding and Encoding of PNG Images&lt;br /&gt;
|-&lt;br /&gt;
|ppm&lt;br /&gt;
|Encoding of portable pixmap Images&lt;br /&gt;
|-&lt;br /&gt;
|webp&lt;br /&gt;
|Decoding of Webp Images&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Traits&amp;lt;ref&amp;gt;http://rustbyexample.com/trait.html&amp;lt;/ref&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|GenericImage&lt;br /&gt;
|A trait for manipulating images.&lt;br /&gt;
|-&lt;br /&gt;
|ImageDecoder&lt;br /&gt;
|The trait that all decoders implement&lt;br /&gt;
|-&lt;br /&gt;
|MutableRefImage&lt;br /&gt;
|A trait for images that allow providing mutable references to pixels.&lt;br /&gt;
|-&lt;br /&gt;
|Pixel&lt;br /&gt;
|A trait that all pixels implement.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Functions&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|load&lt;br /&gt;
|Create a new image from a Reader&lt;br /&gt;
|-&lt;br /&gt;
|load_from_memory&lt;br /&gt;
|Create a new image from a byte slice&lt;br /&gt;
|-&lt;br /&gt;
|open&lt;br /&gt;
|Open the image located at the path specified. The image's format is determined from the path's file extension&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
&lt;br /&gt;
We are adhering to the following design principles for our implementation:&lt;br /&gt;
&lt;br /&gt;
'''Open-Closed Principle''' - Although our task is to evaluate replacing C libraries with Rust libraries, we won't actually be modifying any existing functionality.&lt;br /&gt;
&lt;br /&gt;
'''Interface Segregation Principle''' - The existing code is currently using the ''rust-freetype'' library for rendering fonts on the browser. We will be replacing this with the ''freetype-rs'' library, which divides the functionality offered by the former into smaller libraries which can be individually implemented instead of calling the entire library.&lt;br /&gt;
&lt;br /&gt;
==Flowchart describing Project Implementation==&lt;br /&gt;
[[File:Flowchart_final_M1455.JPG]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
&lt;br /&gt;
===Class Diagram===&lt;br /&gt;
[[File:Class_diagram_M1455.JPG]]&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
The project does not plan to add new functionality. &lt;br /&gt;
The test-cases we propose to run are will ensure that tasks that could be performed with the older C libraries can be executed.&lt;br /&gt;
&lt;br /&gt;
The following test cases are proposed.&lt;br /&gt;
&lt;br /&gt;
# Render different webpages with different fonts. Ensure the text renders correctly&lt;br /&gt;
# Render images of different formats (png, jpeg, bmp, gif) of different resolutions. Ensure that the images are rendered correctly.&lt;br /&gt;
# Record time taken to render and compare against time taken by the older libraries, for both image and text.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_M1455_asa Initial Step Details]&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_aya&amp;diff=91824</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 aya</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_aya&amp;diff=91824"/>
		<updated>2014-11-11T23:46:22Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: moved CSC/ECE 517 Fall 2014/final M1455 aya to CSC/ECE 517 Fall 2014/final M1455 ayaa&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[CSC/ECE 517 Fall 2014/final M1455 ayaa]]&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91823</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91823"/>
		<updated>2014-11-11T23:46:22Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: moved CSC/ECE 517 Fall 2014/final M1455 aya to CSC/ECE 517 Fall 2014/final M1455 ayaa&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Background Information &amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_M1455_asa&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Servo currently depends on a lot of C libraries for image decoding. We wish to evaluate switching some of these to new Rust libraries. This project involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
====Setup of Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone and build servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The scope of our project is limited to changing the libraries used in the image decoding task shown above.&lt;br /&gt;
&lt;br /&gt;
== Requirement analysis ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Servo currently depends on a lot of C libraries, because Rust equivalents for these libraries did not exist when the project started. Our project is to evaluate switching some of these to new Rust libraries that have since been created. It involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Initial step&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our initial step, implemented for the OSS project involved:&lt;br /&gt;
# Building Servo.&lt;br /&gt;
# Adding [http://doc.servo.org/util/time/fn.time.html timing code] to the image decoding implementation in the net crate.&lt;br /&gt;
# Rebuilding Servo.&lt;br /&gt;
# Reporting numbers for different kinds of images (i.e. PNG, JPEG, GIF).&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;b&amp;gt;Final Requirements&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our final project requirements are to:&lt;br /&gt;
* Build Servo and add code that reports (via the println! macro) the time required to decode images into displayable pixels.&lt;br /&gt;
* Add image decoding timing to the profiler.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/freetype-rs freetype-rs] library to replace [https://github.com/servo/rust-freetype rust-freetype] in Servo, rewriting necessary code.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3369&amp;lt;/ref&amp;gt; For this, we are to use [http://doc.crates.io/ Cargo], the dependency manager for Servo.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/image rust-image] library to replace the [https://github.com/servo/rust-stb-image rust-stb-image] and [https://github.com/nothings/stb stb-image] libraries and rewrite the &amp;lt;code&amp;gt;load_from_memory&amp;lt;/code&amp;gt; function which uses these libraries.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3368&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Report the timing differences for loading PNGs and non-PNGs on the same benchmarks. For this step, we are to consider profiling the result and optimizing the hotspots in rust-image.&lt;br /&gt;
&lt;br /&gt;
== Data and component design &amp;lt;ref&amp;gt;http://www.rust-ci.org/PistonDevelopers/piston/doc/image/index.html&amp;lt;/ref&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
===Data Design===&lt;br /&gt;
The system entities that the project deals with is present in the image crate.&lt;br /&gt;
&lt;br /&gt;
The structs and enums used to represent images are as below :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Structures&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ImageBuf&lt;br /&gt;
|An Image whose pixels are contained within a vector&lt;br /&gt;
|-&lt;br /&gt;
|Luma&lt;br /&gt;
|A type to hold a grayscale pixel&lt;br /&gt;
|-&lt;br /&gt;
|LumaA&lt;br /&gt;
|A type to hold a grayscale pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|MutPixels&lt;br /&gt;
|Mutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Pixels&lt;br /&gt;
|Immutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Rgb&lt;br /&gt;
|A type to hold an RGB pixel&lt;br /&gt;
|-&lt;br /&gt;
|Rgba&lt;br /&gt;
|A type to hold an RGB pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|SubImage&lt;br /&gt;
|A View into another image&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Enums&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ColorType&lt;br /&gt;
|An enumeration over supported color types and their bit depths&lt;br /&gt;
|-&lt;br /&gt;
|DynamicImage&lt;br /&gt;
|A Dynamic Image&lt;br /&gt;
|-&lt;br /&gt;
|FilterType&lt;br /&gt;
|Available Sampling Filters&lt;br /&gt;
|-&lt;br /&gt;
|ImageError&lt;br /&gt;
|An enumeration of Image Errors&lt;br /&gt;
|-&lt;br /&gt;
|ImageFormat&lt;br /&gt;
|An enumeration of supported image formats. Not all formats support both encoding and decoding.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Component Design===&lt;br /&gt;
&lt;br /&gt;
Rust image : It is an image processing library. This crate provides basic imaging processing functions and methods for converting to and from image formats.&lt;br /&gt;
All image processing functions provided operate on types that implement the GenericImage trait and return an ImageBuf. The details of other modules and  traits included are :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Modules&amp;lt;ref&amp;gt;http://doc.rust-lang.org/guide.html#crates-and-modules&amp;lt;/ref&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|gif&lt;br /&gt;
|Decoding of GIF Images&lt;br /&gt;
|-&lt;br /&gt;
|imageops&lt;br /&gt;
|Image Processing Functions&lt;br /&gt;
|-&lt;br /&gt;
|jpeg&lt;br /&gt;
|Decoding and Encoding of JPEG Images&lt;br /&gt;
|-&lt;br /&gt;
|png&lt;br /&gt;
|Decoding and Encoding of PNG Images&lt;br /&gt;
|-&lt;br /&gt;
|ppm&lt;br /&gt;
|Encoding of portable pixmap Images&lt;br /&gt;
|-&lt;br /&gt;
|webp&lt;br /&gt;
|Decoding of Webp Images&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Traits&amp;lt;ref&amp;gt;http://rustbyexample.com/trait.html&amp;lt;/ref&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|GenericImage&lt;br /&gt;
|A trait for manipulating images.&lt;br /&gt;
|-&lt;br /&gt;
|ImageDecoder&lt;br /&gt;
|The trait that all decoders implement&lt;br /&gt;
|-&lt;br /&gt;
|MutableRefImage&lt;br /&gt;
|A trait for images that allow providing mutable references to pixels.&lt;br /&gt;
|-&lt;br /&gt;
|Pixel&lt;br /&gt;
|A trait that all pixels implement.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Functions&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|load&lt;br /&gt;
|Create a new image from a Reader&lt;br /&gt;
|-&lt;br /&gt;
|load_from_memory&lt;br /&gt;
|Create a new image from a byte slice&lt;br /&gt;
|-&lt;br /&gt;
|open&lt;br /&gt;
|Open the image located at the path specified. The image's format is determined from the path's file extension&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
&lt;br /&gt;
We are adhering to the following design principles for our implementation:&lt;br /&gt;
&lt;br /&gt;
'''Open-Closed Principle''' - Although our task is to evaluate replacing C libraries with Rust libraries, we won't actually be modifying any existing functionality.&lt;br /&gt;
&lt;br /&gt;
'''Interface Segregation Principle''' - The existing code is currently using the ''rust-freetype'' library for rendering fonts on the browser. We will be replacing this with the ''freetype-rs'' library, which divides the functionality offered by the former into smaller libraries which can be individually implemented instead of calling the entire library.&lt;br /&gt;
&lt;br /&gt;
==Flowchart describing Project Implementation==&lt;br /&gt;
[[File:Flowchart_final_M1455.JPG]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
&lt;br /&gt;
===Class Diagram===&lt;br /&gt;
[[File:Class_diagram_M1455.JPG]]&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
The project does not plan to add new functionality. &lt;br /&gt;
The test-cases we propose to run are will ensure that tasks that could be performed with the older C libraries can be executed.&lt;br /&gt;
&lt;br /&gt;
The following test cases are proposed.&lt;br /&gt;
&lt;br /&gt;
# Render different webpages with different fonts. Ensure the text renders correctly&lt;br /&gt;
# Render images of different formats (png, jpeg, bmp, gif) of different resolutions. Ensure that the images are rendered correctly.&lt;br /&gt;
# Record time taken to render and compare against time taken by the older libraries, for both image and text.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
[http://wiki.expertiza.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_M1455_asa Initial Step Details]&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91815</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91815"/>
		<updated>2014-11-11T23:39:27Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* UML diagrams */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Background Information ==&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Servo currently depends on a lot of C libraries for image decoding. We wish to evaluate switching some of these to new Rust libraries. This project involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
====Setup of Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone and build servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The scope of our project is limited to changing the libraries used in the image decoding task shown above.&lt;br /&gt;
&lt;br /&gt;
== Requirement analysis ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Servo currently depends on a lot of C libraries, because Rust equivalents for these libraries did not exist when the project started. Our project is to evaluate switching some of these to new Rust libraries that have since been created. It involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Initial step&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our initial step, implemented for the OSS project involved:&lt;br /&gt;
# Building Servo.&lt;br /&gt;
# Adding [http://doc.servo.org/util/time/fn.time.html timing code] to the image decoding implementation in the net crate.&lt;br /&gt;
# Rebuilding Servo.&lt;br /&gt;
# Reporting numbers for different kinds of images (i.e. PNG, JPEG, GIF).&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;b&amp;gt;Final Requirements&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our final project requirements are to:&lt;br /&gt;
* Build Servo and add code that reports (via the println! macro) the time required to decode images into displayable pixels.&lt;br /&gt;
* Add image decoding timing to the profiler.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/freetype-rs freetype-rs] library to replace [https://github.com/servo/rust-freetype rust-freetype] in Servo, rewriting necessary code.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3369&amp;lt;/ref&amp;gt; For this, we are to use [http://doc.crates.io/ Cargo], the dependency manager for Servo.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/image rust-image] library to replace the [https://github.com/servo/rust-stb-image rust-stb-image] and [https://github.com/nothings/stb stb-image] libraries and rewrite the &amp;lt;code&amp;gt;load_from_memory&amp;lt;/code&amp;gt; function which uses these libraries.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3368&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Report the timing differences for loading PNGs and non-PNGs on the same benchmarks. For this step, we are to consider profiling the result and optimizing the hotspots in rust-image.&lt;br /&gt;
&lt;br /&gt;
== Data and component design &amp;lt;ref&amp;gt;http://www.rust-ci.org/PistonDevelopers/piston/doc/image/index.html&amp;lt;/ref&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
===Data Design===&lt;br /&gt;
The system entities that the project deals with is present in the image crate.&lt;br /&gt;
&lt;br /&gt;
The structs and enums used to represent images are as below :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Structures&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ImageBuf&lt;br /&gt;
|An Image whose pixels are contained within a vector&lt;br /&gt;
|-&lt;br /&gt;
|Luma&lt;br /&gt;
|A type to hold a grayscale pixel&lt;br /&gt;
|-&lt;br /&gt;
|LumaA&lt;br /&gt;
|A type to hold a grayscale pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|MutPixels&lt;br /&gt;
|Mutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Pixels&lt;br /&gt;
|Immutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Rgb&lt;br /&gt;
|A type to hold an RGB pixel&lt;br /&gt;
|-&lt;br /&gt;
|Rgba&lt;br /&gt;
|A type to hold an RGB pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|SubImage&lt;br /&gt;
|A View into another image&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Enums&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ColorType&lt;br /&gt;
|An enumeration over supported color types and their bit depths&lt;br /&gt;
|-&lt;br /&gt;
|DynamicImage&lt;br /&gt;
|A Dynamic Image&lt;br /&gt;
|-&lt;br /&gt;
|FilterType&lt;br /&gt;
|Available Sampling Filters&lt;br /&gt;
|-&lt;br /&gt;
|ImageError&lt;br /&gt;
|An enumeration of Image Errors&lt;br /&gt;
|-&lt;br /&gt;
|ImageFormat&lt;br /&gt;
|An enumeration of supported image formats. Not all formats support both encoding and decoding.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Component Design===&lt;br /&gt;
&lt;br /&gt;
Rust image : It is an image processing library. This crate provides basic imaging processing functions and methods for converting to and from image formats.&lt;br /&gt;
All image processing functions provided operate on types that implement the GenericImage trait and return an ImageBuf. The details of other modules and  traits included are :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Modules&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|gif&lt;br /&gt;
|Decoding of GIF Images&lt;br /&gt;
|-&lt;br /&gt;
|imageops&lt;br /&gt;
|Image Processing Functions&lt;br /&gt;
|-&lt;br /&gt;
|jpeg&lt;br /&gt;
|Decoding and Encoding of JPEG Images&lt;br /&gt;
|-&lt;br /&gt;
|png&lt;br /&gt;
|Decoding and Encoding of PNG Images&lt;br /&gt;
|-&lt;br /&gt;
|ppm&lt;br /&gt;
|Encoding of portable pixmap Images&lt;br /&gt;
|-&lt;br /&gt;
|webp&lt;br /&gt;
|Decoding of Webp Images&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Traits&amp;lt;ref&amp;gt;http://rustbyexample.com/trait.html&amp;lt;/ref&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|GenericImage&lt;br /&gt;
|A trait for manipulating images.&lt;br /&gt;
|-&lt;br /&gt;
|ImageDecoder&lt;br /&gt;
|The trait that all decoders implement&lt;br /&gt;
|-&lt;br /&gt;
|MutableRefImage&lt;br /&gt;
|A trait for images that allow providing mutable references to pixels.&lt;br /&gt;
|-&lt;br /&gt;
|Pixel&lt;br /&gt;
|A trait that all pixels implement.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Functions&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|load&lt;br /&gt;
|Create a new image from a Reader&lt;br /&gt;
|-&lt;br /&gt;
|load_from_memory&lt;br /&gt;
|Create a new image from a byte slice&lt;br /&gt;
|-&lt;br /&gt;
|open&lt;br /&gt;
|Open the image located at the path specified. The image's format is determined from the path's file extension&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Flowchart describing Project Implementation==&lt;br /&gt;
[[File:Flowchart_final_M1455.JPG]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
&lt;br /&gt;
===Class Diagram===&lt;br /&gt;
[[File:Class_diagram_M1455.JPG]]&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
The project does not plan to add new functionality. &lt;br /&gt;
The test-cases we propose to run are will ensure that tasks that could be performed with the older C libraries can be executed.&lt;br /&gt;
&lt;br /&gt;
The following test cases are proposed.&lt;br /&gt;
&lt;br /&gt;
# Render different webpages with different fonts. Ensure the text renders correctly&lt;br /&gt;
# Render images of different formats (png, jpeg, bmp, gif) of different resolutions. Ensure that the images are rendered correctly.&lt;br /&gt;
# Record time taken to render and compare against time taken by the older libraries, for both image and text.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Class_diagram_M1455.JPG&amp;diff=91813</id>
		<title>File:Class diagram M1455.JPG</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Class_diagram_M1455.JPG&amp;diff=91813"/>
		<updated>2014-11-11T23:37:59Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: Class diagram for M1455&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Class diagram for M1455&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014&amp;diff=91811</id>
		<title>CSC/ECE 517 Fall 2014</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014&amp;diff=91811"/>
		<updated>2014-11-11T23:36:27Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;*[[CSC/ECE_517_Fall_2014/sample_page]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1a 22 as]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 19 mx]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 3 zq]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 4 lf]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 4 wl]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a a7 ch]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 25 rs]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 25 jf]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 8 os]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 8 sn]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 15 gs]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 10 hu]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 20 kv]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 21 as]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 24 sa]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 26 sn]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 6 rl]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 2 ss]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 16 av]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 1 rm]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 1 sj]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 23 ss]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 20 rn]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 22 sp]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/oss M1454 rss]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 26 gn]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 13 va]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 9 aa]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 9 kn]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 11 ap]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 25 ks]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 7 kz]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1a_6_bn]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1a 10 zz]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1a 16 va]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1a F1415 rv]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1a_3_cp]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1b 26 sa]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1b_28_cg]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1b 29 ry]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1b 30 cs]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1b_33_jy]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1b_27_js]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/oss E1453 syy]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/oss E1463 vpd]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/oss E1465 oak]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/oss_M1456_kdv]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/oss_M1453_sst]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/oss_E1456_akk]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/oss_M1455_asa]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/oss_E1458_sst]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/oss_E1457_ags]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/OSS_E1466_gjf]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/oss_M1452_jns]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/oss_E1462_nms]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/OSS_S1455_ajp]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/OSS_S1454_ccc]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/OSS_E1450_cxm]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/OSS_E1455_skn]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/OSS_M1450_vda]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/OSS_E1467_rsv]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/OSS_E1464_vnn]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/OSS_M1451_ahs]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/OSS_E1451_las]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/OSS_E1461_knn]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/oss_E1460_aua]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/oss_E1459_jjr]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/final_E1472_gjfz]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/final_design_doc_M1451_hsss]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/final_E1471_asuv]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/final_E1475_nrnn]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/final_design_doc_M1450_navr]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/final_M1455_aya]]&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91810</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91810"/>
		<updated>2014-11-11T23:35:08Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* Requirement analysis */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Background Information ==&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Servo currently depends on a lot of C libraries for image decoding. We wish to evaluate switching some of these to new Rust libraries. This project involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
====Setup of Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone and build servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The scope of our project is limited to changing the libraries used in the image decoding task shown above.&lt;br /&gt;
&lt;br /&gt;
== Requirement analysis ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Servo currently depends on a lot of C libraries, because Rust equivalents for these libraries did not exist when the project started. Our project is to evaluate switching some of these to new Rust libraries that have since been created. It involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Initial step&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our initial step, implemented for the OSS project involved:&lt;br /&gt;
# Building Servo.&lt;br /&gt;
# Adding [http://doc.servo.org/util/time/fn.time.html timing code] to the image decoding implementation in the net crate.&lt;br /&gt;
# Rebuilding Servo.&lt;br /&gt;
# Reporting numbers for different kinds of images (i.e. PNG, JPEG, GIF).&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;b&amp;gt;Final Requirements&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our final project requirements are to:&lt;br /&gt;
* Build Servo and add code that reports (via the println! macro) the time required to decode images into displayable pixels.&lt;br /&gt;
* Add image decoding timing to the profiler.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/freetype-rs freetype-rs] library to replace [https://github.com/servo/rust-freetype rust-freetype] in Servo, rewriting necessary code.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3369&amp;lt;/ref&amp;gt; For this, we are to use [http://doc.crates.io/ Cargo], the dependency manager for Servo.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/image rust-image] library to replace the [https://github.com/servo/rust-stb-image rust-stb-image] and [https://github.com/nothings/stb stb-image] libraries and rewrite the &amp;lt;code&amp;gt;load_from_memory&amp;lt;/code&amp;gt; function which uses these libraries.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3368&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Report the timing differences for loading PNGs and non-PNGs on the same benchmarks. For this step, we are to consider profiling the result and optimizing the hotspots in rust-image.&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
&lt;br /&gt;
===Data Design===&lt;br /&gt;
The system entities that the project deals with is present in the image crate.&lt;br /&gt;
&lt;br /&gt;
The structs and enums used to represent images are as below :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Structures&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ImageBuf&lt;br /&gt;
|An Image whose pixels are contained within a vector&lt;br /&gt;
|-&lt;br /&gt;
|Luma&lt;br /&gt;
|A type to hold a grayscale pixel&lt;br /&gt;
|-&lt;br /&gt;
|LumaA&lt;br /&gt;
|A type to hold a grayscale pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|MutPixels&lt;br /&gt;
|Mutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Pixels&lt;br /&gt;
|Immutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Rgb&lt;br /&gt;
|A type to hold an RGB pixel&lt;br /&gt;
|-&lt;br /&gt;
|Rgba&lt;br /&gt;
|A type to hold an RGB pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|SubImage&lt;br /&gt;
|A View into another image&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Enums&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ColorType&lt;br /&gt;
|An enumeration over supported color types and their bit depths&lt;br /&gt;
|-&lt;br /&gt;
|DynamicImage&lt;br /&gt;
|A Dynamic Image&lt;br /&gt;
|-&lt;br /&gt;
|FilterType&lt;br /&gt;
|Available Sampling Filters&lt;br /&gt;
|-&lt;br /&gt;
|ImageError&lt;br /&gt;
|An enumeration of Image Errors&lt;br /&gt;
|-&lt;br /&gt;
|ImageFormat&lt;br /&gt;
|An enumeration of supported image formats. Not all formats support both encoding and decoding.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Component Design===&lt;br /&gt;
&lt;br /&gt;
Rust image : It is an image processing library. This crate provides basic imaging processing functions and methods for converting to and from image formats.&lt;br /&gt;
All image processing functions provided operate on types that implement the GenericImage trait and return an ImageBuf. The details of other modules and  traits included are :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Modules&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|gif&lt;br /&gt;
|Decoding of GIF Images&lt;br /&gt;
|-&lt;br /&gt;
|imageops&lt;br /&gt;
|Image Processing Functions&lt;br /&gt;
|-&lt;br /&gt;
|jpeg&lt;br /&gt;
|Decoding and Encoding of JPEG Images&lt;br /&gt;
|-&lt;br /&gt;
|png&lt;br /&gt;
|Decoding and Encoding of PNG Images&lt;br /&gt;
|-&lt;br /&gt;
|ppm&lt;br /&gt;
|Encoding of portable pixmap Images&lt;br /&gt;
|-&lt;br /&gt;
|webp&lt;br /&gt;
|Decoding of Webp Images&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Traits&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|GenericImage&lt;br /&gt;
|A trait for manipulating images.&lt;br /&gt;
|-&lt;br /&gt;
|ImageDecoder&lt;br /&gt;
|The trait that all decoders implement&lt;br /&gt;
|-&lt;br /&gt;
|MutableRefImage&lt;br /&gt;
|A trait for images that allow providing mutable references to pixels.&lt;br /&gt;
|-&lt;br /&gt;
|Pixel&lt;br /&gt;
|A trait that all pixels implement.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Functions&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|load&lt;br /&gt;
|Create a new image from a Reader&lt;br /&gt;
|-&lt;br /&gt;
|load_from_memory&lt;br /&gt;
|Create a new image from a byte slice&lt;br /&gt;
|-&lt;br /&gt;
|open&lt;br /&gt;
|Open the image located at the path specified. The image's format is determined from the path's file extension&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
&lt;br /&gt;
[[File:Flowchart_final_M1455.JPG]]&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
The project does not plan to add new functionality. &lt;br /&gt;
The test-cases we propose to run are will ensure that tasks that could be performed with the older C libraries can be executed.&lt;br /&gt;
&lt;br /&gt;
The following test cases are proposed.&lt;br /&gt;
&lt;br /&gt;
# Render different webpages with different fonts. Ensure the text renders correctly&lt;br /&gt;
# Render images of different formats (png, jpeg, bmp, gif) of different resolutions. Ensure that the images are rendered correctly.&lt;br /&gt;
# Record time taken to render and compare against time taken by the older libraries, for both image and text.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91809</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91809"/>
		<updated>2014-11-11T23:34:51Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* Requirement analysis */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Background Information ==&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Servo currently depends on a lot of C libraries for image decoding. We wish to evaluate switching some of these to new Rust libraries. This project involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
====Setup of Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone and build servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The scope of our project is limited to changing the libraries used in the image decoding task shown above.&lt;br /&gt;
&lt;br /&gt;
== Requirement analysis ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Servo currently depends on a lot of C libraries, because Rust equivalents for these libraries did not exist when the project started. Our project is to evaluate switching some of these to new Rust libraries that have since been created. It involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Initial step&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our initial step, implemented for the OSS project involved:&lt;br /&gt;
# Building Servo.&lt;br /&gt;
# Adding [http://doc.servo.org/util/time/fn.time.html timing code] to the image decoding implementation in the net crate.&lt;br /&gt;
# Rebuilding Servo.&lt;br /&gt;
# Reporting numbers for different kinds of images (i.e. PNG, JPEG, GIF).&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;b&amp;gt;Final Requirements&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our final project requirements are to:&lt;br /&gt;
* Build Servo and add code that reports (via the println! macro) the time required to decode images into displayable pixels.&lt;br /&gt;
* Add image decoding timing to the profiler.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/freetype-rs freetype-rs] library to replace [https://github.com/servo/rust-freetype rust-freetype] in Servo, rewriting necessary code.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3369&amp;lt;/ref&amp;gt; For this, we are to use [http://doc.crates.io/ Cargo], the dependency manager for Servo.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/image rust-image] library to replace the [https://github.com/servo/rust-stb-image rust-stb-image] and [https://github.com/nothings/stb stb-image] libraries and rewrite the &amp;lt;code&amp;gt;load_from_memory&amp;lt;code&amp;gt; function which uses these libraries.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3368&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Report the timing differences for loading PNGs and non-PNGs on the same benchmarks. For this step, we are to consider profiling the result and optimizing the hotspots in rust-image.&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
&lt;br /&gt;
===Data Design===&lt;br /&gt;
The system entities that the project deals with is present in the image crate.&lt;br /&gt;
&lt;br /&gt;
The structs and enums used to represent images are as below :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Structures&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ImageBuf&lt;br /&gt;
|An Image whose pixels are contained within a vector&lt;br /&gt;
|-&lt;br /&gt;
|Luma&lt;br /&gt;
|A type to hold a grayscale pixel&lt;br /&gt;
|-&lt;br /&gt;
|LumaA&lt;br /&gt;
|A type to hold a grayscale pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|MutPixels&lt;br /&gt;
|Mutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Pixels&lt;br /&gt;
|Immutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Rgb&lt;br /&gt;
|A type to hold an RGB pixel&lt;br /&gt;
|-&lt;br /&gt;
|Rgba&lt;br /&gt;
|A type to hold an RGB pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|SubImage&lt;br /&gt;
|A View into another image&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Enums&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ColorType&lt;br /&gt;
|An enumeration over supported color types and their bit depths&lt;br /&gt;
|-&lt;br /&gt;
|DynamicImage&lt;br /&gt;
|A Dynamic Image&lt;br /&gt;
|-&lt;br /&gt;
|FilterType&lt;br /&gt;
|Available Sampling Filters&lt;br /&gt;
|-&lt;br /&gt;
|ImageError&lt;br /&gt;
|An enumeration of Image Errors&lt;br /&gt;
|-&lt;br /&gt;
|ImageFormat&lt;br /&gt;
|An enumeration of supported image formats. Not all formats support both encoding and decoding.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Component Design===&lt;br /&gt;
&lt;br /&gt;
Rust image : It is an image processing library. This crate provides basic imaging processing functions and methods for converting to and from image formats.&lt;br /&gt;
All image processing functions provided operate on types that implement the GenericImage trait and return an ImageBuf. The details of other modules and  traits included are :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Modules&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|gif&lt;br /&gt;
|Decoding of GIF Images&lt;br /&gt;
|-&lt;br /&gt;
|imageops&lt;br /&gt;
|Image Processing Functions&lt;br /&gt;
|-&lt;br /&gt;
|jpeg&lt;br /&gt;
|Decoding and Encoding of JPEG Images&lt;br /&gt;
|-&lt;br /&gt;
|png&lt;br /&gt;
|Decoding and Encoding of PNG Images&lt;br /&gt;
|-&lt;br /&gt;
|ppm&lt;br /&gt;
|Encoding of portable pixmap Images&lt;br /&gt;
|-&lt;br /&gt;
|webp&lt;br /&gt;
|Decoding of Webp Images&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Traits&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|GenericImage&lt;br /&gt;
|A trait for manipulating images.&lt;br /&gt;
|-&lt;br /&gt;
|ImageDecoder&lt;br /&gt;
|The trait that all decoders implement&lt;br /&gt;
|-&lt;br /&gt;
|MutableRefImage&lt;br /&gt;
|A trait for images that allow providing mutable references to pixels.&lt;br /&gt;
|-&lt;br /&gt;
|Pixel&lt;br /&gt;
|A trait that all pixels implement.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Functions&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|load&lt;br /&gt;
|Create a new image from a Reader&lt;br /&gt;
|-&lt;br /&gt;
|load_from_memory&lt;br /&gt;
|Create a new image from a byte slice&lt;br /&gt;
|-&lt;br /&gt;
|open&lt;br /&gt;
|Open the image located at the path specified. The image's format is determined from the path's file extension&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
&lt;br /&gt;
[[File:Flowchart_final_M1455.JPG]]&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
The project does not plan to add new functionality. &lt;br /&gt;
The test-cases we propose to run are will ensure that tasks that could be performed with the older C libraries can be executed.&lt;br /&gt;
&lt;br /&gt;
The following test cases are proposed.&lt;br /&gt;
&lt;br /&gt;
# Render different webpages with different fonts. Ensure the text renders correctly&lt;br /&gt;
# Render images of different formats (png, jpeg, bmp, gif) of different resolutions. Ensure that the images are rendered correctly.&lt;br /&gt;
# Record time taken to render and compare against time taken by the older libraries, for both image and text.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91806</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91806"/>
		<updated>2014-11-11T23:24:19Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* Proposed Test Cases */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Background Information ==&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Servo currently depends on a lot of C libraries for image decoding. We wish to evaluate switching some of these to new Rust libraries. This project involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
====Setup of Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone and build servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The scope of our project is limited to changing the libraries used in the image decoding task shown above.&lt;br /&gt;
&lt;br /&gt;
== Requirement analysis ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Servo currently depends on a lot of C libraries, because Rust equivalents for these libraries did not exist when the project started. Our project is to evaluate switching some of these to new Rust libraries that have since been created. It involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Initial step&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our initial step, implemented for the OSS project involved:&lt;br /&gt;
# Building Servo.&lt;br /&gt;
# Adding [http://doc.servo.org/util/time/fn.time.html timing code] to the image decoding implementation in the net crate.&lt;br /&gt;
# Rebuilding Servo.&lt;br /&gt;
# Reporting numbers for different kinds of images (i.e. PNG, JPEG, GIF).&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;b&amp;gt;Final Requirements&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our final project requirements are to:&lt;br /&gt;
* Build Servo and add code that reports (via the println! macro) the time required to decode images into displayable pixels.&lt;br /&gt;
* Add image decoding timing to the profiler.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/freetype-rs freetype-rs] library to replace [https://github.com/servo/rust-freetype rust-freetype] in Servo, rewriting necessary code.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3369&amp;lt;/ref&amp;gt; For this, we are to use [http://doc.crates.io/ Cargo], the dependency manager for Servo.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/image rust-image] library to replace the [https://github.com/servo/rust-stb-image rust-stb-image] and [https://github.com/nothings/stb stb-image] libraries and rewrite the ''load_from_memory'' function which uses these libraries.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3368&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Report the timing differences for loading PNGs and non-PNGs on the same benchmarks. For this step, we are to consider profiling the result and optimizing the hotspots in rust-image.&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
&lt;br /&gt;
===Data Design===&lt;br /&gt;
The system entities that the project deals with is present in the image crate.&lt;br /&gt;
&lt;br /&gt;
The structs and enums used to represent images are as below :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Structures&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ImageBuf&lt;br /&gt;
|An Image whose pixels are contained within a vector&lt;br /&gt;
|-&lt;br /&gt;
|Luma&lt;br /&gt;
|A type to hold a grayscale pixel&lt;br /&gt;
|-&lt;br /&gt;
|LumaA&lt;br /&gt;
|A type to hold a grayscale pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|MutPixels&lt;br /&gt;
|Mutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Pixels&lt;br /&gt;
|Immutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Rgb&lt;br /&gt;
|A type to hold an RGB pixel&lt;br /&gt;
|-&lt;br /&gt;
|Rgba&lt;br /&gt;
|A type to hold an RGB pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|SubImage&lt;br /&gt;
|A View into another image&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Enums&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ColorType&lt;br /&gt;
|An enumeration over supported color types and their bit depths&lt;br /&gt;
|-&lt;br /&gt;
|DynamicImage&lt;br /&gt;
|A Dynamic Image&lt;br /&gt;
|-&lt;br /&gt;
|FilterType&lt;br /&gt;
|Available Sampling Filters&lt;br /&gt;
|-&lt;br /&gt;
|ImageError&lt;br /&gt;
|An enumeration of Image Errors&lt;br /&gt;
|-&lt;br /&gt;
|ImageFormat&lt;br /&gt;
|An enumeration of supported image formats. Not all formats support both encoding and decoding.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Component Design===&lt;br /&gt;
&lt;br /&gt;
Rust image : It is an image processing library. This crate provides basic imaging processing functions and methods for converting to and from image formats.&lt;br /&gt;
All image processing functions provided operate on types that implement the GenericImage trait and return an ImageBuf. The details of other modules and  traits included are :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Modules&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|gif&lt;br /&gt;
|Decoding of GIF Images&lt;br /&gt;
|-&lt;br /&gt;
|imageops&lt;br /&gt;
|Image Processing Functions&lt;br /&gt;
|-&lt;br /&gt;
|jpeg&lt;br /&gt;
|Decoding and Encoding of JPEG Images&lt;br /&gt;
|-&lt;br /&gt;
|png&lt;br /&gt;
|Decoding and Encoding of PNG Images&lt;br /&gt;
|-&lt;br /&gt;
|ppm&lt;br /&gt;
|Encoding of portable pixmap Images&lt;br /&gt;
|-&lt;br /&gt;
|webp&lt;br /&gt;
|Decoding of Webp Images&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Traits&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|GenericImage&lt;br /&gt;
|A trait for manipulating images.&lt;br /&gt;
|-&lt;br /&gt;
|ImageDecoder&lt;br /&gt;
|The trait that all decoders implement&lt;br /&gt;
|-&lt;br /&gt;
|MutableRefImage&lt;br /&gt;
|A trait for images that allow providing mutable references to pixels.&lt;br /&gt;
|-&lt;br /&gt;
|Pixel&lt;br /&gt;
|A trait that all pixels implement.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Functions&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|load&lt;br /&gt;
|Create a new image from a Reader&lt;br /&gt;
|-&lt;br /&gt;
|load_from_memory&lt;br /&gt;
|Create a new image from a byte slice&lt;br /&gt;
|-&lt;br /&gt;
|open&lt;br /&gt;
|Open the image located at the path specified. The image's format is determined from the path's file extension&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
&lt;br /&gt;
[[File:Flowchart_final_M1455.JPG]]&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
The project does not plan to add new functionality. &lt;br /&gt;
The test-cases we propose to run are will ensure that tasks that could be performed with the older C libraries can be executed.&lt;br /&gt;
&lt;br /&gt;
The following test cases are proposed.&lt;br /&gt;
&lt;br /&gt;
# Render different webpages with different fonts. Ensure the text renders correctly&lt;br /&gt;
# Render images of different formats (png, jpeg, bmp, gif) of different resolutions. Ensure that the images are rendered correctly.&lt;br /&gt;
# Record time taken to render and compare against time taken by the older libraries, for both image and text.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91805</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91805"/>
		<updated>2014-11-11T23:19:46Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* Proposed Test Cases */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Background Information ==&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Servo currently depends on a lot of C libraries for image decoding. We wish to evaluate switching some of these to new Rust libraries. This project involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
====Setup of Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone and build servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The scope of our project is limited to changing the libraries used in the image decoding task shown above.&lt;br /&gt;
&lt;br /&gt;
== Requirement analysis ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Servo currently depends on a lot of C libraries, because Rust equivalents for these libraries did not exist when the project started. Our project is to evaluate switching some of these to new Rust libraries that have since been created. It involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Initial step&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our initial step, implemented for the OSS project involved:&lt;br /&gt;
# Building Servo.&lt;br /&gt;
# Adding [http://doc.servo.org/util/time/fn.time.html timing code] to the image decoding implementation in the net crate.&lt;br /&gt;
# Rebuilding Servo.&lt;br /&gt;
# Reporting numbers for different kinds of images (i.e. PNG, JPEG, GIF).&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;b&amp;gt;Final Requirements&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our final project requirements are to:&lt;br /&gt;
* Build Servo and add code that reports (via the println! macro) the time required to decode images into displayable pixels.&lt;br /&gt;
* Add image decoding timing to the profiler.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/freetype-rs freetype-rs] library to replace [https://github.com/servo/rust-freetype rust-freetype] in Servo, rewriting necessary code.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3369&amp;lt;/ref&amp;gt; For this, we are to use [http://doc.crates.io/ Cargo], the dependency manager for Servo.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/image rust-image] library to replace the [https://github.com/servo/rust-stb-image rust-stb-image] and [https://github.com/nothings/stb stb-image] libraries and rewrite the ''load_from_memory'' function which uses these libraries.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3368&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Report the timing differences for loading PNGs and non-PNGs on the same benchmarks. For this step, we are to consider profiling the result and optimizing the hotspots in rust-image.&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
&lt;br /&gt;
===Data Design===&lt;br /&gt;
The system entities that the project deals with is present in the image crate.&lt;br /&gt;
&lt;br /&gt;
The structs and enums used to represent images are as below :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Structures&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ImageBuf&lt;br /&gt;
|An Image whose pixels are contained within a vector&lt;br /&gt;
|-&lt;br /&gt;
|Luma&lt;br /&gt;
|A type to hold a grayscale pixel&lt;br /&gt;
|-&lt;br /&gt;
|LumaA&lt;br /&gt;
|A type to hold a grayscale pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|MutPixels&lt;br /&gt;
|Mutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Pixels&lt;br /&gt;
|Immutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Rgb&lt;br /&gt;
|A type to hold an RGB pixel&lt;br /&gt;
|-&lt;br /&gt;
|Rgba&lt;br /&gt;
|A type to hold an RGB pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|SubImage&lt;br /&gt;
|A View into another image&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Enums&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ColorType&lt;br /&gt;
|An enumeration over supported color types and their bit depths&lt;br /&gt;
|-&lt;br /&gt;
|DynamicImage&lt;br /&gt;
|A Dynamic Image&lt;br /&gt;
|-&lt;br /&gt;
|FilterType&lt;br /&gt;
|Available Sampling Filters&lt;br /&gt;
|-&lt;br /&gt;
|ImageError&lt;br /&gt;
|An enumeration of Image Errors&lt;br /&gt;
|-&lt;br /&gt;
|ImageFormat&lt;br /&gt;
|An enumeration of supported image formats. Not all formats support both encoding and decoding.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Component Design===&lt;br /&gt;
&lt;br /&gt;
Rust image : It is an image processing library. This crate provides basic imaging processing functions and methods for converting to and from image formats.&lt;br /&gt;
All image processing functions provided operate on types that implement the GenericImage trait and return an ImageBuf. The details of other modules and  traits included are :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Modules&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|gif&lt;br /&gt;
|Decoding of GIF Images&lt;br /&gt;
|-&lt;br /&gt;
|imageops&lt;br /&gt;
|Image Processing Functions&lt;br /&gt;
|-&lt;br /&gt;
|jpeg&lt;br /&gt;
|Decoding and Encoding of JPEG Images&lt;br /&gt;
|-&lt;br /&gt;
|png&lt;br /&gt;
|Decoding and Encoding of PNG Images&lt;br /&gt;
|-&lt;br /&gt;
|ppm&lt;br /&gt;
|Encoding of portable pixmap Images&lt;br /&gt;
|-&lt;br /&gt;
|webp&lt;br /&gt;
|Decoding of Webp Images&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Traits&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|GenericImage&lt;br /&gt;
|A trait for manipulating images.&lt;br /&gt;
|-&lt;br /&gt;
|ImageDecoder&lt;br /&gt;
|The trait that all decoders implement&lt;br /&gt;
|-&lt;br /&gt;
|MutableRefImage&lt;br /&gt;
|A trait for images that allow providing mutable references to pixels.&lt;br /&gt;
|-&lt;br /&gt;
|Pixel&lt;br /&gt;
|A trait that all pixels implement.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Functions&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|load&lt;br /&gt;
|Create a new image from a Reader&lt;br /&gt;
|-&lt;br /&gt;
|load_from_memory&lt;br /&gt;
|Create a new image from a byte slice&lt;br /&gt;
|-&lt;br /&gt;
|open&lt;br /&gt;
|Open the image located at the path specified. The image's format is determined from the path's file extension&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
&lt;br /&gt;
[[File:Flowchart_final_M1455.JPG]]&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
The project does not plan to add new functionality. &lt;br /&gt;
The test-cases we propose to run are will ensure that tasks that could be performed with the older C libraries can be executed.&lt;br /&gt;
&lt;br /&gt;
The following test cases are proposed.&lt;br /&gt;
&lt;br /&gt;
# Render different webpages with different fonts. Ensure the text renders correctly&lt;br /&gt;
# Render images of different formats (png, jpeg, bmp, gif) of different resolutions. Ensure that the images are rendered correctly.&lt;br /&gt;
&lt;br /&gt;
Record time taken to render and compare against time taken by the older libraries, for both image and text.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91799</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91799"/>
		<updated>2014-11-11T23:12:39Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* UML diagrams */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Background Information ==&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Servo currently depends on a lot of C libraries for image decoding. We wish to evaluate switching some of these to new Rust libraries. This project involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
====Setup of Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone and build servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The scope of our project is limited to changing the libraries used in the image decoding task shown above.&lt;br /&gt;
&lt;br /&gt;
== Requirement analysis ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Servo currently depends on a lot of C libraries, because Rust equivalents for these libraries did not exist when the project started. Our project is to evaluate switching some of these to new Rust libraries that have since been created. It involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Initial step&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our initial step, implemented for the OSS project involved:&lt;br /&gt;
# Building Servo.&lt;br /&gt;
# Adding [http://doc.servo.org/util/time/fn.time.html timing code] to the image decoding implementation in the net crate.&lt;br /&gt;
# Rebuilding Servo.&lt;br /&gt;
# Reporting numbers for different kinds of images (i.e. PNG, JPEG, GIF).&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;b&amp;gt;Final Requirements&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our final project requirements are to:&lt;br /&gt;
* Build Servo and add code that reports (via the println! macro) the time required to decode images into displayable pixels.&lt;br /&gt;
* Add image decoding timing to the profiler.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/freetype-rs freetype-rs] library to replace [https://github.com/servo/rust-freetype rust-freetype] in Servo, rewriting necessary code.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3369&amp;lt;/ref&amp;gt; For this, we are to use [http://doc.crates.io/ Cargo], the dependency manager for Servo.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/image rust-image] library to replace the [https://github.com/servo/rust-stb-image rust-stb-image] and [https://github.com/nothings/stb stb-image] libraries and rewrite the ''load_from_memory'' function which uses these libraries.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3368&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Report the timing differences for loading PNGs and non-PNGs on the same benchmarks. For this step, we are to consider profiling the result and optimizing the hotspots in rust-image.&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
&lt;br /&gt;
===Data Design===&lt;br /&gt;
The system entities that the project deals with is present in the image crate.&lt;br /&gt;
&lt;br /&gt;
The structs and enums used to represent images are as below :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Structures&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ImageBuf&lt;br /&gt;
|An Image whose pixels are contained within a vector&lt;br /&gt;
|-&lt;br /&gt;
|Luma&lt;br /&gt;
|A type to hold a grayscale pixel&lt;br /&gt;
|-&lt;br /&gt;
|LumaA&lt;br /&gt;
|A type to hold a grayscale pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|MutPixels&lt;br /&gt;
|Mutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Pixels&lt;br /&gt;
|Immutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Rgb&lt;br /&gt;
|A type to hold an RGB pixel&lt;br /&gt;
|-&lt;br /&gt;
|Rgba&lt;br /&gt;
|A type to hold an RGB pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|SubImage&lt;br /&gt;
|A View into another image&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Enums&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ColorType&lt;br /&gt;
|An enumeration over supported color types and their bit depths&lt;br /&gt;
|-&lt;br /&gt;
|DynamicImage&lt;br /&gt;
|A Dynamic Image&lt;br /&gt;
|-&lt;br /&gt;
|FilterType&lt;br /&gt;
|Available Sampling Filters&lt;br /&gt;
|-&lt;br /&gt;
|ImageError&lt;br /&gt;
|An enumeration of Image Errors&lt;br /&gt;
|-&lt;br /&gt;
|ImageFormat&lt;br /&gt;
|An enumeration of supported image formats. Not all formats support both encoding and decoding.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Component Design===&lt;br /&gt;
&lt;br /&gt;
Rust image : It is an image processing library. This crate provides basic imaging processing functions and methods for converting to and from image formats.&lt;br /&gt;
All image processing functions provided operate on types that implement the GenericImage trait and return an ImageBuf. The details of other modules and  traits included are :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Modules&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|gif&lt;br /&gt;
|Decoding of GIF Images&lt;br /&gt;
|-&lt;br /&gt;
|imageops&lt;br /&gt;
|Image Processing Functions&lt;br /&gt;
|-&lt;br /&gt;
|jpeg&lt;br /&gt;
|Decoding and Encoding of JPEG Images&lt;br /&gt;
|-&lt;br /&gt;
|png&lt;br /&gt;
|Decoding and Encoding of PNG Images&lt;br /&gt;
|-&lt;br /&gt;
|ppm&lt;br /&gt;
|Encoding of portable pixmap Images&lt;br /&gt;
|-&lt;br /&gt;
|webp&lt;br /&gt;
|Decoding of Webp Images&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Traits&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|GenericImage&lt;br /&gt;
|A trait for manipulating images.&lt;br /&gt;
|-&lt;br /&gt;
|ImageDecoder&lt;br /&gt;
|The trait that all decoders implement&lt;br /&gt;
|-&lt;br /&gt;
|MutableRefImage&lt;br /&gt;
|A trait for images that allow providing mutable references to pixels.&lt;br /&gt;
|-&lt;br /&gt;
|Pixel&lt;br /&gt;
|A trait that all pixels implement.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Functions&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|load&lt;br /&gt;
|Create a new image from a Reader&lt;br /&gt;
|-&lt;br /&gt;
|load_from_memory&lt;br /&gt;
|Create a new image from a byte slice&lt;br /&gt;
|-&lt;br /&gt;
|open&lt;br /&gt;
|Open the image located at the path specified. The image's format is determined from the path's file extension&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
&lt;br /&gt;
[[File:Flowchart_final_M1455.JPG]]&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
The project does not plan to add new functionality. &lt;br /&gt;
The test-cases we propose to run are will ensure that the image decoding tasks that could be performed with the older C libraries can be executed after replacement as well.&lt;br /&gt;
&lt;br /&gt;
The following test cases are proposed.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Flowchart_final_M1455.JPG&amp;diff=91797</id>
		<title>File:Flowchart final M1455.JPG</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Flowchart_final_M1455.JPG&amp;diff=91797"/>
		<updated>2014-11-11T23:11:55Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91795</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91795"/>
		<updated>2014-11-11T23:10:03Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* Requirement analysis */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Background Information ==&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Servo currently depends on a lot of C libraries for image decoding. We wish to evaluate switching some of these to new Rust libraries. This project involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
====Setup of Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone and build servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The scope of our project is limited to changing the libraries used in the image decoding task shown above.&lt;br /&gt;
&lt;br /&gt;
== Requirement analysis ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Servo currently depends on a lot of C libraries, because Rust equivalents for these libraries did not exist when the project started. Our project is to evaluate switching some of these to new Rust libraries that have since been created. It involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Initial step&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our initial step, implemented for the OSS project involved:&lt;br /&gt;
# Building Servo.&lt;br /&gt;
# Adding [http://doc.servo.org/util/time/fn.time.html timing code] to the image decoding implementation in the net crate.&lt;br /&gt;
# Rebuilding Servo.&lt;br /&gt;
# Reporting numbers for different kinds of images (i.e. PNG, JPEG, GIF).&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;b&amp;gt;Final Requirements&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our final project requirements are to:&lt;br /&gt;
* Build Servo and add code that reports (via the println! macro) the time required to decode images into displayable pixels.&lt;br /&gt;
* Add image decoding timing to the profiler.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/freetype-rs freetype-rs] library to replace [https://github.com/servo/rust-freetype rust-freetype] in Servo, rewriting necessary code.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3369&amp;lt;/ref&amp;gt; For this, we are to use [http://doc.crates.io/ Cargo], the dependency manager for Servo.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/image rust-image] library to replace the [https://github.com/servo/rust-stb-image rust-stb-image] and [https://github.com/nothings/stb stb-image] libraries and rewrite the ''load_from_memory'' function which uses these libraries.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3368&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Report the timing differences for loading PNGs and non-PNGs on the same benchmarks. For this step, we are to consider profiling the result and optimizing the hotspots in rust-image.&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
&lt;br /&gt;
===Data Design===&lt;br /&gt;
The system entities that the project deals with is present in the image crate.&lt;br /&gt;
&lt;br /&gt;
The structs and enums used to represent images are as below :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Structures&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ImageBuf&lt;br /&gt;
|An Image whose pixels are contained within a vector&lt;br /&gt;
|-&lt;br /&gt;
|Luma&lt;br /&gt;
|A type to hold a grayscale pixel&lt;br /&gt;
|-&lt;br /&gt;
|LumaA&lt;br /&gt;
|A type to hold a grayscale pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|MutPixels&lt;br /&gt;
|Mutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Pixels&lt;br /&gt;
|Immutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Rgb&lt;br /&gt;
|A type to hold an RGB pixel&lt;br /&gt;
|-&lt;br /&gt;
|Rgba&lt;br /&gt;
|A type to hold an RGB pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|SubImage&lt;br /&gt;
|A View into another image&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Enums&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ColorType&lt;br /&gt;
|An enumeration over supported color types and their bit depths&lt;br /&gt;
|-&lt;br /&gt;
|DynamicImage&lt;br /&gt;
|A Dynamic Image&lt;br /&gt;
|-&lt;br /&gt;
|FilterType&lt;br /&gt;
|Available Sampling Filters&lt;br /&gt;
|-&lt;br /&gt;
|ImageError&lt;br /&gt;
|An enumeration of Image Errors&lt;br /&gt;
|-&lt;br /&gt;
|ImageFormat&lt;br /&gt;
|An enumeration of supported image formats. Not all formats support both encoding and decoding.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Component Design===&lt;br /&gt;
&lt;br /&gt;
Rust image : It is an image processing library. This crate provides basic imaging processing functions and methods for converting to and from image formats.&lt;br /&gt;
All image processing functions provided operate on types that implement the GenericImage trait and return an ImageBuf. The details of other modules and  traits included are :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Modules&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|gif&lt;br /&gt;
|Decoding of GIF Images&lt;br /&gt;
|-&lt;br /&gt;
|imageops&lt;br /&gt;
|Image Processing Functions&lt;br /&gt;
|-&lt;br /&gt;
|jpeg&lt;br /&gt;
|Decoding and Encoding of JPEG Images&lt;br /&gt;
|-&lt;br /&gt;
|png&lt;br /&gt;
|Decoding and Encoding of PNG Images&lt;br /&gt;
|-&lt;br /&gt;
|ppm&lt;br /&gt;
|Encoding of portable pixmap Images&lt;br /&gt;
|-&lt;br /&gt;
|webp&lt;br /&gt;
|Decoding of Webp Images&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Traits&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|GenericImage&lt;br /&gt;
|A trait for manipulating images.&lt;br /&gt;
|-&lt;br /&gt;
|ImageDecoder&lt;br /&gt;
|The trait that all decoders implement&lt;br /&gt;
|-&lt;br /&gt;
|MutableRefImage&lt;br /&gt;
|A trait for images that allow providing mutable references to pixels.&lt;br /&gt;
|-&lt;br /&gt;
|Pixel&lt;br /&gt;
|A trait that all pixels implement.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Functions&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|load&lt;br /&gt;
|Create a new image from a Reader&lt;br /&gt;
|-&lt;br /&gt;
|load_from_memory&lt;br /&gt;
|Create a new image from a byte slice&lt;br /&gt;
|-&lt;br /&gt;
|open&lt;br /&gt;
|Open the image located at the path specified. The image's format is determined from the path's file extension&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
&lt;br /&gt;
[[File:Flowchart_final_M1455.png]]&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
The project does not plan to add new functionality. &lt;br /&gt;
The test-cases we propose to run are will ensure that the image decoding tasks that could be performed with the older C libraries can be executed after replacement as well.&lt;br /&gt;
&lt;br /&gt;
The following test cases are proposed.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91794</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91794"/>
		<updated>2014-11-11T23:09:21Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* Data Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Background Information ==&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Servo currently depends on a lot of C libraries for image decoding. We wish to evaluate switching some of these to new Rust libraries. This project involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
====Setup of Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone and build servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The scope of our project is limited to changing the libraries used in the image decoding task shown above.&lt;br /&gt;
&lt;br /&gt;
== Requirement analysis ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Servo currently depends on a lot of C libraries, because Rust equivalents for these libraries did not exist when the project started. Our project is to evaluate switching some of these to new Rust libraries that have since been created. It involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Initial step&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our initial step, implemented for the OSS project involved:&lt;br /&gt;
# Building Servo.&lt;br /&gt;
# Adding [http://doc.servo.org/util/time/fn.time.html timing code] to the image decoding implementation in the net crate.&lt;br /&gt;
# Rebuilding Servo.&lt;br /&gt;
# Reporting numbers for different kinds of images (i.e. PNG, JPEG, GIF).&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;b&amp;gt;Final Requirements&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our final project requirements are to:&lt;br /&gt;
* Build Servo and add code that reports (via the println! macro) the time required to decode images into displayable pixels.&lt;br /&gt;
* Add image decoding timing to the profiler.&lt;br /&gt;
* Import the [https://github.com/PistonDevelopers/freetype-rs freetype-rs] library to replace [https://github.com/servo/rust-freetype rust-freetype] in Servo, rewriting necessary code.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3369&amp;lt;/ref&amp;gt; For this, we are to use [http://doc.crates.io/ Cargo], the dependency manager for Servo.&lt;br /&gt;
* Import the rust-image library to replace the [https://github.com/servo/rust-stb-image rust-stb-image] and [https://github.com/nothings/stb stb-image] libraries and rewrite the ''load_from_memory'' function which uses these libraries.&amp;lt;ref&amp;gt;https://github.com/servo/servo/issues/3368&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Report the timing differences for loading PNGs and non-PNGs on the same benchmarks. For this step, we are to consider profiling the result and optimizing the hotspots in rust-image.&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
&lt;br /&gt;
===Data Design===&lt;br /&gt;
The system entities that the project deals with is present in the image crate.&lt;br /&gt;
&lt;br /&gt;
The structs and enums used to represent images are as below :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Structures&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ImageBuf&lt;br /&gt;
|An Image whose pixels are contained within a vector&lt;br /&gt;
|-&lt;br /&gt;
|Luma&lt;br /&gt;
|A type to hold a grayscale pixel&lt;br /&gt;
|-&lt;br /&gt;
|LumaA&lt;br /&gt;
|A type to hold a grayscale pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|MutPixels&lt;br /&gt;
|Mutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Pixels&lt;br /&gt;
|Immutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Rgb&lt;br /&gt;
|A type to hold an RGB pixel&lt;br /&gt;
|-&lt;br /&gt;
|Rgba&lt;br /&gt;
|A type to hold an RGB pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|SubImage&lt;br /&gt;
|A View into another image&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Enums&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ColorType&lt;br /&gt;
|An enumeration over supported color types and their bit depths&lt;br /&gt;
|-&lt;br /&gt;
|DynamicImage&lt;br /&gt;
|A Dynamic Image&lt;br /&gt;
|-&lt;br /&gt;
|FilterType&lt;br /&gt;
|Available Sampling Filters&lt;br /&gt;
|-&lt;br /&gt;
|ImageError&lt;br /&gt;
|An enumeration of Image Errors&lt;br /&gt;
|-&lt;br /&gt;
|ImageFormat&lt;br /&gt;
|An enumeration of supported image formats. Not all formats support both encoding and decoding.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Component Design===&lt;br /&gt;
&lt;br /&gt;
Rust image : It is an image processing library. This crate provides basic imaging processing functions and methods for converting to and from image formats.&lt;br /&gt;
All image processing functions provided operate on types that implement the GenericImage trait and return an ImageBuf. The details of other modules and  traits included are :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Modules&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|gif&lt;br /&gt;
|Decoding of GIF Images&lt;br /&gt;
|-&lt;br /&gt;
|imageops&lt;br /&gt;
|Image Processing Functions&lt;br /&gt;
|-&lt;br /&gt;
|jpeg&lt;br /&gt;
|Decoding and Encoding of JPEG Images&lt;br /&gt;
|-&lt;br /&gt;
|png&lt;br /&gt;
|Decoding and Encoding of PNG Images&lt;br /&gt;
|-&lt;br /&gt;
|ppm&lt;br /&gt;
|Encoding of portable pixmap Images&lt;br /&gt;
|-&lt;br /&gt;
|webp&lt;br /&gt;
|Decoding of Webp Images&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Traits&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|GenericImage&lt;br /&gt;
|A trait for manipulating images.&lt;br /&gt;
|-&lt;br /&gt;
|ImageDecoder&lt;br /&gt;
|The trait that all decoders implement&lt;br /&gt;
|-&lt;br /&gt;
|MutableRefImage&lt;br /&gt;
|A trait for images that allow providing mutable references to pixels.&lt;br /&gt;
|-&lt;br /&gt;
|Pixel&lt;br /&gt;
|A trait that all pixels implement.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Functions&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|load&lt;br /&gt;
|Create a new image from a Reader&lt;br /&gt;
|-&lt;br /&gt;
|load_from_memory&lt;br /&gt;
|Create a new image from a byte slice&lt;br /&gt;
|-&lt;br /&gt;
|open&lt;br /&gt;
|Open the image located at the path specified. The image's format is determined from the path's file extension&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
&lt;br /&gt;
[[File:Flowchart_final_M1455.png]]&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
The project does not plan to add new functionality. &lt;br /&gt;
The test-cases we propose to run are will ensure that the image decoding tasks that could be performed with the older C libraries can be executed after replacement as well.&lt;br /&gt;
&lt;br /&gt;
The following test cases are proposed.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91776</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91776"/>
		<updated>2014-11-11T23:00:06Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* Class Diagram */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Background Information ==&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Servo currently depends on a lot of C libraries for image decoding. We wish to evaluate switching some of these to new Rust libraries. This project involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
====Setup of Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone and build servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The scope of our project is limited to changing the libraries used in the image decoding task shown above.&lt;br /&gt;
&lt;br /&gt;
== Requirement analysis&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Servo currently depends on a lot of C libraries, because Rust equivalents for these libraries did not exist when the project started. Our project is to evaluate switching some of these to new Rust libraries that have since been created. It involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Initial step:&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our initial step, implemented for the OSS project involved:&lt;br /&gt;
# Building Servo.&lt;br /&gt;
# Adding timing code to the image decoding implementation in the net crate.&lt;br /&gt;
# Rebuilding Servo.&lt;br /&gt;
# Reporting numbers for different kinds of images (i.e. PNG, JPEG, GIF).&lt;br /&gt;
 &lt;br /&gt;
Final Requirements:&lt;br /&gt;
Our final project requirements are to:&lt;br /&gt;
* Build Servo and add code that reports (via the println! macro) the time required to decode images into displayable pixels.&lt;br /&gt;
* Add image decoding timing to the profiler.&lt;br /&gt;
* Import the freetype-rs library to replace rust-freetype in Servo, rewriting necessary code. For this, we are to use Cargo, the dependency manager for Servo.&lt;br /&gt;
* Import the rust-image library to replace the rust-stb-image and stb-image libraries and rewrite the load_from_memory function which uses these libraries.&lt;br /&gt;
* Report the timing differences for loading PNGs and non-PNGs on the same benchmarks. For this step, we are to consider profiling the result and optimizing the hotspots in rust-image.&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
&lt;br /&gt;
===Data Design===&lt;br /&gt;
The system entities that the project deals is present in the image crate.&lt;br /&gt;
The structs and Enums used are as below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Structures&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ImageBuf&lt;br /&gt;
|An Image whose pixels are contained within a vector&lt;br /&gt;
|-&lt;br /&gt;
|Luma&lt;br /&gt;
|A type to hold a grayscale pixel&lt;br /&gt;
|-&lt;br /&gt;
|LumaA&lt;br /&gt;
|A type to hold a grayscale pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|MutPixels&lt;br /&gt;
|Mutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Pixels&lt;br /&gt;
|Immutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Rgb&lt;br /&gt;
|A type to hold an RGB pixel&lt;br /&gt;
|-&lt;br /&gt;
|Rgba&lt;br /&gt;
|A type to hold an RGB pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|SubImage&lt;br /&gt;
|A View into another image&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Enums&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ColorType&lt;br /&gt;
|An enumeration over supported color types and their bit depths&lt;br /&gt;
|-&lt;br /&gt;
|DynamicImage&lt;br /&gt;
|A Dynamic Image&lt;br /&gt;
|-&lt;br /&gt;
|FilterType&lt;br /&gt;
|Available Sampling Filters&lt;br /&gt;
|-&lt;br /&gt;
|ImageError&lt;br /&gt;
|An enumeration of Image Errors&lt;br /&gt;
|-&lt;br /&gt;
|ImageFormat&lt;br /&gt;
|An enumeration of supported image formats. Not all formats support both encoding and decoding.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Component Design===&lt;br /&gt;
&lt;br /&gt;
Rust image : It is an image processing library. This crate provides basic imaging processing functions and methods for converting to and from image formats.&lt;br /&gt;
All image processing functions provided operate on types that implement the GenericImage trait and return an ImageBuf. The details of other modules and  traits included are :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Modules&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|gif&lt;br /&gt;
|Decoding of GIF Images&lt;br /&gt;
|-&lt;br /&gt;
|imageops&lt;br /&gt;
|Image Processing Functions&lt;br /&gt;
|-&lt;br /&gt;
|jpeg&lt;br /&gt;
|Decoding and Encoding of JPEG Images&lt;br /&gt;
|-&lt;br /&gt;
|png&lt;br /&gt;
|Decoding and Encoding of PNG Images&lt;br /&gt;
|-&lt;br /&gt;
|ppm&lt;br /&gt;
|Encoding of portable pixmap Images&lt;br /&gt;
|-&lt;br /&gt;
|webp&lt;br /&gt;
|Decoding of Webp Images&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Traits&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|GenericImage&lt;br /&gt;
|A trait for manipulating images.&lt;br /&gt;
|-&lt;br /&gt;
|ImageDecoder&lt;br /&gt;
|The trait that all decoders implement&lt;br /&gt;
|-&lt;br /&gt;
|MutableRefImage&lt;br /&gt;
|A trait for images that allow providing mutable references to pixels.&lt;br /&gt;
|-&lt;br /&gt;
|Pixel&lt;br /&gt;
|A trait that all pixels implement.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Functions&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|load&lt;br /&gt;
|Create a new image from a Reader&lt;br /&gt;
|-&lt;br /&gt;
|load_from_memory&lt;br /&gt;
|Create a new image from a byte slice&lt;br /&gt;
|-&lt;br /&gt;
|open&lt;br /&gt;
|Open the image located at the path specified. The image's format is determined from the path's file extension&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
===Use case diagram===&lt;br /&gt;
===Class Diagram===&lt;br /&gt;
&lt;br /&gt;
[[File:Flowchart_final_M1455.png]]&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
The project does not plan to add new functionality. &lt;br /&gt;
The test-cases we propose to run are will ensure that the image decoding tasks that could be performed with the older C libraries can be executed after replacement as well.&lt;br /&gt;
&lt;br /&gt;
The following test cases are proposed.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91775</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91775"/>
		<updated>2014-11-11T22:59:52Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* UML diagrams */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Background Information ==&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Servo currently depends on a lot of C libraries for image decoding. We wish to evaluate switching some of these to new Rust libraries. This project involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
====Setup of Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone and build servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The scope of our project is limited to changing the libraries used in the image decoding task shown above.&lt;br /&gt;
&lt;br /&gt;
== Requirement analysis&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Servo currently depends on a lot of C libraries, because Rust equivalents for these libraries did not exist when the project started. Our project is to evaluate switching some of these to new Rust libraries that have since been created. It involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Initial step:&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our initial step, implemented for the OSS project involved:&lt;br /&gt;
# Building Servo.&lt;br /&gt;
# Adding timing code to the image decoding implementation in the net crate.&lt;br /&gt;
# Rebuilding Servo.&lt;br /&gt;
# Reporting numbers for different kinds of images (i.e. PNG, JPEG, GIF).&lt;br /&gt;
 &lt;br /&gt;
Final Requirements:&lt;br /&gt;
Our final project requirements are to:&lt;br /&gt;
* Build Servo and add code that reports (via the println! macro) the time required to decode images into displayable pixels.&lt;br /&gt;
* Add image decoding timing to the profiler.&lt;br /&gt;
* Import the freetype-rs library to replace rust-freetype in Servo, rewriting necessary code. For this, we are to use Cargo, the dependency manager for Servo.&lt;br /&gt;
* Import the rust-image library to replace the rust-stb-image and stb-image libraries and rewrite the load_from_memory function which uses these libraries.&lt;br /&gt;
* Report the timing differences for loading PNGs and non-PNGs on the same benchmarks. For this step, we are to consider profiling the result and optimizing the hotspots in rust-image.&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
&lt;br /&gt;
===Data Design===&lt;br /&gt;
The system entities that the project deals is present in the image crate.&lt;br /&gt;
The structs and Enums used are as below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Structures&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ImageBuf&lt;br /&gt;
|An Image whose pixels are contained within a vector&lt;br /&gt;
|-&lt;br /&gt;
|Luma&lt;br /&gt;
|A type to hold a grayscale pixel&lt;br /&gt;
|-&lt;br /&gt;
|LumaA&lt;br /&gt;
|A type to hold a grayscale pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|MutPixels&lt;br /&gt;
|Mutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Pixels&lt;br /&gt;
|Immutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Rgb&lt;br /&gt;
|A type to hold an RGB pixel&lt;br /&gt;
|-&lt;br /&gt;
|Rgba&lt;br /&gt;
|A type to hold an RGB pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|SubImage&lt;br /&gt;
|A View into another image&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Enums&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ColorType&lt;br /&gt;
|An enumeration over supported color types and their bit depths&lt;br /&gt;
|-&lt;br /&gt;
|DynamicImage&lt;br /&gt;
|A Dynamic Image&lt;br /&gt;
|-&lt;br /&gt;
|FilterType&lt;br /&gt;
|Available Sampling Filters&lt;br /&gt;
|-&lt;br /&gt;
|ImageError&lt;br /&gt;
|An enumeration of Image Errors&lt;br /&gt;
|-&lt;br /&gt;
|ImageFormat&lt;br /&gt;
|An enumeration of supported image formats. Not all formats support both encoding and decoding.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Component Design===&lt;br /&gt;
&lt;br /&gt;
Rust image : It is an image processing library. This crate provides basic imaging processing functions and methods for converting to and from image formats.&lt;br /&gt;
All image processing functions provided operate on types that implement the GenericImage trait and return an ImageBuf. The details of other modules and  traits included are :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Modules&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|gif&lt;br /&gt;
|Decoding of GIF Images&lt;br /&gt;
|-&lt;br /&gt;
|imageops&lt;br /&gt;
|Image Processing Functions&lt;br /&gt;
|-&lt;br /&gt;
|jpeg&lt;br /&gt;
|Decoding and Encoding of JPEG Images&lt;br /&gt;
|-&lt;br /&gt;
|png&lt;br /&gt;
|Decoding and Encoding of PNG Images&lt;br /&gt;
|-&lt;br /&gt;
|ppm&lt;br /&gt;
|Encoding of portable pixmap Images&lt;br /&gt;
|-&lt;br /&gt;
|webp&lt;br /&gt;
|Decoding of Webp Images&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Traits&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|GenericImage&lt;br /&gt;
|A trait for manipulating images.&lt;br /&gt;
|-&lt;br /&gt;
|ImageDecoder&lt;br /&gt;
|The trait that all decoders implement&lt;br /&gt;
|-&lt;br /&gt;
|MutableRefImage&lt;br /&gt;
|A trait for images that allow providing mutable references to pixels.&lt;br /&gt;
|-&lt;br /&gt;
|Pixel&lt;br /&gt;
|A trait that all pixels implement.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Functions&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|load&lt;br /&gt;
|Create a new image from a Reader&lt;br /&gt;
|-&lt;br /&gt;
|load_from_memory&lt;br /&gt;
|Create a new image from a byte slice&lt;br /&gt;
|-&lt;br /&gt;
|open&lt;br /&gt;
|Open the image located at the path specified. The image's format is determined from the path's file extension&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
===Use case diagram===&lt;br /&gt;
===Class Diagram===&lt;br /&gt;
&lt;br /&gt;
[File:Flowchart_final_M1455.png]&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
The project does not plan to add new functionality. &lt;br /&gt;
The test-cases we propose to run are will ensure that the image decoding tasks that could be performed with the older C libraries can be executed after replacement as well.&lt;br /&gt;
&lt;br /&gt;
The following test cases are proposed.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Flowchart_final_M1455.png&amp;diff=91774</id>
		<title>File:Flowchart final M1455.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Flowchart_final_M1455.png&amp;diff=91774"/>
		<updated>2014-11-11T22:59:18Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: Flowchart describing steps required in M1465 semester project&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Flowchart describing steps required in M1465 semester project&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91764</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91764"/>
		<updated>2014-11-11T22:33:38Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* Component Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Background Information ==&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Servo currently depends on a lot of C libraries for image decoding. We wish to evaluate switching some of these to new Rust libraries. This project involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
====Setup of Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone and build servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The scope of our project is limited to changing the libraries used in the image decoding task shown above.&lt;br /&gt;
&lt;br /&gt;
== Requirement analysis&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Servo currently depends on a lot of C libraries, because Rust equivalents for these libraries did not exist when the project started. Our project is to evaluate switching some of these to new Rust libraries that have since been created. It involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Initial step:&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our initial step, implemented for the OSS project involved:&lt;br /&gt;
# Building Servo.&lt;br /&gt;
# Adding timing code to the image decoding implementation in the net crate.&lt;br /&gt;
# Rebuilding Servo.&lt;br /&gt;
# Reporting numbers for different kinds of images (i.e. PNG, JPEG, GIF).&lt;br /&gt;
 &lt;br /&gt;
Final Requirements:&lt;br /&gt;
Our final project requirements are to:&lt;br /&gt;
* Build Servo and add code that reports (via the println! macro) the time required to decode images into displayable pixels.&lt;br /&gt;
* Add image decoding timing to the profiler.&lt;br /&gt;
* Import the freetype-rs library to replace rust-freetype in Servo, rewriting necessary code. For this, we are to use Cargo, the dependency manager for Servo.&lt;br /&gt;
* Import the rust-image library to replace the rust-stb-image and stb-image libraries and rewrite the load_from_memory function which uses these libraries.&lt;br /&gt;
* Report the timing differences for loading PNGs and non-PNGs on the same benchmarks. For this step, we are to consider profiling the result and optimizing the hotspots in rust-image.&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
&lt;br /&gt;
===Data Design===&lt;br /&gt;
The system entities that the project deals is present in the image crate.&lt;br /&gt;
The structs and Enums used are as below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Structures&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ImageBuf&lt;br /&gt;
|An Image whose pixels are contained within a vector&lt;br /&gt;
|-&lt;br /&gt;
|Luma&lt;br /&gt;
|A type to hold a grayscale pixel&lt;br /&gt;
|-&lt;br /&gt;
|LumaA&lt;br /&gt;
|A type to hold a grayscale pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|MutPixels&lt;br /&gt;
|Mutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Pixels&lt;br /&gt;
|Immutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Rgb&lt;br /&gt;
|A type to hold an RGB pixel&lt;br /&gt;
|-&lt;br /&gt;
|Rgba&lt;br /&gt;
|A type to hold an RGB pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|SubImage&lt;br /&gt;
|A View into another image&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Enums&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ColorType&lt;br /&gt;
|An enumeration over supported color types and their bit depths&lt;br /&gt;
|-&lt;br /&gt;
|DynamicImage&lt;br /&gt;
|A Dynamic Image&lt;br /&gt;
|-&lt;br /&gt;
|FilterType&lt;br /&gt;
|Available Sampling Filters&lt;br /&gt;
|-&lt;br /&gt;
|ImageError&lt;br /&gt;
|An enumeration of Image Errors&lt;br /&gt;
|-&lt;br /&gt;
|ImageFormat&lt;br /&gt;
|An enumeration of supported image formats. Not all formats support both encoding and decoding.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Component Design===&lt;br /&gt;
&lt;br /&gt;
Rust image : It is an image processing library. This crate provides basic imaging processing functions and methods for converting to and from image formats.&lt;br /&gt;
All image processing functions provided operate on types that implement the GenericImage trait and return an ImageBuf. The details of other modules and  traits included are :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Modules&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|gif&lt;br /&gt;
|Decoding of GIF Images&lt;br /&gt;
|-&lt;br /&gt;
|imageops&lt;br /&gt;
|Image Processing Functions&lt;br /&gt;
|-&lt;br /&gt;
|jpeg&lt;br /&gt;
|Decoding and Encoding of JPEG Images&lt;br /&gt;
|-&lt;br /&gt;
|png&lt;br /&gt;
|Decoding and Encoding of PNG Images&lt;br /&gt;
|-&lt;br /&gt;
|ppm&lt;br /&gt;
|Encoding of portable pixmap Images&lt;br /&gt;
|-&lt;br /&gt;
|webp&lt;br /&gt;
|Decoding of Webp Images&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Traits&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|GenericImage&lt;br /&gt;
|A trait for manipulating images.&lt;br /&gt;
|-&lt;br /&gt;
|ImageDecoder&lt;br /&gt;
|The trait that all decoders implement&lt;br /&gt;
|-&lt;br /&gt;
|MutableRefImage&lt;br /&gt;
|A trait for images that allow providing mutable references to pixels.&lt;br /&gt;
|-&lt;br /&gt;
|Pixel&lt;br /&gt;
|A trait that all pixels implement.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Functions&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|load&lt;br /&gt;
|Create a new image from a Reader&lt;br /&gt;
|-&lt;br /&gt;
|load_from_memory&lt;br /&gt;
|Create a new image from a byte slice&lt;br /&gt;
|-&lt;br /&gt;
|open&lt;br /&gt;
|Open the image located at the path specified. The image's format is determined from the path's file extension&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
===Use case diagram===&lt;br /&gt;
===Class Diagram===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
The project does not plan to add new functionality. &lt;br /&gt;
The test-cases we propose to run are will ensure that the image decoding tasks that could be performed with the older C libraries can be executed after replacement as well.&lt;br /&gt;
&lt;br /&gt;
The following test cases are proposed.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91763</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91763"/>
		<updated>2014-11-11T22:30:23Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* Data Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Background Information ==&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Servo currently depends on a lot of C libraries for image decoding. We wish to evaluate switching some of these to new Rust libraries. This project involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
====Setup of Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone and build servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The scope of our project is limited to changing the libraries used in the image decoding task shown above.&lt;br /&gt;
&lt;br /&gt;
== Requirement analysis&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Servo currently depends on a lot of C libraries, because Rust equivalents for these libraries did not exist when the project started. Our project is to evaluate switching some of these to new Rust libraries that have since been created. It involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Initial step:&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our initial step, implemented for the OSS project involved:&lt;br /&gt;
# Building Servo.&lt;br /&gt;
# Adding timing code to the image decoding implementation in the net crate.&lt;br /&gt;
# Rebuilding Servo.&lt;br /&gt;
# Reporting numbers for different kinds of images (i.e. PNG, JPEG, GIF).&lt;br /&gt;
 &lt;br /&gt;
Final Requirements:&lt;br /&gt;
Our final project requirements are to:&lt;br /&gt;
* Build Servo and add code that reports (via the println! macro) the time required to decode images into displayable pixels.&lt;br /&gt;
* Add image decoding timing to the profiler.&lt;br /&gt;
* Import the freetype-rs library to replace rust-freetype in Servo, rewriting necessary code. For this, we are to use Cargo, the dependency manager for Servo.&lt;br /&gt;
* Import the rust-image library to replace the rust-stb-image and stb-image libraries and rewrite the load_from_memory function which uses these libraries.&lt;br /&gt;
* Report the timing differences for loading PNGs and non-PNGs on the same benchmarks. For this step, we are to consider profiling the result and optimizing the hotspots in rust-image.&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
&lt;br /&gt;
===Data Design===&lt;br /&gt;
The system entities that the project deals is present in the image crate.&lt;br /&gt;
The structs and Enums used are as below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Structures&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ImageBuf&lt;br /&gt;
|An Image whose pixels are contained within a vector&lt;br /&gt;
|-&lt;br /&gt;
|Luma&lt;br /&gt;
|A type to hold a grayscale pixel&lt;br /&gt;
|-&lt;br /&gt;
|LumaA&lt;br /&gt;
|A type to hold a grayscale pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|MutPixels&lt;br /&gt;
|Mutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Pixels&lt;br /&gt;
|Immutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Rgb&lt;br /&gt;
|A type to hold an RGB pixel&lt;br /&gt;
|-&lt;br /&gt;
|Rgba&lt;br /&gt;
|A type to hold an RGB pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|SubImage&lt;br /&gt;
|A View into another image&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Enums&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ColorType&lt;br /&gt;
|An enumeration over supported color types and their bit depths&lt;br /&gt;
|-&lt;br /&gt;
|DynamicImage&lt;br /&gt;
|A Dynamic Image&lt;br /&gt;
|-&lt;br /&gt;
|FilterType&lt;br /&gt;
|Available Sampling Filters&lt;br /&gt;
|-&lt;br /&gt;
|ImageError&lt;br /&gt;
|An enumeration of Image Errors&lt;br /&gt;
|-&lt;br /&gt;
|ImageFormat&lt;br /&gt;
|An enumeration of supported image formats. Not all formats support both encoding and decoding.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Component Design===&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
===Use case diagram===&lt;br /&gt;
===Class Diagram===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
The project does not plan to add new functionality. &lt;br /&gt;
The test-cases we propose to run are will ensure that the image decoding tasks that could be performed with the older C libraries can be executed after replacement as well.&lt;br /&gt;
&lt;br /&gt;
The following test cases are proposed.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91762</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91762"/>
		<updated>2014-11-11T22:30:04Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* Data and component design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Background Information ==&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Servo currently depends on a lot of C libraries for image decoding. We wish to evaluate switching some of these to new Rust libraries. This project involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
====Setup of Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone and build servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The scope of our project is limited to changing the libraries used in the image decoding task shown above.&lt;br /&gt;
&lt;br /&gt;
== Requirement analysis&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Servo currently depends on a lot of C libraries, because Rust equivalents for these libraries did not exist when the project started. Our project is to evaluate switching some of these to new Rust libraries that have since been created. It involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Initial step:&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our initial step, implemented for the OSS project involved:&lt;br /&gt;
# Building Servo.&lt;br /&gt;
# Adding timing code to the image decoding implementation in the net crate.&lt;br /&gt;
# Rebuilding Servo.&lt;br /&gt;
# Reporting numbers for different kinds of images (i.e. PNG, JPEG, GIF).&lt;br /&gt;
 &lt;br /&gt;
Final Requirements:&lt;br /&gt;
Our final project requirements are to:&lt;br /&gt;
* Build Servo and add code that reports (via the println! macro) the time required to decode images into displayable pixels.&lt;br /&gt;
* Add image decoding timing to the profiler.&lt;br /&gt;
* Import the freetype-rs library to replace rust-freetype in Servo, rewriting necessary code. For this, we are to use Cargo, the dependency manager for Servo.&lt;br /&gt;
* Import the rust-image library to replace the rust-stb-image and stb-image libraries and rewrite the load_from_memory function which uses these libraries.&lt;br /&gt;
* Report the timing differences for loading PNGs and non-PNGs on the same benchmarks. For this step, we are to consider profiling the result and optimizing the hotspots in rust-image.&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
&lt;br /&gt;
===Data Design===&lt;br /&gt;
&amp;lt;b&amp;gt;Structures&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ImageBuf&lt;br /&gt;
|An Image whose pixels are contained within a vector&lt;br /&gt;
|-&lt;br /&gt;
|Luma&lt;br /&gt;
|A type to hold a grayscale pixel&lt;br /&gt;
|-&lt;br /&gt;
|LumaA&lt;br /&gt;
|A type to hold a grayscale pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|MutPixels&lt;br /&gt;
|Mutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Pixels&lt;br /&gt;
|Immutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Rgb&lt;br /&gt;
|A type to hold an RGB pixel&lt;br /&gt;
|-&lt;br /&gt;
|Rgba&lt;br /&gt;
|A type to hold an RGB pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|SubImage&lt;br /&gt;
|A View into another image&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Enums&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ColorType&lt;br /&gt;
|An enumeration over supported color types and their bit depths&lt;br /&gt;
|-&lt;br /&gt;
|DynamicImage&lt;br /&gt;
|A Dynamic Image&lt;br /&gt;
|-&lt;br /&gt;
|FilterType&lt;br /&gt;
|Available Sampling Filters&lt;br /&gt;
|-&lt;br /&gt;
|ImageError&lt;br /&gt;
|An enumeration of Image Errors&lt;br /&gt;
|-&lt;br /&gt;
|ImageFormat&lt;br /&gt;
|An enumeration of supported image formats. Not all formats support both encoding and decoding.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Component Design===&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
===Use case diagram===&lt;br /&gt;
===Class Diagram===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
The project does not plan to add new functionality. &lt;br /&gt;
The test-cases we propose to run are will ensure that the image decoding tasks that could be performed with the older C libraries can be executed after replacement as well.&lt;br /&gt;
&lt;br /&gt;
The following test cases are proposed.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91761</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91761"/>
		<updated>2014-11-11T22:29:37Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* Data and component design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Background Information ==&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Servo currently depends on a lot of C libraries for image decoding. We wish to evaluate switching some of these to new Rust libraries. This project involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
====Setup of Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone and build servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The scope of our project is limited to changing the libraries used in the image decoding task shown above.&lt;br /&gt;
&lt;br /&gt;
== Requirement analysis&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Servo currently depends on a lot of C libraries, because Rust equivalents for these libraries did not exist when the project started. Our project is to evaluate switching some of these to new Rust libraries that have since been created. It involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Initial step:&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our initial step, implemented for the OSS project involved:&lt;br /&gt;
# Building Servo.&lt;br /&gt;
# Adding timing code to the image decoding implementation in the net crate.&lt;br /&gt;
# Rebuilding Servo.&lt;br /&gt;
# Reporting numbers for different kinds of images (i.e. PNG, JPEG, GIF).&lt;br /&gt;
 &lt;br /&gt;
Final Requirements:&lt;br /&gt;
Our final project requirements are to:&lt;br /&gt;
* Build Servo and add code that reports (via the println! macro) the time required to decode images into displayable pixels.&lt;br /&gt;
* Add image decoding timing to the profiler.&lt;br /&gt;
* Import the freetype-rs library to replace rust-freetype in Servo, rewriting necessary code. For this, we are to use Cargo, the dependency manager for Servo.&lt;br /&gt;
* Import the rust-image library to replace the rust-stb-image and stb-image libraries and rewrite the load_from_memory function which uses these libraries.&lt;br /&gt;
* Report the timing differences for loading PNGs and non-PNGs on the same benchmarks. For this step, we are to consider profiling the result and optimizing the hotspots in rust-image.&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Structures&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ImageBuf&lt;br /&gt;
|An Image whose pixels are contained within a vector&lt;br /&gt;
|-&lt;br /&gt;
|Luma&lt;br /&gt;
|A type to hold a grayscale pixel&lt;br /&gt;
|-&lt;br /&gt;
|LumaA&lt;br /&gt;
|A type to hold a grayscale pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|MutPixels&lt;br /&gt;
|Mutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Pixels&lt;br /&gt;
|Immutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Rgb&lt;br /&gt;
|A type to hold an RGB pixel&lt;br /&gt;
|-&lt;br /&gt;
|Rgba&lt;br /&gt;
|A type to hold an RGB pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|SubImage&lt;br /&gt;
|A View into another image&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Enums&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ColorType&lt;br /&gt;
|An enumeration over supported color types and their bit depths&lt;br /&gt;
|-&lt;br /&gt;
|DynamicImage&lt;br /&gt;
|A Dynamic Image&lt;br /&gt;
|-&lt;br /&gt;
|FilterType&lt;br /&gt;
|Available Sampling Filters&lt;br /&gt;
|-&lt;br /&gt;
|ImageError&lt;br /&gt;
|An enumeration of Image Errors&lt;br /&gt;
|-&lt;br /&gt;
|ImageFormat&lt;br /&gt;
|An enumeration of supported image formats. Not all formats support both encoding and decoding.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
===Use case diagram===&lt;br /&gt;
===Class Diagram===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
The project does not plan to add new functionality. &lt;br /&gt;
The test-cases we propose to run are will ensure that the image decoding tasks that could be performed with the older C libraries can be executed after replacement as well.&lt;br /&gt;
&lt;br /&gt;
The following test cases are proposed.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91760</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91760"/>
		<updated>2014-11-11T22:28:09Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* Data and component design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Background Information ==&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Servo currently depends on a lot of C libraries for image decoding. We wish to evaluate switching some of these to new Rust libraries. This project involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
====Setup of Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone and build servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The scope of our project is limited to changing the libraries used in the image decoding task shown above.&lt;br /&gt;
&lt;br /&gt;
== Requirement analysis&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Servo currently depends on a lot of C libraries, because Rust equivalents for these libraries did not exist when the project started. Our project is to evaluate switching some of these to new Rust libraries that have since been created. It involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Initial step:&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our initial step, implemented for the OSS project involved:&lt;br /&gt;
# Building Servo.&lt;br /&gt;
# Adding timing code to the image decoding implementation in the net crate.&lt;br /&gt;
# Rebuilding Servo.&lt;br /&gt;
# Reporting numbers for different kinds of images (i.e. PNG, JPEG, GIF).&lt;br /&gt;
 &lt;br /&gt;
Final Requirements:&lt;br /&gt;
Our final project requirements are to:&lt;br /&gt;
* Build Servo and add code that reports (via the println! macro) the time required to decode images into displayable pixels.&lt;br /&gt;
* Add image decoding timing to the profiler.&lt;br /&gt;
* Import the freetype-rs library to replace rust-freetype in Servo, rewriting necessary code. For this, we are to use Cargo, the dependency manager for Servo.&lt;br /&gt;
* Import the rust-image library to replace the rust-stb-image and stb-image libraries and rewrite the load_from_memory function which uses these libraries.&lt;br /&gt;
* Report the timing differences for loading PNGs and non-PNGs on the same benchmarks. For this step, we are to consider profiling the result and optimizing the hotspots in rust-image.&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Structures&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class = &amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|ImageBuf&lt;br /&gt;
|An Image whose pixels are contained within a vector&lt;br /&gt;
|-&lt;br /&gt;
|Luma&lt;br /&gt;
|A type to hold a grayscale pixel&lt;br /&gt;
|-&lt;br /&gt;
|LumaA&lt;br /&gt;
|A type to hold a grayscale pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|MutPixels&lt;br /&gt;
|Mutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Pixels&lt;br /&gt;
|Immutable pixel iterator&lt;br /&gt;
|-&lt;br /&gt;
|Rgb&lt;br /&gt;
|A type to hold an RGB pixel&lt;br /&gt;
|-&lt;br /&gt;
|Rgba&lt;br /&gt;
|A type to hold an RGB pixel with an alpha channel&lt;br /&gt;
|-&lt;br /&gt;
|SubImage&lt;br /&gt;
|A View into another image&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
===Use case diagram===&lt;br /&gt;
===Class Diagram===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
The project does not plan to add new functionality. &lt;br /&gt;
The test-cases we propose to run are will ensure that the image decoding tasks that could be performed with the older C libraries can be executed after replacement as well.&lt;br /&gt;
&lt;br /&gt;
The following test cases are proposed.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91757</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91757"/>
		<updated>2014-11-11T22:22:40Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* Requirement analysishttps://github.com/servo/servo/wiki/Replace-C-libraries-student-project */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Background Information ==&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Servo currently depends on a lot of C libraries for image decoding. We wish to evaluate switching some of these to new Rust libraries. This project involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
====Setup of Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone and build servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The scope of our project is limited to changing the libraries used in the image decoding task shown above.&lt;br /&gt;
&lt;br /&gt;
== Requirement analysis&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Servo currently depends on a lot of C libraries, because Rust equivalents for these libraries did not exist when the project started. Our project is to evaluate switching some of these to new Rust libraries that have since been created. It involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Initial step:&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Our initial step, implemented for the OSS project involved:&lt;br /&gt;
# Building Servo.&lt;br /&gt;
# Adding timing code to the image decoding implementation in the net crate.&lt;br /&gt;
# Rebuilding Servo.&lt;br /&gt;
# Reporting numbers for different kinds of images (i.e. PNG, JPEG, GIF).&lt;br /&gt;
 &lt;br /&gt;
Final Requirements:&lt;br /&gt;
Our final project requirements are to:&lt;br /&gt;
* Build Servo and add code that reports (via the println! macro) the time required to decode images into displayable pixels.&lt;br /&gt;
* Add image decoding timing to the profiler.&lt;br /&gt;
* Import the freetype-rs library to replace rust-freetype in Servo, rewriting necessary code. For this, we are to use Cargo, the dependency manager for Servo.&lt;br /&gt;
* Import the rust-image library to replace the rust-stb-image and stb-image libraries and rewrite the load_from_memory function which uses these libraries.&lt;br /&gt;
* Report the timing differences for loading PNGs and non-PNGs on the same benchmarks. For this step, we are to consider profiling the result and optimizing the hotspots in rust-image.&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
===Use case diagram===&lt;br /&gt;
===Class Diagram===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
The project does not plan to add new functionality. &lt;br /&gt;
The test-cases we propose to run are will ensure that the image decoding tasks that could be performed with the older C libraries can be executed after replacement as well.&lt;br /&gt;
&lt;br /&gt;
The following test cases are proposed.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91756</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91756"/>
		<updated>2014-11-11T22:19:42Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* Proposed Test Cases */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Background Information ==&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Servo currently depends on a lot of C libraries for image decoding. We wish to evaluate switching some of these to new Rust libraries. This project involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
====Setup of Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone and build servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The scope of our project is limited to changing the libraries used in the image decoding task shown above.&lt;br /&gt;
&lt;br /&gt;
== Requirement analysis&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
===Use case diagram===&lt;br /&gt;
===Class Diagram===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
The project does not plan to add new functionality. &lt;br /&gt;
The test-cases we propose to run are will ensure that the image decoding tasks that could be performed with the older C libraries can be executed after replacement as well.&lt;br /&gt;
&lt;br /&gt;
The following test cases are proposed.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91753</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91753"/>
		<updated>2014-11-11T21:55:09Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* Architecture of system https://github.com/servo/servo/wiki/Design#task-supervision-diagram */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Background Information ==&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Servo currently depends on a lot of C libraries for image decoding. We wish to evaluate switching some of these to new Rust libraries. This project involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
====Setup of Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone and build servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The scope of our project is limited to changing the libraries used in the image decoding task shown above.&lt;br /&gt;
&lt;br /&gt;
== Requirement analysis&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
===Use case diagram===&lt;br /&gt;
===Class Diagram===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91752</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91752"/>
		<updated>2014-11-11T21:51:41Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* Development Environment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Background Information ==&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Servo currently depends on a lot of C libraries for image decoding. We wish to evaluate switching some of these to new Rust libraries. This project involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
====Setup of Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone and build servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The scope of our project is limited to the image decoding task shown above.&lt;br /&gt;
&lt;br /&gt;
== Requirement analysis&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
===Use case diagram===&lt;br /&gt;
===Class Diagram===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91751</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91751"/>
		<updated>2014-11-11T21:51:20Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* Architecture of system https://github.com/servo/servo/wiki/Design#task-supervision-diagram */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Background Information ==&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Servo currently depends on a lot of C libraries for image decoding. We wish to evaluate switching some of these to new Rust libraries. This project involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
====Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone and build servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The scope of our project is limited to the image decoding task shown above.&lt;br /&gt;
&lt;br /&gt;
== Requirement analysis&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
===Use case diagram===&lt;br /&gt;
===Class Diagram===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91748</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91748"/>
		<updated>2014-11-11T21:39:55Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* Preface */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Background Information ==&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Servo currently depends on a lot of C libraries for image decoding. We wish to evaluate switching some of these to new Rust libraries. This project involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
====Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone and build servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
== Requirement analysis&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
===Use case diagram===&lt;br /&gt;
===Class Diagram===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91747</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91747"/>
		<updated>2014-11-11T21:39:19Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Preface ==&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Servo currently depends on a lot of C libraries for image decoding. We wish to evaluate switching some of these to new Rust libraries. This project involves rewriting the code that uses these libraries as well as taking measurements before and after to determine the costs involved.&lt;br /&gt;
&lt;br /&gt;
====Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone and build servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
== Requirement analysis&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
===Use case diagram===&lt;br /&gt;
===Class Diagram===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91746</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91746"/>
		<updated>2014-11-11T21:37:33Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* Requirement analysishttps://github.com/servo/servo/wiki/Replace-C-libraries-student-project */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project is meant to evaluate the feasibility of replacing the certain image decoding libraries written in C with their Rust equivalents.&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
====Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone and build servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
== Requirement analysis&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
===Use case diagram===&lt;br /&gt;
===Class Diagram===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91745</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91745"/>
		<updated>2014-11-11T21:36:32Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* Development Environment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project is meant to evaluate the feasibility of replacing the certain image decoding libraries written in C with their Rust equivalents.&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
====Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a Debian based 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone and build servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
== Requirement analysis&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
===Use case diagram===&lt;br /&gt;
===Class Diagram===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91744</id>
		<title>CSC/ECE 517 Fall 2014/final M1455 yaaa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_M1455_yaaa&amp;diff=91744"/>
		<updated>2014-11-11T21:35:59Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: Created page with &amp;quot;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains design details for the project on [https://github.com/servo/servo/wiki/Replace-C-libraries-student-project Evaluate replacing C libraries with modern Rust equivalents] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project is meant to evaluate the feasibility of replacing the certain image decoding libraries written in C with their Rust equivalents.&lt;br /&gt;
&lt;br /&gt;
===Rust===&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a new programming language for developing reliable and efficient systems. It is designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety.&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory.&lt;br /&gt;
&lt;br /&gt;
===Servo===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Servo_%28layout_engine%29 Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. &lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Rust’s lightweight task mechanism promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation. Servo is not designed to create a full browser but is rather focused on creating a reliable and fast browser engine.&lt;br /&gt;
&lt;br /&gt;
====Development Environment====&lt;br /&gt;
Servo is currently developed on 64bit OS X and 64bit Linux. &lt;br /&gt;
&lt;br /&gt;
The steps needed to build on a 64 bit Linux machine are included below. The instructions for other platforms are available [https://github.com/servo/servo#prerequisites here].&lt;br /&gt;
&lt;br /&gt;
* Install the prerequisite dependencies&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Clone and build servo repository&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone https://www.github.com/servo/servo&lt;br /&gt;
cd servo&lt;br /&gt;
./mach build&lt;br /&gt;
./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
== Requirement analysis&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Replace-C-libraries-student-project&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML diagrams ==&lt;br /&gt;
===Use case diagram===&lt;br /&gt;
===Class Diagram===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1460_aua&amp;diff=91035</id>
		<title>CSC/ECE 517 Fall 2014/oss E1460 aua</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1460_aua&amp;diff=91035"/>
		<updated>2014-10-30T00:29:55Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* Elimination of Boolean Zen */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Expertiza - Refactoring StudentQuizController==&lt;br /&gt;
Expertiza is a web application developed using Ruby on Rails that serves as a peer-review system. The application allows students to submit and peer-review learning objects (articles, code, web sites, etc)&amp;lt;ref&amp;gt;[https://github.com/expertiza/expertiza Expertiza on GitHub]&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza Wiki Page]&amp;lt;/ref&amp;gt;. It is an open source project and it's codebase is maintained in GitHub. We are contributing to Expertiza as a part of our Object-Oriented Design and Development's Open-Source Software (OSS) Project. Our goal in this project is to refactor the &amp;lt;b&amp;gt;StudentQuiz controller&amp;lt;/b&amp;gt;. In this Wiki Page, we would be explaining the changes that we have made for the same.&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Project Description==&lt;br /&gt;
The &amp;lt;b&amp;gt;StudentQuiz controller&amp;lt;/b&amp;gt; consists of methods involved in creating, scoring &amp;amp; recording responses of the quizzes taken by reviewers or students of the other teams with the same topic. &lt;br /&gt;
&amp;lt;br&amp;gt;The changes that are needed to be done are described as follows:&amp;lt;ref&amp;gt;[https://docs.google.com/a/ncsu.edu/document/d/1FZCL9KWSdVNsX9BowuZ3gxbCOJoiWX-GVLctSZei3No/edit# GoogleDoc for our project requirements]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Pluralize the class. (StudentQuizzesController)&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Rename methods to conform to RESTful style. (e.g. :- Rename the list method to index.)&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Reduce the number of instance variables per controller action.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Review Method &amp;lt;b&amp;gt;graded?&amp;lt;/b&amp;gt; for boolean zen.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Perform Code cleanup by removing unused code.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Use good Ruby style guidelines in the code.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Split a method performing multiple tasks, into seperate methods.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Fix logical errors in the code.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Modifications made to the Existing Code==&lt;br /&gt;
&lt;br /&gt;
===Pluralized the class name StudentQuizController===&lt;br /&gt;
----&lt;br /&gt;
As per the Rails convention the controller class names are suggested to be plural.&lt;br /&gt;
This helps in generating RESTful routing URI helpers. Also, naming the classes as plural seems intuitive.&amp;lt;ref&amp;gt;[http://stackoverflow.com/questions/646951/singular-or-plural-controller-and-helper-names-in-rails Using the Singular or Plural controller and helper names in Rails]&amp;lt;/ref&amp;gt;. &lt;br /&gt;
We used the refactor functionality in RubyMine to rename the &amp;lt;b&amp;gt;StudentQuiz&amp;lt;/b&amp;gt; controller class to &amp;lt;b&amp;gt;StudentQuizzes&amp;lt;/b&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The following files were modified and/or renamed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
app/controllers/review_mapping_controller.rb&lt;br /&gt;
app/controllers/{student_quiz_controller.rb → student_quizzes_controller.rb}&lt;br /&gt;
app/helpers/student_quiz_helper.rb&lt;br /&gt;
app/helpers/student_quizzes_helper.rb&lt;br /&gt;
app/views/questionnaires/view.html.erb&lt;br /&gt;
app/views/{student_quiz → student_quizzes}/_quiz_form.html.erb&lt;br /&gt;
app/views/{student_quiz → student_quizzes}/_responses.html.erb&lt;br /&gt;
app/views/{student_quiz → student_quizzes}/_set_dynamic_quiz.html.erb&lt;br /&gt;
app/views/{student_quiz → student_quizzes}/_set_self_quiz.html.erb&lt;br /&gt;
app/views/{student_quiz → student_quizzes}/finished_quiz.html.erb&lt;br /&gt;
app/views/{student_quiz → student_quizzes}/grade_essays.html.erb&lt;br /&gt;
app/views/{student_quiz → student_quizzes}/list.html.erb&lt;br /&gt;
app/views/{student_quiz → student_quizzes}/take_quiz.html.erb&lt;br /&gt;
app/views/student_task/view.html.erb&lt;br /&gt;
app/views/tree_display/actions/_assignments_actions.html.erb&lt;br /&gt;
test/functional/{student_quiz_controller_test.rb → student_quizzes_controller_test.rb}&lt;br /&gt;
test/test_helper.rb&lt;br /&gt;
test/unit/helpers/student_quiz_helper_test.rb&lt;br /&gt;
test/unit/helpers/student_quizzes_helper_test.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The detailed change-set for this refactor can be seen [https://github.com/ankit3005/expertiza/commit/20981333a14a3f468f76cd6d414b3088975b71bd here].&lt;br /&gt;
&lt;br /&gt;
===RESTful style implementation===&lt;br /&gt;
----&lt;br /&gt;
The purpose of the &amp;lt;b&amp;gt;list&amp;lt;/b&amp;gt; method in the &amp;lt;b&amp;gt;StudentQuizzes controller&amp;lt;/b&amp;gt; is to list all the quizzes that are available to a particular user for a particular assignment. RESTful guidelines state that a method that returns a list of all available objects, in this case the quizzes, should be named as &amp;lt;b&amp;gt;index&amp;lt;/b&amp;gt;. Therefore, we renamed the list method to the index method in the controller and in all the files that had references to the list method of the student_quizzes_controller (For e.g. :- The view finished_quiz.html.erb of the Student Quiz controller, the review_mapping controller.rb etc.).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Before Refactoring :&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt; Method : list&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def list&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
&lt;br /&gt;
    @assignment = Assignment.find(@participant.parent_id)&lt;br /&gt;
&lt;br /&gt;
    # Find the current phase that the assignment is in.&lt;br /&gt;
    @quiz_phase = @assignment.get_current_stage(AssignmentParticipant.find(params[:id]).topic_id)&lt;br /&gt;
&lt;br /&gt;
    @quiz_mappings = QuizResponseMap.where(reviewer_id: @participant.id)&lt;br /&gt;
&lt;br /&gt;
    # Calculate the number of quizzes that the user has completed so far.&lt;br /&gt;
    @num_quizzes_total = @quiz_mappings.size&lt;br /&gt;
&lt;br /&gt;
    @num_quizzes_completed = 0&lt;br /&gt;
    @quiz_mappings.each do |map|&lt;br /&gt;
      @num_quizzes_completed += 1 if map.response&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if @assignment.staggered_deadline?&lt;br /&gt;
      @quiz_mappings.each { |quiz_mapping|&lt;br /&gt;
        if @assignment.team_assignment?&lt;br /&gt;
          participant = AssignmentTeam.get_first_member(quiz_mapping.reviewee_id)&lt;br /&gt;
        else&lt;br /&gt;
          participant = quiz_mapping.reviewee&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        if !participant.nil? and !participant.topic_id.nil?&lt;br /&gt;
          quiz_due_date = TopicDeadline.where(topic_id: participant.topic_id, deadline_type_id: 1).first&lt;br /&gt;
        end&lt;br /&gt;
      }&lt;br /&gt;
      deadline_type_id = DeadlineType.find_by_name('quiz').id&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Refactoring :&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt; Method : index&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def index&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(participant.user_id)&lt;br /&gt;
    @assignment = Assignment.find(participant.parent_id)&lt;br /&gt;
    @quiz_mappings = QuizResponseMap.get_mappings_for_reviewer(participant.id)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Instance Variable Reductions===&lt;br /&gt;
----&lt;br /&gt;
In Rails, the data is shared between the controllers and views through the instance variables. The instance variabIes that are set during the execution a particular controller method are accessible to the view. Excessive usage of this standard method of data sharing between the controller and the view results in increased coupling between them &amp;lt;ref&amp;gt;[http://blog.remarkablelabs.com/2013/01/how-to-decrease-coupling-in-your-controllers-views-with-decent_exposure-for-better-maintainability Decreasing Controller-View Coupling in Rails]&amp;lt;/ref&amp;gt;. Increased coupling results in several problems, including less maintainability of code, difficulty in code reuse etc. &amp;lt;ref&amp;gt;[http://en.wikipedia.org/wiki/Coupling_(computer_programming)#Disadvantages Disadvantages of Tight Coupling - Wikipedia]&amp;lt;/ref&amp;gt; Thus, we need to reduce coupling as much as possible and in this case it can be achieved by reducing as many instance variables as possible in the controller. Therefore, we have refactored our code in order to eliminate unnecessary instance variables and to convert all the instance variables to local variables that are not used in the views.&lt;br /&gt;
&lt;br /&gt;
In the &amp;lt;b&amp;gt;take_quiz method&amp;lt;/b&amp;gt;, the following instance variables were removed: &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* Changed the &amp;lt;b&amp;gt;quizzes&amp;lt;/b&amp;gt; instance variable to a local variable.&lt;br /&gt;
* Eliminated the instance variable &amp;lt;b&amp;gt;assignment&amp;lt;/b&amp;gt; which was not being used anywhere.&lt;br /&gt;
* Eliminated the local variable &amp;lt;b&amp;gt;teams&amp;lt;/b&amp;gt; which was not being used any where&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Before Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def self.take_quiz assignment_id , reviewer_id&lt;br /&gt;
  @quizzes = Array.new&lt;br /&gt;
  reviewer = Participant.where(user_id: reviewer_id, parent_id: assignment_id).first&lt;br /&gt;
  @assignment = Assignment.find(assignment_id)&lt;br /&gt;
  teams = TeamsUser.where(user_id: reviewer_id)&lt;br /&gt;
  Team.where(parent_id: assignment_id).each do |quiz_creator|&lt;br /&gt;
    unless TeamsUser.find_by_team_id(quiz_creator.id).user_id == reviewer_id&lt;br /&gt;
      Questionnaire.where(instructor_id: quiz_creator.id).each do |questionnaire|&lt;br /&gt;
        if !@assignment.team_assignment?&lt;br /&gt;
          unless QuizResponseMap.where(reviewed_object_id: questionnaire.id, reviewer_id:  reviewer.id).first&lt;br /&gt;
            @quizzes.push(questionnaire)&lt;br /&gt;
          end&lt;br /&gt;
        else unless QuizResponseMap.where(reviewed_object_id: questionnaire.id, reviewer_id:  reviewer_id).first&lt;br /&gt;
               @quizzes.push(questionnaire)&lt;br /&gt;
             end&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  return @quizzes&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def self.take_quiz assignment_id , reviewer_id&lt;br /&gt;
    quizzes = Array.new&lt;br /&gt;
    reviewer = Participant.where(user_id: reviewer_id, parent_id: assignment_id).first&lt;br /&gt;
    Team.where(parent_id: assignment_id).each do |quiz_creator|&lt;br /&gt;
      unless TeamsUser.find_by_team_id(quiz_creator.id).user_id == reviewer_id&lt;br /&gt;
        Questionnaire.where(instructor_id: quiz_creator.id).each do |questionnaire|&lt;br /&gt;
          unless QuizResponseMap.where(reviewed_object_id: questionnaire.id, reviewer_id:  reviewer.id).first&lt;br /&gt;
            quizzes.push(questionnaire)&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    return quizzes&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Follow principle of Boolean Zen===&lt;br /&gt;
----&lt;br /&gt;
In cases where a method only returns a boolean value by evaluating an expression (using the if..else construct), the if..else statement is redundant and can be eliminated. We have a method &amp;lt;b&amp;gt; graded? &amp;lt;/b&amp;gt; that does this thing. Thus, we eliminated the if..else construct in the graded? method as it was redundant.&amp;lt;ref&amp;gt;[https://www.cs.utexas.edu/~scottm/cs312/handouts/slides/topic16_boolean_logic.pdf About Boolean Zen]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; Before Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Method : graded?&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def graded?(response, question)&lt;br /&gt;
  if Score.where(question_id: question.id, response_id:  response.id).first&lt;br /&gt;
    return true&lt;br /&gt;
  else&lt;br /&gt;
    return false&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; After Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt; Method : graded?&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def graded?(response, question)&lt;br /&gt;
  return (Score.where(question_id: question.id, response_id:  response.id).first)&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Code Cleanup===&lt;br /&gt;
----&lt;br /&gt;
At some places, we found certain statements and variable assignments that were not being used later on in the method or code. We have eliminated such unused statements, so that methods contain only code that is being used later on. This would improve the readability and the maintainability of the code. For example in the code below we eliminated the &amp;lt;b&amp;gt;@quiz_phase&amp;lt;/b&amp;gt; and the &amp;lt;b&amp;gt;@num_quizzes_total&amp;lt;/b&amp;gt; variables because they were not being used anywhere in the code. Also, since the &amp;lt;b&amp;gt;local&amp;lt;/b&amp;gt; variables &amp;lt;b&amp;gt;quiz_due_date, deadline_type_id, participant&amp;lt;/b&amp;gt; were not being used anywhere, we could eliminate the entire &amp;lt;b&amp;gt;if&amp;lt;/b&amp;gt; block from the code below. We then converted the instance variable &amp;lt;b&amp;gt;participant&amp;lt;/b&amp;gt; to a local variable because it was not being used in the corresponding view.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Before Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Method : list&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def list&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
&lt;br /&gt;
    @assignment = Assignment.find(@participant.parent_id)&lt;br /&gt;
&lt;br /&gt;
    # Find the current phase that the assignment is in.&lt;br /&gt;
    @quiz_phase = @assignment.get_current_stage(AssignmentParticipant.find(params[:id]).topic_id)&lt;br /&gt;
&lt;br /&gt;
    @quiz_mappings = QuizResponseMap.where(reviewer_id: @participant.id)&lt;br /&gt;
&lt;br /&gt;
    # Calculate the number of quizzes that the user has completed so far.&lt;br /&gt;
    @num_quizzes_total = @quiz_mappings.size&lt;br /&gt;
&lt;br /&gt;
    @num_quizzes_completed = 0&lt;br /&gt;
    @quiz_mappings.each do |map|&lt;br /&gt;
      @num_quizzes_completed += 1 if map.response&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if @assignment.staggered_deadline?&lt;br /&gt;
      @quiz_mappings.each { |quiz_mapping|&lt;br /&gt;
        if @assignment.team_assignment?&lt;br /&gt;
          participant = AssignmentTeam.get_first_member(quiz_mapping.reviewee_id)&lt;br /&gt;
        else&lt;br /&gt;
          participant = quiz_mapping.reviewee&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        if !participant.nil? and !participant.topic_id.nil?&lt;br /&gt;
          quiz_due_date = TopicDeadline.where(topic_id: participant.topic_id, deadline_type_id: 1).first&lt;br /&gt;
        end&lt;br /&gt;
      }&lt;br /&gt;
      deadline_type_id = DeadlineType.find_by_name('quiz').id&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt; Method : index&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def index&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(participant.user_id)&lt;br /&gt;
    @assignment = Assignment.find(participant.parent_id)&lt;br /&gt;
    @quiz_mappings = QuizResponseMap.get_mappings_for_reviewer(participant.id)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Following Ruby Style Guidelines (Global Rules)===&lt;br /&gt;
----&lt;br /&gt;
At many places in the code we found that the Ruby Style Guidelines were not followed. We have refactored the code so that it uses the good code style guidelines. The following are some of the refactorings the we have done:-&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
==== Used .eql? instead of &amp;quot;==&amp;quot; ====&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;b&amp;gt;Before Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt; Method : finished_quiz&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; if score.score == -1 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; if score.score.eql? -1 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Eliminated the &amp;quot;== true/false&amp;quot; check ====&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;b&amp;gt;Before Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt; Method : finished_quiz&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; if essay_not_graded == true &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; if essay_not_graded &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Use `&amp;amp;&amp;amp;` and `||` rather than `and` and `or` to keep boolean precedence ====&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;b&amp;gt;Before Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt; Method: record_response&lt;br /&gt;
&amp;lt;pre&amp;gt; elsif  correct_answer and params[&amp;quot;#{question.id}&amp;quot;] == correct_answer.txt &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt; Method: calculate_score&lt;br /&gt;
&amp;lt;pre&amp;gt; elsif  correct_answer &amp;amp;&amp;amp; params[&amp;quot;#{question.id}&amp;quot;]== correct_answer.txt &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Use key: ‘value’, not :key =&amp;gt; ‘value’ ====&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;b&amp;gt;Before Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt; Method: record_response&lt;br /&gt;
&amp;lt;pre&amp;gt;new_score = Score.new :comments =&amp;gt; choice, :question_id =&amp;gt; question.id, :response_id =&amp;gt; @response.id&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt; Method: calculate_score&lt;br /&gt;
&amp;lt;pre&amp;gt;new_score = Score.new comments: choice, question_id: question.id, response_id: response.id&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Replace find_by_...  with a where command ====&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;b&amp;gt; Before Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt; Method: record_response&lt;br /&gt;
&amp;lt;pre&amp;gt; if (QuestionType.find_by_question_id question.id).q_type == 'MCC' &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt; After Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt; Method: calculate_score&lt;br /&gt;
&amp;lt;pre&amp;gt;ques_type = (QuestionType.where( question_id: question.id)).q_type&lt;br /&gt;
if ques_type.eql? 'MCC' &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Used .nil? instead of &amp;quot;== nil&amp;quot; ====&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;b&amp;gt;Before Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt; Method: record_response&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if params[&amp;quot;#{question.id}&amp;quot;] == nil&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt; Method: calculate_score&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if params[&amp;quot;#{question.id}&amp;quot;].nil?&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Used a Boolean variable when that is sufficient====&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;b&amp;gt;Before Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt; Method: record_response&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
valid = 1&lt;br /&gt;
 if valid == 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt; Method: calculate_score&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
valid = false&lt;br /&gt;
 if valid&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Use good conditional statements====&lt;br /&gt;
----&lt;br /&gt;
Using unless is a good practice. But it is not a good practice to use unless and ! within the condition. Instead we could use an if condition itself.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Before Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt; Method: record_response&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
unless new_score.comments != &amp;quot;&amp;quot; &amp;amp;&amp;amp; new_score.comments&lt;br /&gt;
   valid = false&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt; Method: calculate_score&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if new_score.comments.empty? || new_score.comments.nil?&lt;br /&gt;
   valid = false&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Use of Routing Helpers====&lt;br /&gt;
----&lt;br /&gt;
Routing helpers are a simpler alternative to the otherwise complex hard coded URLs which reduce the readability of the code. Routing helpers allow us to declare possible common routes for a given controller. Routing helpers have been implemented since they maintain consistency even if changes are made to the routing paths. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Before Refactoring&amp;lt;/b&amp;gt;:&lt;br /&gt;
&amp;lt;br&amp;gt; config.rb does not contain a student_quizzes resource&lt;br /&gt;
&amp;lt;br&amp;gt; review_mapping_controller.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
redirect_to :controller =&amp;gt; 'student_quizzes', :action =&amp;gt; 'index', :id =&amp;gt; params[:participant_id]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt; config.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
resources :student_quizzes, :only =&amp;gt; [:index]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
review_mapping_controller.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
redirect_to student_quizzes_path(:id =&amp;gt; params[:participant_id])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Replace controller method with a model method ===&lt;br /&gt;
----&lt;br /&gt;
Rails 4 conventions dictate the use of a fat model and skinny controller.&lt;br /&gt;
It is better to place the search function in the model rather than placing it in the controller.&lt;br /&gt;
The search code belonged to the &amp;lt;b&amp;gt;quiz_response_map&amp;lt;/b&amp;gt; model, since it queries that particular table in the database.&lt;br /&gt;
The code was extracted into the &amp;lt;b&amp;gt;get_mappings_for_reviewer&amp;lt;/b&amp;gt; method and placed in the file &amp;lt;b&amp;gt;quiz_response_map.rb&amp;lt;/b&amp;gt;. This method was then called from the &amp;lt;b&amp;gt;StudentQuizzes&amp;lt;/b&amp;gt; controller.&lt;br /&gt;
&amp;lt;ref name = &amp;quot;stackoverflow&amp;quot;&amp;gt;[http://stackoverflow.com/questions/14044681/fat-models-and-skinny-controllers-sounds-like-creating-god-models Fat Models and Skinny Controllers.]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Before Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt; student_quizzes_controller.rb&lt;br /&gt;
&amp;lt;br&amp;gt; Method : index&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 @quiz_mappings = QuizResponseMap.where(reviewer_id: participant.id)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt; student_quizzes_controller.rb&lt;br /&gt;
&amp;lt;br&amp;gt; Method : index&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 @quiz_mappings = QuizResponseMap.get_mappings_for_reviewer(participant.id)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt; quiz_response_map.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def self.get_mappings_for_reviewer(participant_id)&lt;br /&gt;
  return QuizResponseMap.where(reviewer_id: participant_id)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Changes made in method logic===&lt;br /&gt;
----&lt;br /&gt;
We have made certain changes in the logic of the methods calculate_score and record_response (previously the code of both these methods was only in record_response) primarily to improve the existing logic and eliminate redundant code. These changes are described as follows:&lt;br /&gt;
&lt;br /&gt;
* The &amp;lt;b&amp;gt;score&amp;lt;/b&amp;gt; variable was already being set to 0 on the loop entry, therefore it was redundant to reset score to zero again. Thus, we eliminated this line of code inside the if statement.&lt;br /&gt;
&amp;lt;b&amp;gt;Before Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
questions.each do |question|		&lt;br /&gt;
  score = 0		&lt;br /&gt;
  if (QuestionType.find_by_question_id question.id).q_type == 'MCC'		&lt;br /&gt;
    score = 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
questions.each do |question|&lt;br /&gt;
 score = 0&lt;br /&gt;
 if ques_type.eql? 'MCC'&lt;br /&gt;
    # Eliminated score = 0 over here&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
* The variable &amp;lt;b&amp;gt;correct_answer&amp;lt;/b&amp;gt; stored multiple values as the where condition to which it was assigned was returning multiple values. Therefore it seemed more intuitive to rename &amp;lt;b&amp;gt;correct_answer&amp;lt;/b&amp;gt; to &amp;lt;b&amp;gt;correct_answers&amp;lt;/b&amp;gt; so that it is apparent that it contains multiple values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Before Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
correct_answer = QuizQuestionChoice.where(question_id: question.id, iscorrect: 1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
correct_answers = QuizQuestionChoice.where(question_id: question.id, iscorrect: true)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
* The below piece of code found out the question type twice in the same loop. Therefore we extracted it and assigned it to a local variable so that the query is executed only once.&lt;br /&gt;
&amp;lt;b&amp;gt;Before Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# First Query&lt;br /&gt;
if (QuestionType.find_by_question_id question.id).q_type == 'MCC'&lt;br /&gt;
# Repetition of the query in the same loop&lt;br /&gt;
if (QuestionType.find_by_question_id question.id).q_type == 'Essay'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Querying only once and assigning it to a local variable ques_type&lt;br /&gt;
ques_type = (QuestionType.where( question_id: question.id)).q_type&lt;br /&gt;
# Usage 1 of ques_type&lt;br /&gt;
if ques_type.eql? 'MCC'&lt;br /&gt;
# Usage 2 of ques_type&lt;br /&gt;
if ques_type.eql? 'Essay'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
* The &amp;lt;b&amp;gt;new_scores&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;scores&amp;lt;/b&amp;gt; array stored almost the similar values. The &amp;lt;b&amp;gt;scores&amp;lt;/b&amp;gt; array contained a copy of the value that the &amp;lt;b&amp;gt;new_scores&amp;lt;/b&amp;gt; array contained. Therefore we eliminated the &amp;lt;b&amp;gt;new_scores&amp;lt;/b&amp;gt; array and are performing all the operations only on the &amp;lt;b&amp;gt;scores&amp;lt;/b&amp;gt; array.&lt;br /&gt;
&amp;lt;b&amp;gt;Before Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Part 1&lt;br /&gt;
new_score = Score.new :comments =&amp;gt; choice, :question_id =&amp;gt; question.id, :response_id =&amp;gt; @response.id&lt;br /&gt;
&lt;br /&gt;
unless new_score.valid?&lt;br /&gt;
 valid = 1&lt;br /&gt;
end&lt;br /&gt;
new_scores.push(new_score)&lt;br /&gt;
&lt;br /&gt;
# Part 2		  &lt;br /&gt;
new_scores.each do |score_update|&lt;br /&gt;
 score_update.score = score&lt;br /&gt;
 scores.push(score_update)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;After Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Part 1&lt;br /&gt;
new_score = Score.new comments: choice, question_id: question.id, response_id: response.id&lt;br /&gt;
&lt;br /&gt;
unless new_score.valid?&lt;br /&gt;
  valid = false&lt;br /&gt;
end&lt;br /&gt;
scores.push(new_score)&lt;br /&gt;
	&lt;br /&gt;
# Part 2		&lt;br /&gt;
scores.each do |score_update|&lt;br /&gt;
  score_update.score = score&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
* The logic to compute the final score for a multiple-choice, multiple-correct type of question seemed to be incorrect and therefore we fixed it.&lt;br /&gt;
&amp;lt;b&amp;gt;Before Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Part 1 of the Scoring Logic&lt;br /&gt;
questions.each do |question|&lt;br /&gt;
 score = 0&lt;br /&gt;
 if (QuestionType.find_by_question_id question.id).q_type == 'MCC'&lt;br /&gt;
  score = 0&lt;br /&gt;
  if params[&amp;quot;#{question.id}&amp;quot;] == nil&lt;br /&gt;
   valid = 1&lt;br /&gt;
  else&lt;br /&gt;
    correct_answer = QuizQuestionChoice.where(question_id: question.id, iscorrect: 1)&lt;br /&gt;
    params[&amp;quot;#{question.id}&amp;quot;].each do |choice|&lt;br /&gt;
    correct_answer.each do |correct|&lt;br /&gt;
    if choice == correct.txt&lt;br /&gt;
      score += 1&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
# Part 2 of the scoring logic which seems to award full points even if you marked some extra options apart from marking all correct answers&lt;br /&gt;
  unless score == correct_answer.count&lt;br /&gt;
   score = 0&lt;br /&gt;
  else&lt;br /&gt;
   score = 1&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;After Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Part 1 of the Scoring Logic&lt;br /&gt;
questions.each do |question|&lt;br /&gt;
 score = 0&lt;br /&gt;
 correct_answers = QuizQuestionChoice.where(question_id: question.id, iscorrect: true)&lt;br /&gt;
 ques_type = (QuestionType.where( question_id: question.id)).q_type&lt;br /&gt;
  if ques_type.eql? 'MCC'&lt;br /&gt;
     if params[&amp;quot;#{question.id}&amp;quot;].nil?&lt;br /&gt;
       valid = false&lt;br /&gt;
     else&lt;br /&gt;
        params[&amp;quot;#{question.id}&amp;quot;].each do |choice|&lt;br /&gt;
          correct_answers.each do |correct|&lt;br /&gt;
          if choice.eql? correct.txt&lt;br /&gt;
             score += 1&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
# Part 2 of the scoring logic - We have also compared the number of options the user selected to the total number of correct answers&lt;br /&gt;
if score.eql? correct_answers.count &amp;amp;&amp;amp; score == params[&amp;quot;#{question.id}&amp;quot;].count&lt;br /&gt;
  score = 1&lt;br /&gt;
else&lt;br /&gt;
  score = 0&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
* The &amp;lt;b&amp;gt;record_response&amp;lt;/b&amp;gt; function was performing two distinct operations : One operation was saving the response to the database and the other was to calculate the score for the questions. We created a new function &amp;lt;b&amp;gt;calculate_score&amp;lt;/b&amp;gt; that would calculate the score for the questions and &amp;lt;b&amp;gt;record_response&amp;lt;/b&amp;gt; now only performs the task of saving responses to the database.&lt;br /&gt;
&amp;lt;b&amp;gt;Before Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def record_response&lt;br /&gt;
  @map = ResponseMap.find(params[:map_id])&lt;br /&gt;
  @response = Response.new()&lt;br /&gt;
  @response.map_id = params[:map_id]&lt;br /&gt;
  @response.created_at = DateTime.current&lt;br /&gt;
  @response.updated_at = DateTime.current&lt;br /&gt;
  @response.save&lt;br /&gt;
&lt;br /&gt;
  @questionnaire = Questionnaire.find(@map.reviewed_object_id)&lt;br /&gt;
  scores = Array.new&lt;br /&gt;
  new_scores = Array.new&lt;br /&gt;
  valid = 0&lt;br /&gt;
  questions = Question.where(questionnaire_id: @questionnaire.id)&lt;br /&gt;
  questions.each do |question|&lt;br /&gt;
    score = 0&lt;br /&gt;
    if (QuestionType.find_by_question_id question.id).q_type == 'MCC'&lt;br /&gt;
      score = 0&lt;br /&gt;
      if params[&amp;quot;#{question.id}&amp;quot;] == nil&lt;br /&gt;
        valid = 1&lt;br /&gt;
      else&lt;br /&gt;
        correct_answer = QuizQuestionChoice.where(question_id: question.id, iscorrect: 1)&lt;br /&gt;
        params[&amp;quot;#{question.id}&amp;quot;].each do |choice|&lt;br /&gt;
&lt;br /&gt;
          correct_answer.each do |correct|&lt;br /&gt;
            if choice == correct.txt&lt;br /&gt;
              score += 1&lt;br /&gt;
            end&lt;br /&gt;
&lt;br /&gt;
          end&lt;br /&gt;
          new_score = Score.new :comments =&amp;gt; choice, :question_id =&amp;gt; question.id, :response_id =&amp;gt; @response.id&lt;br /&gt;
&lt;br /&gt;
          unless new_score.valid?&lt;br /&gt;
            valid = 1&lt;br /&gt;
          end&lt;br /&gt;
          new_scores.push(new_score)&lt;br /&gt;
&lt;br /&gt;
        end&lt;br /&gt;
        unless score == correct_answer.count&lt;br /&gt;
          score = 0&lt;br /&gt;
        else&lt;br /&gt;
          score = 1&lt;br /&gt;
        end&lt;br /&gt;
        new_scores.each do |score_update|&lt;br /&gt;
          score_update.score = score&lt;br /&gt;
          scores.push(score_update)&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      score = 0&lt;br /&gt;
      correct_answer = QuizQuestionChoice.where(question_id: question.id, iscorrect:  1).first&lt;br /&gt;
      if (QuestionType.find_by_question_id question.id).q_type == 'Essay'&lt;br /&gt;
        score = -1&lt;br /&gt;
      elsif  correct_answer and params[&amp;quot;#{question.id}&amp;quot;] == correct_answer.txt&lt;br /&gt;
        score = 1&lt;br /&gt;
      end&lt;br /&gt;
      new_score = Score.new :comments =&amp;gt; params[&amp;quot;#{question.id}&amp;quot;], :question_id =&amp;gt; question.id, :response_id =&amp;gt; @response.id, :score =&amp;gt; score&lt;br /&gt;
      unless new_score.comments != &amp;quot;&amp;quot; &amp;amp;&amp;amp; new_score.comments&lt;br /&gt;
        valid = 1&lt;br /&gt;
      end&lt;br /&gt;
      scores.push(new_score)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  if valid == 0&lt;br /&gt;
    scores.each do |score|&lt;br /&gt;
      score.save&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to :controller =&amp;gt; 'student_quizzes', :action =&amp;gt; 'finished_quiz', :map_id =&amp;gt; @map.id&lt;br /&gt;
  else&lt;br /&gt;
    flash[:error] = &amp;quot;Please answer every question.&amp;quot;&lt;br /&gt;
    redirect_to :action =&amp;gt; :take_quiz, :assignment_id =&amp;gt; params[:assignment_id], :questionnaire_id =&amp;gt; @questionnaire.id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;After Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# New record_response method&lt;br /&gt;
  def record_response&lt;br /&gt;
    map = ResponseMap.find(params[:map_id])&lt;br /&gt;
    response = Response.new&lt;br /&gt;
    response.map_id = params[:map_id]&lt;br /&gt;
    response.created_at = DateTime.current&lt;br /&gt;
    response.updated_at = DateTime.current&lt;br /&gt;
    response.save&lt;br /&gt;
&lt;br /&gt;
    calculate_score map,response&lt;br /&gt;
&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# New calculate_score&lt;br /&gt;
def calculate_score map, response&lt;br /&gt;
    questionnaire = Questionnaire.find(map.reviewed_object_id)&lt;br /&gt;
    scores = Array.new&lt;br /&gt;
    valid = true&lt;br /&gt;
    questions = Question.where(questionnaire_id: questionnaire.id)&lt;br /&gt;
    questions.each do |question|&lt;br /&gt;
      score = 0&lt;br /&gt;
      correct_answers = QuizQuestionChoice.where(question_id: question.id, iscorrect: true)&lt;br /&gt;
      ques_type = (QuestionType.where( question_id: question.id)).q_type&lt;br /&gt;
      if ques_type.eql? 'MCC'&lt;br /&gt;
        if params[&amp;quot;#{question.id}&amp;quot;].nil?&lt;br /&gt;
          valid = false&lt;br /&gt;
        else&lt;br /&gt;
          params[&amp;quot;#{question.id}&amp;quot;].each do |choice|&lt;br /&gt;
&lt;br /&gt;
            correct_answers.each do |correct|&lt;br /&gt;
              if choice.eql? correct.txt&lt;br /&gt;
                score += 1&lt;br /&gt;
              end&lt;br /&gt;
&lt;br /&gt;
            end&lt;br /&gt;
            new_score = Score.new comments: choice, question_id: question.id, response_id: response.id&lt;br /&gt;
&lt;br /&gt;
            unless new_score.valid?&lt;br /&gt;
              valid = false&lt;br /&gt;
            end&lt;br /&gt;
            scores.push(new_score)&lt;br /&gt;
&lt;br /&gt;
          end&lt;br /&gt;
          if score.eql? correct_answers.count &amp;amp;&amp;amp; score == params[&amp;quot;#{question.id}&amp;quot;].count&lt;br /&gt;
            score = 1&lt;br /&gt;
          else&lt;br /&gt;
            score = 0&lt;br /&gt;
          end&lt;br /&gt;
          scores.each do |score_update|&lt;br /&gt;
            score_update.score = score&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        correct_answer = correct_answers.first&lt;br /&gt;
        if ques_type.eql? 'Essay'&lt;br /&gt;
          score = -1&lt;br /&gt;
        elsif  correct_answer &amp;amp;&amp;amp; params[&amp;quot;#{question.id}&amp;quot;]== correct_answer.txt&lt;br /&gt;
          score = 1&lt;br /&gt;
        end&lt;br /&gt;
        new_score = Score.new :comments =&amp;gt; params[&amp;quot;#{question.id}&amp;quot;], :question_id =&amp;gt; question.id, :response_id =&amp;gt; response.id, :score =&amp;gt; score&lt;br /&gt;
        if new_score.comments.empty? || new_score.comments.nil?&lt;br /&gt;
          valid = false&lt;br /&gt;
        end&lt;br /&gt;
        scores.push(new_score)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    if valid&lt;br /&gt;
      scores.each do |score|&lt;br /&gt;
        score.save&lt;br /&gt;
      end&lt;br /&gt;
      redirect_to :controller =&amp;gt; 'student_quizzes', :action =&amp;gt; 'finished_quiz', :map_id =&amp;gt; map.id&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;Please answer every question.&amp;quot;&lt;br /&gt;
      redirect_to :action =&amp;gt; :take_quiz, :assignment_id =&amp;gt; params[:assignment_id], :questionnaire_id =&amp;gt; questionnaire.id&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014&amp;diff=91006</id>
		<title>CSC/ECE 517 Fall 2014</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014&amp;diff=91006"/>
		<updated>2014-10-29T23:56:24Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;*[[CSC/ECE_517_Fall_2014/sample_page]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1a 22 as]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 19 mx]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 3 zq]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 4 lf]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 4 wl]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a a7 ch]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 25 rs]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 25 jf]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 8 os]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 8 sn]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 15 gs]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 10 hu]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 20 kv]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 21 as]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 24 sa]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 26 sn]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 6 rl]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 2 ss]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 16 av]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 1 rm]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 1 sj]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 23 ss]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 20 rn]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 22 sp]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/oss M1454 rss]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 26 gn]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 13 va]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 9 aa]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 9 kn]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 11 ap]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 25 ks]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1a 7 kz]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1a_6_bn]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1a 10 zz]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1a 16 va]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1a F1415 rv]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1a_3_cp]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/ch1b 26 sa]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1b_28_cg]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1b 29 ry]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1b 30 cs]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1b_33_jy]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/ch1b_27_js]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/oss E1453 syy]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/oss E1463 vpd]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/oss E1465 oak]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/oss_M1456_kdv]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/oss_M1453_sst]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/oss_E1456_akk]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/oss_M1455_asa]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/oss_E1458_sst]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/oss_E1457_ags]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/OSS_E1466_gjf]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/oss_M1452_jns]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/oss_E1462_nms]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/OSS_S1455_ajp]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/OSS_S1454_ccc]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/OSS_E1450_cxm]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/OSS_E1455_skn]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/OSS_M1450_vda]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/OSS_E1467_rsv]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/OSS_E1464_vnn]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/OSS_M1451_ahs]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/OSS_E1451_las]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2014/OSS_E1461_knn]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2014/oss_E1460_aua]]&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1460_aua&amp;diff=89897</id>
		<title>CSC/ECE 517 Fall 2014/oss E1460 aua</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1460_aua&amp;diff=89897"/>
		<updated>2014-10-27T16:22:19Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* Use of Routing Helpers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Expertiza - Refactoring StudentQuizController=&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza&amp;lt;ref name=&amp;quot;expertiza&amp;gt;''Expertiza'' http://wikis.lib.ncsu.edu/index.php/Expertiza&amp;lt;/ref&amp;gt; is a web application available to both students and professors. The Expertiza project is a system to create reusable learning objects through peer review. Expertiza supports team projects, and the submission of almost any document type, including URLs and wiki pages. Students can keep a track of their assignments, teammates and can conduct peer reviews on diverse topics and projects. It is an open source project developed on Ruby on Rails platform. More information on Expertiza can be found [https://github.com/expertiza/expertiza here]. The source code can be forked and cloned for making modifications. &lt;br /&gt;
ertiza with main focus of Refactoring the Users Controller. &lt;br /&gt;
&lt;br /&gt;
==Project Description==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Classes :&amp;lt;/b&amp;gt; student_quiz_controller.rb&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;What it does : &amp;lt;/b&amp;gt;This class records the quizzes that the student has attempted and its progress and also submits grades for the essays in the quizzes attempted by the student.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;What has to be changed : &amp;lt;/b&amp;gt;&lt;br /&gt;
*change list to index (and others in the RESTful style)&lt;br /&gt;
* Pluralize the class (StudentQuizzesController)&lt;br /&gt;
* graded? - review boolean zen&lt;br /&gt;
* Reduce the number of instance variables per controller action.&lt;br /&gt;
* Change the instance variables to local variables if they are not being used in the view. &lt;br /&gt;
* Modify methods to conform to RESTful style &lt;br /&gt;
* Code cleanup by using string interpolation instead of concatenation, replacing '==' with eql? and :key =&amp;gt;'value' with key: 'value', modifying declarations of Arrays and Hashes,removing commented out code&lt;br /&gt;
* Replace find_by with where to follow Rails 4.0 conventions&lt;br /&gt;
&lt;br /&gt;
==Modification to Existing Code==&lt;br /&gt;
&lt;br /&gt;
===Pluralized the class name StudentQuizController===&lt;br /&gt;
As per Rails convention the controller class names are sugested to be plural.&lt;br /&gt;
This helps in generating RESTful routing URI helpers. Also, naming the classes as plural seems more natural and helps in understanding&amp;lt;ref&amp;gt;http://stackoverflow.com/questions/646951/singular-or-plural-controller-and-helper-names-in-rails&amp;lt;/ref&amp;gt;. &lt;br /&gt;
We used the refactor functionality in RubyMineto rename StudentQuiz controller class to StudentQuizzes.&lt;br /&gt;
&lt;br /&gt;
The following files were modified and/or renamed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
app/controllers/review_mapping_controller.rb&lt;br /&gt;
app/controllers/{student_quiz_controller.rb → student_quizzes_controller.rb}&lt;br /&gt;
app/helpers/student_quiz_helper.rb&lt;br /&gt;
app/helpers/student_quizzes_helper.rb&lt;br /&gt;
app/views/questionnaires/view.html.erb&lt;br /&gt;
app/views/{student_quiz → student_quizzes}/_quiz_form.html.erb&lt;br /&gt;
app/views/{student_quiz → student_quizzes}/_responses.html.erb&lt;br /&gt;
app/views/{student_quiz → student_quizzes}/_set_dynamic_quiz.html.erb&lt;br /&gt;
app/views/{student_quiz → student_quizzes}/_set_self_quiz.html.erb&lt;br /&gt;
app/views/{student_quiz → student_quizzes}/finished_quiz.html.erb&lt;br /&gt;
app/views/{student_quiz → student_quizzes}/grade_essays.html.erb&lt;br /&gt;
app/views/{student_quiz → student_quizzes}/list.html.erb&lt;br /&gt;
app/views/{student_quiz → student_quizzes}/take_quiz.html.erb&lt;br /&gt;
app/views/student_task/view.html.erb&lt;br /&gt;
app/views/tree_display/actions/_assignments_actions.html.erb&lt;br /&gt;
test/functional/{student_quiz_controller_test.rb → student_quizzes_controller_test.rb}&lt;br /&gt;
test/test_helper.rb&lt;br /&gt;
test/unit/helpers/student_quiz_helper_test.rb&lt;br /&gt;
test/unit/helpers/student_quizzes_helper_test.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The detailed changeset for this refactor can be seen [https://github.com/ankit3005/expertiza/commit/20981333a14a3f468f76cd6d414b3088975b71bd here]. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===RESTful style implementation===&lt;br /&gt;
* Modifications to student_quiz_controller.rb :&lt;br /&gt;
The purpose of the list method in the Student Quizzes controller is to list all the quizzes that are available to this user for a particular assignment. RESTful guidelines state that a method that returns a list of all available objects, in this case the quizzes, should be named as index. Therefore, we renamed the list method to the index method in the controller and in all the files that had references to the list method of the student_quiz_controller (For e.g. :- The view finished_quiz.html.erb of the Student Quiz controller, the review_mapping controller.rb etc.).&lt;br /&gt;
&lt;br /&gt;
Before Refactoring :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def list&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
&lt;br /&gt;
    @assignment = Assignment.find(@participant.parent_id)&lt;br /&gt;
&lt;br /&gt;
    # Find the current phase that the assignment is in.&lt;br /&gt;
    @quiz_phase = @assignment.get_current_stage(AssignmentParticipant.find(params[:id]).topic_id)&lt;br /&gt;
&lt;br /&gt;
    @quiz_mappings = QuizResponseMap.where(reviewer_id: @participant.id)&lt;br /&gt;
&lt;br /&gt;
    # Calculate the number of quizzes that the user has completed so far.&lt;br /&gt;
    @num_quizzes_total = @quiz_mappings.size&lt;br /&gt;
&lt;br /&gt;
    @num_quizzes_completed = 0&lt;br /&gt;
    @quiz_mappings.each do |map|&lt;br /&gt;
      @num_quizzes_completed += 1 if map.response&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if @assignment.staggered_deadline?&lt;br /&gt;
      @quiz_mappings.each { |quiz_mapping|&lt;br /&gt;
        if @assignment.team_assignment?&lt;br /&gt;
          participant = AssignmentTeam.get_first_member(quiz_mapping.reviewee_id)&lt;br /&gt;
        else&lt;br /&gt;
          participant = quiz_mapping.reviewee&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        if !participant.nil? and !participant.topic_id.nil?&lt;br /&gt;
          quiz_due_date = TopicDeadline.where(topic_id: participant.topic_id, deadline_type_id: 1).first&lt;br /&gt;
        end&lt;br /&gt;
      }&lt;br /&gt;
      deadline_type_id = DeadlineType.find_by_name('quiz').id&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After Refactoring :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def index&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(participant.user_id)&lt;br /&gt;
    @assignment = Assignment.find(participant.parent_id)&lt;br /&gt;
    @quiz_mappings = QuizResponseMap.get_mappings_for_reviewer(participant.id)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Instance Variable Reductions===&lt;br /&gt;
In Rails, data is shared between the controllers and views through the instance variables. The instance variabIes that are set during the execution a particular controller method are accessible to the view. Excessive usage of this standard method of data sharing between the controller and the view results in increased coupling between them. &amp;lt;ref&amp;gt;http://blog.remarkablelabs.com/2013/01/how-to-decrease-coupling-in-your-controllers-views-with-decent_exposure-for-better-maintainability&amp;lt;/ref&amp;gt; Increased coupling results in several problems, including less maintainability of code, difficulty in code reuse etc. &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Coupling_(computer_programming)#Disadvantages&amp;lt;/ref&amp;gt; Thus, we need to reduce coupling to the maximum possible extent and in this case it can be achieved by reducing as many instance variables as possible. Therefore, we have refactored our code in order to eliminate unused and unneccessary instance variables.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Before Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
student_quizzes_controller.rb&lt;br /&gt;
&lt;br /&gt;
In the take_quiz method, the following instance variables were removed&lt;br /&gt;
Changed the quizzes instance variable to a local variable.&lt;br /&gt;
Eliminated instance variable assignment which was not used anywhere.&lt;br /&gt;
Eliminated local variable teams which was not used any where&lt;br /&gt;
The unified diff of the changes made is shown below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def self.take_quiz assignment_id , reviewer_id&lt;br /&gt;
-    @quizzes = Array.new&lt;br /&gt;
+    quizzes = Array.new&lt;br /&gt;
     reviewer = Participant.where(user_id: reviewer_id, parent_id: assignment_id).first&lt;br /&gt;
-    @assignment = Assignment.find(assignment_id)&lt;br /&gt;
-    teams = TeamsUser.where(user_id: reviewer_id)&lt;br /&gt;
     Team.where(parent_id: assignment_id).each do |quiz_creator|&lt;br /&gt;
       unless TeamsUser.find_by_team_id(quiz_creator.id).user_id == reviewer_id&lt;br /&gt;
         Questionnaire.where(instructor_id: quiz_creator.id).each do |questionnaire|&lt;br /&gt;
-          if !@assignment.team_assignment?&lt;br /&gt;
-            unless QuizResponseMap.where(reviewed_object_id: questionnaire.id, reviewer_id:  reviewer.id).first&lt;br /&gt;
-              @quizzes.push(questionnaire)&lt;br /&gt;
-            end&lt;br /&gt;
-          else unless QuizResponseMap.where(reviewed_object_id: questionnaire.id, reviewer_id:  reviewer_id).first&lt;br /&gt;
-            @quizzes.push(questionnaire)&lt;br /&gt;
+          unless QuizResponseMap.where(reviewed_object_id: questionnaire.id, reviewer_id:  reviewer.id).first&lt;br /&gt;
+            quizzes.push(questionnaire)&lt;br /&gt;
           end&lt;br /&gt;
         end&lt;br /&gt;
       end&lt;br /&gt;
     end&lt;br /&gt;
+    return quizzes&lt;br /&gt;
   end&lt;br /&gt;
-  return @quizzes&lt;br /&gt;
-end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Code Cleanup===&lt;br /&gt;
Code cleanup in the controller so that the code conforms closely to Rails conventions and enhanced readability of code.&lt;br /&gt;
* Replaced String concats with #{} in paginate_list&lt;br /&gt;
Before Refactoring :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After Refactoring :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Replaced '==' with eql?&lt;br /&gt;
Before Refactoring :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After Refactoring :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Replaced :key =&amp;gt;'value' with key: 'value'&lt;br /&gt;
&lt;br /&gt;
Before Refactoring :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Modified declarations of Arrays and Hashes&lt;br /&gt;
Before Refactoring :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After Refactoring :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Removed unused methods like self.participants_in and commented out code.&lt;br /&gt;
&lt;br /&gt;
===Use of Routing Helpers===&lt;br /&gt;
Routing helpers are a simpler alternative to the otherwise complex hard coded URLs which reduce the readability of the code.Routing helpers allow us to declare possible common routes for a given controller. Routing helpers have been implemented since they maintain consistency even if changes are made to the routing paths. &lt;br /&gt;
&lt;br /&gt;
Before Refactoring:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
After Refactoring&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Replace find_by_.. with where in querying===&lt;br /&gt;
Rails 4 conventions dictate the use of 'where()' over the use of 'find_by_...' methods while querying ActiveRecords. The code has been refactored to replace the usages of find_by.. with where().&lt;br /&gt;
&lt;br /&gt;
Before Refactoring&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After Refactoring&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Replace controller method with a model method ===&lt;br /&gt;
Rails 4 conventions dictate the use of 'where()' over the use of 'find_by_...' methods while querying ActiveRecords. The code has been refactored to replace the usages of find_by.. with where().&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before Refactoring&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    @quiz_mappings = QuizResponseMap.where(reviewer_id: participant.id)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After Refactoring&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 @quiz_mappings = QuizResponseMap.get_mappings_for_reviewer(participant.id)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1460_aua&amp;diff=89896</id>
		<title>CSC/ECE 517 Fall 2014/oss E1460 aua</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_E1460_aua&amp;diff=89896"/>
		<updated>2014-10-27T16:22:07Z</updated>

		<summary type="html">&lt;p&gt;Aagrawa5: /* Code Cleanup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Expertiza - Refactoring StudentQuizController=&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Expertiza&amp;lt;ref name=&amp;quot;expertiza&amp;gt;''Expertiza'' http://wikis.lib.ncsu.edu/index.php/Expertiza&amp;lt;/ref&amp;gt; is a web application available to both students and professors. The Expertiza project is a system to create reusable learning objects through peer review. Expertiza supports team projects, and the submission of almost any document type, including URLs and wiki pages. Students can keep a track of their assignments, teammates and can conduct peer reviews on diverse topics and projects. It is an open source project developed on Ruby on Rails platform. More information on Expertiza can be found [https://github.com/expertiza/expertiza here]. The source code can be forked and cloned for making modifications. &lt;br /&gt;
ertiza with main focus of Refactoring the Users Controller. &lt;br /&gt;
&lt;br /&gt;
==Project Description==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Classes :&amp;lt;/b&amp;gt; student_quiz_controller.rb&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;What it does : &amp;lt;/b&amp;gt;This class records the quizzes that the student has attempted and its progress and also submits grades for the essays in the quizzes attempted by the student.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;What has to be changed : &amp;lt;/b&amp;gt;&lt;br /&gt;
*change list to index (and others in the RESTful style)&lt;br /&gt;
* Pluralize the class (StudentQuizzesController)&lt;br /&gt;
* graded? - review boolean zen&lt;br /&gt;
* Reduce the number of instance variables per controller action.&lt;br /&gt;
* Change the instance variables to local variables if they are not being used in the view. &lt;br /&gt;
* Modify methods to conform to RESTful style &lt;br /&gt;
* Code cleanup by using string interpolation instead of concatenation, replacing '==' with eql? and :key =&amp;gt;'value' with key: 'value', modifying declarations of Arrays and Hashes,removing commented out code&lt;br /&gt;
* Replace find_by with where to follow Rails 4.0 conventions&lt;br /&gt;
&lt;br /&gt;
==Modification to Existing Code==&lt;br /&gt;
&lt;br /&gt;
===Pluralized the class name StudentQuizController===&lt;br /&gt;
As per Rails convention the controller class names are sugested to be plural.&lt;br /&gt;
This helps in generating RESTful routing URI helpers. Also, naming the classes as plural seems more natural and helps in understanding&amp;lt;ref&amp;gt;http://stackoverflow.com/questions/646951/singular-or-plural-controller-and-helper-names-in-rails&amp;lt;/ref&amp;gt;. &lt;br /&gt;
We used the refactor functionality in RubyMineto rename StudentQuiz controller class to StudentQuizzes.&lt;br /&gt;
&lt;br /&gt;
The following files were modified and/or renamed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
app/controllers/review_mapping_controller.rb&lt;br /&gt;
app/controllers/{student_quiz_controller.rb → student_quizzes_controller.rb}&lt;br /&gt;
app/helpers/student_quiz_helper.rb&lt;br /&gt;
app/helpers/student_quizzes_helper.rb&lt;br /&gt;
app/views/questionnaires/view.html.erb&lt;br /&gt;
app/views/{student_quiz → student_quizzes}/_quiz_form.html.erb&lt;br /&gt;
app/views/{student_quiz → student_quizzes}/_responses.html.erb&lt;br /&gt;
app/views/{student_quiz → student_quizzes}/_set_dynamic_quiz.html.erb&lt;br /&gt;
app/views/{student_quiz → student_quizzes}/_set_self_quiz.html.erb&lt;br /&gt;
app/views/{student_quiz → student_quizzes}/finished_quiz.html.erb&lt;br /&gt;
app/views/{student_quiz → student_quizzes}/grade_essays.html.erb&lt;br /&gt;
app/views/{student_quiz → student_quizzes}/list.html.erb&lt;br /&gt;
app/views/{student_quiz → student_quizzes}/take_quiz.html.erb&lt;br /&gt;
app/views/student_task/view.html.erb&lt;br /&gt;
app/views/tree_display/actions/_assignments_actions.html.erb&lt;br /&gt;
test/functional/{student_quiz_controller_test.rb → student_quizzes_controller_test.rb}&lt;br /&gt;
test/test_helper.rb&lt;br /&gt;
test/unit/helpers/student_quiz_helper_test.rb&lt;br /&gt;
test/unit/helpers/student_quizzes_helper_test.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The detailed changeset for this refactor can be seen [https://github.com/ankit3005/expertiza/commit/20981333a14a3f468f76cd6d414b3088975b71bd here]. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===RESTful style implementation===&lt;br /&gt;
* Modifications to student_quiz_controller.rb :&lt;br /&gt;
The purpose of the list method in the Student Quizzes controller is to list all the quizzes that are available to this user for a particular assignment. RESTful guidelines state that a method that returns a list of all available objects, in this case the quizzes, should be named as index. Therefore, we renamed the list method to the index method in the controller and in all the files that had references to the list method of the student_quiz_controller (For e.g. :- The view finished_quiz.html.erb of the Student Quiz controller, the review_mapping controller.rb etc.).&lt;br /&gt;
&lt;br /&gt;
Before Refactoring :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def list&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
&lt;br /&gt;
    @assignment = Assignment.find(@participant.parent_id)&lt;br /&gt;
&lt;br /&gt;
    # Find the current phase that the assignment is in.&lt;br /&gt;
    @quiz_phase = @assignment.get_current_stage(AssignmentParticipant.find(params[:id]).topic_id)&lt;br /&gt;
&lt;br /&gt;
    @quiz_mappings = QuizResponseMap.where(reviewer_id: @participant.id)&lt;br /&gt;
&lt;br /&gt;
    # Calculate the number of quizzes that the user has completed so far.&lt;br /&gt;
    @num_quizzes_total = @quiz_mappings.size&lt;br /&gt;
&lt;br /&gt;
    @num_quizzes_completed = 0&lt;br /&gt;
    @quiz_mappings.each do |map|&lt;br /&gt;
      @num_quizzes_completed += 1 if map.response&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if @assignment.staggered_deadline?&lt;br /&gt;
      @quiz_mappings.each { |quiz_mapping|&lt;br /&gt;
        if @assignment.team_assignment?&lt;br /&gt;
          participant = AssignmentTeam.get_first_member(quiz_mapping.reviewee_id)&lt;br /&gt;
        else&lt;br /&gt;
          participant = quiz_mapping.reviewee&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        if !participant.nil? and !participant.topic_id.nil?&lt;br /&gt;
          quiz_due_date = TopicDeadline.where(topic_id: participant.topic_id, deadline_type_id: 1).first&lt;br /&gt;
        end&lt;br /&gt;
      }&lt;br /&gt;
      deadline_type_id = DeadlineType.find_by_name('quiz').id&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After Refactoring :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def index&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(participant.user_id)&lt;br /&gt;
    @assignment = Assignment.find(participant.parent_id)&lt;br /&gt;
    @quiz_mappings = QuizResponseMap.get_mappings_for_reviewer(participant.id)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Instance Variable Reductions===&lt;br /&gt;
In Rails, data is shared between the controllers and views through the instance variables. The instance variabIes that are set during the execution a particular controller method are accessible to the view. Excessive usage of this standard method of data sharing between the controller and the view results in increased coupling between them. &amp;lt;ref&amp;gt;http://blog.remarkablelabs.com/2013/01/how-to-decrease-coupling-in-your-controllers-views-with-decent_exposure-for-better-maintainability&amp;lt;/ref&amp;gt; Increased coupling results in several problems, including less maintainability of code, difficulty in code reuse etc. &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Coupling_(computer_programming)#Disadvantages&amp;lt;/ref&amp;gt; Thus, we need to reduce coupling to the maximum possible extent and in this case it can be achieved by reducing as many instance variables as possible. Therefore, we have refactored our code in order to eliminate unused and unneccessary instance variables.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Before Refactoring&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
student_quizzes_controller.rb&lt;br /&gt;
&lt;br /&gt;
In the take_quiz method, the following instance variables were removed&lt;br /&gt;
Changed the quizzes instance variable to a local variable.&lt;br /&gt;
Eliminated instance variable assignment which was not used anywhere.&lt;br /&gt;
Eliminated local variable teams which was not used any where&lt;br /&gt;
The unified diff of the changes made is shown below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def self.take_quiz assignment_id , reviewer_id&lt;br /&gt;
-    @quizzes = Array.new&lt;br /&gt;
+    quizzes = Array.new&lt;br /&gt;
     reviewer = Participant.where(user_id: reviewer_id, parent_id: assignment_id).first&lt;br /&gt;
-    @assignment = Assignment.find(assignment_id)&lt;br /&gt;
-    teams = TeamsUser.where(user_id: reviewer_id)&lt;br /&gt;
     Team.where(parent_id: assignment_id).each do |quiz_creator|&lt;br /&gt;
       unless TeamsUser.find_by_team_id(quiz_creator.id).user_id == reviewer_id&lt;br /&gt;
         Questionnaire.where(instructor_id: quiz_creator.id).each do |questionnaire|&lt;br /&gt;
-          if !@assignment.team_assignment?&lt;br /&gt;
-            unless QuizResponseMap.where(reviewed_object_id: questionnaire.id, reviewer_id:  reviewer.id).first&lt;br /&gt;
-              @quizzes.push(questionnaire)&lt;br /&gt;
-            end&lt;br /&gt;
-          else unless QuizResponseMap.where(reviewed_object_id: questionnaire.id, reviewer_id:  reviewer_id).first&lt;br /&gt;
-            @quizzes.push(questionnaire)&lt;br /&gt;
+          unless QuizResponseMap.where(reviewed_object_id: questionnaire.id, reviewer_id:  reviewer.id).first&lt;br /&gt;
+            quizzes.push(questionnaire)&lt;br /&gt;
           end&lt;br /&gt;
         end&lt;br /&gt;
       end&lt;br /&gt;
     end&lt;br /&gt;
+    return quizzes&lt;br /&gt;
   end&lt;br /&gt;
-  return @quizzes&lt;br /&gt;
-end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Code Cleanup===&lt;br /&gt;
Code cleanup in the controller so that the code conforms closely to Rails conventions and enhanced readability of code.&lt;br /&gt;
* Replaced String concats with #{} in paginate_list&lt;br /&gt;
Before Refactoring :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After Refactoring :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Replaced '==' with eql?&lt;br /&gt;
Before Refactoring :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After Refactoring :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Replaced :key =&amp;gt;'value' with key: 'value'&lt;br /&gt;
&lt;br /&gt;
Before Refactoring :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Modified declarations of Arrays and Hashes&lt;br /&gt;
Before Refactoring :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After Refactoring :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Removed unused methods like self.participants_in and commented out code.&lt;br /&gt;
&lt;br /&gt;
===Use of Routing Helpers===&lt;br /&gt;
Routing helpers are a simpler alternative to the otherwise complex hard coded URLs which reduce the readability of the code.Routing helpers allow us to declare possible common routes for a given controller. Routing helpers have been implemented since they maintain consistency even if changes are made to the routing paths. &lt;br /&gt;
&lt;br /&gt;
Before Refactoring:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
After Refactoring&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def show_selection&lt;br /&gt;
      @user = User.where(name: params[:user][:name]).take&lt;br /&gt;
      if @user != nil&lt;br /&gt;
        role=get_role&lt;br /&gt;
        if role.parent_id.eql? nil || role.parent_id &amp;lt; (session[:user]).role_id || @user.id.eql?(session[:user]).id&lt;br /&gt;
          render action: 'show'&lt;br /&gt;
        else&lt;br /&gt;
          flash[:note] = 'The specified user is not available for editing.'&lt;br /&gt;
          redirect_to users_path  #Replaced URL with routing helper &lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        flash[:note] = params[:user][:name]+' does not exist.'&lt;br /&gt;
      redirect_to users_path  #Replaced URL with routing helper&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Replace find_by_.. with where in querying===&lt;br /&gt;
Rails 4 conventions dictate the use of 'where()' over the use of 'find_by_...' methods while querying ActiveRecords. The code has been refactored to replace the usages of find_by.. with where().&lt;br /&gt;
&lt;br /&gt;
Before Refactoring&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After Refactoring&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Replace controller method with a model method ===&lt;br /&gt;
Rails 4 conventions dictate the use of 'where()' over the use of 'find_by_...' methods while querying ActiveRecords. The code has been refactored to replace the usages of find_by.. with where().&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Before Refactoring&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    @quiz_mappings = QuizResponseMap.where(reviewer_id: participant.id)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After Refactoring&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 @quiz_mappings = QuizResponseMap.get_mappings_for_reviewer(participant.id)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aagrawa5</name></author>
	</entry>
</feed>