From 3c9a0952b5bc46c5d762f7a798a73ce997e5eb25 Mon Sep 17 00:00:00 2001 From: Timothy Nikkel Date: Mon, 23 Sep 2019 23:31:45 +0000 Subject: [PATCH] Bug 1582273. Pass scrollbar flags from gecko to webrender so it can identify them. r=gw Differential Revision: https://phabricator.services.mozilla.com/D46587 --HG-- extra : moz-landing-system : lando --- gfx/webrender_bindings/WebRenderAPI.h | 21 +++++++++++---------- gfx/webrender_bindings/src/bindings.rs | 4 ++-- gfx/wr/examples/alpha_perf.rs | 2 +- gfx/wr/examples/animation.rs | 2 +- gfx/wr/examples/basic.rs | 2 +- gfx/wr/examples/blob.rs | 4 ++-- gfx/wr/examples/document.rs | 2 +- gfx/wr/examples/frame_output.rs | 4 ++-- gfx/wr/examples/iframe.rs | 4 ++-- gfx/wr/examples/image_resize.rs | 2 +- gfx/wr/examples/multiwindow.rs | 2 +- gfx/wr/examples/scrolling.rs | 4 ++-- gfx/wr/examples/texture_cache_stress.rs | 2 +- gfx/wr/examples/yuv.rs | 2 +- gfx/wr/webrender/src/scene_building.rs | 16 +++++----------- gfx/wr/webrender_api/src/display_item.rs | 9 ++++++--- gfx/wr/webrender_api/src/display_list.rs | 12 ++++++------ gfx/wr/wrench/src/yaml_frame_reader.rs | 2 +- gfx/wr/wrench/src/yaml_frame_writer.rs | 6 +++++- layout/painting/nsDisplayList.cpp | 14 ++++++++++++-- 20 files changed, 64 insertions(+), 52 deletions(-) diff --git a/gfx/webrender_bindings/WebRenderAPI.h b/gfx/webrender_bindings/WebRenderAPI.h index e32cac082767..54c921b399d1 100644 --- a/gfx/webrender_bindings/WebRenderAPI.h +++ b/gfx/webrender_bindings/WebRenderAPI.h @@ -336,16 +336,17 @@ class MOZ_RAII AutoTransactionSender { */ struct MOZ_STACK_CLASS StackingContextParams : public WrStackingContextParams { StackingContextParams() - : WrStackingContextParams{WrStackingContextClip::None(), - nullptr, - nullptr, - wr::TransformStyle::Flat, - wr::WrReferenceFrameKind::Transform, - nullptr, - /* is_backface_visible = */ true, - /* cache_tiles = */ false, - wr::MixBlendMode::Normal, - /* is_backdrop_root = */ false} {} + : WrStackingContextParams{ + WrStackingContextClip::None(), + nullptr, + nullptr, + wr::TransformStyle::Flat, + wr::WrReferenceFrameKind::Transform, + nullptr, + /* prim_flags = */ wr::PrimitiveFlags_IS_BACKFACE_VISIBLE, + /* cache_tiles = */ false, + wr::MixBlendMode::Normal, + /* is_backdrop_root = */ false} {} void SetPreserve3D(bool aPreserve) { transform_style = diff --git a/gfx/webrender_bindings/src/bindings.rs b/gfx/webrender_bindings/src/bindings.rs index a754eea5688d..b4fa67d1e6c2 100644 --- a/gfx/webrender_bindings/src/bindings.rs +++ b/gfx/webrender_bindings/src/bindings.rs @@ -2065,7 +2065,7 @@ pub struct WrStackingContextParams { pub transform_style: TransformStyle, pub reference_frame_kind: WrReferenceFrameKind, pub scrolling_relative_to: *const u64, - pub is_backface_visible: bool, + pub prim_flags: PrimitiveFlags, /// True if picture caching should be enabled for this stacking context. pub cache_tiles: bool, pub mix_blend_mode: MixBlendMode, @@ -2185,7 +2185,7 @@ pub extern "C" fn wr_dp_push_stacking_context( .dl_builder .push_stacking_context(bounds.origin, wr_spatial_id, - params.is_backface_visible, + params.prim_flags, wr_clip_id, params.transform_style, params.mix_blend_mode, diff --git a/gfx/wr/examples/alpha_perf.rs b/gfx/wr/examples/alpha_perf.rs index ca32f7fb371a..5a4ab1eb1072 100644 --- a/gfx/wr/examples/alpha_perf.rs +++ b/gfx/wr/examples/alpha_perf.rs @@ -37,7 +37,7 @@ impl Example for App { builder.push_simple_stacking_context( bounds.origin, space_and_clip.spatial_id, - true, + PrimitiveFlags::IS_BACKFACE_VISIBLE, ); for _ in 0 .. self.rect_count { diff --git a/gfx/wr/examples/animation.rs b/gfx/wr/examples/animation.rs index ab53e4b15a70..4cd7f343ceed 100644 --- a/gfx/wr/examples/animation.rs +++ b/gfx/wr/examples/animation.rs @@ -68,7 +68,7 @@ impl App { builder.push_simple_stacking_context_with_filters( LayoutPoint::zero(), spatial_id, - true, + PrimitiveFlags::IS_BACKFACE_VISIBLE, &filters, &[], &[] diff --git a/gfx/wr/examples/basic.rs b/gfx/wr/examples/basic.rs index d5e5d09fba50..87d22a2e9b13 100644 --- a/gfx/wr/examples/basic.rs +++ b/gfx/wr/examples/basic.rs @@ -197,7 +197,7 @@ impl Example for App { builder.push_simple_stacking_context( content_bounds.origin, spatial_id, - true, + PrimitiveFlags::IS_BACKFACE_VISIBLE, ); let image_mask_key = api.generate_image_key(); diff --git a/gfx/wr/examples/blob.rs b/gfx/wr/examples/blob.rs index 470e9587c415..0ebc12f0d75a 100644 --- a/gfx/wr/examples/blob.rs +++ b/gfx/wr/examples/blob.rs @@ -16,7 +16,7 @@ use rayon::{ThreadPool, ThreadPoolBuilder}; use rayon::prelude::*; use std::collections::HashMap; use std::sync::Arc; -use webrender::api::{self, DisplayListBuilder, DocumentId, PipelineId, RenderApi, Transaction}; +use webrender::api::{self, DisplayListBuilder, DocumentId, PipelineId, PrimitiveFlags, RenderApi, Transaction}; use webrender::api::{ColorF, CommonItemProperties, SpaceAndClipInfo}; use webrender::api::units::*; use webrender::euclid::{size2, rect}; @@ -229,7 +229,7 @@ impl Example for App { builder.push_simple_stacking_context( LayoutPoint::zero(), space_and_clip.spatial_id, - true, + PrimitiveFlags::IS_BACKFACE_VISIBLE, ); let bounds = (30, 30).by(500, 500); diff --git a/gfx/wr/examples/document.rs b/gfx/wr/examples/document.rs index cb19c8574e29..ea11ec51876a 100644 --- a/gfx/wr/examples/document.rs +++ b/gfx/wr/examples/document.rs @@ -118,7 +118,7 @@ impl Example for App { builder.push_simple_stacking_context( doc.content_rect.origin, space_and_clip.spatial_id, - true, + PrimitiveFlags::IS_BACKFACE_VISIBLE, ); builder.push_rect( &CommonItemProperties::new(local_rect, space_and_clip), diff --git a/gfx/wr/examples/frame_output.rs b/gfx/wr/examples/frame_output.rs index c3e1e190b681..7531388f7596 100644 --- a/gfx/wr/examples/frame_output.rs +++ b/gfx/wr/examples/frame_output.rs @@ -119,7 +119,7 @@ impl App { builder.push_simple_stacking_context( document.content_rect.origin, space_and_clip.spatial_id, - true, + PrimitiveFlags::IS_BACKFACE_VISIBLE, ); builder.push_rect( @@ -164,7 +164,7 @@ impl Example for App { builder.push_simple_stacking_context( bounds.origin, space_and_clip.spatial_id, - true, + PrimitiveFlags::IS_BACKFACE_VISIBLE, ); builder.push_image( diff --git a/gfx/wr/examples/iframe.rs b/gfx/wr/examples/iframe.rs index f89f3b59ad85..c5cb38120cd5 100644 --- a/gfx/wr/examples/iframe.rs +++ b/gfx/wr/examples/iframe.rs @@ -41,7 +41,7 @@ impl Example for App { sub_builder.push_simple_stacking_context( sub_bounds.origin, space_and_clip.spatial_id, - true, + PrimitiveFlags::IS_BACKFACE_VISIBLE, ); // green rect visible == success @@ -73,7 +73,7 @@ impl Example for App { builder.push_simple_stacking_context( sub_bounds.origin, space_and_clip.spatial_id, - true, + PrimitiveFlags::IS_BACKFACE_VISIBLE, ); // red rect under the iframe: if this is visible, things have gone wrong diff --git a/gfx/wr/examples/image_resize.rs b/gfx/wr/examples/image_resize.rs index e71e9bc2aa86..63e44d67922a 100644 --- a/gfx/wr/examples/image_resize.rs +++ b/gfx/wr/examples/image_resize.rs @@ -44,7 +44,7 @@ impl Example for App { builder.push_simple_stacking_context( bounds.origin, space_and_clip.spatial_id, - true, + PrimitiveFlags::IS_BACKFACE_VISIBLE, ); let image_size = LayoutSize::new(100.0, 100.0); diff --git a/gfx/wr/examples/multiwindow.rs b/gfx/wr/examples/multiwindow.rs index 477e7afb1002..84a123fde4f8 100644 --- a/gfx/wr/examples/multiwindow.rs +++ b/gfx/wr/examples/multiwindow.rs @@ -190,7 +190,7 @@ impl Window { builder.push_simple_stacking_context( bounds.origin, space_and_clip.spatial_id, - true, + PrimitiveFlags::IS_BACKFACE_VISIBLE, ); builder.push_rect( diff --git a/gfx/wr/examples/scrolling.rs b/gfx/wr/examples/scrolling.rs index 72954a53669f..21cda52497a5 100644 --- a/gfx/wr/examples/scrolling.rs +++ b/gfx/wr/examples/scrolling.rs @@ -36,7 +36,7 @@ impl Example for App { builder.push_simple_stacking_context( LayoutPoint::zero(), root_space_and_clip.spatial_id, - true, + PrimitiveFlags::IS_BACKFACE_VISIBLE, ); if true { @@ -46,7 +46,7 @@ impl Example for App { builder.push_simple_stacking_context( LayoutPoint::new(10., 10.), root_space_and_clip.spatial_id, - true, + PrimitiveFlags::IS_BACKFACE_VISIBLE, ); // set the scrolling clip let space_and_clip1 = builder.define_scroll_frame( diff --git a/gfx/wr/examples/texture_cache_stress.rs b/gfx/wr/examples/texture_cache_stress.rs index 1fed7793457e..f99553fcb152 100644 --- a/gfx/wr/examples/texture_cache_stress.rs +++ b/gfx/wr/examples/texture_cache_stress.rs @@ -102,7 +102,7 @@ impl Example for App { builder.push_simple_stacking_context( bounds.origin, space_and_clip.spatial_id, - true, + PrimitiveFlags::IS_BACKFACE_VISIBLE, ); let x0 = 50.0; diff --git a/gfx/wr/examples/yuv.rs b/gfx/wr/examples/yuv.rs index 15b542e1c8ee..dd9b2059aabb 100644 --- a/gfx/wr/examples/yuv.rs +++ b/gfx/wr/examples/yuv.rs @@ -99,7 +99,7 @@ impl Example for App { builder.push_simple_stacking_context( bounds.origin, space_and_clip.spatial_id, - true, + PrimitiveFlags::IS_BACKFACE_VISIBLE, ); let yuv_chanel1 = api.generate_image_key(); diff --git a/gfx/wr/webrender/src/scene_building.rs b/gfx/wr/webrender/src/scene_building.rs index 8ebef53babcd..0646c9e775ef 100644 --- a/gfx/wr/webrender/src/scene_building.rs +++ b/gfx/wr/webrender/src/scene_building.rs @@ -361,7 +361,7 @@ impl<'a> SceneBuilder<'a> { root_pipeline.pipeline_id, CompositeOps::default(), TransformStyle::Flat, - /* is_backface_visible = */ true, + /* prim_flags = */ PrimitiveFlags::IS_BACKFACE_VISIBLE, /* create_tile_cache = */ false, ROOT_SPATIAL_NODE_INDEX, ClipChainId::NONE, @@ -912,7 +912,7 @@ impl<'a> SceneBuilder<'a> { filters: ItemRange, filter_datas: &[TempFilterData], filter_primitives: ItemRange, - is_backface_visible: bool, + prim_flags: PrimitiveFlags, apply_pipeline_clip: bool, ) { // Avoid doing unnecessary work for empty stacking contexts. @@ -939,7 +939,7 @@ impl<'a> SceneBuilder<'a> { pipeline_id, composition_operations, stacking_context.transform_style, - is_backface_visible, + prim_flags, stacking_context.cache_tiles, spatial_node_index, clip_chain_id, @@ -1373,7 +1373,7 @@ impl<'a> SceneBuilder<'a> { item.filters(), item.filter_datas(), item.filter_primitives(), - info.is_backface_visible, + info.prim_flags, apply_pipeline_clip, ); return Some(subtraversal); @@ -1771,7 +1771,7 @@ impl<'a> SceneBuilder<'a> { pipeline_id: PipelineId, composite_ops: CompositeOps, transform_style: TransformStyle, - is_backface_visible: bool, + prim_flags: PrimitiveFlags, create_tile_cache: bool, spatial_node_index: SpatialNodeIndex, clip_chain_id: ClipChainId, @@ -1895,12 +1895,6 @@ impl<'a> SceneBuilder<'a> { |sc| sc.snap_to_device.clone(), ); - let prim_flags = if is_backface_visible { - PrimitiveFlags::IS_BACKFACE_VISIBLE - } else { - PrimitiveFlags::empty() - }; - // Push the SC onto the stack, so we know how to handle things in // pop_stacking_context. self.sc_stack.push(FlattenedStackingContext { diff --git a/gfx/wr/webrender_api/src/display_item.rs b/gfx/wr/webrender_api/src/display_item.rs index 5766105ce2fe..dc564b4fc1bb 100644 --- a/gfx/wr/webrender_api/src/display_item.rs +++ b/gfx/wr/webrender_api/src/display_item.rs @@ -34,12 +34,15 @@ pub const MAX_BLUR_RADIUS: f32 = 300.; pub type ItemTag = (u64, u16); bitflags! { + #[repr(C)] #[derive(Deserialize, MallocSizeOf, Serialize, PeekPoke)] pub struct PrimitiveFlags: u8 { /// The CSS backface-visibility property (yes, it can be really granular) const IS_BACKFACE_VISIBLE = 1 << 0; - /// If set, this primitive represents part of a scroll bar - const IS_SCROLL_BAR = 1 << 1; + /// If set, this primitive represents a scroll bar container + const IS_SCROLLBAR_CONTAINER = 1 << 1; + /// If set, this primitive represents a scroll bar thumb + const IS_SCROLLBAR_THUMB = 1 << 2; } } @@ -670,7 +673,7 @@ pub struct ReferenceFrame { pub struct PushStackingContextDisplayItem { pub origin: LayoutPoint, pub spatial_id: SpatialId, - pub is_backface_visible: bool, + pub prim_flags: PrimitiveFlags, pub stacking_context: StackingContext, } diff --git a/gfx/wr/webrender_api/src/display_list.rs b/gfx/wr/webrender_api/src/display_list.rs index 2e6426a5630b..47a69aa45be2 100644 --- a/gfx/wr/webrender_api/src/display_list.rs +++ b/gfx/wr/webrender_api/src/display_list.rs @@ -1254,7 +1254,7 @@ impl DisplayListBuilder { &mut self, origin: LayoutPoint, spatial_id: di::SpatialId, - is_backface_visible: bool, + prim_flags: di::PrimitiveFlags, clip_id: Option, transform_style: di::TransformStyle, mix_blend_mode: di::MixBlendMode, @@ -1270,7 +1270,7 @@ impl DisplayListBuilder { let item = di::DisplayItem::PushStackingContext(di::PushStackingContextDisplayItem { origin, spatial_id, - is_backface_visible, + prim_flags, stacking_context: di::StackingContext { transform_style, mix_blend_mode, @@ -1289,12 +1289,12 @@ impl DisplayListBuilder { &mut self, origin: LayoutPoint, spatial_id: di::SpatialId, - is_backface_visible: bool, + prim_flags: di::PrimitiveFlags, ) { self.push_simple_stacking_context_with_filters( origin, spatial_id, - is_backface_visible, + prim_flags, &[], &[], &[], @@ -1306,7 +1306,7 @@ impl DisplayListBuilder { &mut self, origin: LayoutPoint, spatial_id: di::SpatialId, - is_backface_visible: bool, + prim_flags: di::PrimitiveFlags, filters: &[di::FilterOp], filter_datas: &[di::FilterData], filter_primitives: &[di::FilterPrimitive], @@ -1314,7 +1314,7 @@ impl DisplayListBuilder { self.push_stacking_context( origin, spatial_id, - is_backface_visible, + prim_flags, None, di::TransformStyle::Flat, di::MixBlendMode::Normal, diff --git a/gfx/wr/wrench/src/yaml_frame_reader.rs b/gfx/wr/wrench/src/yaml_frame_reader.rs index 4ded299a2943..5a7421d6baac 100644 --- a/gfx/wr/wrench/src/yaml_frame_reader.rs +++ b/gfx/wr/wrench/src/yaml_frame_reader.rs @@ -2035,7 +2035,7 @@ impl YamlFrameReader { dl.push_stacking_context( bounds.origin, *self.spatial_id_stack.last().unwrap(), - info.flags.contains(PrimitiveFlags::IS_BACKFACE_VISIBLE), + info.flags, clip_node_id, transform_style, mix_blend_mode, diff --git a/gfx/wr/wrench/src/yaml_frame_writer.rs b/gfx/wr/wrench/src/yaml_frame_writer.rs index bd7801869156..f700e0d1aef3 100644 --- a/gfx/wr/wrench/src/yaml_frame_writer.rs +++ b/gfx/wr/wrench/src/yaml_frame_writer.rs @@ -204,6 +204,8 @@ fn maybe_radius_yaml(radius: &BorderRadius) -> Option { fn common_node(v: &mut Table, clip_id_mapper: &mut ClipIdMapper, info: &CommonItemProperties) { rect_node(v, "clip-rect", &info.clip_rect); bool_node(v, "backface-visible", info.flags.contains(PrimitiveFlags::IS_BACKFACE_VISIBLE)); + bool_node(v, "scrollbar-container", info.flags.contains(PrimitiveFlags::IS_SCROLLBAR_CONTAINER)); + bool_node(v, "scrollbar-thumb", info.flags.contains(PrimitiveFlags::IS_SCROLLBAR_THUMB)); clip_and_scroll_node(v, clip_id_mapper, info.clip_id, info.spatial_id); @@ -1293,7 +1295,9 @@ impl YamlFrameWriter { item.spatial_id ); point_node(&mut v, "origin", &item.origin); - bool_node(&mut v, "backface-visible", item.is_backface_visible); + bool_node(&mut v, "backface-visible", item.prim_flags.contains(PrimitiveFlags::IS_BACKFACE_VISIBLE)); + bool_node(&mut v, "scrollbar-container", item.prim_flags.contains(PrimitiveFlags::IS_SCROLLBAR_CONTAINER)); + bool_node(&mut v, "scrollbar-thumb", item.prim_flags.contains(PrimitiveFlags::IS_SCROLLBAR_THUMB)); write_stacking_context( &mut v, &item.stacking_context, diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp index 068fed8e9a94..75237a3033d3 100644 --- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -6941,6 +6941,12 @@ bool nsDisplayOwnLayer::CreateWebRenderCommands( params.animation = prop.ptrOr(nullptr); params.clip = wr::WrStackingContextClip::ClipChain(aBuilder.CurrentClipChainId()); + if (IsScrollbarContainer()) { + params.prim_flags |= wr::PrimitiveFlags_IS_SCROLLBAR_CONTAINER; + } + if (IsScrollThumbLayer()) { + params.prim_flags |= wr::PrimitiveFlags_IS_SCROLLBAR_THUMB; + } StackingContextHelper sc(aSc, GetActiveScrolledRoot(), mFrame, this, aBuilder, params); @@ -8626,7 +8632,9 @@ bool nsDisplayTransform::CreateWebRenderCommands( params.mBoundTransform = &newTransformMatrix; params.animation = animationsId ? &prop : nullptr; params.mTransformPtr = transformForSC; - params.is_backface_visible = !BackfaceIsHidden(); + params.prim_flags = !BackfaceIsHidden() + ? wr::PrimitiveFlags_IS_BACKFACE_VISIBLE + : wr::PrimitiveFlags{0}; params.mDeferredTransformItem = deferredTransformItem; params.mAnimated = animated; // Determine if we would have to rasterize any items in local raster space @@ -9329,7 +9337,9 @@ bool nsDisplayPerspective::CreateWebRenderCommands( wr::StackingContextParams params; params.mTransformPtr = &perspectiveMatrix; params.reference_frame_kind = wr::WrReferenceFrameKind::Perspective; - params.is_backface_visible = !BackfaceIsHidden(); + params.prim_flags = !BackfaceIsHidden() + ? wr::PrimitiveFlags_IS_BACKFACE_VISIBLE + : wr::PrimitiveFlags{0}; params.SetPreserve3D(preserve3D); params.clip = wr::WrStackingContextClip::ClipChain(aBuilder.CurrentClipChainId());