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

Replace GLUT with GLFW #563

Merged
merged 5 commits into from Jul 10, 2013
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Update to latest Rust.

  • Loading branch information
metajack committed Jul 9, 2013
commit 870db398366bb5f2a19fdc301d8d7641c27cae0b
@@ -48,7 +48,7 @@ impl<E> DisplayList<E> {
/// Draws the display list into the given render context.
pub fn draw_into_context(&self, render_context: &RenderContext) {
debug!("Beginning display list.");
for self.list.each |item| {
for self.list.iter().advance |item| {
// FIXME(Issue #150): crashes
//debug!("drawing %?", *item);
item.draw_into_context(render_context)
@@ -389,7 +389,7 @@ impl Font {

let mut origin = copy baseline_origin;
let mut azglyphs = ~[];
vec::reserve(&mut azglyphs, range.length());
azglyphs.reserve(range.length());

for run.iter_slices_for_range(range) |glyphs, _offset, slice_range| {
for glyphs.iter_glyphs_for_char_range(slice_range) |_i, glyph| {
@@ -433,7 +433,7 @@ impl Font {
let mut advance = Au(0);
for run.iter_slices_for_range(range) |glyphs, _offset, slice_range| {
for glyphs.iter_glyphs_for_char_range(slice_range) |_i, glyph| {
advance += glyph.advance_();
advance = advance + glyph.advance_();
}
}
RunMetrics::new(advance, self.metrics.ascent, self.metrics.descent)
@@ -445,7 +445,7 @@ impl Font {
-> RunMetrics {
let mut advance = Au(0);
for glyphs.iter_glyphs_for_char_range(slice_range) |_i, glyph| {
advance += glyph.advance_();
advance = advance + glyph.advance_();
}
RunMetrics::new(advance, self.metrics.ascent, self.metrics.descent)
}
@@ -126,7 +126,7 @@ impl FontFamily {
// TODO(Issue #190): if not in the fast path above, do
// expensive matching of weights, etc.
let this: &mut FontFamily = self; // FIXME: borrow checker workaround
for this.entries.each |entry| {
for this.entries.iter().advance |entry| {
if (style.weight.is_bold() == entry.is_bold()) &&
(style.italic == entry.is_italic()) {

@@ -28,7 +28,6 @@ use freetype::tt_os2::TT_OS2;
use std::cast;
use std::ptr;
use std::str;
use std::vec;

fn float_to_fixed_ft(f: float) -> i32 {
float_to_fixed(6, f)
@@ -63,7 +62,7 @@ pub struct FontHandle {

#[unsafe_destructor]
impl Drop for FontHandle {
fn finalize(&self) {
fn drop(&self) {
assert!(self.face.is_not_null());
unsafe {
if !FT_Done_Face(self.face).succeeded() {
@@ -81,7 +80,7 @@ impl FontHandleMethods for FontHandle {
let ft_ctx: FT_Library = fctx.ctx.ctx;
if ft_ctx.is_null() { return Err(()); }

let face_result = do vec::as_imm_buf(buf) |bytes: *u8, len: uint| {
let face_result = do buf.as_imm_buf |bytes: *u8, len: uint| {
create_face_from_buffer(ft_ctx, bytes, len, style.pt_size)
};

@@ -17,7 +17,7 @@ struct FreeTypeLibraryHandle {
}

impl Drop for FreeTypeLibraryHandle {
fn finalize(&self) {
fn drop(&self) {
assert!(self.ctx.is_not_null());
unsafe {
FT_Done_FreeType(self.ctx);
@@ -139,7 +139,7 @@ struct AutoPattern {
}

impl Drop for AutoPattern {
fn finalize(&self) {
fn drop(&self) {
unsafe {
FcPatternDestroy(self.pattern);
}
@@ -29,15 +29,14 @@ use core_text::font_descriptor::{kCTFontDefaultOrientation};
use core_text;

use std::ptr;
use std::vec;

pub struct FontTable {
data: CFData,
}

// Noncopyable.
impl Drop for FontTable {
fn finalize(&self) {}
fn drop(&self) {}
}

impl FontTable {
@@ -80,9 +79,9 @@ impl FontHandle {
impl FontHandleMethods for FontHandle {
fn new_from_buffer(_: &FontContextHandle, buf: ~[u8], style: &SpecifiedFontStyle)
-> Result<FontHandle, ()> {
let fontprov : CGDataProvider = vec::as_imm_buf(buf, |cbuf, len| {
let fontprov : CGDataProvider = do buf.as_imm_buf |cbuf, len| {
core_graphics::data_provider::new_from_buffer(cbuf, len)
});
};

let cgfont = core_graphics::font::create_with_data_provider(&fontprov);
let ctfont = core_text::font::new_from_CGFont(&cgfont, style.pt_size);
@@ -75,7 +75,7 @@ priv struct RenderTask<C> {
last_paint_msg: Option<(arc::ARC<LayerBufferSet>, Size2D<uint>)>,
}

impl<C: RenderListener + Owned> RenderTask<C> {
impl<C: RenderListener + Send> RenderTask<C> {
pub fn create(id: uint,
port: Port<Msg>,
compositor: C,
@@ -347,7 +347,7 @@ impl<'self> DetailedGlyphStore {
// FIXME: Is this right? --pcwalton
// TODO: should fix this somewhere else
if count == 0 {
return vec::slice(self.detail_buffer, 0, 0);
return self.detail_buffer.slice(0, 0);
}

assert!((count as uint) <= self.detail_buffer.len());
@@ -365,7 +365,7 @@ impl<'self> DetailedGlyphStore {
Some(i) => {
assert!(i + (count as uint) <= self.detail_buffer.len());
// return a slice into the buffer
vec::slice(self.detail_buffer, i, i + count as uint)
self.detail_buffer.slice(i, i + count as uint)
}
}
}
@@ -635,17 +635,19 @@ impl<'self> GlyphStore {
}

for range.eachi |i| {
if !self.iter_glyphs_for_char_index(i, callback) {
// FIXME: Work around rust#2202. We should be able to pass the callback directly.
if !self.iter_glyphs_for_char_index(i, |a, b| callback(a, b)) {
break
}
}

true
}

pub fn iter_all_glyphs(&'self self, cb: &fn(uint, &GlyphInfo<'self>) -> bool) -> bool {
pub fn iter_all_glyphs(&'self self, callback: &fn(uint, &GlyphInfo<'self>) -> bool) -> bool {
for uint::range(0, self.entry_buffer.len()) |i| {
if !self.iter_glyphs_for_char_index(i, cb) {
// FIXME: Work around rust#2202. We should be able to pass the callback directly.
if !self.iter_glyphs_for_char_index(i, |a, b| callback(a, b)) {
break;
}
}
@@ -118,7 +118,7 @@ impl ShapedGlyphData {
} else {
// adjust the pen..
if y_advance > Au(0) {
*y_pos -= y_advance;
*y_pos = *y_pos - y_advance;
}

Some(Point2D(x_offset, *y_pos - y_offset))
@@ -143,7 +143,7 @@ pub struct Shaper {

#[unsafe_destructor]
impl Drop for Shaper {
fn finalize(&self) {
fn drop(&self) {
unsafe {
assert!(self.hb_face.is_not_null());
hb_face_destroy(self.hb_face);
@@ -123,7 +123,7 @@ impl<'self> TextRun {
}

pub fn char_len(&self) -> uint {
do self.glyphs.foldl(0u) |len, slice_glyphs| {
do self.glyphs.iter().fold(0u) |len, slice_glyphs| {
len + slice_glyphs.get().char_len()
}
}
@@ -161,7 +161,7 @@ impl<'self> TextRun {
f: &fn(&GlyphStore, uint, &Range) -> bool)
-> bool {
let mut offset = 0;
for self.glyphs.each |slice_glyphs| {
for self.glyphs.iter().advance |slice_glyphs| {
// Determine the range of this slice that we need.
let slice_range = Range::new(offset, slice_glyphs.get().char_len());
let mut char_range = range.intersect(&slice_range);
@@ -205,7 +205,7 @@ impl Constellation {
}

ExitMsg(sender) => {
for self.pipelines.each |_, pipeline| {
for self.pipelines.iter().advance |(_, pipeline)| {
pipeline.exit();
}
self.image_cache_task.exit();
@@ -240,7 +240,7 @@ impl Constellation {
// Don't navigate on Navigate type, because that is handled by forward/back
match pipeline.navigation_type.get() {
constellation_msg::Load => {
let evicted = self.navigation_context.navigate(id);
let _evicted = self.navigation_context.navigate(id);
/* FIXME(tkuehn): the following code causes a segfault
for evicted.iter().advance |id| {
self.pipelines.get(id).exit();
@@ -254,9 +254,9 @@ impl BlockFlowData {
for self.box.iter().advance |&box| {
do box.with_model |model| {
top_offset = model.margin.top + model.border.top + model.padding.top;
cur_y += top_offset;
cur_y = cur_y + top_offset;
left_offset = model.offset();
}
};
}

// TODO(eatkinson): the translation here is probably
@@ -284,8 +284,8 @@ impl BlockFlowData {
for BlockFlow(self).each_child |kid| {
do kid.with_mut_base |child_node| {
child_node.position.origin.y = cur_y;
cur_y += child_node.position.size.height;
}
cur_y = cur_y + child_node.position.size.height;
};
}

let height = if self.is_root {
@@ -304,7 +304,7 @@ impl BlockFlowData {
base.model.border.top + base.model.border.bottom;
base.position.size.height = height + noncontent_height;

noncontent_height += base.model.margin.top + base.model.margin.bottom;
noncontent_height = noncontent_height + base.model.margin.top + base.model.margin.bottom;
}
});

@@ -57,6 +57,7 @@ use extra::net::url::Url;
/// A box's type influences how its styles are interpreted during layout. For example, replaced
/// content such as images are resized differently from tables, text, or other content. Different
/// types of boxes may also contain custom data; for example, text boxes contain text.
#[deriving(Clone)]
pub enum RenderBox {
GenericRenderBoxClass(@mut RenderBoxBase),
ImageRenderBoxClass(@mut ImageRenderBox),
@@ -308,7 +309,7 @@ impl RenderBox {
left_range.shift_by(slice_range.length() as int);
} else {
debug!("split_to_width: case=enlarging span");
remaining_width -= advance;
remaining_width = remaining_width - advance;
left_range.extend_by(slice_range.length() as int);
}
} else { // The advance is more than the remaining width.
@@ -840,10 +841,10 @@ impl RenderBox {
pub fn dump_indent(&self, indent: uint) {
let mut string = ~"";
for uint::range(0u, indent) |_i| {
string += " ";
string.push_str(" ");
}

string += self.debug_str();
string.push_str(self.debug_str());
debug!("%s", string);
}

@@ -863,4 +864,61 @@ impl RenderBox {

fmt!("box b%?: %s", self.id(), representation)
}

//
// Painting
//

/// Adds the display items necessary to paint the borders of this render box to a display list
/// if necessary.
pub fn paint_borders_if_applicable<E:ExtraDisplayListData>(&self,
list: &Cell<DisplayList<E>>,
abs_bounds: &Rect<Au>) {
// Fast path.
let border = do self.with_base |base| {
base.model.border
};
if border.is_zero() {
return
}

// Are all the widths equal?
//
// FIXME(pcwalton): Obviously this is wrong.
let borders = [ border.top, border.right, border.bottom ];
if borders.iter().all(|a| *a == border.left) {
let border_width = border.top;
let bounds = Rect {
origin: Point2D {
x: abs_bounds.origin.x + border_width.scale_by(0.5),
y: abs_bounds.origin.y + border_width.scale_by(0.5),
},
size: Size2D {
width: abs_bounds.size.width - border_width,
height: abs_bounds.size.height - border_width
}
};

let top_color = self.style().border_top_color();
let color = top_color.to_gfx_color(); // FIXME

// Append the border to the display list.
do list.with_mut_ref |list| {
let border_display_item = ~BorderDisplayItem {
base: BaseDisplayItem {
bounds: bounds,
extra: ExtraDisplayListData::new(*self),
},
width: border_width,
color: color,
};

list.append_item(BorderDisplayItemClass(border_display_item))
}
} else {
warn!("ignoring unimplemented border widths");
}
}

}

@@ -164,15 +164,15 @@ impl FloatFlowData {
for self.box.iter().advance |&box| {
do box.with_model |model| {
top_offset = model.margin.top + model.border.top + model.padding.top;
cur_y += top_offset;
cur_y = cur_y + top_offset;
}
}

for FloatFlow(self).each_child |kid| {
do kid.with_mut_base |child_node| {
child_node.position.origin.y = cur_y;
cur_y += child_node.position.size.height;
}
cur_y = cur_y + child_node.position.size.height;
};
}

let mut height = cur_y - top_offset;
@@ -187,7 +187,7 @@ impl FloatFlowData {
base.model.border.top + base.model.border.bottom;
base.position.size.height = height + noncontent_height;

noncontent_height += base.model.margin.top + base.model.margin.bottom;
noncontent_height = noncontent_height + base.model.margin.top + base.model.margin.bottom;
}
});

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.