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

[DO NOT MERGE] Initiate image loads in the script thread #14781

Closed
wants to merge 8 commits into from

Fetch complete images from the cache for canvas operations.

  • Loading branch information
jdm committed Jan 11, 2017
commit 731eff6f1d66bd571af6a2d6761b6fb44c2b61ca
@@ -337,18 +337,19 @@ impl<'a> From<&'a WebGLContextAttributes> for GLContextAttributes {

pub mod utils {
use dom::window::Window;
use net_traits::image_cache_thread::ImageResponse;
use net_traits::image_cache_thread::{ImageResponse, UsePlaceholder, ImageOrMetadataAvailable};
use net_traits::image_cache_thread::CanRequestImages;
use servo_url::ServoUrl;

pub fn request_image_from_cache(window: &Window, url: ServoUrl) -> ImageResponse {
panic!()
/*let image_cache = window.image_cache_thread();
let (response_chan, response_port) = ipc::channel().unwrap();
image_cache.request_image(url.into(), ImageCacheChan(response_chan), None);
let result = response_port.recv().unwrap();
match result {
ImageCacheResult::InitiateRequest(..) => panic!("unexpected image request initiator"),
ImageCacheResult::Response(result) => result.image_response,
}*/
let image_cache = window.image_cache_thread();
//XXXjdm add a image cache mode that doesn't store anything for NotRequested?
let response =
image_cache.find_image_or_metadata(url.into(), UsePlaceholder::No);
match response {
Ok(ImageOrMetadataAvailable::ImageAvailable(image)) =>
ImageResponse::Loaded(image),
_ => ImageResponse::None,
}
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.