aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
Diffstat (limited to 'components')
-rw-r--r--components/canvas/webgl_mode/inprocess.rs3
-rw-r--r--components/canvas/webgl_thread.rs36
-rw-r--r--components/compositing/compositor.rs102
-rw-r--r--components/compositing/lib.rs2
-rw-r--r--components/constellation/Cargo.toml1
-rw-r--r--components/constellation/constellation.rs3
-rw-r--r--components/layout/display_list/builder.rs36
-rw-r--r--components/layout/display_list/conversions.rs2
-rw-r--r--components/layout/display_list/items.rs8
-rw-r--r--components/layout/display_list/webrender_helpers.rs37
-rw-r--r--components/layout_2020/display_list/background.rs4
-rw-r--r--components/layout_2020/display_list/conversions.rs2
-rw-r--r--components/layout_2020/display_list/mod.rs89
-rw-r--r--components/layout_2020/display_list/stacking_context.rs25
-rw-r--r--components/layout_thread/lib.rs11
-rw-r--r--components/layout_thread_2020/lib.rs11
-rw-r--r--components/malloc_size_of/lib.rs4
-rw-r--r--components/script/dom/htmlmediaelement.rs15
-rw-r--r--components/script_traits/compositor.rs4
-rw-r--r--components/script_traits/lib.rs24
-rw-r--r--components/servo/lib.rs59
-rw-r--r--components/webgpu/Cargo.toml1
-rw-r--r--components/webgpu/lib.rs6
23 files changed, 229 insertions, 256 deletions
diff --git a/components/canvas/webgl_mode/inprocess.rs b/components/canvas/webgl_mode/inprocess.rs
index 749f0062aeb..aad799776db 100644
--- a/components/canvas/webgl_mode/inprocess.rs
+++ b/components/canvas/webgl_mode/inprocess.rs
@@ -12,8 +12,7 @@ use log::debug;
use sparkle::gl::GlType;
use surfman::chains::{SwapChainAPI, SwapChains, SwapChainsAPI};
use surfman::{Device, SurfaceInfo, SurfaceTexture};
-use webrender::RenderApiSender;
-use webrender_api::DocumentId;
+use webrender_api::{DocumentId, RenderApiSender};
use webrender_surfman::WebrenderSurfman;
use webrender_traits::{
WebrenderExternalImageApi, WebrenderExternalImageRegistry, WebrenderImageSource,
diff --git a/components/canvas/webgl_thread.rs b/components/canvas/webgl_thread.rs
index 8e1e55f4c91..eacc94c590b 100644
--- a/components/canvas/webgl_thread.rs
+++ b/components/canvas/webgl_thread.rs
@@ -32,11 +32,10 @@ use surfman::{
self, Adapter, Connection, Context, ContextAttributeFlags, ContextAttributes, Device,
GLVersion, SurfaceAccess, SurfaceInfo, SurfaceType,
};
-use webrender::{RenderApi, RenderApiSender, Transaction};
-use webrender_api::units::DeviceIntSize;
use webrender_api::{
- DirtyRect, DocumentId, ExternalImageData, ExternalImageId, ExternalImageType, ImageBufferKind,
- ImageData, ImageDescriptor, ImageDescriptorFlags, ImageFormat, ImageKey,
+ units::DeviceIntSize, DirtyRect, DocumentId, ExternalImageData, ExternalImageId,
+ ExternalImageType, ImageData, ImageDescriptor, ImageDescriptorFlags, ImageFormat, ImageKey,
+ RenderApi, RenderApiSender, TextureTarget, Transaction,
};
use webrender_traits::{WebrenderExternalImageRegistry, WebrenderImageHandlerType};
use webxr::SurfmanGL as WebXRSurfman;
@@ -576,7 +575,7 @@ impl WebGLThread {
let descriptor_attributes = self.device.context_descriptor_attributes(&descriptor);
let gl_version = descriptor_attributes.version;
let has_alpha = requested_flags.contains(ContextAttributeFlags::ALPHA);
- let image_buffer_kind = current_wr_image_buffer_kind(&self.device);
+ let texture_target = current_wr_texture_target(&self.device);
self.device.make_context_current(&ctx).unwrap();
let framebuffer = self
@@ -635,7 +634,7 @@ impl WebGLThread {
size.to_i32(),
has_alpha,
id,
- image_buffer_kind,
+ texture_target,
);
self.cached_context_info
@@ -691,7 +690,7 @@ impl WebGLThread {
.state
.requested_flags
.contains(ContextAttributeFlags::ALPHA);
- let image_buffer_kind = current_wr_image_buffer_kind(&self.device);
+ let texture_target = current_wr_texture_target(&self.device);
Self::update_wr_external_image(
&mut self.webrender_api,
self.webrender_doc,
@@ -699,7 +698,7 @@ impl WebGLThread {
has_alpha,
context_id,
info.image_key,
- image_buffer_kind,
+ texture_target,
);
debug_assert_eq!(data.gl.get_error(), gl::NO_ERROR);
@@ -895,10 +894,10 @@ impl WebGLThread {
size: Size2D<i32>,
alpha: bool,
context_id: WebGLContextId,
- image_buffer_kind: ImageBufferKind,
+ target: TextureTarget,
) -> ImageKey {
let descriptor = Self::image_descriptor(size, alpha);
- let data = Self::external_image_data(context_id, image_buffer_kind);
+ let data = Self::external_image_data(context_id, target);
let image_key = webrender_api.generate_image_key();
let mut txn = Transaction::new();
@@ -916,10 +915,10 @@ impl WebGLThread {
alpha: bool,
context_id: WebGLContextId,
image_key: ImageKey,
- image_buffer_kind: ImageBufferKind,
+ target: TextureTarget,
) {
let descriptor = Self::image_descriptor(size, alpha);
- let data = Self::external_image_data(context_id, image_buffer_kind);
+ let data = Self::external_image_data(context_id, target);
let mut txn = Transaction::new();
txn.update_image(image_key, descriptor, data, &DirtyRect::All);
@@ -940,14 +939,11 @@ impl WebGLThread {
}
/// Helper function to create a `ImageData::External` instance.
- fn external_image_data(
- context_id: WebGLContextId,
- image_buffer_kind: ImageBufferKind,
- ) -> ImageData {
+ fn external_image_data(context_id: WebGLContextId, target: TextureTarget) -> ImageData {
let data = ExternalImageData {
id: ExternalImageId(context_id.0 as u64),
channel_index: 0,
- image_type: ExternalImageType::TextureHandle(image_buffer_kind),
+ image_type: ExternalImageType::TextureHandle(target),
};
ImageData::External(data)
}
@@ -977,10 +973,10 @@ struct WebGLContextInfo {
}
// TODO(pcwalton): Add `GL_TEXTURE_EXTERNAL_OES`?
-fn current_wr_image_buffer_kind(device: &Device) -> ImageBufferKind {
+fn current_wr_texture_target(device: &Device) -> TextureTarget {
match device.surface_gl_texture_target() {
- gl::TEXTURE_RECTANGLE => ImageBufferKind::TextureRect,
- _ => ImageBufferKind::Texture2D,
+ gl::TEXTURE_RECTANGLE => TextureTarget::Rect,
+ _ => TextureTarget::Default,
}
}
diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs
index 809d231d831..5f3068f21e6 100644
--- a/components/compositing/compositor.rs
+++ b/components/compositing/compositor.rs
@@ -42,14 +42,13 @@ use script_traits::{
use servo_geometry::{DeviceIndependentPixel, FramebufferUintLength};
use style_traits::{CSSPixel, DevicePixel, PinchZoomFactor};
use time::{now, precise_time_ns, precise_time_s};
-use webrender;
-use webrender::{CaptureBits, RenderApi, Transaction};
use webrender_api::units::{
DeviceIntPoint, DeviceIntSize, DevicePoint, LayoutPoint, LayoutVector2D, WorldPoint,
};
use webrender_api::{
- self, BuiltDisplayList, DirtyRect, DocumentId, Epoch as WebRenderEpoch, ExternalScrollId,
- HitTestFlags, PipelineId as WebRenderPipelineId, ScrollClamping, ScrollLocation, ZoomFactor,
+ self, BuiltDisplayList, CaptureBits, DirtyRect, DocumentId, Epoch as WebRenderEpoch,
+ ExternalScrollId, HitTestFlags, PipelineId as WebRenderPipelineId, RenderApi, ScrollClamping,
+ ScrollLocation, Transaction, ZoomFactor,
};
use webrender_surfman::WebrenderSurfman;
@@ -652,55 +651,58 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
WebRenderEpoch(0),
None,
Default::default(),
- (pipeline, Default::default()),
+ (pipeline, Default::default(), Default::default()),
false,
);
-
self.webrender_api
.send_transaction(self.webrender_document, txn);
},
- WebrenderMsg::Layout(script_traits::WebrenderMsg::SendScrollNode(point, scroll_id)) => {
+ WebrenderMsg::Layout(script_traits::WebrenderMsg::SendScrollNode(
+ point,
+ scroll_id,
+ clamping,
+ )) => {
self.waiting_for_results_of_scroll = true;
let mut txn = Transaction::new();
- txn.scroll_node_with_id(point, scroll_id, ScrollClamping::ToContentBounds);
- txn.generate_frame(0);
+ txn.scroll_node_with_id(point, scroll_id, clamping);
+ txn.generate_frame();
self.webrender_api
.send_transaction(self.webrender_document, txn);
},
WebrenderMsg::Layout(script_traits::WebrenderMsg::SendDisplayList {
display_list_info,
+ content_size,
display_list_descriptor,
display_list_receiver,
- }) => {
- let display_list_data = match display_list_receiver.recv() {
- Ok(display_list_data) => display_list_data,
- _ => return warn!("Could not recieve WebRender display list."),
- };
-
- self.waiting_on_pending_frame = true;
-
- let pipeline_id = display_list_info.pipeline_id;
- let details = self.pipeline_details(PipelineId::from_webrender(pipeline_id));
- details.hit_test_items = display_list_info.hit_test_info;
- details.install_new_scroll_tree(display_list_info.scroll_tree);
-
- let mut txn = Transaction::new();
- txn.set_display_list(
- display_list_info.epoch,
- None,
- display_list_info.viewport_size,
- (
- pipeline_id,
- BuiltDisplayList::from_data(display_list_data, display_list_descriptor),
- ),
- true,
- );
- txn.generate_frame(0);
- self.webrender_api
- .send_transaction(self.webrender_document, txn);
+ }) => match display_list_receiver.recv() {
+ Ok(data) => {
+ self.waiting_on_pending_frame = true;
+
+ let pipeline_id = display_list_info.pipeline_id;
+ let details = self.pipeline_details(PipelineId::from_webrender(pipeline_id));
+ details.hit_test_items = display_list_info.hit_test_info;
+ details.install_new_scroll_tree(display_list_info.scroll_tree);
+
+ let mut txn = Transaction::new();
+ txn.set_display_list(
+ display_list_info.epoch,
+ None,
+ display_list_info.viewport_size,
+ (
+ pipeline_id,
+ content_size,
+ BuiltDisplayList::from_data(data, display_list_descriptor),
+ ),
+ true,
+ );
+ txn.generate_frame();
+ self.webrender_api
+ .send_transaction(self.webrender_document, txn);
+ },
+ Err(e) => warn!("error receiving display list data: {e:?}"),
},
WebrenderMsg::Layout(script_traits::WebrenderMsg::HitTest(
@@ -876,7 +878,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
let pipeline_id = frame_tree.pipeline.id.to_webrender();
let mut txn = Transaction::new();
txn.set_root_pipeline(pipeline_id);
- txn.generate_frame(0);
+ txn.generate_frame();
self.webrender_api
.send_transaction(self.webrender_document, txn);
@@ -925,16 +927,14 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
self.pipeline_details.remove(&pipeline_id);
}
- fn send_window_size(&mut self, size_type: WindowSizeType) {
+ fn send_window_size(&self, size_type: WindowSizeType) {
let dppx = self.page_zoom * self.embedder_coordinates.hidpi_factor;
- let mut transaction = Transaction::new();
- transaction.set_document_view(
+ self.webrender_api.set_document_view(
+ self.webrender_document,
self.embedder_coordinates.get_viewport(),
self.embedder_coordinates.hidpi_factor.get(),
);
- self.webrender_api
- .send_transaction(self.webrender_document, transaction);
let initial_viewport = self.embedder_coordinates.viewport.size.to_f32() / dppx;
@@ -1197,17 +1197,17 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
pub fn on_scroll_event(
&mut self,
- scroll_location: ScrollLocation,
+ delta: ScrollLocation,
cursor: DeviceIntPoint,
phase: TouchEventType,
) {
match phase {
- TouchEventType::Move => self.on_scroll_window_event(scroll_location, cursor),
+ TouchEventType::Move => self.on_scroll_window_event(delta, cursor),
TouchEventType::Up | TouchEventType::Cancel => {
- self.on_scroll_window_event(scroll_location, cursor);
+ self.on_scroll_window_event(delta, cursor);
},
TouchEventType::Down => {
- self.on_scroll_window_event(scroll_location, cursor);
+ self.on_scroll_window_event(delta, cursor);
},
}
}
@@ -1215,7 +1215,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
fn on_scroll_window_event(&mut self, scroll_location: ScrollLocation, cursor: DeviceIntPoint) {
self.pending_scroll_zoom_events.push(ScrollZoomEvent {
magnification: 1.0,
- scroll_location,
+ scroll_location: scroll_location,
cursor: cursor,
event_count: 1,
});
@@ -1309,7 +1309,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
self.set_pinch_zoom_level(old_zoom * combined_event.magnification);
txn.set_pinch_zoom(ZoomFactor::new(self.pinch_zoom_level()));
}
- txn.generate_frame(0);
+ txn.generate_frame();
self.webrender_api
.send_transaction(self.webrender_document, txn);
self.waiting_for_results_of_scroll = true
@@ -1397,7 +1397,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
fn update_page_zoom_for_webrender(&mut self) {
let page_zoom = ZoomFactor::new(self.page_zoom.get());
- let mut txn = webrender::Transaction::new();
+ let mut txn = Transaction::new();
txn.set_page_zoom(page_zoom);
self.webrender_api
.send_transaction(self.webrender_document, txn);
@@ -1612,7 +1612,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
// Paint the scene.
// TODO(gw): Take notice of any errors the renderer returns!
self.clear_background();
- self.webrender.render(size, 0 /* buffer_age */).ok();
+ self.webrender.render(size).ok();
},
);
@@ -1907,7 +1907,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
self.webrender.set_debug_flags(flags);
let mut txn = Transaction::new();
- txn.generate_frame(0);
+ txn.generate_frame();
self.webrender_api
.send_transaction(self.webrender_document, txn);
}
diff --git a/components/compositing/lib.rs b/components/compositing/lib.rs
index 5eb6eeded48..6b22d81f0d1 100644
--- a/components/compositing/lib.rs
+++ b/components/compositing/lib.rs
@@ -9,8 +9,8 @@ use std::rc::Rc;
use compositing_traits::{CompositorProxy, CompositorReceiver, ConstellationMsg};
use crossbeam_channel::Sender;
use profile_traits::{mem, time};
-use webrender::RenderApi;
use webrender_api::DocumentId;
+use webrender_api::RenderApi;
use webrender_surfman::WebrenderSurfman;
pub use crate::compositor::{IOCompositor, ShutdownState};
diff --git a/components/constellation/Cargo.toml b/components/constellation/Cargo.toml
index 6d880a03c60..1544fceba57 100644
--- a/components/constellation/Cargo.toml
+++ b/components/constellation/Cargo.toml
@@ -42,7 +42,6 @@ servo_remutex = { path = "../remutex" }
servo_url = { path = "../url" }
style_traits = { path = "../style_traits" }
webgpu = { path = "../webgpu" }
-webrender = { workspace = true }
webrender_api = { workspace = true }
webrender_traits = { path = "../webrender_traits" }
webxr-api = { git = "https://github.com/servo/webxr", features = ["ipc"] }
diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs
index 2207251de70..ffdb43a815a 100644
--- a/components/constellation/constellation.rs
+++ b/components/constellation/constellation.rs
@@ -156,8 +156,7 @@ use servo_rand::{random, Rng, ServoRng, SliceRandom};
use servo_url::{Host, ImmutableOrigin, ServoUrl};
use style_traits::CSSPixel;
use webgpu::{self, WebGPU, WebGPURequest};
-use webrender::{RenderApi, RenderApiSender};
-use webrender_api::DocumentId;
+use webrender_api::{DocumentId, RenderApi, RenderApiSender};
use webrender_traits::WebrenderExternalImageRegistry;
use crate::browsingcontext::{
diff --git a/components/layout/display_list/builder.rs b/components/layout/display_list/builder.rs
index 6decaf26011..0e799f4b66f 100644
--- a/components/layout/display_list/builder.rs
+++ b/components/layout/display_list/builder.rs
@@ -46,11 +46,10 @@ use style::values::specified::ui::CursorKind;
use style::values::RGBA;
use style_traits::{CSSPixel, ToCss};
use webrender_api::units::{LayoutRect, LayoutTransform, LayoutVector2D};
-use webrender_api::{
- self, BorderDetails, BorderRadius, BorderSide, BoxShadowClipMode, ColorF, ColorU,
- ExternalScrollId, FilterOp, GlyphInstance, ImageRendering, LineStyle, NinePatchBorder,
- NinePatchBorderSource, NormalBorder, PropertyBinding, ScrollSensitivity, StickyOffsetBounds,
-};
+use webrender_api::{self, BorderDetails, BorderRadius, BorderSide, BoxShadowClipMode, ColorF};
+use webrender_api::{ColorU, ExternalScrollId, FilterOp, GlyphInstance, ImageRendering, LineStyle};
+use webrender_api::{NinePatchBorder, NinePatchBorderSource, NormalBorder, PropertyBinding};
+use webrender_api::{ScrollSensitivity, StickyOffsetBounds};
use crate::block::BlockFlow;
use crate::context::LayoutContext;
@@ -2113,7 +2112,7 @@ impl Fragment {
}
// Text
- let (largest_advance, mut glyphs) = convert_text_run_to_glyphs(
+ let mut glyphs = convert_text_run_to_glyphs(
text_fragment.run.clone(),
text_fragment.range,
baseline_origin,
@@ -2127,22 +2126,6 @@ impl Fragment {
};
state.indexable_text.insert(self.node, indexable_text);
- // FIXME(mrobinson, #30313): This is a serious hack to enable a WebRender upgrade.
- // Servo is not calculating glyph boundaries and is instead relying on the
- // measured size of the content box here -- which is based on the positioning
- // of the text. The issue is that glyphs can extend beyond the boundaries
- // established by their brush origin and advance. Servo should be measuring
- // the ink boundary rectangle based on the brush origin and the glyph extents
- // instead.
- //
- // We don't yet have that information here, so in the meantime simply expand
- // the boundary rectangle of the text by the largest character advance of the
- // painted text run in all directions. This is used as a heuristic for a
- // reasonable amount of "fudge" space to include the entire text run.
- let inflated_bounds = stacking_relative_content_box
- .inflate(largest_advance, largest_advance)
- .to_layout();
-
// Process glyphs in chunks to avoid overflowing WebRender's internal limits (#17230).
while !glyphs.is_empty() {
let mut rest_of_glyphs = vec![];
@@ -2154,7 +2137,7 @@ impl Fragment {
state.add_display_item(DisplayItem::Text(CommonDisplayItem::with_data(
base.clone(),
webrender_api::TextDisplayItem {
- bounds: inflated_bounds,
+ bounds: stacking_relative_content_box.to_layout(),
common: items::empty_common_item_properties(),
font_key: text_fragment.run.font_key,
color: text_color.to_layout(),
@@ -3025,8 +3008,7 @@ fn convert_text_run_to_glyphs(
text_run: Arc<TextRun>,
range: Range<ByteIndex>,
mut origin: Point2D<Au>,
-) -> (Au, Vec<GlyphInstance>) {
- let mut largest_advance = Au(0);
+) -> Vec<GlyphInstance> {
let mut glyphs = vec![];
for slice in text_run.natural_word_slices_in_visual_order(&range) {
@@ -3036,8 +3018,6 @@ fn convert_text_run_to_glyphs(
} else {
glyph.advance()
};
- largest_advance = largest_advance.max(glyph.advance());
-
if !slice.glyphs.is_whitespace() {
let glyph_offset = glyph.offset().unwrap_or(Point2D::zero());
let point = origin + glyph_offset.to_vector();
@@ -3050,7 +3030,7 @@ fn convert_text_run_to_glyphs(
origin.x += glyph_advance;
}
}
- (largest_advance, glyphs)
+ return glyphs;
}
pub struct IndexableTextItem {
diff --git a/components/layout/display_list/conversions.rs b/components/layout/display_list/conversions.rs
index d081f40a10f..ecf20be3869 100644
--- a/components/layout/display_list/conversions.rs
+++ b/components/layout/display_list/conversions.rs
@@ -39,7 +39,7 @@ impl ToLayout for Filter {
type Type = wr::FilterOp;
fn to_layout(&self) -> Self::Type {
match *self {
- Filter::Blur(radius) => wr::FilterOp::Blur(radius.px(), radius.px()),
+ Filter::Blur(radius) => wr::FilterOp::Blur(radius.px()),
Filter::Brightness(amount) => wr::FilterOp::Brightness(amount.0),
Filter::Contrast(amount) => wr::FilterOp::Contrast(amount.0),
Filter::Grayscale(amount) => wr::FilterOp::Grayscale(amount.0),
diff --git a/components/layout/display_list/items.rs b/components/layout/display_list/items.rs
index 58a90447849..53e08fff1cb 100644
--- a/components/layout/display_list/items.rs
+++ b/components/layout/display_list/items.rs
@@ -30,10 +30,11 @@ pub use style::dom::OpaqueNode;
use webrender_api as wr;
use webrender_api::units::{LayoutPixel, LayoutRect, LayoutTransform};
use webrender_api::{
- BorderRadius, ClipChainId, ClipId, ClipMode, CommonItemProperties, ComplexClipRegion,
- ExternalScrollId, FilterOp, GlyphInstance, GradientStop, ImageKey, MixBlendMode,
- PrimitiveFlags, ScrollSensitivity, Shadow, SpatialId, StickyOffsetBounds, TransformStyle,
+ BorderRadius, ClipId, ClipMode, CommonItemProperties, ComplexClipRegion, ExternalScrollId,
+ FilterOp, GlyphInstance, GradientStop, ImageKey, MixBlendMode, PrimitiveFlags,
+ ScrollSensitivity, Shadow, SpatialId, StickyOffsetBounds, TransformStyle,
};
+use wr::ClipChainId;
/// The factor that we multiply the blur radius by in order to inflate the boundaries of display
/// items that involve a blur. This ensures that the display item boundaries include all the ink.
@@ -495,6 +496,7 @@ pub fn empty_common_item_properties() -> CommonItemProperties {
clip_rect: LayoutRect::max_rect(),
clip_id: ClipId::root(wr::PipelineId::dummy()),
spatial_id: SpatialId::root_scroll_node(wr::PipelineId::dummy()),
+ hit_info: None,
flags: PrimitiveFlags::empty(),
}
}
diff --git a/components/layout/display_list/webrender_helpers.rs b/components/layout/display_list/webrender_helpers.rs
index 1e584c0c06f..a8130a15936 100644
--- a/components/layout/display_list/webrender_helpers.rs
+++ b/components/layout/display_list/webrender_helpers.rs
@@ -49,7 +49,6 @@ impl<'a> ClipScrollState<'a> {
let root_clip_chain =
builder.define_clip_chain(None, [ClipId::root(state.compositor_info.pipeline_id)]);
-
state.add_clip_node_mapping(0, root_clip_chain);
state.add_clip_node_mapping(1, root_clip_chain);
@@ -115,7 +114,11 @@ impl DisplayList {
epoch: Epoch,
) -> (DisplayListBuilder, CompositorDisplayListInfo, IsContentful) {
let webrender_pipeline = pipeline_id.to_webrender();
- let mut builder = DisplayListBuilder::new(webrender_pipeline);
+ let mut builder = DisplayListBuilder::with_capacity(
+ webrender_pipeline,
+ self.bounds().size,
+ 1024 * 1024, // 1 MB of space
+ );
let content_size = self.bounds().size;
let mut state = ClipScrollState::new(
@@ -153,16 +156,17 @@ impl DisplayItem {
let internal_clip_id = clip_and_scroll_indices
.clipping
.unwrap_or(clip_and_scroll_indices.scrolling);
- let current_clip_chain_id = state.webrender_clip_id_for_index(internal_clip_id.to_index());
+ let current_clip_id = state.webrender_clip_id_for_index(internal_clip_id.to_index());
let hit_test_bounds = self.bounds().intersection(&self.base().clip_rect);
let build_common_item_properties = |base: &BaseDisplayItem| {
CommonItemProperties {
clip_rect: base.clip_rect,
spatial_id: current_scroll_node_id.spatial_id,
- clip_id: ClipId::ClipChain(current_clip_chain_id),
+ clip_id: ClipId::ClipChain(current_clip_id),
// TODO(gw): Make use of the WR backface visibility functionality.
flags: PrimitiveFlags::default(),
+ hit_info: None,
}
};
@@ -183,15 +187,10 @@ impl DisplayItem {
current_scroll_node_id,
);
- builder.push_hit_test(
- &CommonItemProperties {
- clip_rect: bounds,
- spatial_id: current_scroll_node_id.spatial_id,
- clip_id: ClipId::ClipChain(current_clip_chain_id),
- flags: PrimitiveFlags::default(),
- },
- (hit_test_index as u64, 0u16),
- );
+ let mut common = build_common_item_properties(base);
+ common.hit_info = Some((hit_test_index as u64, 0u16));
+ common.clip_rect = bounds;
+ builder.push_hit_test(&common);
};
match *self {
@@ -303,13 +302,7 @@ impl DisplayItem {
scrolling_relative_to: None,
},
),
- (Some(t), None) => (
- t,
- ReferenceFrameKind::Transform {
- is_2d_scale_translation: false,
- should_snap: false,
- },
- ),
+ (Some(t), None) => (t, ReferenceFrameKind::Transform),
(Some(t), Some(p)) => (
p.then(&t),
ReferenceFrameKind::Perspective {
@@ -328,7 +321,7 @@ impl DisplayItem {
);
let index = frame_index.to_index();
- state.add_clip_node_mapping(index, current_clip_chain_id);
+ state.add_clip_node_mapping(index, current_clip_id);
state.register_spatial_node(
index,
new_spatial_id,
@@ -415,7 +408,7 @@ impl DisplayItem {
let spatial_id = builder
.define_scroll_frame(
&parent_space_and_clip_info,
- external_id,
+ Some(external_id),
node.content_rect,
item_rect,
scroll_sensitivity,
diff --git a/components/layout_2020/display_list/background.rs b/components/layout_2020/display_list/background.rs
index a8e5b6cce24..6ea3f743122 100644
--- a/components/layout_2020/display_list/background.rs
+++ b/components/layout_2020/display_list/background.rs
@@ -66,8 +66,8 @@ pub(super) fn painting_area<'a>(
};
// The 'backgound-clip' property maps directly to `clip_rect` in `CommonItemProperties`:
let mut common = builder.common_properties(*painting_area, &fb.fragment.style);
- if let Some(clip_chain_id) = clip {
- common.clip_id = wr::ClipId::ClipChain(clip_chain_id)
+ if let Some(clip_id) = clip {
+ common.clip_id = clip_id
}
(painting_area, common)
}
diff --git a/components/layout_2020/display_list/conversions.rs b/components/layout_2020/display_list/conversions.rs
index b0022c99cdf..e7f86c0ad36 100644
--- a/components/layout_2020/display_list/conversions.rs
+++ b/components/layout_2020/display_list/conversions.rs
@@ -19,7 +19,7 @@ impl ToWebRender for ComputedFilter {
type Type = FilterOp;
fn to_webrender(&self) -> Self::Type {
match *self {
- ComputedFilter::Blur(radius) => FilterOp::Blur(radius.px(), radius.px()),
+ ComputedFilter::Blur(radius) => FilterOp::Blur(radius.px()),
ComputedFilter::Brightness(amount) => FilterOp::Brightness(amount.0),
ComputedFilter::Contrast(amount) => FilterOp::Contrast(amount.0),
ComputedFilter::Grayscale(amount) => FilterOp::Grayscale(amount.0),
diff --git a/components/layout_2020/display_list/mod.rs b/components/layout_2020/display_list/mod.rs
index 228aa6df62f..edaf7b294ca 100644
--- a/components/layout_2020/display_list/mod.rs
+++ b/components/layout_2020/display_list/mod.rs
@@ -20,7 +20,7 @@ use style::values::computed::{BorderStyle, Color, Length, LengthPercentage, Outl
use style::values::specified::text::TextDecorationLine;
use style::values::specified::ui::CursorKind;
use style_traits::CSSPixel;
-use webrender_api::{self as wr, units, ClipChainId, ClipId, CommonItemProperties};
+use webrender_api::{self as wr, units};
use crate::context::LayoutContext;
use crate::display_list::conversions::ToWebRender;
@@ -73,7 +73,7 @@ impl DisplayList {
epoch: wr::Epoch,
) -> Self {
Self {
- wr: wr::DisplayListBuilder::new(pipeline_id),
+ wr: wr::DisplayListBuilder::new(pipeline_id, content_size),
compositor_info: CompositorDisplayListInfo::new(
viewport_size,
content_size,
@@ -95,7 +95,7 @@ pub(crate) struct DisplayListBuilder<'a> {
/// only passing the builder instead passing the containing
/// [stacking_context::StackingContextFragment] as an argument to display
/// list building functions.
- current_clip_chain_id: ClipChainId,
+ current_clip_id: wr::ClipId,
/// The [OpaqueNode] handle to the node used to paint the page background
/// if the background was a canvas.
@@ -128,8 +128,8 @@ impl DisplayList {
root_stacking_context: &StackingContext,
) -> (FnvHashMap<BrowsingContextId, Size2D<f32, CSSPixel>>, bool) {
let mut builder = DisplayListBuilder {
- current_scroll_node_id: self.compositor_info.root_reference_frame_id,
- current_clip_chain_id: ClipChainId(0, self.compositor_info.pipeline_id),
+ current_scroll_node_id: self.compositor_info.root_scroll_node_id,
+ current_clip_id: wr::ClipId::root(self.wr.pipeline_id),
element_for_canvas_background: fragment_tree.canvas_background.from_element,
is_contentful: false,
context,
@@ -157,7 +157,8 @@ impl<'a> DisplayListBuilder<'a> {
wr::CommonItemProperties {
clip_rect,
spatial_id: self.current_scroll_node_id.spatial_id,
- clip_id: ClipId::ClipChain(self.current_clip_chain_id),
+ clip_id: self.current_clip_id,
+ hit_info: None,
flags: style.get_webrender_primitive_flags(),
}
}
@@ -282,21 +283,12 @@ impl Fragment {
return;
}
- if let Some(hit_info) =
- builder.hit_info(&fragment.parent_style, fragment.base.tag, Cursor::Text)
- {
- let clip_chain_id = builder.current_clip_chain_id;
- let spatial_id = builder.current_scroll_node_id.spatial_id;
- builder.wr().push_hit_test(
- &CommonItemProperties {
- clip_rect: rect.to_webrender(),
- clip_id: ClipId::ClipChain(clip_chain_id),
- spatial_id,
- flags: fragment.parent_style.get_webrender_primitive_flags(),
- },
- hit_info,
- );
- }
+ let common = builder.common_properties(rect.to_webrender(), &fragment.parent_style);
+
+ let hit_info = builder.hit_info(&fragment.parent_style, fragment.base.tag, Cursor::Text);
+ let mut hit_test_common = common.clone();
+ hit_test_common.hit_info = hit_info;
+ builder.wr().push_hit_test(&hit_test_common);
let color = fragment.parent_style.clone_color();
let font_metrics = &fragment.font_metrics;
@@ -328,7 +320,6 @@ impl Fragment {
}
// Text.
- let common = builder.common_properties(rect.to_webrender(), &fragment.parent_style);
builder.wr().push_text(
&common,
rect.to_webrender(),
@@ -387,9 +378,9 @@ struct BuilderForBoxFragment<'a> {
padding_rect: OnceCell<units::LayoutRect>,
content_rect: OnceCell<units::LayoutRect>,
border_radius: wr::BorderRadius,
- border_edge_clip_chain_id: OnceCell<Option<ClipChainId>>,
- padding_edge_clip_chain_id: OnceCell<Option<ClipChainId>>,
- content_edge_clip_chain_id: OnceCell<Option<ClipChainId>>,
+ border_edge_clip_id: OnceCell<Option<wr::ClipId>>,
+ padding_edge_clip_id: OnceCell<Option<wr::ClipId>>,
+ content_edge_clip_id: OnceCell<Option<wr::ClipId>>,
}
impl<'a> BuilderForBoxFragment<'a> {
@@ -444,9 +435,9 @@ impl<'a> BuilderForBoxFragment<'a> {
border_radius,
padding_rect: OnceCell::new(),
content_rect: OnceCell::new(),
- border_edge_clip_chain_id: OnceCell::new(),
- padding_edge_clip_chain_id: OnceCell::new(),
- content_edge_clip_chain_id: OnceCell::new(),
+ border_edge_clip_id: OnceCell::new(),
+ padding_edge_clip_id: OnceCell::new(),
+ content_edge_clip_id: OnceCell::new(),
}
}
@@ -470,14 +461,14 @@ impl<'a> BuilderForBoxFragment<'a> {
})
}
- fn border_edge_clip(&self, builder: &mut DisplayListBuilder) -> Option<ClipChainId> {
+ fn border_edge_clip(&self, builder: &mut DisplayListBuilder) -> Option<wr::ClipId> {
*self
- .border_edge_clip_chain_id
+ .border_edge_clip_id
.get_or_init(|| clip_for_radii(self.border_radius, self.border_rect, builder))
}
- fn padding_edge_clip(&self, builder: &mut DisplayListBuilder) -> Option<ClipChainId> {
- *self.padding_edge_clip_chain_id.get_or_init(|| {
+ fn padding_edge_clip(&self, builder: &mut DisplayListBuilder) -> Option<wr::ClipId> {
+ *self.padding_edge_clip_id.get_or_init(|| {
clip_for_radii(
inner_radii(
self.border_radius,
@@ -492,8 +483,8 @@ impl<'a> BuilderForBoxFragment<'a> {
})
}
- fn content_edge_clip(&self, builder: &mut DisplayListBuilder) -> Option<ClipChainId> {
- *self.content_edge_clip_chain_id.get_or_init(|| {
+ fn content_edge_clip(&self, builder: &mut DisplayListBuilder) -> Option<wr::ClipId> {
+ *self.content_edge_clip_id.get_or_init(|| {
clip_for_radii(
inner_radii(
self.border_radius,
@@ -523,16 +514,14 @@ impl<'a> BuilderForBoxFragment<'a> {
self.fragment.base.tag,
Cursor::Default,
);
- let hit_info = match hit_info {
- Some(hit_info) => hit_info,
- None => return,
- };
-
- let mut common = builder.common_properties(self.border_rect, &self.fragment.style);
- if let Some(clip_chain_id) = self.border_edge_clip(builder) {
- common.clip_id = ClipId::ClipChain(clip_chain_id);
+ if hit_info.is_some() {
+ let mut common = builder.common_properties(self.border_rect, &self.fragment.style);
+ common.hit_info = hit_info;
+ if let Some(clip_id) = self.border_edge_clip(builder) {
+ common.clip_id = clip_id
+ }
+ builder.wr().push_hit_test(&common)
}
- builder.wr().push_hit_test(&common, hit_info);
}
fn build_background(&mut self, builder: &mut DisplayListBuilder) {
@@ -881,27 +870,21 @@ fn clip_for_radii(
radii: wr::BorderRadius,
rect: units::LayoutRect,
builder: &mut DisplayListBuilder,
-) -> Option<ClipChainId> {
+) -> Option<wr::ClipId> {
if radii.is_zero() {
None
} else {
- let clip_chain_id = builder.current_clip_chain_id.clone();
let parent_space_and_clip = wr::SpaceAndClipInfo {
spatial_id: builder.current_scroll_node_id.spatial_id,
- clip_id: ClipId::ClipChain(clip_chain_id),
+ clip_id: builder.current_clip_id,
};
- let new_clip_id = builder.wr().define_clip_rounded_rect(
+ Some(builder.wr().define_clip_rounded_rect(
&parent_space_and_clip,
wr::ComplexClipRegion {
rect,
radii,
mode: wr::ClipMode::Clip,
},
- );
- Some(
- builder
- .wr()
- .define_clip_chain(Some(clip_chain_id), [new_clip_id]),
- )
+ ))
}
}
diff --git a/components/layout_2020/display_list/stacking_context.rs b/components/layout_2020/display_list/stacking_context.rs
index f69e8f6e946..0e6abdbdc11 100644
--- a/components/layout_2020/display_list/stacking_context.rs
+++ b/components/layout_2020/display_list/stacking_context.rs
@@ -19,7 +19,6 @@ use style::values::generics::transform;
use style::values::specified::box_::DisplayOutside;
use webrender_api as wr;
use webrender_api::units::{LayoutPoint, LayoutRect, LayoutTransform, LayoutVector2D};
-use webrender_api::ScrollSensitivity;
use super::DisplayList;
use crate::cell::ArcRefCell;
@@ -152,16 +151,17 @@ impl DisplayList {
external_id: wr::ExternalScrollId,
content_rect: LayoutRect,
clip_rect: LayoutRect,
- scroll_sensitivity: ScrollSensitivity,
+ scroll_sensitivity: wr::ScrollSensitivity,
+ external_scroll_offset: LayoutVector2D,
) -> (ScrollTreeNodeId, wr::ClipChainId) {
let parent_space_and_clip_info = wr::SpaceAndClipInfo {
spatial_id: parent_scroll_node_id.spatial_id,
clip_id: wr::ClipId::root(self.wr.pipeline_id),
};
+
let new_clip_id = self
.wr
.define_clip_rect(&parent_space_and_clip_info, clip_rect);
-
let new_clip_chain_id = self
.wr
.define_clip_chain(Some(*parent_clip_chain_id), [new_clip_id]);
@@ -170,11 +170,11 @@ impl DisplayList {
.wr
.define_scroll_frame(
&parent_space_and_clip_info,
- external_id,
+ Some(external_id),
content_rect,
clip_rect,
scroll_sensitivity,
- LayoutVector2D::zero(), /* external_scroll_offset */
+ external_scroll_offset,
)
.spatial_id;
@@ -203,7 +203,7 @@ pub(crate) struct StackingContextFragment {
impl StackingContextFragment {
fn build_display_list(&self, builder: &mut DisplayListBuilder) {
builder.current_scroll_node_id = self.scroll_node_id;
- builder.current_clip_chain_id = self.clip_chain_id;
+ builder.current_clip_id = wr::ClipId::ClipChain(self.clip_chain_id);
self.fragment
.borrow()
.build_display_list(builder, &self.containing_block, self.section);
@@ -965,9 +965,9 @@ impl BoxFragment {
let sensitivity =
if ComputedOverflow::Hidden == overflow_x && ComputedOverflow::Hidden == overflow_y {
- ScrollSensitivity::Script
+ wr::ScrollSensitivity::Script
} else {
- ScrollSensitivity::ScriptAndInputEvents
+ wr::ScrollSensitivity::ScriptAndInputEvents
};
let padding_rect = self
@@ -985,6 +985,7 @@ impl BoxFragment {
.to_webrender(),
padding_rect,
sensitivity,
+ LayoutVector2D::zero(),
),
)
}
@@ -1013,13 +1014,7 @@ impl BoxFragment {
scrolling_relative_to: None,
},
),
- (Some(transform), None) => (
- transform,
- wr::ReferenceFrameKind::Transform {
- is_2d_scale_translation: false,
- should_snap: false,
- },
- ),
+ (Some(transform), None) => (transform, wr::ReferenceFrameKind::Transform),
(Some(transform), Some(perspective)) => (
perspective.then(&transform),
wr::ReferenceFrameKind::Perspective {
diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs
index 515648e21e3..6d5fca7f03c 100644
--- a/components/layout_thread/lib.rs
+++ b/components/layout_thread/lib.rs
@@ -108,7 +108,7 @@ use style::thread_state::{self, ThreadState};
use style::traversal::DomTraversal;
use style::traversal_flags::TraversalFlags;
use style_traits::{CSSPixel, DevicePixel, SpeculativePainter};
-use webrender_api::{units, ColorF, HitTestFlags};
+use webrender_api::{units, ColorF, HitTestFlags, ScrollClamping};
/// Information needed by the layout thread.
pub struct LayoutThread {
@@ -1072,7 +1072,7 @@ impl LayoutThread {
.maybe_observe_paint_time(self, epoch, is_contentful.0);
self.webrender_api
- .send_display_list(compositor_info, builder.finalize().1);
+ .send_display_list(compositor_info, builder.finalize());
},
);
}
@@ -1507,8 +1507,11 @@ impl LayoutThread {
.insert(state.scroll_id, state.scroll_offset);
let point = Point2D::new(-state.scroll_offset.x, -state.scroll_offset.y);
- self.webrender_api
- .send_scroll_node(units::LayoutPoint::from_untyped(point), state.scroll_id);
+ self.webrender_api.send_scroll_node(
+ units::LayoutPoint::from_untyped(point),
+ state.scroll_id,
+ ScrollClamping::ToContentBounds,
+ );
}
fn set_scroll_states<'a, 'b>(
diff --git a/components/layout_thread_2020/lib.rs b/components/layout_thread_2020/lib.rs
index 56bbd204e78..7cacdb4e180 100644
--- a/components/layout_thread_2020/lib.rs
+++ b/components/layout_thread_2020/lib.rs
@@ -91,7 +91,7 @@ use style::thread_state::{self, ThreadState};
use style::traversal::DomTraversal;
use style::traversal_flags::TraversalFlags;
use style_traits::{CSSPixel, DevicePixel, SpeculativePainter};
-use webrender_api::{units, HitTestFlags};
+use webrender_api::{units, HitTestFlags, ScrollClamping};
/// Information needed by the layout thread.
pub struct LayoutThread {
@@ -1169,8 +1169,11 @@ impl LayoutThread {
.insert(state.scroll_id, state.scroll_offset);
let point = Point2D::new(-state.scroll_offset.x, -state.scroll_offset.y);
- self.webrender_api
- .send_scroll_node(units::LayoutPoint::from_untyped(point), state.scroll_id);
+ self.webrender_api.send_scroll_node(
+ units::LayoutPoint::from_untyped(point),
+ state.scroll_id,
+ ScrollClamping::ToContentBounds,
+ );
}
fn set_scroll_states<'a, 'b>(
@@ -1277,7 +1280,7 @@ impl LayoutThread {
.maybe_observe_paint_time(self, epoch, is_contentful);
self.webrender_api
- .send_display_list(display_list.compositor_info, display_list.wr.finalize().1);
+ .send_display_list(display_list.compositor_info, display_list.wr.finalize());
self.update_iframe_sizes(iframe_sizes);
diff --git a/components/malloc_size_of/lib.rs b/components/malloc_size_of/lib.rs
index 9a7be7423e6..c472a5c3606 100644
--- a/components/malloc_size_of/lib.rs
+++ b/components/malloc_size_of/lib.rs
@@ -62,7 +62,7 @@ use webrender_api::{
BorderRadius, BorderStyle, BoxShadowClipMode, ColorF, ComplexClipRegion, ExtendMode,
ExternalScrollId, FilterOp, FontInstanceKey, GlyphInstance, GradientStop, ImageKey,
ImageRendering, LineStyle, MixBlendMode, NinePatchBorder, NormalBorder, RepeatMode,
- StickyOffsetBounds, TransformStyle,
+ ScrollSensitivity, StickyOffsetBounds, TransformStyle,
};
/// A C function that takes a pointer to a heap allocation and returns its size.
@@ -844,6 +844,8 @@ malloc_size_of_is_0!(NormalBorder);
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(RepeatMode);
#[cfg(feature = "webrender_api")]
+malloc_size_of_is_0!(ScrollSensitivity);
+#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(StickyOffsetBounds);
#[cfg(feature = "webrender_api")]
malloc_size_of_is_0!(TransformStyle);
diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs
index acd15800935..fc74a6ab9a3 100644
--- a/components/script/dom/htmlmediaelement.rs
+++ b/components/script/dom/htmlmediaelement.rs
@@ -34,10 +34,9 @@ use servo_media::player::{PlaybackState, Player, PlayerError, PlayerEvent, SeekL
use servo_media::{ClientContextId, ServoMedia, SupportsMediaType};
use servo_url::ServoUrl;
use time::{self, Duration, Timespec};
-use webrender_api::{
- ExternalImageData, ExternalImageId, ExternalImageType, ImageBufferKind, ImageData,
- ImageDescriptor, ImageDescriptorFlags, ImageFormat, ImageKey,
-};
+use webrender_api::ImageKey;
+use webrender_api::{ExternalImageData, ExternalImageId, ExternalImageType, TextureTarget};
+use webrender_api::{ImageData, ImageDescriptor, ImageDescriptorFlags, ImageFormat};
use crate::document_loader::{LoadBlocker, LoadType};
use crate::dom::attr::Attr;
@@ -230,9 +229,9 @@ impl VideoFrameRenderer for MediaFrameRenderer {
let image_data = if frame.is_gl_texture() && self.player_id.is_some() {
let texture_target = if frame.is_external_oes() {
- ImageBufferKind::TextureExternal
+ TextureTarget::External
} else {
- ImageBufferKind::Texture2D
+ TextureTarget::Default
};
ImageData::External(ExternalImageData {
@@ -259,9 +258,9 @@ impl VideoFrameRenderer for MediaFrameRenderer {
let image_data = if frame.is_gl_texture() && self.player_id.is_some() {
let texture_target = if frame.is_external_oes() {
- ImageBufferKind::TextureExternal
+ TextureTarget::External
} else {
- ImageBufferKind::Texture2D
+ TextureTarget::Default
};
ImageData::External(ExternalImageData {
diff --git a/components/script_traits/compositor.rs b/components/script_traits/compositor.rs
index 43ab572e3bc..b63106d88ab 100644
--- a/components/script_traits/compositor.rs
+++ b/components/script_traits/compositor.rs
@@ -220,9 +220,6 @@ pub struct CompositorDisplayListInfo {
/// The size of the viewport that this display list renders into.
pub viewport_size: LayoutSize,
- /// The size of this display list's content.
- pub content_size: LayoutSize,
-
/// The epoch of the display list.
pub epoch: Epoch,
@@ -273,7 +270,6 @@ impl CompositorDisplayListInfo {
CompositorDisplayListInfo {
pipeline_id,
viewport_size,
- content_size,
epoch,
hit_test_info: Default::default(),
scroll_tree,
diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs
index 64c213955c2..0edf96b2d65 100644
--- a/components/script_traits/lib.rs
+++ b/components/script_traits/lib.rs
@@ -57,10 +57,13 @@ use servo_atoms::Atom;
use servo_url::{ImmutableOrigin, ServoUrl};
use style_traits::{CSSPixel, SpeculativePainter};
use webgpu::identity::WebGPUMsg;
-use webrender_api::units::{DeviceIntSize, DevicePixel, LayoutPixel, LayoutPoint, WorldPoint};
+use webrender_api::units::{
+ DeviceIntSize, DevicePixel, LayoutPixel, LayoutPoint, LayoutSize, WorldPoint,
+};
use webrender_api::{
BuiltDisplayList, BuiltDisplayListDescriptor, DocumentId, ExternalImageData, ExternalScrollId,
HitTestFlags, ImageData, ImageDescriptor, ImageKey, PipelineId as WebRenderPipelineId,
+ ScrollClamping,
};
use crate::compositor::CompositorDisplayListInfo;
@@ -1120,11 +1123,13 @@ pub enum WebrenderMsg {
/// Inform WebRender of the existence of this pipeline.
SendInitialTransaction(WebRenderPipelineId),
/// Perform a scroll operation.
- SendScrollNode(LayoutPoint, ExternalScrollId),
+ SendScrollNode(LayoutPoint, ExternalScrollId, ScrollClamping),
/// Inform WebRender of a new display list for the given pipeline.
SendDisplayList {
/// The [CompositorDisplayListInfo] that describes the display list being sent.
display_list_info: CompositorDisplayListInfo,
+ /// The content size of this display list as calculated by WebRender.
+ content_size: LayoutSize,
/// A descriptor of this display list used to construct this display list from raw data.
display_list_descriptor: BuiltDisplayListDescriptor,
/// An [ipc::IpcBytesReceiver] used to send the raw data of the display list.
@@ -1163,8 +1168,16 @@ impl WebrenderIpcSender {
}
/// Perform a scroll operation.
- pub fn send_scroll_node(&self, point: LayoutPoint, scroll_id: ExternalScrollId) {
- if let Err(e) = self.0.send(WebrenderMsg::SendScrollNode(point, scroll_id)) {
+ pub fn send_scroll_node(
+ &self,
+ point: LayoutPoint,
+ scroll_id: ExternalScrollId,
+ clamping: ScrollClamping,
+ ) {
+ if let Err(e) = self
+ .0
+ .send(WebrenderMsg::SendScrollNode(point, scroll_id, clamping))
+ {
warn!("Error sending scroll node: {}", e);
}
}
@@ -1173,12 +1186,13 @@ impl WebrenderIpcSender {
pub fn send_display_list(
&self,
display_list_info: CompositorDisplayListInfo,
- list: BuiltDisplayList,
+ (_, content_size, list): (WebRenderPipelineId, LayoutSize, BuiltDisplayList),
) {
let (display_list_data, display_list_descriptor) = list.into_data();
let (display_list_sender, display_list_receiver) = ipc::bytes_channel().unwrap();
if let Err(e) = self.0.send(WebrenderMsg::SendDisplayList {
display_list_info,
+ content_size,
display_list_descriptor,
display_list_receiver,
}) {
diff --git a/components/servo/lib.rs b/components/servo/lib.rs
index e62a8e5f11b..b131f5e2523 100644
--- a/components/servo/lib.rs
+++ b/components/servo/lib.rs
@@ -23,6 +23,15 @@ use std::collections::HashMap;
use std::path::PathBuf;
use std::rc::Rc;
use std::sync::{Arc, Mutex};
+use webrender_api::{DocumentId, FontInstanceKey, FontKey, ImageKey, RenderApiSender};
+
+#[cfg(feature = "webdriver")]
+fn webdriver(port: u16, constellation: Sender<ConstellationMsg>) {
+ webdriver_server::start_server(port, constellation);
+}
+
+#[cfg(not(feature = "webdriver"))]
+fn webdriver(_port: u16, _constellation: Sender<ConstellationMsg>) {}
use bluetooth::BluetoothThreadFactory;
use bluetooth_traits::BluetoothRequest;
@@ -50,7 +59,7 @@ use constellation::{
use crossbeam_channel::{unbounded, Sender};
use embedder_traits::{EmbedderMsg, EmbedderProxy, EmbedderReceiver, EventLoopWaker};
use env_logger::Builder as EnvLoggerBuilder;
-use euclid::Scale;
+use euclid::{Scale, Size2D};
#[cfg(all(
not(target_os = "windows"),
not(target_os = "ios"),
@@ -77,11 +86,6 @@ use servo_config::{opts, pref, prefs};
use servo_media::player::context::GlContext;
use servo_media::ServoMedia;
use surfman::GLApi;
-use webrender::{RenderApiSender, ShaderPrecacheFlags};
-use webrender_api::{DocumentId, FontInstanceKey, FontKey, ImageKey};
-use webrender_traits::{
- WebrenderExternalImageHandlers, WebrenderExternalImageRegistry, WebrenderImageHandlerType,
-};
pub use {
background_hang_monitor, bluetooth, bluetooth_traits, canvas, canvas_traits, compositing,
constellation, devtools, devtools_traits, embedder_traits, euclid, gfx, ipc_channel,
@@ -90,14 +94,10 @@ pub use {
servo_config, servo_geometry, servo_url as url, servo_url, style, style_traits, webgpu,
webrender_api, webrender_surfman, webrender_traits,
};
-
-#[cfg(feature = "webdriver")]
-fn webdriver(port: u16, constellation: Sender<ConstellationMsg>) {
- webdriver_server::start_server(port, constellation);
-}
-
-#[cfg(not(feature = "webdriver"))]
-fn webdriver(_port: u16, _constellation: Sender<ConstellationMsg>) {}
+use webrender::ShaderPrecacheFlags;
+use webrender_traits::WebrenderExternalImageHandlers;
+use webrender_traits::WebrenderExternalImageRegistry;
+use webrender_traits::WebrenderImageHandlerType;
#[cfg(feature = "media-gstreamer")]
mod media_platform {
@@ -187,11 +187,9 @@ impl webrender_api::RenderNotifier for RenderNotifier {
Box::new(RenderNotifier::new(self.compositor_proxy.clone()))
}
- fn wake_up(&self, composite_needed: bool) {
- if composite_needed {
- self.compositor_proxy
- .recomposite(CompositingReason::NewWebRenderFrame);
- }
+ fn wake_up(&self) {
+ self.compositor_proxy
+ .recomposite(CompositingReason::NewWebRenderFrame);
}
fn new_frame_ready(
@@ -205,7 +203,7 @@ impl webrender_api::RenderNotifier for RenderNotifier {
self.compositor_proxy
.send(CompositorMsg::NewScrollFrameReady(composite_needed));
} else {
- self.wake_up(true);
+ self.wake_up();
}
}
}
@@ -305,7 +303,7 @@ where
None
};
- let coordinates: compositing::windowing::EmbedderCoordinates = window.get_coordinates();
+ let coordinates = window.get_coordinates();
let device_pixel_ratio = coordinates.hidpi_factor.get();
let viewport_size = coordinates.viewport.size.to_f32() / device_pixel_ratio;
@@ -317,6 +315,10 @@ where
);
let render_notifier = Box::new(RenderNotifier::new(compositor_proxy.clone()));
+
+ // Cast from `DeviceIndependentPixel` to `DevicePixel`
+ let window_size = Size2D::from_untyped(viewport_size.to_i32().to_untyped());
+
webrender::Renderer::new(
webrender_gl.clone(),
render_notifier,
@@ -337,12 +339,20 @@ where
..Default::default()
},
None,
+ window_size,
)
.expect("Unable to initialize webrender!")
};
let webrender_api = webrender_api_sender.create_api();
- let webrender_document = webrender_api.add_document(coordinates.get_viewport().size);
+ let wr_document_layer = 0; //TODO
+ let webrender_document =
+ webrender_api.add_document(coordinates.framebuffer, wr_document_layer);
+ webrender_api.set_document_view(
+ webrender_document,
+ coordinates.get_viewport(),
+ coordinates.hidpi_factor.get(),
+ );
// Important that this call is done in a single-threaded fashion, we
// can't defer it after `create_constellation` has started.
@@ -535,9 +545,8 @@ where
self.compositor.on_wheel_event(delta, location);
},
- EmbedderEvent::Scroll(scroll_location, cursor, phase) => {
- self.compositor
- .on_scroll_event(scroll_location, cursor, phase);
+ EmbedderEvent::Scroll(delta, cursor, phase) => {
+ self.compositor.on_scroll_event(delta, cursor, phase);
},
EmbedderEvent::Zoom(magnification) => {
diff --git a/components/webgpu/Cargo.toml b/components/webgpu/Cargo.toml
index 718df8f418d..a0494808b2e 100644
--- a/components/webgpu/Cargo.toml
+++ b/components/webgpu/Cargo.toml
@@ -20,7 +20,6 @@ msg = { path = "../msg" }
serde = { workspace = true, features = ["serde_derive"] }
servo_config = { path = "../config" }
smallvec = { workspace = true, features = ["serde"] }
-webrender = { workspace = true }
webrender_api = { workspace = true }
webrender_traits = { path = "../webrender_traits" }
wgpu-core = { version = "0.17", features = ["replay", "trace", "serial-pass", "wgsl"] }
diff --git a/components/webgpu/lib.rs b/components/webgpu/lib.rs
index 443190fced7..36531059d4a 100644
--- a/components/webgpu/lib.rs
+++ b/components/webgpu/lib.rs
@@ -26,8 +26,10 @@ use msg::constellation_msg::PipelineId;
use serde::{Deserialize, Serialize};
use servo_config::pref;
use smallvec::SmallVec;
-use webrender::{RenderApi, RenderApiSender, Transaction};
-use webrender_api::{DirtyRect, DocumentId, ExternalImageId, ImageData, ImageDescriptor, ImageKey};
+use webrender_api::{
+ DirtyRect, DocumentId, ExternalImageId, ImageData, ImageDescriptor, ImageKey, RenderApi,
+ RenderApiSender, Transaction,
+};
use webrender_traits::{
WebrenderExternalImageApi, WebrenderExternalImageRegistry, WebrenderImageHandlerType,
WebrenderImageSource,