WR update: APIs update

This commit is contained in:
Paul Rouget 2019-03-18 20:31:43 +08:00
parent ecc11826d2
commit a20455fd6b
6 changed files with 43 additions and 20 deletions

View file

@ -6,6 +6,7 @@ use servo_atoms::Atom;
use std::fmt;
use std::fs::File;
use std::io::{Error, Read};
use std::path::PathBuf;
use webrender_api::NativeFontHandle;
/// Platform specific font representation for Linux.
@ -61,7 +62,7 @@ impl FontTemplateData {
pub fn native_font(&self) -> Option<NativeFontHandle> {
if self.bytes.is_none() {
Some(NativeFontHandle {
pathname: String::from(&*self.identifier),
path: PathBuf::from(&*self.identifier),
index: 0,
})
} else {

View file

@ -280,7 +280,8 @@ impl FontHandleMethods for FontHandle {
let face = font_file
.unwrap()
.create_face(0, dwrote::DWRITE_FONT_SIMULATIONS_NONE);
.create_face(0, dwrote::DWRITE_FONT_SIMULATIONS_NONE)
.map_err(|_| ())?;
let info = FontInfo::new_from_face(&face)?;
(info, face)
} else {

View file

@ -64,11 +64,6 @@ where
}
}
pub fn descriptor_from_atom(ident: &Atom) -> FontDescriptor {
let fonts = FONT_ATOM_MAP.lock().unwrap();
fonts.get(ident).unwrap().clone()
}
pub fn font_from_atom(ident: &Atom) -> Font {
let fonts = FONT_ATOM_MAP.lock().unwrap();
FontCollection::system()

View file

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::platform::windows::font_list::{descriptor_from_atom, font_from_atom};
use crate::platform::windows::font_list::font_from_atom;
use servo_atoms::Atom;
use std::fmt;
use std::io;
@ -59,10 +59,16 @@ impl FontTemplateData {
}
pub fn native_font(&self) -> Option<NativeFontHandle> {
if self.bytes.is_none() {
Some(descriptor_from_atom(&self.identifier))
} else {
None
if self.bytes.is_some() {
return None;
}
let font = font_from_atom(&self.identifier);
let face = font.create_font_face();
let files = face.get_files();
let path = files.iter().next()?.get_font_file_path()?;
Some(NativeFontHandle {
path,
index: face.get_index(),
})
}
}

View file

@ -2012,6 +2012,7 @@ impl Fragment {
offset: LayoutVector2D::new(shadow.horizontal.px(), shadow.vertical.px()),
color: self.style.resolve_color(shadow.color).to_layout(),
blur_radius: shadow.blur.px(),
should_inflate: true,
},
},
)));

View file

@ -10,8 +10,10 @@
use crate::display_list::items::{ClipScrollNode, ClipScrollNodeType};
use crate::display_list::items::{DisplayItem, DisplayList, StackingContextType};
use msg::constellation_msg::PipelineId;
use webrender_api::{self, ClipId, DisplayListBuilder, RasterSpace, SpaceAndClipInfo, SpatialId};
use webrender_api::{LayoutPoint, SpecificDisplayItem};
use webrender_api::{
self, ClipId, DisplayListBuilder, RasterSpace, ReferenceFrameKind, SpaceAndClipInfo, SpatialId,
};
use webrender_api::{LayoutPoint, PropertyBinding, SpecificDisplayItem};
pub trait WebRenderDisplayListConverter {
fn convert_to_webrender(&self, pipeline_id: PipelineId) -> DisplayListBuilder;
@ -204,18 +206,32 @@ impl WebRenderDisplayItemConverter for DisplayItem {
let mut info = webrender_api::LayoutPrimitiveInfo::new(stacking_context.bounds);
let spatial_id =
if let Some(frame_index) = stacking_context.established_reference_frame {
debug_assert!(
stacking_context.transform.is_some() ||
stacking_context.perspective.is_some()
);
let (transform, ref_frame) =
match (stacking_context.transform, stacking_context.perspective) {
(None, Some(p)) => (
p,
ReferenceFrameKind::Perspective {
scrolling_relative_to: None,
},
),
(Some(t), None) => (t, ReferenceFrameKind::Transform),
(Some(t), Some(p)) => (
t.pre_mul(&p),
ReferenceFrameKind::Perspective {
scrolling_relative_to: None,
},
),
(None, None) => unreachable!(),
};
let spatial_id = builder.push_reference_frame(
&stacking_context.bounds,
state.active_spatial_id,
stacking_context.transform_style,
stacking_context.transform.map(Into::into),
stacking_context.perspective,
PropertyBinding::Value(transform),
ref_frame,
);
state.spatial_ids[frame_index.to_index()] = Some(spatial_id);
state.clip_ids[frame_index.to_index()] = Some(cur_clip_id);
@ -233,7 +249,9 @@ impl WebRenderDisplayItemConverter for DisplayItem {
stacking_context.transform_style,
stacking_context.mix_blend_mode,
&stacking_context.filters,
&[],
RasterSpace::Screen,
/* cache_tiles = */ false,
);
},
DisplayItem::PopStackingContext(_) => builder.pop_stacking_context(),
@ -273,6 +291,7 @@ impl WebRenderDisplayItemConverter for DisplayItem {
node.clip.complex.clone(),
None,
scroll_sensitivity,
webrender_api::LayoutVector2D::zero(),
);
state.clip_ids[item.node_index.to_index()] = Some(space_clip_info.clip_id);