Bug 1356057 - Add a WrGlyphInstance struct r=kats

MozReview-Commit-ID: ApIOZyS4VV7

--HG--
extra : rebase_source : cffc119aee9ddf030bc99317667805278295a5ac
extra : histedit_source : 29ce59257222377ffbadf0987ebbe85f1d736a8e
This commit is contained in:
Ryan Hunt 2017-04-12 23:28:40 -04:00
Родитель 98343720ca
Коммит 6aa2c5a2aa
3 изменённых файлов: 32 добавлений и 14 удалений

Просмотреть файл

@ -23,7 +23,6 @@ type WrBuiltDisplayListDescriptor = BuiltDisplayListDescriptor;
type WrEpoch = Epoch;
type WrExternalImageId = ExternalImageId;
type WrFontKey = FontKey;
type WrGlyphInstance = GlyphInstance;
type WrIdNamespace = IdNamespace;
type WrImageFormat = ImageFormat;
type WrImageRendering = ImageRendering;
@ -155,6 +154,7 @@ impl From<ItemRange> for WrItemRange {
}
#[repr(C)]
#[derive(Debug, Clone)]
pub struct WrPoint {
x: f32,
y: f32,
@ -234,6 +234,25 @@ impl WrColor {
}
}
#[repr(C)]
#[derive(Debug, Clone)]
pub struct WrGlyphInstance {
index: u32,
point: WrPoint,
}
impl WrGlyphInstance {
pub fn to_glyph_instance(&self) -> GlyphInstance {
GlyphInstance {
index: self.index,
point: self.point.to_point(),
}
}
pub fn to_glyph_instances(glyphs: &[WrGlyphInstance]) -> Vec<GlyphInstance> {
glyphs.iter().map(|x| x.to_glyph_instance()).collect()
}
}
#[repr(C)]
pub struct WrGradientStop {
offset: f32,
@ -1211,7 +1230,7 @@ pub extern "C" fn wr_dp_push_text(state: &mut WrState,
let glyph_slice = unsafe { slice::from_raw_parts(glyphs, glyph_count as usize) };
let mut glyph_vector = Vec::new();
glyph_vector.extend_from_slice(&glyph_slice);
glyph_vector.extend_from_slice(&WrGlyphInstance::to_glyph_instances(glyph_slice));
let colorf = ColorF::new(color.r, color.g, color.b, color.a);

Просмотреть файл

@ -78,7 +78,6 @@ void* get_proc_address_from_glcontext(void* glcontext_ptr, const char* procname)
// -----
typedef uint64_t WrExternalImageId;
typedef mozilla::gfx::Point Point2D; // TODO: get rid of this somehow
// Some useful defines to stub out webrender binding functions for when we
// build gecko without webrender. We try to tell the compiler these functions

Просмотреть файл

@ -257,9 +257,19 @@ enum class WrImageRendering: uint32_t {
Sentinel /* this must be last for serialization purposes. */
};
struct WrPoint {
float x;
float y;
bool operator==(const WrPoint& aOther) const {
return x == aOther.x &&
y == aOther.y;
}
};
struct WrGlyphInstance {
uint32_t index;
Point2D point;
WrPoint point;
bool operator==(const WrGlyphInstance& aOther) const {
return index == aOther.index &&
@ -372,16 +382,6 @@ struct WrGradientStop {
}
};
struct WrPoint {
float x;
float y;
bool operator==(const WrPoint& aOther) const {
return x == aOther.x &&
y == aOther.y;
}
};
enum class WrBoxShadowClipMode: uint32_t {
None = 0,
Outset = 1,