aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/canvasrenderingcontext2d.rs
diff options
context:
space:
mode:
authorGlenn Watson <gw@intuitionlibrary.com>2015-04-20 13:34:26 +1000
committerGlenn Watson <gw@intuitionlibrary.com>2015-04-23 09:40:24 +1000
commitd8aef7208e5ed9705f551f0bf0e0cd6607ff224f (patch)
tree4a2954d38055abea3189f8afd8cf580f8d90c600 /components/script/dom/canvasrenderingcontext2d.rs
parente278e5b9a27738bdca7a151b4295628e1f179e29 (diff)
downloadservo-d8aef7208e5ed9705f551f0bf0e0cd6607ff224f.tar.gz
servo-d8aef7208e5ed9705f551f0bf0e0cd6607ff224f.zip
Refactored image cache task - details below.
* Simpler image cache API for clients to use. * Significantly fewer threads. * One thread for image cache task (multiplexes commands, decoder threads and async resource requests). * 4 threads for decoder worker tasks. * Removed ReflowEvent hacks in script and layout tasks. * Image elements pass a Trusted<T> to image cache, which is used to dirty nodes via script task. Previous use of Untrusted addresses was unsafe. * Image requests such as background-image on layout / paint threads trigger repaint only rather than full reflow. * Add reflow batching for when multiple images load quickly. * Reduces the number of paints loading wikipedia from ~95 to ~35. * Reasonably simple to add proper prefetch support in a follow up PR. * Async loaded images always construct Image fragments now, instead of generic. * Image fragments support the image not being present. * Simpler implementation of synchronous image loading for reftests. * Removed image holder. * image.onload support. * image NaturalWidth and NaturalHeight support. * Updated WPT expectations.
Diffstat (limited to 'components/script/dom/canvasrenderingcontext2d.rs')
-rw-r--r--components/script/dom/canvasrenderingcontext2d.rs15
1 files changed, 5 insertions, 10 deletions
diff --git a/components/script/dom/canvasrenderingcontext2d.rs b/components/script/dom/canvasrenderingcontext2d.rs
index f6111739d8b..022b31dd055 100644
--- a/components/script/dom/canvasrenderingcontext2d.rs
+++ b/components/script/dom/canvasrenderingcontext2d.rs
@@ -33,7 +33,7 @@ use canvas::canvas_paint_task::{LinearGradientStyle, RadialGradientStyle};
use canvas::canvas_paint_task::{LineCapStyle, LineJoinStyle, CompositionOrBlending};
use net_traits::image::base::Image;
-use net_traits::image_cache_task::{ImageResponseMsg, Msg};
+use net_traits::image_cache_task::ImageCacheChan;
use png::PixelsByColorType;
use std::borrow::ToOwned;
@@ -275,16 +275,11 @@ impl CanvasRenderingContext2D {
let canvas = self.canvas.root();
let window = window_from_node(canvas.r()).root();
let window = window.r();
- let image_cache_task = window.image_cache_task().clone();
- image_cache_task.send(Msg::Prefetch(url.clone()));
- image_cache_task.send(Msg::Decode(url.clone()));
+ let image_cache = window.image_cache_task();
let (response_chan, response_port) = channel();
- image_cache_task.send(Msg::WaitForImage(url, response_chan));
- match response_port.recv().unwrap() {
- ImageResponseMsg::ImageReady(image) => Some(image),
- ImageResponseMsg::ImageFailed => None,
- _ => panic!("Image Cache: Unknown Result")
- }
+ image_cache.request_image(url, ImageCacheChan(response_chan), None);
+ let result = response_port.recv().unwrap();
+ result.image
}
fn create_drawable_rect(&self, x: f64, y: f64, w: f64, h: f64) -> Option<Rect<f32>> {