mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Upgrade WebRender to e491e1ae637b2eed1e7195855d88357e5eb3ddf9 (#30323)
* Upgrade vendored version of WebRender * Patch WebRender: upgrade version of gleam * Restore hit testing implementation * Fix WebRender warnings * Adapt Servo to new WebRender * Update results * Add a workaround for #30313 This slightly expands text boundaries in order to take into account the fact that layout isn't measuring glyph boundaries.
This commit is contained in:
parent
c079acb3c3
commit
a9d37cb85a
563 changed files with 48524 additions and 51657 deletions
|
@ -71,10 +71,11 @@ 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};
|
||||
use webrender_api::{ColorU, ExternalScrollId, FilterOp, GlyphInstance, ImageRendering, LineStyle};
|
||||
use webrender_api::{NinePatchBorder, NinePatchBorderSource, NormalBorder, PropertyBinding};
|
||||
use webrender_api::{ScrollSensitivity, StickyOffsetBounds};
|
||||
use webrender_api::{
|
||||
self, BorderDetails, BorderRadius, BorderSide, BoxShadowClipMode, ColorF, ColorU,
|
||||
ExternalScrollId, FilterOp, GlyphInstance, ImageRendering, LineStyle, NinePatchBorder,
|
||||
NinePatchBorderSource, NormalBorder, PropertyBinding, ScrollSensitivity, StickyOffsetBounds,
|
||||
};
|
||||
|
||||
static THREAD_TINT_COLORS: [ColorF; 8] = [
|
||||
ColorF {
|
||||
|
@ -2117,7 +2118,7 @@ impl Fragment {
|
|||
}
|
||||
|
||||
// Text
|
||||
let mut glyphs = convert_text_run_to_glyphs(
|
||||
let (largest_advance, mut glyphs) = convert_text_run_to_glyphs(
|
||||
text_fragment.run.clone(),
|
||||
text_fragment.range,
|
||||
baseline_origin,
|
||||
|
@ -2131,6 +2132,22 @@ 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![];
|
||||
|
@ -2142,7 +2159,7 @@ impl Fragment {
|
|||
state.add_display_item(DisplayItem::Text(CommonDisplayItem::with_data(
|
||||
base.clone(),
|
||||
webrender_api::TextDisplayItem {
|
||||
bounds: stacking_relative_content_box.to_layout(),
|
||||
bounds: inflated_bounds,
|
||||
common: items::empty_common_item_properties(),
|
||||
font_key: text_fragment.run.font_key,
|
||||
color: text_color.to_layout(),
|
||||
|
@ -3013,7 +3030,8 @@ fn convert_text_run_to_glyphs(
|
|||
text_run: Arc<TextRun>,
|
||||
range: Range<ByteIndex>,
|
||||
mut origin: Point2D<Au>,
|
||||
) -> Vec<GlyphInstance> {
|
||||
) -> (Au, Vec<GlyphInstance>) {
|
||||
let mut largest_advance = Au(0);
|
||||
let mut glyphs = vec![];
|
||||
|
||||
for slice in text_run.natural_word_slices_in_visual_order(&range) {
|
||||
|
@ -3023,6 +3041,8 @@ 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();
|
||||
|
@ -3035,7 +3055,7 @@ fn convert_text_run_to_glyphs(
|
|||
origin.x += glyph_advance;
|
||||
}
|
||||
}
|
||||
return glyphs;
|
||||
(largest_advance, glyphs)
|
||||
}
|
||||
|
||||
pub struct IndexableTextItem {
|
||||
|
|
|
@ -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()),
|
||||
Filter::Blur(radius) => wr::FilterOp::Blur(radius.px(), 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),
|
||||
|
|
|
@ -29,11 +29,10 @@ use style::computed_values::_servo_top_layer::T as InTopLayer;
|
|||
use webrender_api as wr;
|
||||
use webrender_api::units::{LayoutPixel, LayoutRect, LayoutTransform};
|
||||
use webrender_api::{
|
||||
BorderRadius, ClipId, ClipMode, CommonItemProperties, ComplexClipRegion, ExternalScrollId,
|
||||
FilterOp, GlyphInstance, GradientStop, ImageKey, MixBlendMode, PrimitiveFlags,
|
||||
ScrollSensitivity, Shadow, SpatialId, StickyOffsetBounds, TransformStyle,
|
||||
BorderRadius, ClipChainId, ClipId, ClipMode, CommonItemProperties, ComplexClipRegion,
|
||||
ExternalScrollId, FilterOp, GlyphInstance, GradientStop, ImageKey, MixBlendMode,
|
||||
PrimitiveFlags, ScrollSensitivity, Shadow, SpatialId, StickyOffsetBounds, TransformStyle,
|
||||
};
|
||||
use wr::ClipChainId;
|
||||
|
||||
pub use style::dom::OpaqueNode;
|
||||
|
||||
|
@ -497,7 +496,6 @@ 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(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ 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);
|
||||
|
||||
|
@ -111,11 +112,7 @@ impl DisplayList {
|
|||
epoch: Epoch,
|
||||
) -> (DisplayListBuilder, CompositorDisplayListInfo, IsContentful) {
|
||||
let webrender_pipeline = pipeline_id.to_webrender();
|
||||
let mut builder = DisplayListBuilder::with_capacity(
|
||||
webrender_pipeline,
|
||||
self.bounds().size,
|
||||
1024 * 1024, // 1 MB of space
|
||||
);
|
||||
let mut builder = DisplayListBuilder::new(webrender_pipeline);
|
||||
|
||||
let content_size = self.bounds().size;
|
||||
let mut state = ClipScrollState::new(
|
||||
|
@ -153,17 +150,16 @@ impl DisplayItem {
|
|||
let internal_clip_id = clip_and_scroll_indices
|
||||
.clipping
|
||||
.unwrap_or(clip_and_scroll_indices.scrolling);
|
||||
let current_clip_id = state.webrender_clip_id_for_index(internal_clip_id.to_index());
|
||||
let current_clip_chain_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_id),
|
||||
clip_id: ClipId::ClipChain(current_clip_chain_id),
|
||||
// TODO(gw): Make use of the WR backface visibility functionality.
|
||||
flags: PrimitiveFlags::default(),
|
||||
hit_info: None,
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -184,10 +180,15 @@ impl DisplayItem {
|
|||
current_scroll_node_id,
|
||||
);
|
||||
|
||||
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);
|
||||
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),
|
||||
);
|
||||
};
|
||||
|
||||
match *self {
|
||||
|
@ -299,7 +300,13 @@ impl DisplayItem {
|
|||
scrolling_relative_to: None,
|
||||
},
|
||||
),
|
||||
(Some(t), None) => (t, ReferenceFrameKind::Transform),
|
||||
(Some(t), None) => (
|
||||
t,
|
||||
ReferenceFrameKind::Transform {
|
||||
is_2d_scale_translation: false,
|
||||
should_snap: false,
|
||||
},
|
||||
),
|
||||
(Some(t), Some(p)) => (
|
||||
p.then(&t),
|
||||
ReferenceFrameKind::Perspective {
|
||||
|
@ -318,7 +325,7 @@ impl DisplayItem {
|
|||
);
|
||||
|
||||
let index = frame_index.to_index();
|
||||
state.add_clip_node_mapping(index, current_clip_id);
|
||||
state.add_clip_node_mapping(index, current_clip_chain_id);
|
||||
state.register_spatial_node(
|
||||
index,
|
||||
new_spatial_id,
|
||||
|
@ -405,7 +412,7 @@ impl DisplayItem {
|
|||
let spatial_id = builder
|
||||
.define_scroll_frame(
|
||||
&parent_space_and_clip_info,
|
||||
Some(external_id),
|
||||
external_id,
|
||||
node.content_rect,
|
||||
item_rect,
|
||||
scroll_sensitivity,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue