mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Auto merge of #22973 - paulrouget:wrupdate, r=emilio
WR update ~Need https://github.com/tomaka/winit/issues/803~ @emilio can I ask you to look at the *"WR udpate: layout"* commit? There are a few changes I'm not sure about (should_inflate, the new filters_data and cache_tiles). Fix: #22993 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22973) <!-- Reviewable:end -->
This commit is contained in:
commit
525484a4d9
25 changed files with 321 additions and 197 deletions
|
@ -151,7 +151,7 @@ impl webrender::OutputImageHandler for OutputHandler {
|
|||
fn lock(
|
||||
&mut self,
|
||||
id: webrender_api::PipelineId,
|
||||
) -> Option<(u32, webrender_api::DeviceIntSize)> {
|
||||
) -> Option<(u32, webrender_api::FramebufferIntSize)> {
|
||||
// Insert a fence in the WR command queue
|
||||
let gl_sync = self
|
||||
.webrender_gl
|
||||
|
@ -164,7 +164,7 @@ impl webrender::OutputImageHandler for OutputHandler {
|
|||
self.lock_channel.1.recv().unwrap().map(|(tex_id, size)| {
|
||||
(
|
||||
tex_id,
|
||||
webrender_api::DeviceIntSize::new(size.width, size.height),
|
||||
webrender_api::FramebufferIntSize::new(size.width, size.height),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ embedder_traits = {path = "../embedder_traits"}
|
|||
euclid = "0.19"
|
||||
gfx_traits = {path = "../gfx_traits"}
|
||||
gleam = {version = "0.6", optional = true}
|
||||
image = "0.20"
|
||||
image = "0.21"
|
||||
ipc-channel = "0.11"
|
||||
libc = "0.2"
|
||||
keyboard-types = "0.4.3"
|
||||
|
|
|
@ -41,7 +41,10 @@ use std::rc::Rc;
|
|||
use style_traits::viewport::ViewportConstraints;
|
||||
use style_traits::{CSSPixel, DevicePixel, PinchZoomFactor};
|
||||
use time::{now, precise_time_ns, precise_time_s};
|
||||
use webrender_api::{self, DeviceIntPoint, DevicePoint, HitTestFlags, HitTestResult};
|
||||
use webrender_api::{
|
||||
self, DeviceIntPoint, DevicePoint, FramebufferIntRect, FramebufferIntSize, HitTestFlags,
|
||||
HitTestResult,
|
||||
};
|
||||
use webrender_api::{LayoutVector2D, ScrollLocation};
|
||||
use webvr_traits::WebVRMainThreadHeartbeat;
|
||||
|
||||
|
@ -575,10 +578,16 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
fn send_window_size(&self, size_type: WindowSizeType) {
|
||||
let dppx = self.page_zoom * self.embedder_coordinates.hidpi_factor;
|
||||
|
||||
self.webrender_api.set_window_parameters(
|
||||
let flipped_viewport = {
|
||||
let fb_height = self.embedder_coordinates.framebuffer.height;
|
||||
let mut view = self.embedder_coordinates.viewport.clone();
|
||||
view.origin.y = fb_height - view.origin.y - view.size.height;
|
||||
FramebufferIntRect::from_untyped(&view.to_untyped())
|
||||
};
|
||||
|
||||
self.webrender_api.set_document_view(
|
||||
self.webrender_document,
|
||||
self.embedder_coordinates.framebuffer,
|
||||
self.embedder_coordinates.viewport,
|
||||
flipped_viewport,
|
||||
self.embedder_coordinates.hidpi_factor.get(),
|
||||
);
|
||||
|
||||
|
@ -612,9 +621,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
self.update_zoom_transform();
|
||||
}
|
||||
|
||||
if self.embedder_coordinates.viewport == old_coords.viewport &&
|
||||
self.embedder_coordinates.framebuffer == old_coords.framebuffer
|
||||
{
|
||||
if self.embedder_coordinates.viewport == old_coords.viewport {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1203,11 +1210,16 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
|| {
|
||||
debug!("compositor: compositing");
|
||||
|
||||
let size = FramebufferIntSize::from_untyped(
|
||||
&self.embedder_coordinates.framebuffer.to_untyped(),
|
||||
);
|
||||
|
||||
self.window.gl().clear_color(1.0, 1.0, 1.0, 0.0);
|
||||
self.window.gl().clear(gleam::gl::COLOR_BUFFER_BIT);
|
||||
|
||||
// Paint the scene.
|
||||
// TODO(gw): Take notice of any errors the renderer returns!
|
||||
self.webrender
|
||||
.render(self.embedder_coordinates.framebuffer)
|
||||
.ok();
|
||||
self.webrender.render(size).ok();
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use gleam::gl;
|
||||
use image::RgbImage;
|
||||
use servo_geometry::DeviceUintLength;
|
||||
use servo_geometry::FramebufferUintLength;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct RenderTargetInfo {
|
||||
|
@ -15,8 +15,8 @@ pub struct RenderTargetInfo {
|
|||
|
||||
pub fn initialize_png(
|
||||
gl: &dyn gl::Gl,
|
||||
width: DeviceUintLength,
|
||||
height: DeviceUintLength,
|
||||
width: FramebufferUintLength,
|
||||
height: FramebufferUintLength,
|
||||
) -> RenderTargetInfo {
|
||||
let framebuffer_ids = gl.gen_framebuffers(1);
|
||||
gl.bind_framebuffer(gl::FRAMEBUFFER, framebuffer_ids[0]);
|
||||
|
@ -82,8 +82,8 @@ pub fn initialize_png(
|
|||
pub fn draw_img(
|
||||
gl: &dyn gl::Gl,
|
||||
render_target_info: RenderTargetInfo,
|
||||
width: DeviceUintLength,
|
||||
height: DeviceUintLength,
|
||||
width: FramebufferUintLength,
|
||||
height: FramebufferUintLength,
|
||||
) -> RgbImage {
|
||||
let width = width.get() as usize;
|
||||
let height = height.get() as usize;
|
||||
|
|
|
@ -17,7 +17,9 @@ use std::fmt::{Debug, Error, Formatter};
|
|||
#[cfg(feature = "gl")]
|
||||
use std::rc::Rc;
|
||||
use style_traits::DevicePixel;
|
||||
use webrender_api::{DeviceIntPoint, DeviceIntRect, DeviceIntSize, DevicePoint, ScrollLocation};
|
||||
use webrender_api::{
|
||||
DeviceIntPoint, DeviceIntRect, DeviceIntSize, DevicePoint, FramebufferIntSize, ScrollLocation,
|
||||
};
|
||||
use webvr::VRServiceManager;
|
||||
use webvr_traits::WebVRMainThreadHeartbeat;
|
||||
|
||||
|
@ -167,7 +169,7 @@ pub struct EmbedderCoordinates {
|
|||
/// Size of the native window.
|
||||
pub window: (DeviceIntSize, DeviceIntPoint),
|
||||
/// Size of the GL buffer in the window.
|
||||
pub framebuffer: DeviceIntSize,
|
||||
pub framebuffer: FramebufferIntSize,
|
||||
/// Coordinates of the document within the framebuffer.
|
||||
pub viewport: DeviceIntRect,
|
||||
}
|
||||
|
|
|
@ -8,12 +8,11 @@ extern crate malloc_size_of_derive;
|
|||
use app_units::{Au, MAX_AU, MIN_AU};
|
||||
use euclid::{Length, Point2D, Rect, Size2D};
|
||||
use std::f32;
|
||||
use style_traits::DevicePixel;
|
||||
use webrender_api::{LayoutPoint, LayoutRect, LayoutSize};
|
||||
use webrender_api::{FramebufferPixel, LayoutPoint, LayoutRect, LayoutSize};
|
||||
|
||||
// Units for use with euclid::length and euclid::scale_factor.
|
||||
|
||||
pub type DeviceUintLength = Length<u32, DevicePixel>;
|
||||
pub type FramebufferUintLength = Length<u32, FramebufferPixel>;
|
||||
|
||||
/// A normalized "pixel" at the default resolution for the display.
|
||||
///
|
||||
|
|
|
@ -63,5 +63,5 @@ servo-fontconfig = "0.2.1"
|
|||
xml5ever = {version = "0.12"}
|
||||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
dwrote = "0.7"
|
||||
dwrote = "0.8"
|
||||
truetype = "0.26"
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
},
|
||||
)));
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -20,7 +20,7 @@ headers-ext = "0.0.3"
|
|||
http = "0.1"
|
||||
hyper = "0.12"
|
||||
hyper_serde = "0.9"
|
||||
piston_image = {package = "image", version = "0.20"}
|
||||
piston_image = {package = "image", version = "0.21"}
|
||||
ipc-channel = "0.11"
|
||||
lazy_static = "1"
|
||||
log = "0.4"
|
||||
|
|
|
@ -58,7 +58,7 @@ html5ever = "0.22"
|
|||
http = "0.1"
|
||||
hyper = "0.12"
|
||||
hyper_serde = "0.9"
|
||||
image = "0.20"
|
||||
image = "0.21"
|
||||
indexmap = "1.0.2"
|
||||
ipc-channel = "0.11"
|
||||
itertools = "0.8"
|
||||
|
|
|
@ -242,6 +242,7 @@ where
|
|||
},
|
||||
renderer_kind: renderer_kind,
|
||||
enable_subpixel_aa: opts.enable_subpixel_text_antialiasing,
|
||||
clear_color: None,
|
||||
..Default::default()
|
||||
},
|
||||
None,
|
||||
|
|
|
@ -16,7 +16,7 @@ cookie = "0.11"
|
|||
crossbeam-channel = "0.3"
|
||||
euclid = "0.19"
|
||||
hyper = "0.12"
|
||||
image = "0.20"
|
||||
image = "0.21"
|
||||
ipc-channel = "0.11"
|
||||
keyboard-types = "0.4.3"
|
||||
log = "0.4"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue