Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacing C libraries with Rust equivalents - student project #4215

Closed
wants to merge 29 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c4156d4
Initial commit for migrating to freetype-rs library from rust-freetype
ankit3005 Nov 29, 2014
66623ea
added constant to freetype_rs library ft_sfnt_os2
ankit3005 Nov 29, 2014
ff891d8
Changed freetyp-rs dependency to local fork on github
ankit3005 Nov 29, 2014
754a841
Changes to use DynamicImage type from the new rust image library
anishashetty Nov 30, 2014
254e9c9
fix in Cargo.lock after updating freetype-rs dependency
ankit3005 Nov 30, 2014
552cc7b
Replaced png::Image references with DynamicImage
ynandak Dec 1, 2014
f712870
Small fix in gfx/render_context.rs
ynandak Dec 1, 2014
dbd681a
Replaced certain instances of png::Image use - build successful
ynandak Dec 1, 2014
82d3720
Minor change to render_context.rs::draw_image()
ynandak Dec 2, 2014
61557e5
Added changes to accept ImageFormat
anishashetty Dec 2, 2014
d2d9a99
Changes to fix runtime data.len() assertion crash
ynandak Dec 3, 2014
1a0f513
Minor fix in render_context
ynandak Dec 3, 2014
1bca917
Changes to base.rs to resolve ImageFormat based on file extension
anishashetty Dec 3, 2014
0954f6d
Merge branch 'master' of https://github.com/ankit3005/servo
anishashetty Dec 3, 2014
8ce5e11
Updated RGB in draw_image()
ynandak Dec 3, 2014
169160a
net component compiles with profiler in place
ankit3005 Dec 3, 2014
91f719e
whitespace changes to clean up mach test-tidy
ankit3005 Dec 3, 2014
7f20adc
Minor cleanup. Removed unnecessary line
ankit3005 Dec 3, 2014
4c33555
Changed freetype-rs dependency from fork to upstream repo
ankit3005 Dec 3, 2014
b7b50f8
Changed freetype-rs version to old working commit
ankit3005 Dec 4, 2014
ba24947
Clean up commented code
ankit3005 Dec 4, 2014
3d518cd
Add profiling to image decoding
ankit3005 Dec 4, 2014
d6bb6b4
Code clean up. Removed unused functions and imports
ankit3005 Dec 4, 2014
ad709d6
minor cleanup
ankit3005 Dec 4, 2014
d1aaa2c
Remove a println statement
ankit3005 Dec 4, 2014
dfa0b92
Fixed image rendering. Now working as intended
ynandak Dec 4, 2014
85b5efc
Updated Cargo.lock
ynandak Dec 4, 2014
9e2b0c7
Removed debugging println!
ynandak Dec 4, 2014
768709a
whitespace changes to clean up test-tidy
ankit3005 Dec 4, 2014
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Added changes to accept ImageFormat

  • Loading branch information
anishashetty committed Dec 2, 2014
commit 61557e5ab48b9099c33ea1097d8a80cddbe9376b
@@ -43,12 +43,13 @@ fn byte_swap_and_premultiply(data: &mut [u8]) {
}
}

pub fn load_from_memory(buffer: &[u8]) -> Option<DynamicImage> {
pub fn load_from_memory(buffer: &[u8],ext: &str) -> Option<DynamicImage> {
if buffer.len() == 0 {
return None;
}
else {
let result = servo_image::load_from_memory(buffer,servo_image::ImageFormat::JPEG);

let result = servo_image::load_from_memory(buffer,get_format(ext));
if (result.is_ok()) {
let v = result.unwrap();
return Some(v);
@@ -57,5 +58,16 @@ pub fn load_from_memory(buffer: &[u8]) -> Option<DynamicImage> {
return None;
}
}
}
fn get_format(ext: &str) -> servo_image::ImageFormat {
match ext.to_ascii().to_uppercase().as_str_ascii() {
"PNG" => {return servo_image::ImageFormat::PNG;},
"JPEG" => {return servo_image::ImageFormat::JPEG;},
"JPG" => {return servo_image::ImageFormat::JPEG;},
"GIF"=> {return servo_image::ImageFormat::GIF;},
"WEBP" => {return servo_image::ImageFormat::WEBP;},
"PPM" => {return servo_image::ImageFormat::PPM;},
_ => {return servo_image::ImageFormat::PNG;},
}
}

}
@@ -313,7 +313,12 @@ impl ImageCache {
self.task_pool.execute(proc() {
let url = url_clone;
debug!("image_cache_task: started image decode for {:s}", url.serialize());
let image = load_from_memory(data.as_slice());
let s=url.serialize();
let mut ext="";
for x in s.as_slice().split('.') { ext=x; }
println!("{}",ext);

let image = load_from_memory(data.as_slice(),ext);
let image = image.map(|image| Arc::new(box image));
to_cache.send(StoreImage(url.clone(), image));
debug!("image_cache_task: ended image decode for {:s}", url.serialize());
@@ -980,7 +985,7 @@ mod tests {
#[test]
fn sync_cache_should_wait_for_images() {
let mock_resource_task = mock_resource_task(box SendTestImage);

let image_cache_task = ImageCacheTask::new_sync(mock_resource_task.clone(), TaskPool::new(4));
let url = Url::parse("file:///").unwrap();

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.