mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Auto merge of #14412 - glennw:update-wr-clip-2, r=pcwalton
Update WR + gleam (nested clip stack, scroll locations). <!-- 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/14412) <!-- Reviewable:end -->
This commit is contained in:
commit
bffac0f55e
10 changed files with 91 additions and 80 deletions
|
@ -116,7 +116,8 @@ impl WebGLPaintThread {
|
|||
webrender_api_sender: webrender_traits::RenderApiSender)
|
||||
-> Result<(WebGLPaintThread, GLLimits), String> {
|
||||
let wr_api = webrender_api_sender.create_api();
|
||||
match wr_api.request_webgl_context(&size, attrs) {
|
||||
let device_size = webrender_traits::DeviceIntSize::from_untyped(&size);
|
||||
match wr_api.request_webgl_context(&device_size, attrs) {
|
||||
Ok((id, limits)) => {
|
||||
let painter = WebGLPaintThread {
|
||||
data: WebGLPaintTaskData::WebRender(wr_api, id),
|
||||
|
@ -252,7 +253,8 @@ impl WebGLPaintThread {
|
|||
}
|
||||
}
|
||||
WebGLPaintTaskData::WebRender(ref api, id) => {
|
||||
api.resize_webgl_context(id, &size);
|
||||
let device_size = webrender_traits::DeviceIntSize::from_untyped(&size);
|
||||
api.resize_webgl_context(id, &device_size);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ use SendableFrameTree;
|
|||
use compositor_thread::{CompositorProxy, CompositorReceiver};
|
||||
use compositor_thread::{InitialCompositorState, Msg, RenderListener};
|
||||
use delayed_composition::DelayedCompositionTimerProxy;
|
||||
use euclid::{Point2D, Size2D};
|
||||
use euclid::Point2D;
|
||||
use euclid::point::TypedPoint2D;
|
||||
use euclid::scale_factor::ScaleFactor;
|
||||
use euclid::size::TypedSize2D;
|
||||
|
@ -40,7 +40,7 @@ use style_traits::viewport::ViewportConstraints;
|
|||
use time::{precise_time_ns, precise_time_s};
|
||||
use touch::{TouchHandler, TouchAction};
|
||||
use webrender;
|
||||
use webrender_traits::{self, ScrollEventPhase, ServoScrollRootId};
|
||||
use webrender_traits::{self, ScrollEventPhase, ServoScrollRootId, LayoutPoint};
|
||||
use windowing::{self, MouseWindowEvent, WindowEvent, WindowMethods, WindowNavigateMsg};
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
|
@ -336,11 +336,11 @@ impl webrender_traits::RenderNotifier for RenderNotifier {
|
|||
|
||||
fn pipeline_size_changed(&mut self,
|
||||
pipeline_id: webrender_traits::PipelineId,
|
||||
size: Option<Size2D<f32>>) {
|
||||
size: Option<webrender_traits::LayoutSize>) {
|
||||
let pipeline_id = pipeline_id.from_webrender();
|
||||
|
||||
if let Some(size) = size {
|
||||
let msg = ConstellationMsg::FrameSize(pipeline_id, size);
|
||||
let msg = ConstellationMsg::FrameSize(pipeline_id, size.to_untyped());
|
||||
if let Err(e) = self.constellation_chan.send(msg) {
|
||||
warn!("Compositor resize to constellation failed ({}).", e);
|
||||
}
|
||||
|
@ -773,7 +773,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
scroll_root_id: ScrollRootId,
|
||||
point: Point2D<f32>) {
|
||||
self.webrender_api.scroll_layers_with_scroll_root_id(
|
||||
point,
|
||||
LayoutPoint::from_untyped(&point),
|
||||
pipeline_id.to_webrender(),
|
||||
ServoScrollRootId(scroll_root_id.0));
|
||||
}
|
||||
|
@ -1134,7 +1134,10 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
let delta = (combined_event.delta / self.scale).to_untyped();
|
||||
let cursor =
|
||||
(combined_event.cursor.to_f32() / self.scale).to_untyped();
|
||||
self.webrender_api.scroll(delta, cursor, combined_event.phase);
|
||||
let delta = webrender_traits::LayerPoint::from_untyped(&delta);
|
||||
let location = webrender_traits::ScrollLocation::Delta(delta);
|
||||
let cursor = webrender_traits::WorldPoint::from_untyped(&cursor);
|
||||
self.webrender_api.scroll(location, cursor, combined_event.phase);
|
||||
last_combined_event = None
|
||||
}
|
||||
}
|
||||
|
@ -1174,8 +1177,11 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
// TODO(gw): Support zoom (WR issue #28).
|
||||
if let Some(combined_event) = last_combined_event {
|
||||
let delta = (combined_event.delta / self.scale).to_untyped();
|
||||
let delta = webrender_traits::LayoutPoint::from_untyped(&delta);
|
||||
let cursor = (combined_event.cursor.to_f32() / self.scale).to_untyped();
|
||||
self.webrender_api.scroll(delta, cursor, combined_event.phase);
|
||||
let location = webrender_traits::ScrollLocation::Delta(delta);
|
||||
let cursor = webrender_traits::WorldPoint::from_untyped(&cursor);
|
||||
self.webrender_api.scroll(location, cursor, combined_event.phase);
|
||||
self.waiting_for_results_of_scroll = true
|
||||
}
|
||||
|
||||
|
@ -1316,7 +1322,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
for scroll_layer_state in self.webrender_api.get_scroll_layer_state() {
|
||||
let stacking_context_scroll_state = StackingContextScrollState {
|
||||
scroll_root_id: scroll_layer_state.scroll_root_id.from_webrender(),
|
||||
scroll_offset: scroll_layer_state.scroll_offset,
|
||||
scroll_offset: scroll_layer_state.scroll_offset.to_untyped(),
|
||||
};
|
||||
let pipeline_id = scroll_layer_state.pipeline_id;
|
||||
stacking_context_scroll_states_per_pipeline
|
||||
|
@ -1464,7 +1470,8 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
debug!("compositor: compositing");
|
||||
|
||||
// Paint the scene.
|
||||
self.webrender.render(self.window_size.to_untyped());
|
||||
let size = webrender_traits::DeviceUintSize::from_untyped(&self.window_size.to_untyped());
|
||||
self.webrender.render(size);
|
||||
});
|
||||
|
||||
let rv = match target {
|
||||
|
|
|
@ -16,7 +16,7 @@ use msg::constellation_msg::PipelineId;
|
|||
use style::computed_values::{image_rendering, mix_blend_mode};
|
||||
use style::computed_values::filter::{self, Filter};
|
||||
use style::values::computed::BorderStyle;
|
||||
use webrender_traits::{self, DisplayListBuilder};
|
||||
use webrender_traits::{self, DisplayListBuilder, LayoutTransform};
|
||||
|
||||
pub trait WebRenderDisplayListConverter {
|
||||
fn convert_to_webrender(&self, pipeline_id: PipelineId) -> DisplayListBuilder;
|
||||
|
@ -61,36 +61,38 @@ impl ToBoxShadowClipMode for BoxShadowClipMode {
|
|||
}
|
||||
|
||||
trait ToSizeF {
|
||||
fn to_sizef(&self) -> Size2D<f32>;
|
||||
fn to_sizef(&self) -> webrender_traits::LayoutSize;
|
||||
}
|
||||
|
||||
trait ToPointF {
|
||||
fn to_pointf(&self) -> Point2D<f32>;
|
||||
fn to_pointf(&self) -> webrender_traits::LayoutPoint;
|
||||
}
|
||||
|
||||
impl ToPointF for Point2D<Au> {
|
||||
fn to_pointf(&self) -> Point2D<f32> {
|
||||
Point2D::new(self.x.to_f32_px(), self.y.to_f32_px())
|
||||
fn to_pointf(&self) -> webrender_traits::LayoutPoint {
|
||||
webrender_traits::LayoutPoint::new(self.x.to_f32_px(), self.y.to_f32_px())
|
||||
}
|
||||
}
|
||||
|
||||
impl ToSizeF for Size2D<Au> {
|
||||
fn to_sizef(&self) -> Size2D<f32> {
|
||||
Size2D::new(self.width.to_f32_px(), self.height.to_f32_px())
|
||||
fn to_sizef(&self) -> webrender_traits::LayoutSize {
|
||||
webrender_traits::LayoutSize::new(self.width.to_f32_px(), self.height.to_f32_px())
|
||||
}
|
||||
}
|
||||
|
||||
trait ToRectF {
|
||||
fn to_rectf(&self) -> Rect<f32>;
|
||||
fn to_rectf(&self) -> webrender_traits::LayoutRect;
|
||||
}
|
||||
|
||||
impl ToRectF for Rect<Au> {
|
||||
fn to_rectf(&self) -> Rect<f32> {
|
||||
fn to_rectf(&self) -> webrender_traits::LayoutRect {
|
||||
let x = self.origin.x.to_f32_px();
|
||||
let y = self.origin.y.to_f32_px();
|
||||
let w = self.size.width.to_f32_px();
|
||||
let h = self.size.height.to_f32_px();
|
||||
Rect::new(Point2D::new(x, y), Size2D::new(w, h))
|
||||
let point = webrender_traits::LayoutPoint::new(x, y);
|
||||
let size = webrender_traits::LayoutSize::new(w, h);
|
||||
webrender_traits::LayoutRect::new(point, size)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -340,12 +342,16 @@ impl WebRenderDisplayItemConverter for DisplayItem {
|
|||
ScrollPolicy::FixedPosition => webrender_traits::ScrollPolicy::Fixed,
|
||||
};
|
||||
|
||||
let clip = builder.new_clip_region(&stacking_context.overflow.to_rectf(),
|
||||
vec![],
|
||||
None);
|
||||
|
||||
builder.push_stacking_context(webrender_scroll_policy,
|
||||
stacking_context.bounds.to_rectf(),
|
||||
stacking_context.overflow.to_rectf(),
|
||||
clip,
|
||||
stacking_context.z_index,
|
||||
&stacking_context.transform,
|
||||
&stacking_context.perspective,
|
||||
&LayoutTransform::from_untyped(&stacking_context.transform),
|
||||
&LayoutTransform::from_untyped(&stacking_context.perspective),
|
||||
stacking_context.blend_mode.to_blend_mode(),
|
||||
stacking_context.filters.to_filter_ops());
|
||||
}
|
||||
|
|
|
@ -961,8 +961,9 @@ impl LayoutThread {
|
|||
self.epoch.next();
|
||||
let Epoch(epoch_number) = self.epoch;
|
||||
|
||||
let viewport_size = webrender_traits::LayoutSize::from_untyped(&viewport_size);
|
||||
self.webrender_api.set_root_display_list(
|
||||
get_root_flow_background_color(layout_root),
|
||||
Some(get_root_flow_background_color(layout_root)),
|
||||
webrender_traits::Epoch(epoch_number),
|
||||
viewport_size,
|
||||
builder);
|
||||
|
|
|
@ -172,6 +172,9 @@ impl<Window> Browser<Window> where Window: WindowMethods + 'static {
|
|||
enable_scrollbars: opts.output_file.is_none(),
|
||||
renderer_kind: renderer_kind,
|
||||
enable_subpixel_aa: opts.enable_subpixel_text_antialiasing,
|
||||
clear_empty_tiles: true,
|
||||
clear_framebuffer: true,
|
||||
clear_color: webrender_traits::ColorF::new(1.0, 1.0, 1.0, 1.0),
|
||||
})
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue