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

Rollup of changes #515

Merged
merged 25 commits into from Jun 14, 2013
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a53a7f6
Add link following and refactor the profiler.
Jun 6, 2013
9085b88
Implement scrolling and better zooming
Jun 6, 2013
abe6a06
Update rust-layers for GL_LINEAR zooming
pcwalton Jun 6, 2013
bf4df24
Provide an interface to the engine for the script task
Jun 6, 2013
ff1178f
handle relative url's when clicking
Jun 6, 2013
0bbf2fc
Refactor flow tree construction and actually use display property.
Jun 8, 2013
1fbfd7d
Implement horizontal scrolling and pinch-to-zoom
pcwalton Jun 9, 2013
7b28462
Send status messages to the compositor
Jun 7, 2013
a9ed2d8
Spin the event loop every 50 ms to allow Rust channels to be processed.
pcwalton Jun 10, 2013
e50cee9
Resolve relative URLs that begin with '//'
pcwalton Jun 10, 2013
f3ad95f
Added a command-line argument for rendering tiles at higher resolutions
Jun 11, 2013
1aa8d64
Fix URL relativization so that links on Wikipedia work
pcwalton Jun 11, 2013
96b9be6
Add a cheesy progress indicator
pcwalton Jun 11, 2013
204c5b6
Add a spinner for layout
pcwalton Jun 11, 2013
aad5113
Update submodules
pcwalton Jun 12, 2013
162ba83
Fix merge fallout
pcwalton Jun 12, 2013
aee2611
Make script and style display:none
pcwalton Jun 12, 2013
e1b9e01
Fix merge fallout which was disabling all CSS classes.
pcwalton Jun 12, 2013
327e799
test: Add a box model smoketest
pcwalton Jun 12, 2013
b75b2de
Compute percent widths/margins properly and fix numerous small visual…
Jun 4, 2013
4017839
Fix padding
Jun 4, 2013
badf1b8
Vertical margins now contribute to content height.
Jun 4, 2013
f3cdbaf
Stop sorting after every profiler datum comes in.
pcwalton Jun 13, 2013
2ec3412
Fix submodules and test_slam_layout
pcwalton Jun 13, 2013
c35abb2
Update rust-glut
pcwalton Jun 14, 2013
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -12,6 +12,8 @@ pub struct LayerBuffer {
// The rect in the containing RenderLayer that this represents.
rect: Rect<uint>,

screen_pos: Rect<uint>,

// NB: stride is in pixels, like OpenGL GL_UNPACK_ROW_LENGTH.
stride: uint
}
@@ -22,9 +24,17 @@ pub struct LayerBufferSet {
buffers: ~[LayerBuffer]
}

/// The status of the renderer.
#[deriving(Eq)]
pub enum RenderState {
IdleRenderState,
RenderingRenderState,
}

/// The interface used to by the renderer to acquire draw targets for each rendered frame and
/// submit them to be drawn to the display.
pub trait Compositor {
fn paint(&self, layer_buffer_set: LayerBufferSet, new_size: Size2D<uint>);
fn set_render_state(&self, render_state: RenderState);
}

@@ -18,6 +18,8 @@ use azure::scaled_font::ScaledFont;
use azure::azure_hl::{BackendType, ColorPattern};
use geom::{Point2D, Rect, Size2D};

use servo_util::time::ProfilerChan;

// FontHandle encapsulates access to the platform's font API,
// e.g. quartz, FreeType. It provides access to metrics and tables
// needed by the text shaper as well as access to the underlying font
@@ -210,13 +212,15 @@ pub struct Font {
style: UsedFontStyle,
metrics: FontMetrics,
backend: BackendType,
profiler_chan: ProfilerChan,
}

pub impl Font {
fn new_from_buffer(ctx: &FontContext,
buffer: ~[u8],
style: &SpecifiedFontStyle,
backend: BackendType)
backend: BackendType,
profiler_chan: ProfilerChan)
-> Result<@mut Font, ()> {
let handle = FontHandleMethods::new_from_buffer(&ctx.handle, buffer, style);
let handle: FontHandle = if handle.is_ok() {
@@ -235,11 +239,13 @@ pub impl Font {
style: copy *style,
metrics: metrics,
backend: backend,
profiler_chan: profiler_chan,
});
}

fn new_from_adopted_handle(_fctx: &FontContext, handle: FontHandle,
style: &SpecifiedFontStyle, backend: BackendType) -> @mut Font {
style: &SpecifiedFontStyle, backend: BackendType,
profiler_chan: ProfilerChan) -> @mut Font {
let metrics = handle.get_metrics();

@mut Font {
@@ -249,19 +255,21 @@ pub impl Font {
style: copy *style,
metrics: metrics,
backend: backend,
profiler_chan: profiler_chan,
}
}

fn new_from_existing_handle(fctx: &FontContext, handle: &FontHandle,
style: &SpecifiedFontStyle, backend: BackendType) -> Result<@mut Font,()> {
style: &SpecifiedFontStyle, backend: BackendType,
profiler_chan: ProfilerChan) -> Result<@mut Font,()> {

// TODO(Issue #179): convert between specified and used font style here?
let styled_handle = match handle.clone_with_style(&fctx.handle, style) {
Ok(result) => result,
Err(()) => return Err(())
};

return Ok(Font::new_from_adopted_handle(fctx, styled_handle, style, backend));
return Ok(Font::new_from_adopted_handle(fctx, styled_handle, style, backend, profiler_chan));
}

priv fn get_shaper(@mut self) -> @Shaper {
@@ -40,17 +40,18 @@ pub struct FontContext {
handle: FontContextHandle,
backend: BackendType,
generic_fonts: HashMap<~str,~str>,
profiler_chan: ProfilerChan,
}

#[allow(non_implicitly_copyable_typarams)]
pub impl<'self> FontContext {
fn new(backend: BackendType,
needs_font_list: bool,
prof_chan: ProfilerChan)
profiler_chan: ProfilerChan)
-> FontContext {
let handle = FontContextHandle::new();
let font_list = if needs_font_list {
Some(FontList::new(&handle, prof_chan.clone())) }
Some(FontList::new(&handle, profiler_chan.clone())) }
else { None };

// TODO: Allow users to specify these.
@@ -69,6 +70,7 @@ pub impl<'self> FontContext {
handle: handle,
backend: backend,
generic_fonts: generic_fonts,
profiler_chan: profiler_chan,
}
}

@@ -125,7 +127,8 @@ pub impl<'self> FontContext {
for result.each |font_entry| {
found = true;
// TODO(Issue #203): route this instantion through FontContext's Font instance cache.
let instance = Font::new_from_existing_handle(self, &font_entry.handle, style, self.backend);
let instance = Font::new_from_existing_handle(self, &font_entry.handle, style, self.backend,
self.profiler_chan.clone());
do result::iter(&instance) |font: &@mut Font| { fonts.push(*font); }
};

@@ -139,8 +142,14 @@ pub impl<'self> FontContext {
for last_resort.each |family| {
let result = list.find_font_in_family(*family,style);
for result.each |font_entry| {
let instance = Font::new_from_existing_handle(self, &font_entry.handle, style, self.backend);
do result::iter(&instance) |font: &@mut Font| { fonts.push(*font); }
let instance = Font::new_from_existing_handle(self,
&font_entry.handle,
style,
self.backend,
self.profiler_chan.clone());
do result::iter(&instance) |font: &@mut Font| {
fonts.push(*font);
}
}
}

@@ -163,7 +172,8 @@ pub impl<'self> FontContext {
Ok(Font::new_from_adopted_handle(self,
handle,
&desc.style,
self.backend))
self.backend,
self.profiler_chan.clone()))
})
}
};
@@ -13,6 +13,11 @@ pub struct Opts {
render_backend: BackendType,
n_render_threads: uint,
tile_size: uint,
profiler_period: Option<f64>,

/// A scale factor to apply to tiles, to allow rendering tiles at higher resolutions for
/// testing pan and zoom code.
zoom: uint,
}

#[allow(non_implicitly_copyable_typarams)]
@@ -26,13 +31,14 @@ pub fn from_cmdline_args(args: &[~str]) -> Opts {
getopts::optopt(~"r"), // rendering backend
getopts::optopt(~"s"), // size of tiles
getopts::optopt(~"t"), // threads to render with
getopts::optflagopt(~"p"), // profiler flag and output interval
getopts::optopt(~"z"), // zoom level
];

let opt_match = match getopts::getopts(args, opts) {
result::Ok(m) => { copy m }
result::Err(f) => { fail!(getopts::fail_str(copy f)) }
};

let urls = if opt_match.free.is_empty() {
fail!(~"servo asks that you provide 1 or more URLs")
} else {
@@ -68,10 +74,24 @@ pub fn from_cmdline_args(args: &[~str]) -> Opts {
None => 1, // FIXME: Number of cores.
};

let profiler_period: Option<f64> =
// if only flag is present, default to 5 second period
match getopts::opt_default(&opt_match, ~"p", ~"5") {
Some(period) => Some(f64::from_str(period).get()),
None => None,
};

let zoom: uint = match getopts::opt_maybe_str(&opt_match, ~"z") {
Some(zoom_str) => uint::from_str(zoom_str).get(),
None => 1,
};

Opts {
urls: urls,
render_backend: render_backend,
n_render_threads: n_render_threads,
tile_size: tile_size,
profiler_period: profiler_period,
zoom: zoom,
}
}
@@ -37,6 +37,7 @@ pub fn render_layers(layer_ref: *RenderLayer,
f: RenderFn)
-> LayerBufferSet {
let tile_size = opts.tile_size;
let scale = opts.zoom;

// FIXME: Try not to create a new array here.
let mut new_buffer_ports = ~[];
@@ -45,12 +46,12 @@ pub fn render_layers(layer_ref: *RenderLayer,
do time::profile(time::RenderingPrepBuffCategory, prof_chan.clone()) {
let layer: &RenderLayer = unsafe { cast::transmute(layer_ref) };
let mut y = 0;
while y < layer.size.height {
while y < layer.size.height * scale {
let mut x = 0;
while x < layer.size.width {
while x < layer.size.width * scale {
// Figure out the dimension of this tile.
let right = uint::min(x + tile_size, layer.size.width);
let bottom = uint::min(y + tile_size, layer.size.height);
let right = uint::min(x + tile_size, layer.size.width * scale);
let bottom = uint::min(y + tile_size, layer.size.height * scale);
let width = right - x;
let height = bottom - y;

@@ -65,7 +66,8 @@ pub fn render_layers(layer_ref: *RenderLayer,

debug!("tile aligned_width %u", aligned_width);

let tile_rect = Rect(Point2D(x, y), Size2D(aligned_width, height));
let tile_rect = Rect(Point2D(x / scale, y / scale), Size2D(aligned_width, height)); //change this
let screen_rect = Rect(Point2D(x, y), Size2D(aligned_width, height)); //change this

let buffer;
// FIXME: Try harder to search for a matching tile.
@@ -112,6 +114,7 @@ pub fn render_layers(layer_ref: *RenderLayer,
stride,
B8G8R8A8),
rect: tile_rect,
screen_pos: screen_rect,
stride: stride as uint
};
//}
@@ -5,7 +5,7 @@
// The task that handles all rendering/painting.

use azure::AzFloat;
use compositor::Compositor;
use compositor::{Compositor, IdleRenderState, RenderingRenderState};
use font_context::FontContext;
use geom::matrix2d::Matrix2D;
use opts::Opts;
@@ -18,9 +18,7 @@ use core::task::SingleThreaded;
use std::task_pool::TaskPool;
use servo_net::util::spawn_listener;

use servo_util::time::ProfilerChan;
use servo_util::time::profile;
use servo_util::time::time;
use servo_util::time::{ProfilerChan, profile};
use servo_util::time;

pub enum Msg {
@@ -124,7 +122,8 @@ impl<C: Compositor + Owned> Renderer<C> {

fn render(&mut self, render_layer: RenderLayer) {
debug!("renderer: rendering");
do time("rendering") {
self.compositor.set_render_state(RenderingRenderState);
do profile(time::RenderingCategory, self.profiler_chan.clone()) {
let layer_buffer_set = do render_layers(&render_layer,
&self.opts,
self.profiler_chan.clone()) |render_layer_ref,
@@ -142,17 +141,24 @@ impl<C: Compositor + Owned> Renderer<C> {

// Apply the translation to render the tile we want.
let matrix: Matrix2D<AzFloat> = Matrix2D::identity();
let matrix = matrix.translate(&-(layer_buffer.rect.origin.x as AzFloat),
&-(layer_buffer.rect.origin.y as AzFloat));
let scale = thread_render_context.opts.zoom as f32;

let matrix = matrix.scale(scale as AzFloat, scale as AzFloat);
let matrix = matrix.translate(-(layer_buffer.rect.origin.x as f32) as AzFloat,
-(layer_buffer.rect.origin.y as f32) as AzFloat);


layer_buffer.draw_target.set_transform(&matrix);

// Clear the buffer.
ctx.clear();


// Draw the display list.
let render_layer: &RenderLayer = unsafe {
cast::transmute(render_layer_ref)
};

render_layer.display_list.draw_into_context(&ctx);
}

@@ -163,6 +169,7 @@ impl<C: Compositor + Owned> Renderer<C> {

debug!("renderer: returning surface");
self.compositor.paint(layer_buffer_set, render_layer.size);
self.compositor.set_render_state(IdleRenderState);
}
}
}
@@ -6,6 +6,8 @@ use font_context::FontContext;
use geometry::Au;
use text::glyph::{BreakTypeNormal, GlyphStore};
use font::{Font, FontDescriptor, RunMetrics};
use servo_util::time;
use servo_util::time::profile;
use servo_util::range::Range;

/// A text run.
@@ -44,7 +46,9 @@ pub impl<'self> TextRun {
fn new(font: @mut Font, text: ~str, underline: bool) -> TextRun {
let mut glyph_store = GlyphStore::new(str::char_len(text));
TextRun::compute_potential_breaks(text, &mut glyph_store);
font.shape_text(text, &mut glyph_store);
do profile(time::LayoutShapingCategory, font.profiler_chan.clone()) {
font.shape_text(text, &mut glyph_store);
}

let run = TextRun {
text: text,
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.