Make usage of simd in gfx optional

This commit is contained in:
Simon Sapin 2017-10-12 00:59:37 +02:00
parent 5e72173e8c
commit d9a311963f
4 changed files with 12 additions and 4 deletions

View file

@ -5,7 +5,7 @@
use app_units::Au;
use euclid::Point2D;
use range::{self, EachIndex, Range, RangeIndex};
#[cfg(any(target_feature = "sse2", target_feature = "neon"))]
#[cfg(all(feature = "unstable", any(target_feature = "sse2", target_feature = "neon")))]
use simd::u32x4;
use std::{fmt, mem, u16};
use std::cmp::{Ordering, PartialOrd};
@ -74,6 +74,7 @@ pub type GlyphId = u32;
// TODO: make this more type-safe.
const FLAG_CHAR_IS_SPACE: u32 = 0x40000000;
#[cfg(feature = "unstable")]
#[cfg(any(target_feature = "sse2", target_feature = "neon"))]
const FLAG_CHAR_IS_SPACE_SHIFT: u32 = 30;
const FLAG_IS_SIMPLE_GLYPH: u32 = 0x80000000;
@ -591,6 +592,7 @@ impl<'a> GlyphStore {
}
#[inline]
#[cfg(feature = "unstable")]
#[cfg(any(target_feature = "sse2", target_feature = "neon"))]
fn advance_for_byte_range_simple_glyphs(&self, range: &Range<ByteIndex>, extra_word_spacing: Au) -> Au {
let advance_mask = u32x4::splat(GLYPH_ADVANCE_MASK);
@ -634,13 +636,14 @@ impl<'a> GlyphStore {
/// When SIMD isn't available, fallback to the slow path.
#[inline]
#[cfg(not(any(target_feature = "sse2", target_feature = "neon")))]
#[cfg(not(all(feature = "unstable", any(target_feature = "sse2", target_feature = "neon"))))]
fn advance_for_byte_range_simple_glyphs(&self, range: &Range<ByteIndex>, extra_word_spacing: Au) -> Au {
self.advance_for_byte_range_slow_path(range, extra_word_spacing)
}
/// Used for SIMD.
#[inline]
#[cfg(feature = "unstable")]
#[cfg(any(target_feature = "sse2", target_feature = "neon"))]
#[allow(unsafe_code)]
fn transmute_entry_buffer_to_u32_buffer(&self) -> &[u32] {