aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2015-08-31 12:20:49 -0600
committerbors-servo <metajack+bors@gmail.com>2015-08-31 12:20:49 -0600
commit108251bece897b96a8b205df22e7d3e790979331 (patch)
treeb2828bbacf1191b4c05ec7a67c65720b0936792e
parentaee011a524c096d7535bb95a1e76a1586784aeb8 (diff)
parent5f126ff301152785add9efb512badd70388d3806 (diff)
downloadservo-108251bece897b96a8b205df22e7d3e790979331.tar.gz
servo-108251bece897b96a8b205df22e7d3e790979331.zip
Auto merge of #7434 - mbrubeck:drop-table, r=pcwalton
Remove unused font shaping code and flags r? @pcwalton <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7434) <!-- Reviewable:end -->
-rw-r--r--components/gfx/platform/macos/font.rs5
-rw-r--r--components/gfx/text/glyph.rs177
2 files changed, 12 insertions, 170 deletions
diff --git a/components/gfx/platform/macos/font.rs b/components/gfx/platform/macos/font.rs
index b96f217e0c9..eb33e326230 100644
--- a/components/gfx/platform/macos/font.rs
+++ b/components/gfx/platform/macos/font.rs
@@ -33,11 +33,6 @@ pub struct FontTable {
data: CFData,
}
-// Noncopyable.
-impl Drop for FontTable {
- fn drop(&mut self) {}
-}
-
impl FontTable {
pub fn wrap(data: CFData) -> FontTable {
FontTable { data: data }
diff --git a/components/gfx/text/glyph.rs b/components/gfx/text/glyph.rs
index 29918e5d2d9..d27128014b5 100644
--- a/components/gfx/text/glyph.rs
+++ b/components/gfx/text/glyph.rs
@@ -58,17 +58,7 @@ impl GlyphEntry {
starts_ligature,
glyph_count);
- let mut val = FLAG_NOT_MISSING;
-
- if !starts_cluster {
- val |= FLAG_NOT_CLUSTER_START;
- }
- if !starts_ligature {
- val |= FLAG_NOT_LIGATURE_GROUP_START;
- }
- val |= (glyph_count as u32) << GLYPH_COUNT_SHIFT;
-
- GlyphEntry::new(val)
+ GlyphEntry::new(glyph_count as u32)
}
/// Create a GlyphEntry for the case where glyphs couldn't be found for the specified
@@ -76,55 +66,22 @@ impl GlyphEntry {
fn missing(glyph_count: usize) -> GlyphEntry {
assert!(glyph_count <= u16::MAX as usize);
- GlyphEntry::new((glyph_count as u32) << GLYPH_COUNT_SHIFT)
+ GlyphEntry::new(glyph_count as u32)
}
}
/// The id of a particular glyph within a font
pub type GlyphId = u32;
-// TODO: unify with bit flags?
-#[derive(PartialEq, Copy, Clone)]
-pub enum BreakType {
- None,
- Normal,
- Hyphen,
-}
-
-static BREAK_TYPE_NONE: u8 = 0x0;
-static BREAK_TYPE_NORMAL: u8 = 0x1;
-static BREAK_TYPE_HYPHEN: u8 = 0x2;
-
-fn break_flag_to_enum(flag: u8) -> BreakType {
- if (flag & BREAK_TYPE_NORMAL) != 0 {
- BreakType::Normal
- } else if (flag & BREAK_TYPE_HYPHEN) != 0 {
- BreakType::Hyphen
- } else {
- BreakType::None
- }
-}
-
-fn break_enum_to_flag(e: BreakType) -> u8 {
- match e {
- BreakType::None => BREAK_TYPE_NONE,
- BreakType::Normal => BREAK_TYPE_NORMAL,
- BreakType::Hyphen => BREAK_TYPE_HYPHEN,
- }
-}
-
// TODO: make this more type-safe.
-static FLAG_CHAR_IS_SPACE: u32 = 0x10000000;
-// These two bits store some BREAK_TYPE_* flags
-static FLAG_CAN_BREAK_MASK: u32 = 0x60000000;
-static FLAG_CAN_BREAK_SHIFT: u32 = 29;
-static FLAG_IS_SIMPLE_GLYPH: u32 = 0x80000000;
+const FLAG_CHAR_IS_SPACE: u32 = 0x40000000;
+const FLAG_IS_SIMPLE_GLYPH: u32 = 0x80000000;
// glyph advance; in Au's.
-static GLYPH_ADVANCE_MASK: u32 = 0x0FFF0000;
-static GLYPH_ADVANCE_SHIFT: u32 = 16;
-static GLYPH_ID_MASK: u32 = 0x0000FFFF;
+const GLYPH_ADVANCE_MASK: u32 = 0x3FFF0000;
+const GLYPH_ADVANCE_SHIFT: u32 = 16;
+const GLYPH_ID_MASK: u32 = 0x0000FFFF;
// Non-simple glyphs (more than one glyph per char; missing glyph,
// newline, tab, large advance, or nonzero x/y offsets) may have one
@@ -132,21 +89,8 @@ static GLYPH_ID_MASK: u32 = 0x0000FFFF;
// side array so that there is a 1:1 mapping of GlyphEntry to
// unicode char.
-// The number of detailed glyphs for this char. If the char couldn't
-// be mapped to a glyph (!FLAG_NOT_MISSING), then this actually holds
-// the UTF8 code point instead.
-static GLYPH_COUNT_MASK: u32 = 0x00FFFF00;
-static GLYPH_COUNT_SHIFT: u32 = 8;
-// N.B. following Gecko, these are all inverted so that a lot of
-// missing chars can be memset with zeros in one fell swoop.
-static FLAG_NOT_MISSING: u32 = 0x00000001;
-static FLAG_NOT_CLUSTER_START: u32 = 0x00000002;
-static FLAG_NOT_LIGATURE_GROUP_START: u32 = 0x00000004;
-
-static FLAG_CHAR_IS_TAB: u32 = 0x00000008;
-static FLAG_CHAR_IS_NEWLINE: u32 = 0x00000010;
-//static FLAG_CHAR_IS_LOW_SURROGATE: u32 = 0x00000020;
-//static CHAR_IDENTITY_FLAGS_MASK: u32 = 0x00000038;
+// The number of detailed glyphs for this char.
+const GLYPH_COUNT_MASK: u32 = 0x0000FFFF;
fn is_simple_glyph_id(id: GlyphId) -> bool {
((id as u32) & GLYPH_ID_MASK) == id
@@ -164,7 +108,6 @@ type DetailedGlyphCount = u16;
// Getters and setters for GlyphEntry. Setter methods are functional,
// because GlyphEntry is immutable and only a u32 in size.
impl GlyphEntry {
- // getter methods
#[inline(always)]
fn advance(&self) -> Au {
Au(((self.value & GLYPH_ADVANCE_MASK) >> GLYPH_ADVANCE_SHIFT) as i32)
@@ -174,62 +117,20 @@ impl GlyphEntry {
self.value & GLYPH_ID_MASK
}
- fn is_ligature_start(&self) -> bool {
- self.has_flag(!FLAG_NOT_LIGATURE_GROUP_START)
- }
-
- fn is_cluster_start(&self) -> bool {
- self.has_flag(!FLAG_NOT_CLUSTER_START)
- }
-
- // True if original char was normal (U+0020) space. Other chars may
- // map to space glyph, but this does not account for them.
+ /// True if original char was normal (U+0020) space. Other chars may
+ /// map to space glyph, but this does not account for them.
fn char_is_space(&self) -> bool {
self.has_flag(FLAG_CHAR_IS_SPACE)
}
- fn char_is_tab(&self) -> bool {
- !self.is_simple() && self.has_flag(FLAG_CHAR_IS_TAB)
- }
-
- fn char_is_newline(&self) -> bool {
- !self.is_simple() && self.has_flag(FLAG_CHAR_IS_NEWLINE)
- }
-
- fn can_break_before(&self) -> BreakType {
- let flag = ((self.value & FLAG_CAN_BREAK_MASK) >> FLAG_CAN_BREAK_SHIFT) as u8;
- break_flag_to_enum(flag)
- }
-
- // setter methods
#[inline(always)]
fn set_char_is_space(&self) -> GlyphEntry {
GlyphEntry::new(self.value | FLAG_CHAR_IS_SPACE)
}
- #[inline(always)]
- fn set_char_is_tab(&self) -> GlyphEntry {
- assert!(!self.is_simple());
- GlyphEntry::new(self.value | FLAG_CHAR_IS_TAB)
- }
-
- #[inline(always)]
- fn set_char_is_newline(&self) -> GlyphEntry {
- assert!(!self.is_simple());
- GlyphEntry::new(self.value | FLAG_CHAR_IS_NEWLINE)
- }
-
- #[inline(always)]
- fn set_can_break_before(&self, e: BreakType) -> GlyphEntry {
- let flag = (break_enum_to_flag(e) as u32) << FLAG_CAN_BREAK_SHIFT;
- GlyphEntry::new(self.value | flag)
- }
-
- // helper methods
-
fn glyph_count(&self) -> u16 {
assert!(!self.is_simple());
- ((self.value & GLYPH_COUNT_MASK) >> GLYPH_COUNT_SHIFT) as u16
+ (self.value & GLYPH_COUNT_MASK) as u16
}
#[inline(always)]
@@ -576,9 +477,6 @@ impl<'a> GlyphStore {
}
};
- // FIXME(pcwalton): Is this necessary? I think it's a no-op.
- entry = entry.adapt_character_flags_of_entry(self.entry_buffer[i.to_usize()]);
-
if character == Some(' ') {
entry = entry.set_char_is_space()
}
@@ -647,62 +545,11 @@ impl<'a> GlyphStore {
.fold(Au(0), |advance, (_, glyph)| advance + glyph.advance())
}
- // getter methods
pub fn char_is_space(&self, i: CharIndex) -> bool {
assert!(i < self.char_len());
self.entry_buffer[i.to_usize()].char_is_space()
}
- pub fn char_is_tab(&self, i: CharIndex) -> bool {
- assert!(i < self.char_len());
- self.entry_buffer[i.to_usize()].char_is_tab()
- }
-
- pub fn char_is_newline(&self, i: CharIndex) -> bool {
- assert!(i < self.char_len());
- self.entry_buffer[i.to_usize()].char_is_newline()
- }
-
- pub fn is_ligature_start(&self, i: CharIndex) -> bool {
- assert!(i < self.char_len());
- self.entry_buffer[i.to_usize()].is_ligature_start()
- }
-
- pub fn is_cluster_start(&self, i: CharIndex) -> bool {
- assert!(i < self.char_len());
- self.entry_buffer[i.to_usize()].is_cluster_start()
- }
-
- pub fn can_break_before(&self, i: CharIndex) -> BreakType {
- assert!(i < self.char_len());
- self.entry_buffer[i.to_usize()].can_break_before()
- }
-
- // setter methods
- pub fn set_char_is_space(&mut self, i: CharIndex) {
- assert!(i < self.char_len());
- let entry = self.entry_buffer[i.to_usize()];
- self.entry_buffer[i.to_usize()] = entry.set_char_is_space();
- }
-
- pub fn set_char_is_tab(&mut self, i: CharIndex) {
- assert!(i < self.char_len());
- let entry = self.entry_buffer[i.to_usize()];
- self.entry_buffer[i.to_usize()] = entry.set_char_is_tab();
- }
-
- pub fn set_char_is_newline(&mut self, i: CharIndex) {
- assert!(i < self.char_len());
- let entry = self.entry_buffer[i.to_usize()];
- self.entry_buffer[i.to_usize()] = entry.set_char_is_newline();
- }
-
- pub fn set_can_break_before(&mut self, i: CharIndex, t: BreakType) {
- assert!(i < self.char_len());
- let entry = self.entry_buffer[i.to_usize()];
- self.entry_buffer[i.to_usize()] = entry.set_can_break_before(t);
- }
-
pub fn space_count_in_range(&self, range: &Range<CharIndex>) -> u32 {
let mut spaces = 0;
for index in range.each_index() {