mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Some hacks to make text line breaking a bit faster.
This commit is contained in:
parent
7bbff6154c
commit
84216f838f
2 changed files with 12 additions and 7 deletions
|
@ -371,7 +371,7 @@ pub impl Font : FontMethods {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn measure_text(run: &TextRun, range: Range) -> RunMetrics {
|
fn measure_text(run: &TextRun, range: Range) -> RunMetrics {
|
||||||
assert range.is_valid_for_string(run.text);
|
//assert range.is_valid_for_string(run.text);
|
||||||
|
|
||||||
debug!("measuring text range '%s'", run.text.substr(range.begin(), range.length()));
|
debug!("measuring text range '%s'", run.text.substr(range.begin(), range.length()));
|
||||||
|
|
||||||
|
@ -389,7 +389,7 @@ pub impl Font : FontMethods {
|
||||||
// looking at actual glyph extents can yield a tighter box.
|
// looking at actual glyph extents can yield a tighter box.
|
||||||
|
|
||||||
let metrics = RunMetrics { advance_width: advance,
|
let metrics = RunMetrics { advance_width: advance,
|
||||||
bounding_box: bounds,
|
bounding_box: move bounds,
|
||||||
ascent: self.metrics.ascent,
|
ascent: self.metrics.ascent,
|
||||||
descent: self.metrics.descent,
|
descent: self.metrics.descent,
|
||||||
};
|
};
|
||||||
|
|
|
@ -154,18 +154,19 @@ pure fn MissingGlyphsEntry(glyphCount: uint) -> GlyphEntry {
|
||||||
// because GlyphEntry is immutable and only a u32 in size.
|
// because GlyphEntry is immutable and only a u32 in size.
|
||||||
impl GlyphEntry {
|
impl GlyphEntry {
|
||||||
// getter methods
|
// getter methods
|
||||||
|
#[inline(always)]
|
||||||
pure fn advance() -> Au {
|
pure fn advance() -> Au {
|
||||||
assert self.is_simple();
|
//assert self.is_simple();
|
||||||
from_int(((self.value & GLYPH_ADVANCE_MASK) >> GLYPH_ADVANCE_SHIFT) as int)
|
from_int(((self.value & GLYPH_ADVANCE_MASK) >> GLYPH_ADVANCE_SHIFT) as int)
|
||||||
}
|
}
|
||||||
|
|
||||||
pure fn index() -> GlyphIndex {
|
pure fn index() -> GlyphIndex {
|
||||||
assert self.is_simple();
|
//assert self.is_simple();
|
||||||
self.value & GLYPH_ID_MASK
|
self.value & GLYPH_ID_MASK
|
||||||
}
|
}
|
||||||
|
|
||||||
pure fn offset() -> Point2D<Au> {
|
pure fn offset() -> Point2D<Au> {
|
||||||
assert self.is_simple();
|
//assert self.is_simple();
|
||||||
Point2D(Au(0), Au(0))
|
Point2D(Au(0), Au(0))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,6 +207,7 @@ impl GlyphEntry {
|
||||||
GlyphEntry(self.value | FLAG_CHAR_IS_TAB)
|
GlyphEntry(self.value | FLAG_CHAR_IS_TAB)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
pure fn set_char_is_newline() -> GlyphEntry {
|
pure fn set_char_is_newline() -> GlyphEntry {
|
||||||
assert !self.is_simple();
|
assert !self.is_simple();
|
||||||
GlyphEntry(self.value | FLAG_CHAR_IS_NEWLINE)
|
GlyphEntry(self.value | FLAG_CHAR_IS_NEWLINE)
|
||||||
|
@ -230,10 +232,12 @@ impl GlyphEntry {
|
||||||
((self.value & GLYPH_COUNT_MASK) >> GLYPH_COUNT_SHIFT) as u16
|
((self.value & GLYPH_COUNT_MASK) >> GLYPH_COUNT_SHIFT) as u16
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
pure fn is_simple() -> bool {
|
pure fn is_simple() -> bool {
|
||||||
self.has_flag(FLAG_IS_SIMPLE_GLYPH)
|
self.has_flag(FLAG_IS_SIMPLE_GLYPH)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
/*priv*/ pure fn has_flag(flag: u32) -> bool {
|
/*priv*/ pure fn has_flag(flag: u32) -> bool {
|
||||||
(self.value & flag) != 0
|
(self.value & flag) != 0
|
||||||
}
|
}
|
||||||
|
@ -428,6 +432,7 @@ impl GlyphInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
fn advance() -> Au {
|
fn advance() -> Au {
|
||||||
match self {
|
match self {
|
||||||
SimpleGlyphInfo(store, entry_i) => store.entry_buffer[entry_i].advance(),
|
SimpleGlyphInfo(store, entry_i) => store.entry_buffer[entry_i].advance(),
|
||||||
|
@ -534,13 +539,13 @@ impl GlyphStore {
|
||||||
match entry.is_simple() {
|
match entry.is_simple() {
|
||||||
true => {
|
true => {
|
||||||
let proxy = SimpleGlyphInfo(self, i);
|
let proxy = SimpleGlyphInfo(self, i);
|
||||||
if !cb(i, proxy) { return false; }
|
cb(i, move proxy);
|
||||||
},
|
},
|
||||||
false => {
|
false => {
|
||||||
let glyphs = self.detail_store.get_detailed_glyphs_for_entry(i, entry.glyph_count());
|
let glyphs = self.detail_store.get_detailed_glyphs_for_entry(i, entry.glyph_count());
|
||||||
for uint::range(0, glyphs.len()) |j| {
|
for uint::range(0, glyphs.len()) |j| {
|
||||||
let proxy = DetailGlyphInfo(self, i, j as u16);
|
let proxy = DetailGlyphInfo(self, i, j as u16);
|
||||||
cb(i, proxy);
|
cb(i, move proxy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue