mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Decode images in parallel
This commit is contained in:
parent
830a41ad94
commit
b46aaa509d
3 changed files with 24 additions and 18 deletions
|
@ -19,6 +19,8 @@ import style::style::SpecifiedStyle;
|
||||||
import text::text_layout_methods;
|
import text::text_layout_methods;
|
||||||
import vec::{push, push_all};
|
import vec::{push, push_all};
|
||||||
|
|
||||||
|
import future::future;
|
||||||
|
|
||||||
enum BoxKind {
|
enum BoxKind {
|
||||||
BlockBox,
|
BlockBox,
|
||||||
InlineBox,
|
InlineBox,
|
||||||
|
@ -27,7 +29,7 @@ enum BoxKind {
|
||||||
}
|
}
|
||||||
|
|
||||||
class Appearance {
|
class Appearance {
|
||||||
let mut background_image: option<@image>;
|
let mut background_image: option<future<~image>>;
|
||||||
let mut background_color: Color;
|
let mut background_color: Color;
|
||||||
|
|
||||||
new() {
|
new() {
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
export build_display_list;
|
export build_display_list;
|
||||||
|
|
||||||
import dl = display_list;
|
import base::{Box, TextBox, BTree, BoxTreeReadMethods};
|
||||||
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 box_builder::box_builder_methods;
|
import box_builder::box_builder_methods;
|
||||||
import text::text_layout_methods;
|
import dl = display_list;
|
||||||
import geom::size::Size2D;
|
import dom::base::{Text, NodeScope};
|
||||||
|
import dom::rcu::Scope;
|
||||||
import geom::point::Point2D;
|
import geom::point::Point2D;
|
||||||
import geom::rect::Rect;
|
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;
|
import vec::push;
|
||||||
|
|
||||||
#[doc = "
|
#[doc = "
|
||||||
|
@ -85,9 +86,10 @@ fn box_to_display_items(box: @Box, origin: Point2D<au>) -> ~[dl::display_item] {
|
||||||
bounds: bounds
|
bounds: bounds
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
(_, some(image)) {
|
(_, some(image)) {
|
||||||
|
// FIXME: This should not copy and instead should use an ARC.
|
||||||
push(items, dl::display_item({
|
push(items, dl::display_item({
|
||||||
item_type: dl::display_item_image(~copy *image),
|
item_type: dl::display_item_image(copy image.get()),
|
||||||
bounds: bounds
|
bounds: bounds
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@ import image::base::load;
|
||||||
import base::{Box, BTree, NTree, LayoutData, BoxTreeReadMethods, SpecifiedStyle};
|
import base::{Box, BTree, NTree, LayoutData, BoxTreeReadMethods, SpecifiedStyle};
|
||||||
import style::{default_style_methods, style_methods};
|
import style::{default_style_methods, style_methods};
|
||||||
|
|
||||||
|
import future_spawn = future::spawn;
|
||||||
|
|
||||||
trait ApplyStyleBoxMethods {
|
trait ApplyStyleBoxMethods {
|
||||||
fn apply_style_for_subtree();
|
fn apply_style_for_subtree();
|
||||||
fn apply_style();
|
fn apply_style();
|
||||||
|
@ -28,7 +30,7 @@ impl ApplyStyleBoxMethods of ApplyStyleBoxMethods for @Box {
|
||||||
"]
|
"]
|
||||||
fn apply_style() {
|
fn apply_style() {
|
||||||
// Right now, we only handle images.
|
// Right now, we only handle images.
|
||||||
self.node.read(|node| {
|
do self.node.read |node| {
|
||||||
alt node.kind {
|
alt node.kind {
|
||||||
~Element(element) {
|
~Element(element) {
|
||||||
let style = self.node.get_specified_style();
|
let style = self.node.get_specified_style();
|
||||||
|
@ -44,10 +46,10 @@ impl ApplyStyleBoxMethods of ApplyStyleBoxMethods for @Box {
|
||||||
some(url) {
|
some(url) {
|
||||||
// FIXME: Some sort of BASE HREF support!
|
// FIXME: Some sort of BASE HREF support!
|
||||||
// FIXME: Parse URLs!
|
// FIXME: Parse URLs!
|
||||||
// FIXME: Do not load synchronously!
|
self.appearance.background_image = some(do future_spawn {
|
||||||
|
~load(url)
|
||||||
|
});
|
||||||
#debug("loading image from %s", url);
|
#debug("loading image from %s", url);
|
||||||
let image = @load(url);
|
|
||||||
self.appearance.background_image = some(image);
|
|
||||||
}
|
}
|
||||||
none {
|
none {
|
||||||
/* Ignore. */
|
/* Ignore. */
|
||||||
|
@ -59,7 +61,7 @@ impl ApplyStyleBoxMethods of ApplyStyleBoxMethods for @Box {
|
||||||
}
|
}
|
||||||
_ { /* Ignore. */ }
|
_ { /* Ignore. */ }
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue