servo: Decode images in parallel

Source-Repo: https://github.com/servo/servo
Source-Revision: b46aaa509d5a1c6b671fdaa87d2fd91acf469411
This commit is contained in:
Patrick Walton 2012-07-19 11:28:22 -07:00
Родитель e23648685a
Коммит ce70f374a0
3 изменённых файлов: 24 добавлений и 18 удалений

Просмотреть файл

@ -19,6 +19,8 @@ import style::style::SpecifiedStyle;
import text::text_layout_methods;
import vec::{push, push_all};
import future::future;
enum BoxKind {
BlockBox,
InlineBox,
@ -27,7 +29,7 @@ enum BoxKind {
}
class Appearance {
let mut background_image: option<@image>;
let mut background_image: option<future<~image>>;
let mut background_color: Color;
new() {

Просмотреть файл

@ -1,18 +1,19 @@
export build_display_list;
import dl = display_list;
import dom::rcu::Scope;
import dom::base::{Text, NodeScope};
import gfx::geometry::{au, au_to_px, box, px_to_au};
import gfx::renderer;
import util::color::methods;
import util::tree;
import base::{Box, TextBox, BTree, BoxTreeReadMethods};
import box_builder::box_builder_methods;
import text::text_layout_methods;
import geom::size::Size2D;
import dl = display_list;
import dom::base::{Text, NodeScope};
import dom::rcu::Scope;
import geom::point::Point2D;
import geom::rect::Rect;
import base::{Box, TextBox, BTree, BoxTreeReadMethods};
import geom::size::Size2D;
import gfx::geometry::{au, au_to_px, box, px_to_au};
import gfx::renderer;
import text::text_layout_methods;
import util::color::methods;
import util::tree;
import vec::push;
#[doc = "
@ -85,9 +86,10 @@ fn box_to_display_items(box: @Box, origin: Point2D<au>) -> ~[dl::display_item] {
bounds: bounds
}));
}
(_, some(image)) {
(_, some(image)) {
// FIXME: This should not copy and instead should use an ARC.
push(items, dl::display_item({
item_type: dl::display_item_image(~copy *image),
item_type: dl::display_item_image(copy image.get()),
bounds: bounds
}));
}

Просмотреть файл

@ -6,6 +6,8 @@ import image::base::load;
import base::{Box, BTree, NTree, LayoutData, BoxTreeReadMethods, SpecifiedStyle};
import style::{default_style_methods, style_methods};
import future_spawn = future::spawn;
trait ApplyStyleBoxMethods {
fn apply_style_for_subtree();
fn apply_style();
@ -28,7 +30,7 @@ impl ApplyStyleBoxMethods of ApplyStyleBoxMethods for @Box {
"]
fn apply_style() {
// Right now, we only handle images.
self.node.read(|node| {
do self.node.read |node| {
alt node.kind {
~Element(element) {
let style = self.node.get_specified_style();
@ -44,10 +46,10 @@ impl ApplyStyleBoxMethods of ApplyStyleBoxMethods for @Box {
some(url) {
// FIXME: Some sort of BASE HREF support!
// FIXME: Parse URLs!
// FIXME: Do not load synchronously!
self.appearance.background_image = some(do future_spawn {
~load(url)
});
#debug("loading image from %s", url);
let image = @load(url);
self.appearance.background_image = some(image);
}
none {
/* Ignore. */
@ -59,7 +61,7 @@ impl ApplyStyleBoxMethods of ApplyStyleBoxMethods for @Box {
}
_ { /* Ignore. */ }
}
})
}
}
}