mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Use Vec for GlyphStore::entry_buffer.
This commit is contained in:
parent
bba4bef106
commit
1695d16384
1 changed files with 24 additions and 24 deletions
|
@ -467,7 +467,7 @@ pub enum GlyphInfo<'a> {
|
||||||
impl<'a> GlyphInfo<'a> {
|
impl<'a> GlyphInfo<'a> {
|
||||||
pub fn index(self) -> GlyphIndex {
|
pub fn index(self) -> GlyphIndex {
|
||||||
match self {
|
match self {
|
||||||
SimpleGlyphInfo(store, entry_i) => store.entry_buffer[entry_i].index(),
|
SimpleGlyphInfo(store, entry_i) => store.entry_buffer.get(entry_i).index(),
|
||||||
DetailGlyphInfo(store, entry_i, detail_j) => {
|
DetailGlyphInfo(store, entry_i, detail_j) => {
|
||||||
store.detail_store.get_detailed_glyph_with_index(entry_i, detail_j).index
|
store.detail_store.get_detailed_glyph_with_index(entry_i, detail_j).index
|
||||||
}
|
}
|
||||||
|
@ -478,7 +478,7 @@ impl<'a> GlyphInfo<'a> {
|
||||||
// FIXME: Resolution conflicts with IteratorUtil trait so adding trailing _
|
// FIXME: Resolution conflicts with IteratorUtil trait so adding trailing _
|
||||||
pub fn advance(self) -> Au {
|
pub fn advance(self) -> Au {
|
||||||
match self {
|
match self {
|
||||||
SimpleGlyphInfo(store, entry_i) => store.entry_buffer[entry_i].advance(),
|
SimpleGlyphInfo(store, entry_i) => store.entry_buffer.get(entry_i).advance(),
|
||||||
DetailGlyphInfo(store, entry_i, detail_j) => {
|
DetailGlyphInfo(store, entry_i, detail_j) => {
|
||||||
store.detail_store.get_detailed_glyph_with_index(entry_i, detail_j).advance
|
store.detail_store.get_detailed_glyph_with_index(entry_i, detail_j).advance
|
||||||
}
|
}
|
||||||
|
@ -499,7 +499,7 @@ impl<'a> GlyphInfo<'a> {
|
||||||
pub struct GlyphStore {
|
pub struct GlyphStore {
|
||||||
// TODO(pcwalton): Allocation of this buffer is expensive. Consider a small-vector
|
// TODO(pcwalton): Allocation of this buffer is expensive. Consider a small-vector
|
||||||
// optimization.
|
// optimization.
|
||||||
entry_buffer: ~[GlyphEntry],
|
entry_buffer: Vec<GlyphEntry>,
|
||||||
|
|
||||||
detail_store: DetailedGlyphStore,
|
detail_store: DetailedGlyphStore,
|
||||||
|
|
||||||
|
@ -513,7 +513,7 @@ impl<'a> GlyphStore {
|
||||||
assert!(length > 0);
|
assert!(length > 0);
|
||||||
|
|
||||||
GlyphStore {
|
GlyphStore {
|
||||||
entry_buffer: slice::from_elem(length, GlyphEntry::initial()),
|
entry_buffer: Vec::from_elem(length, GlyphEntry::initial()),
|
||||||
detail_store: DetailedGlyphStore::new(),
|
detail_store: DetailedGlyphStore::new(),
|
||||||
is_whitespace: is_whitespace,
|
is_whitespace: is_whitespace,
|
||||||
}
|
}
|
||||||
|
@ -550,9 +550,9 @@ impl<'a> GlyphStore {
|
||||||
self.detail_store.add_detailed_glyphs_for_entry(i, glyph);
|
self.detail_store.add_detailed_glyphs_for_entry(i, glyph);
|
||||||
GlyphEntry::complex(data.cluster_start, data.ligature_start, 1)
|
GlyphEntry::complex(data.cluster_start, data.ligature_start, 1)
|
||||||
}
|
}
|
||||||
}.adapt_character_flags_of_entry(self.entry_buffer[i]);
|
}.adapt_character_flags_of_entry(*self.entry_buffer.get(i));
|
||||||
|
|
||||||
self.entry_buffer[i] = entry;
|
*self.entry_buffer.get_mut(i) = entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_glyphs_for_char_index(&mut self, i: uint, data_for_glyphs: &[GlyphData]) {
|
pub fn add_glyphs_for_char_index(&mut self, i: uint, data_for_glyphs: &[GlyphData]) {
|
||||||
|
@ -576,11 +576,11 @@ impl<'a> GlyphStore {
|
||||||
first_glyph_data.ligature_start,
|
first_glyph_data.ligature_start,
|
||||||
glyph_count)
|
glyph_count)
|
||||||
}
|
}
|
||||||
}.adapt_character_flags_of_entry(self.entry_buffer[i]);
|
}.adapt_character_flags_of_entry(*self.entry_buffer.get(i));
|
||||||
|
|
||||||
debug!("Adding multiple glyphs[idx={:u}, count={:u}]: {:?}", i, glyph_count, entry);
|
debug!("Adding multiple glyphs[idx={:u}, count={:u}]: {:?}", i, glyph_count, entry);
|
||||||
|
|
||||||
self.entry_buffer[i] = entry;
|
*self.entry_buffer.get_mut(i) = entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
// used when a character index has no associated glyph---for example, a ligature continuation.
|
// used when a character index has no associated glyph---for example, a ligature continuation.
|
||||||
|
@ -590,7 +590,7 @@ impl<'a> GlyphStore {
|
||||||
let entry = GlyphEntry::complex(cluster_start, ligature_start, 0);
|
let entry = GlyphEntry::complex(cluster_start, ligature_start, 0);
|
||||||
debug!("adding spacer for chracter without associated glyph[idx={:u}]", i);
|
debug!("adding spacer for chracter without associated glyph[idx={:u}]", i);
|
||||||
|
|
||||||
self.entry_buffer[i] = entry;
|
*self.entry_buffer.get_mut(i) = entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iter_glyphs_for_char_index(&'a self, i: uint) -> GlyphIterator<'a> {
|
pub fn iter_glyphs_for_char_index(&'a self, i: uint) -> GlyphIterator<'a> {
|
||||||
|
@ -617,57 +617,57 @@ impl<'a> GlyphStore {
|
||||||
// getter methods
|
// getter methods
|
||||||
pub fn char_is_space(&self, i: uint) -> bool {
|
pub fn char_is_space(&self, i: uint) -> bool {
|
||||||
assert!(i < self.entry_buffer.len());
|
assert!(i < self.entry_buffer.len());
|
||||||
self.entry_buffer[i].char_is_space()
|
self.entry_buffer.get(i).char_is_space()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn char_is_tab(&self, i: uint) -> bool {
|
pub fn char_is_tab(&self, i: uint) -> bool {
|
||||||
assert!(i < self.entry_buffer.len());
|
assert!(i < self.entry_buffer.len());
|
||||||
self.entry_buffer[i].char_is_tab()
|
self.entry_buffer.get(i).char_is_tab()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn char_is_newline(&self, i: uint) -> bool {
|
pub fn char_is_newline(&self, i: uint) -> bool {
|
||||||
assert!(i < self.entry_buffer.len());
|
assert!(i < self.entry_buffer.len());
|
||||||
self.entry_buffer[i].char_is_newline()
|
self.entry_buffer.get(i).char_is_newline()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_ligature_start(&self, i: uint) -> bool {
|
pub fn is_ligature_start(&self, i: uint) -> bool {
|
||||||
assert!(i < self.entry_buffer.len());
|
assert!(i < self.entry_buffer.len());
|
||||||
self.entry_buffer[i].is_ligature_start()
|
self.entry_buffer.get(i).is_ligature_start()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_cluster_start(&self, i: uint) -> bool {
|
pub fn is_cluster_start(&self, i: uint) -> bool {
|
||||||
assert!(i < self.entry_buffer.len());
|
assert!(i < self.entry_buffer.len());
|
||||||
self.entry_buffer[i].is_cluster_start()
|
self.entry_buffer.get(i).is_cluster_start()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn can_break_before(&self, i: uint) -> BreakType {
|
pub fn can_break_before(&self, i: uint) -> BreakType {
|
||||||
assert!(i < self.entry_buffer.len());
|
assert!(i < self.entry_buffer.len());
|
||||||
self.entry_buffer[i].can_break_before()
|
self.entry_buffer.get(i).can_break_before()
|
||||||
}
|
}
|
||||||
|
|
||||||
// setter methods
|
// setter methods
|
||||||
pub fn set_char_is_space(&mut self, i: uint) {
|
pub fn set_char_is_space(&mut self, i: uint) {
|
||||||
assert!(i < self.entry_buffer.len());
|
assert!(i < self.entry_buffer.len());
|
||||||
let entry = self.entry_buffer[i];
|
let entry = *self.entry_buffer.get(i);
|
||||||
self.entry_buffer[i] = entry.set_char_is_space();
|
*self.entry_buffer.get_mut(i) = entry.set_char_is_space();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_char_is_tab(&mut self, i: uint) {
|
pub fn set_char_is_tab(&mut self, i: uint) {
|
||||||
assert!(i < self.entry_buffer.len());
|
assert!(i < self.entry_buffer.len());
|
||||||
let entry = self.entry_buffer[i];
|
let entry = *self.entry_buffer.get(i);
|
||||||
self.entry_buffer[i] = entry.set_char_is_tab();
|
*self.entry_buffer.get_mut(i) = entry.set_char_is_tab();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_char_is_newline(&mut self, i: uint) {
|
pub fn set_char_is_newline(&mut self, i: uint) {
|
||||||
assert!(i < self.entry_buffer.len());
|
assert!(i < self.entry_buffer.len());
|
||||||
let entry = self.entry_buffer[i];
|
let entry = *self.entry_buffer.get(i);
|
||||||
self.entry_buffer[i] = entry.set_char_is_newline();
|
*self.entry_buffer.get_mut(i) = entry.set_char_is_newline();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_can_break_before(&mut self, i: uint, t: BreakType) {
|
pub fn set_can_break_before(&mut self, i: uint, t: BreakType) {
|
||||||
assert!(i < self.entry_buffer.len());
|
assert!(i < self.entry_buffer.len());
|
||||||
let entry = self.entry_buffer[i];
|
let entry = *self.entry_buffer.get(i);
|
||||||
self.entry_buffer[i] = entry.set_can_break_before(t);
|
*self.entry_buffer.get_mut(i) = entry.set_can_break_before(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -722,7 +722,7 @@ impl<'a> Iterator<(uint, GlyphInfo<'a>)> for GlyphIterator<'a> {
|
||||||
Some(i) => {
|
Some(i) => {
|
||||||
self.char_index = i;
|
self.char_index = i;
|
||||||
assert!(i < self.store.entry_buffer.len());
|
assert!(i < self.store.entry_buffer.len());
|
||||||
let entry = &self.store.entry_buffer[i];
|
let entry = self.store.entry_buffer.get(i);
|
||||||
if entry.is_simple() {
|
if entry.is_simple() {
|
||||||
Some((self.char_index, SimpleGlyphInfo(self.store, i)))
|
Some((self.char_index, SimpleGlyphInfo(self.store, i)))
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue