Skip to content

Commit

Permalink
WR update: APIs update
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrouget committed Mar 22, 2019
1 parent ecc1182 commit a20455f
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 20 deletions.
3 changes: 2 additions & 1 deletion components/gfx/platform/freetype/font_template.rs
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion components/gfx/platform/windows/font.rs
Expand Up @@ -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 {
Expand Down
5 changes: 0 additions & 5 deletions components/gfx/platform/windows/font_list.rs
Expand Up @@ -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()
Expand Down
16 changes: 11 additions & 5 deletions components/gfx/platform/windows/font_template.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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(),
})
}
}
1 change: 1 addition & 0 deletions components/layout/display_list/builder.rs
Expand Up @@ -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,
},
},
)));
Expand Down
35 changes: 27 additions & 8 deletions components/layout/display_list/webrender_helpers.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand All @@ -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(),
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit a20455f

Please sign in to comment.