Bug 1581448 - Add support for specifying extra per-primitive flags in WR display lists r=kvark,nical

This patch replaces the is_backface_visible bool in the common
per-primitive data in the display list with a PrimitiveFlags
enumeration. This will allow Gecko to specify extra information
about certain primitive, such as tagging scroll bars.

Differential Revision: https://phabricator.services.mozilla.com/D45970

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Glenn Watson 2019-09-18 06:27:34 +00:00
Родитель db60a948f1
Коммит ff53edd4e5
14 изменённых файлов: 188 добавлений и 143 удалений

Просмотреть файл

@ -2357,6 +2357,17 @@ pub extern "C" fn wr_dp_push_iframe(state: &mut WrState,
); );
} }
// A helper fn to construct a PrimitiveFlags
fn prim_flags(
is_backface_visible: bool,
) -> PrimitiveFlags {
if is_backface_visible {
PrimitiveFlags::IS_BACKFACE_VISIBLE
} else {
PrimitiveFlags::empty()
}
}
#[no_mangle] #[no_mangle]
pub extern "C" fn wr_dp_push_rect(state: &mut WrState, pub extern "C" fn wr_dp_push_rect(state: &mut WrState,
rect: LayoutRect, rect: LayoutRect,
@ -2376,7 +2387,7 @@ pub extern "C" fn wr_dp_push_rect(state: &mut WrState,
clip_rect: clip_rect.unwrap_or(LayoutRect::zero()), clip_rect: clip_rect.unwrap_or(LayoutRect::zero()),
clip_id: space_and_clip.clip_id, clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id, spatial_id: space_and_clip.spatial_id,
is_backface_visible, flags: prim_flags(is_backface_visible),
hit_info: state.current_tag, hit_info: state.current_tag,
}; };
@ -2406,7 +2417,7 @@ pub extern "C" fn wr_dp_push_rect_with_parent_clip(
clip_rect: clip_rect.unwrap(), clip_rect: clip_rect.unwrap(),
clip_id: space_and_clip.clip_id, clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id, spatial_id: space_and_clip.spatial_id,
is_backface_visible, flags: prim_flags(is_backface_visible),
hit_info: state.current_tag, hit_info: state.current_tag,
}; };
@ -2458,7 +2469,7 @@ pub extern "C" fn wr_dp_push_backdrop_filter_with_parent_clip(
clip_rect: clip_rect.unwrap(), clip_rect: clip_rect.unwrap(),
clip_id: space_and_clip.clip_id, clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id, spatial_id: space_and_clip.spatial_id,
is_backface_visible, flags: prim_flags(is_backface_visible),
hit_info: state.current_tag, hit_info: state.current_tag,
}; };
@ -2486,7 +2497,7 @@ pub extern "C" fn wr_dp_push_clear_rect(state: &mut WrState,
clip_rect: clip_rect.unwrap(), clip_rect: clip_rect.unwrap(),
clip_id: space_and_clip.clip_id, clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id, spatial_id: space_and_clip.spatial_id,
is_backface_visible: true, flags: prim_flags(true),
hit_info: state.current_tag, hit_info: state.current_tag,
}; };
@ -2512,7 +2523,7 @@ pub extern "C" fn wr_dp_push_hit_test(state: &mut WrState,
clip_rect: clip_rect.unwrap(), clip_rect: clip_rect.unwrap(),
clip_id: space_and_clip.clip_id, clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id, spatial_id: space_and_clip.spatial_id,
is_backface_visible, flags: prim_flags(is_backface_visible),
hit_info: state.current_tag, hit_info: state.current_tag,
}; };
@ -2539,7 +2550,7 @@ pub extern "C" fn wr_dp_push_clear_rect_with_parent_clip(
clip_rect: clip_rect.unwrap(), clip_rect: clip_rect.unwrap(),
clip_id: space_and_clip.clip_id, clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id, spatial_id: space_and_clip.spatial_id,
is_backface_visible: true, flags: prim_flags(true),
hit_info: state.current_tag, hit_info: state.current_tag,
}; };
@ -2566,7 +2577,7 @@ pub extern "C" fn wr_dp_push_image(state: &mut WrState,
clip_rect: clip, clip_rect: clip,
clip_id: space_and_clip.clip_id, clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id, spatial_id: space_and_clip.spatial_id,
is_backface_visible, flags: prim_flags(is_backface_visible),
hit_info: state.current_tag, hit_info: state.current_tag,
}; };
@ -2606,7 +2617,7 @@ pub extern "C" fn wr_dp_push_repeating_image(state: &mut WrState,
clip_rect: clip, clip_rect: clip,
clip_id: space_and_clip.clip_id, clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id, spatial_id: space_and_clip.spatial_id,
is_backface_visible, flags: prim_flags(is_backface_visible),
hit_info: state.current_tag, hit_info: state.current_tag,
}; };
@ -2650,7 +2661,7 @@ pub extern "C" fn wr_dp_push_yuv_planar_image(state: &mut WrState,
clip_rect: clip, clip_rect: clip,
clip_id: space_and_clip.clip_id, clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id, spatial_id: space_and_clip.spatial_id,
is_backface_visible, flags: prim_flags(is_backface_visible),
hit_info: state.current_tag, hit_info: state.current_tag,
}; };
@ -2686,7 +2697,7 @@ pub extern "C" fn wr_dp_push_yuv_NV12_image(state: &mut WrState,
clip_rect: clip, clip_rect: clip,
clip_id: space_and_clip.clip_id, clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id, spatial_id: space_and_clip.spatial_id,
is_backface_visible, flags: prim_flags(is_backface_visible),
hit_info: state.current_tag, hit_info: state.current_tag,
}; };
@ -2721,7 +2732,7 @@ pub extern "C" fn wr_dp_push_yuv_interleaved_image(state: &mut WrState,
clip_rect: clip, clip_rect: clip,
clip_id: space_and_clip.clip_id, clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id, spatial_id: space_and_clip.spatial_id,
is_backface_visible, flags: prim_flags(is_backface_visible),
hit_info: state.current_tag, hit_info: state.current_tag,
}; };
@ -2757,7 +2768,7 @@ pub extern "C" fn wr_dp_push_text(state: &mut WrState,
clip_rect: clip, clip_rect: clip,
spatial_id: space_and_clip.spatial_id, spatial_id: space_and_clip.spatial_id,
clip_id: space_and_clip.clip_id, clip_id: space_and_clip.clip_id,
is_backface_visible, flags: prim_flags(is_backface_visible),
hit_info: state.current_tag hit_info: state.current_tag
}; };
@ -2813,7 +2824,7 @@ pub extern "C" fn wr_dp_push_line(state: &mut WrState,
clip_rect: *clip, clip_rect: *clip,
clip_id: space_and_clip.clip_id, clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id, spatial_id: space_and_clip.spatial_id,
is_backface_visible, flags: prim_flags(is_backface_visible),
hit_info: state.current_tag, hit_info: state.current_tag,
}; };
@ -2858,7 +2869,7 @@ pub extern "C" fn wr_dp_push_border(state: &mut WrState,
clip_rect: clip, clip_rect: clip,
clip_id: space_and_clip.clip_id, clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id, spatial_id: space_and_clip.spatial_id,
is_backface_visible, flags: prim_flags(is_backface_visible),
hit_info: state.current_tag, hit_info: state.current_tag,
}; };
@ -2907,7 +2918,7 @@ pub extern "C" fn wr_dp_push_border_image(state: &mut WrState,
clip_rect: clip, clip_rect: clip,
clip_id: space_and_clip.clip_id, clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id, spatial_id: space_and_clip.spatial_id,
is_backface_visible, flags: prim_flags(is_backface_visible),
hit_info: state.current_tag, hit_info: state.current_tag,
}; };
@ -2965,7 +2976,7 @@ pub extern "C" fn wr_dp_push_border_gradient(state: &mut WrState,
clip_rect: clip, clip_rect: clip,
clip_id: space_and_clip.clip_id, clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id, spatial_id: space_and_clip.spatial_id,
is_backface_visible, flags: prim_flags(is_backface_visible),
hit_info: state.current_tag, hit_info: state.current_tag,
}; };
@ -3027,7 +3038,7 @@ pub extern "C" fn wr_dp_push_border_radial_gradient(state: &mut WrState,
clip_rect: clip, clip_rect: clip,
clip_id: space_and_clip.clip_id, clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id, spatial_id: space_and_clip.spatial_id,
is_backface_visible, flags: prim_flags(is_backface_visible),
hit_info: state.current_tag, hit_info: state.current_tag,
}; };
@ -3070,7 +3081,7 @@ pub extern "C" fn wr_dp_push_linear_gradient(state: &mut WrState,
clip_rect: clip, clip_rect: clip,
clip_id: space_and_clip.clip_id, clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id, spatial_id: space_and_clip.spatial_id,
is_backface_visible, flags: prim_flags(is_backface_visible),
hit_info: state.current_tag, hit_info: state.current_tag,
}; };
@ -3114,7 +3125,7 @@ pub extern "C" fn wr_dp_push_radial_gradient(state: &mut WrState,
clip_rect: clip, clip_rect: clip,
clip_id: space_and_clip.clip_id, clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id, spatial_id: space_and_clip.spatial_id,
is_backface_visible, flags: prim_flags(is_backface_visible),
hit_info: state.current_tag, hit_info: state.current_tag,
}; };
@ -3147,7 +3158,7 @@ pub extern "C" fn wr_dp_push_box_shadow(state: &mut WrState,
clip_rect: clip, clip_rect: clip,
clip_id: space_and_clip.clip_id, clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id, spatial_id: space_and_clip.spatial_id,
is_backface_visible, flags: prim_flags(is_backface_visible),
hit_info: state.current_tag, hit_info: state.current_tag,
}; };

Просмотреть файл

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use api::{BorderRadius, ClipMode, HitTestFlags, HitTestItem, HitTestResult, ItemTag}; use api::{BorderRadius, ClipMode, HitTestFlags, HitTestItem, HitTestResult, ItemTag, PrimitiveFlags};
use api::PipelineId; use api::PipelineId;
use api::units::*; use api::units::*;
use crate::clip::{ClipChainId, ClipDataStore, ClipNode, ClipItemKind, ClipStore}; use crate::clip::{ClipChainId, ClipDataStore, ClipNode, ClipItemKind, ClipStore};
@ -104,7 +104,7 @@ impl HitTestingItem {
rect: info.rect, rect: info.rect,
clip_rect: info.clip_rect, clip_rect: info.clip_rect,
tag, tag,
is_backface_visible: info.is_backface_visible, is_backface_visible: info.flags.contains(PrimitiveFlags::IS_BACKFACE_VISIBLE),
spatial_node_index, spatial_node_index,
clip_chain_range, clip_chain_range,
} }

Просмотреть файл

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use api::{ColorF, DebugCommand, DocumentId, ExternalImageData, ExternalImageId}; use api::{ColorF, DebugCommand, DocumentId, ExternalImageData, ExternalImageId, PrimitiveFlags};
use api::{ImageFormat, ItemTag, NotificationRequest, Shadow, FilterOp, MAX_BLUR_RADIUS}; use api::{ImageFormat, ItemTag, NotificationRequest, Shadow, FilterOp, MAX_BLUR_RADIUS};
use api::units::*; use api::units::*;
use api; use api;
@ -554,7 +554,7 @@ pub struct LayoutPrimitiveInfo {
/// but that's an ongoing project, so for now it exists and is used :( /// but that's an ongoing project, so for now it exists and is used :(
pub rect: LayoutRect, pub rect: LayoutRect,
pub clip_rect: LayoutRect, pub clip_rect: LayoutRect,
pub is_backface_visible: bool, pub flags: PrimitiveFlags,
pub hit_info: Option<ItemTag>, pub hit_info: Option<ItemTag>,
} }
@ -563,7 +563,7 @@ impl LayoutPrimitiveInfo {
Self { Self {
rect, rect,
clip_rect, clip_rect,
is_backface_visible: true, flags: PrimitiveFlags::default(),
hit_info: None, hit_info: None,
} }
} }

Просмотреть файл

@ -4,7 +4,7 @@
use api::{MixBlendMode, PipelineId, PremultipliedColorF, FilterPrimitiveKind}; use api::{MixBlendMode, PipelineId, PremultipliedColorF, FilterPrimitiveKind};
use api::{PropertyBinding, PropertyBindingId, FilterPrimitive, FontRenderMode}; use api::{PropertyBinding, PropertyBindingId, FilterPrimitive, FontRenderMode};
use api::{DebugFlags, RasterSpace, ImageKey, ColorF}; use api::{DebugFlags, RasterSpace, ImageKey, ColorF, PrimitiveFlags};
use api::units::*; use api::units::*;
use crate::box_shadow::{BLUR_SAMPLE_SCALE}; use crate::box_shadow::{BLUR_SAMPLE_SCALE};
use crate::clip::{ClipStore, ClipChainInstance, ClipDataHandle, ClipChainId}; use crate::clip::{ClipStore, ClipChainInstance, ClipDataHandle, ClipChainId};
@ -2283,7 +2283,7 @@ impl PrimitiveList {
prim_instance: PrimitiveInstance, prim_instance: PrimitiveInstance,
prim_size: LayoutSize, prim_size: LayoutSize,
spatial_node_index: SpatialNodeIndex, spatial_node_index: SpatialNodeIndex,
is_backface_visible: bool, prim_flags: PrimitiveFlags,
insert_position: PrimitiveListPosition, insert_position: PrimitiveListPosition,
) { ) {
let mut flags = ClusterFlags::empty(); let mut flags = ClusterFlags::empty();
@ -2300,7 +2300,7 @@ impl PrimitiveList {
_ => {} _ => {}
} }
if is_backface_visible { if prim_flags.contains(PrimitiveFlags::IS_BACKFACE_VISIBLE) {
flags.insert(ClusterFlags::IS_BACKFACE_VISIBLE); flags.insert(ClusterFlags::IS_BACKFACE_VISIBLE);
} }
@ -2345,13 +2345,13 @@ impl PrimitiveList {
prim_instance: PrimitiveInstance, prim_instance: PrimitiveInstance,
prim_size: LayoutSize, prim_size: LayoutSize,
spatial_node_index: SpatialNodeIndex, spatial_node_index: SpatialNodeIndex,
is_backface_visible: bool, flags: PrimitiveFlags,
) { ) {
self.push( self.push(
prim_instance, prim_instance,
prim_size, prim_size,
spatial_node_index, spatial_node_index,
is_backface_visible, flags,
PrimitiveListPosition::Begin, PrimitiveListPosition::Begin,
) )
} }
@ -2362,13 +2362,13 @@ impl PrimitiveList {
prim_instance: PrimitiveInstance, prim_instance: PrimitiveInstance,
prim_size: LayoutSize, prim_size: LayoutSize,
spatial_node_index: SpatialNodeIndex, spatial_node_index: SpatialNodeIndex,
is_backface_visible: bool, flags: PrimitiveFlags,
) { ) {
self.push( self.push(
prim_instance, prim_instance,
prim_size, prim_size,
spatial_node_index, spatial_node_index,
is_backface_visible, flags,
PrimitiveListPosition::End, PrimitiveListPosition::End,
) )
} }
@ -2583,7 +2583,7 @@ impl PicturePrimitive {
context_3d: Picture3DContext<OrderedPictureChild>, context_3d: Picture3DContext<OrderedPictureChild>,
frame_output_pipeline_id: Option<PipelineId>, frame_output_pipeline_id: Option<PipelineId>,
apply_local_clip_rect: bool, apply_local_clip_rect: bool,
is_backface_visible: bool, flags: PrimitiveFlags,
requested_raster_space: RasterSpace, requested_raster_space: RasterSpace,
prim_list: PrimitiveList, prim_list: PrimitiveList,
spatial_node_index: SpatialNodeIndex, spatial_node_index: SpatialNodeIndex,
@ -2600,7 +2600,7 @@ impl PicturePrimitive {
frame_output_pipeline_id, frame_output_pipeline_id,
extra_gpu_data_handles: SmallVec::new(), extra_gpu_data_handles: SmallVec::new(),
apply_local_clip_rect, apply_local_clip_rect,
is_backface_visible, is_backface_visible: flags.contains(PrimitiveFlags::IS_BACKFACE_VISIBLE),
requested_raster_space, requested_raster_space,
spatial_node_index, spatial_node_index,
local_rect: LayoutRect::zero(), local_rect: LayoutRect::zero(),

Просмотреть файл

@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use api::PrimitiveFlags;
use api::units::*; use api::units::*;
use crate::clip_scroll_tree::SpatialNodeIndex; use crate::clip_scroll_tree::SpatialNodeIndex;
use crate::intern::{Internable, InternDebug, Handle as InternHandle}; use crate::intern::{Internable, InternDebug, Handle as InternHandle};
@ -34,13 +35,13 @@ pub type BackdropKey = PrimKey<Backdrop>;
impl BackdropKey { impl BackdropKey {
pub fn new( pub fn new(
is_backface_visible: bool, flags: PrimitiveFlags,
prim_size: LayoutSize, prim_size: LayoutSize,
backdrop: Backdrop, backdrop: Backdrop,
) -> Self { ) -> Self {
BackdropKey { BackdropKey {
common: PrimKeyCommonData { common: PrimKeyCommonData {
is_backface_visible, flags,
prim_size: prim_size.into(), prim_size: prim_size.into(),
}, },
kind: backdrop, kind: backdrop,
@ -86,7 +87,7 @@ impl InternablePrimitive for Backdrop {
info: &LayoutPrimitiveInfo, info: &LayoutPrimitiveInfo,
) -> BackdropKey { ) -> BackdropKey {
BackdropKey::new( BackdropKey::new(
info.is_backface_visible, info.flags,
info.rect.size, info.rect.size,
self self
) )

Просмотреть файл

@ -4,7 +4,7 @@
use api::{ use api::{
ColorF, ColorU, ExtendMode, GradientStop, ColorF, ColorU, ExtendMode, GradientStop,
PremultipliedColorF, LineOrientation, PremultipliedColorF, LineOrientation, PrimitiveFlags,
}; };
use api::units::{LayoutPoint, LayoutSize, LayoutVector2D}; use api::units::{LayoutPoint, LayoutSize, LayoutVector2D};
use crate::scene_building::IsVisible; use crate::scene_building::IsVisible;
@ -78,13 +78,13 @@ pub struct LinearGradientKey {
impl LinearGradientKey { impl LinearGradientKey {
pub fn new( pub fn new(
is_backface_visible: bool, flags: PrimitiveFlags,
prim_size: LayoutSize, prim_size: LayoutSize,
linear_grad: LinearGradient, linear_grad: LinearGradient,
) -> Self { ) -> Self {
LinearGradientKey { LinearGradientKey {
common: PrimKeyCommonData { common: PrimKeyCommonData {
is_backface_visible, flags,
prim_size: prim_size.into(), prim_size: prim_size.into(),
}, },
extend_mode: linear_grad.extend_mode, extend_mode: linear_grad.extend_mode,
@ -308,7 +308,7 @@ impl InternablePrimitive for LinearGradient {
info: &LayoutPrimitiveInfo, info: &LayoutPrimitiveInfo,
) -> LinearGradientKey { ) -> LinearGradientKey {
LinearGradientKey::new( LinearGradientKey::new(
info.is_backface_visible, info.flags,
info.rect.size, info.rect.size,
self self
) )
@ -384,13 +384,13 @@ pub struct RadialGradientKey {
impl RadialGradientKey { impl RadialGradientKey {
pub fn new( pub fn new(
is_backface_visible: bool, flags: PrimitiveFlags,
prim_size: LayoutSize, prim_size: LayoutSize,
radial_grad: RadialGradient, radial_grad: RadialGradient,
) -> Self { ) -> Self {
RadialGradientKey { RadialGradientKey {
common: PrimKeyCommonData { common: PrimKeyCommonData {
is_backface_visible, flags,
prim_size: prim_size.into(), prim_size: prim_size.into(),
}, },
extend_mode: radial_grad.extend_mode, extend_mode: radial_grad.extend_mode,
@ -538,7 +538,7 @@ impl InternablePrimitive for RadialGradient {
info: &LayoutPrimitiveInfo, info: &LayoutPrimitiveInfo,
) -> RadialGradientKey { ) -> RadialGradientKey {
RadialGradientKey::new( RadialGradientKey::new(
info.is_backface_visible, info.flags,
info.rect.size, info.rect.size,
self, self,
) )

Просмотреть файл

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use api::{ use api::{
AlphaType, ColorDepth, ColorF, ColorU, AlphaType, ColorDepth, ColorF, ColorU, PrimitiveFlags,
ImageKey as ApiImageKey, ImageRendering, ImageKey as ApiImageKey, ImageRendering,
PremultipliedColorF, Shadow, YuvColorSpace, ColorRange, YuvFormat, PremultipliedColorF, Shadow, YuvColorSpace, ColorRange, YuvFormat,
}; };
@ -85,13 +85,13 @@ pub type ImageKey = PrimKey<Image>;
impl ImageKey { impl ImageKey {
pub fn new( pub fn new(
is_backface_visible: bool, flags: PrimitiveFlags,
prim_size: LayoutSize, prim_size: LayoutSize,
image: Image, image: Image,
) -> Self { ) -> Self {
ImageKey { ImageKey {
common: PrimKeyCommonData { common: PrimKeyCommonData {
is_backface_visible, flags,
prim_size: prim_size.into(), prim_size: prim_size.into(),
}, },
kind: image, kind: image,
@ -327,7 +327,7 @@ impl InternablePrimitive for Image {
info: &LayoutPrimitiveInfo, info: &LayoutPrimitiveInfo,
) -> ImageKey { ) -> ImageKey {
ImageKey::new( ImageKey::new(
info.is_backface_visible, info.flags,
info.rect.size, info.rect.size,
self self
) )
@ -393,14 +393,14 @@ pub type YuvImageKey = PrimKey<YuvImage>;
impl YuvImageKey { impl YuvImageKey {
pub fn new( pub fn new(
is_backface_visible: bool, flags: PrimitiveFlags,
prim_size: LayoutSize, prim_size: LayoutSize,
yuv_image: YuvImage, yuv_image: YuvImage,
) -> Self { ) -> Self {
YuvImageKey { YuvImageKey {
common: PrimKeyCommonData { common: PrimKeyCommonData {
is_backface_visible, flags,
prim_size: prim_size.into(), prim_size: prim_size.into(),
}, },
kind: yuv_image, kind: yuv_image,
@ -509,7 +509,7 @@ impl InternablePrimitive for YuvImage {
info: &LayoutPrimitiveInfo, info: &LayoutPrimitiveInfo,
) -> YuvImageKey { ) -> YuvImageKey {
YuvImageKey::new( YuvImageKey::new(
info.is_backface_visible, info.flags,
info.rect.size, info.rect.size,
self, self,
) )

Просмотреть файл

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use api::{BorderRadius, ClipMode, ColorF}; use api::{BorderRadius, ClipMode, ColorF};
use api::{ImageRendering, RepeatMode}; use api::{ImageRendering, RepeatMode, PrimitiveFlags};
use api::{PremultipliedColorF, PropertyBinding, Shadow, GradientStop}; use api::{PremultipliedColorF, PropertyBinding, Shadow, GradientStop};
use api::{BoxShadowClipMode, LineStyle, LineOrientation, BorderStyle}; use api::{BoxShadowClipMode, LineStyle, LineOrientation, BorderStyle};
use api::{PrimitiveKeyKind}; use api::{PrimitiveKeyKind};
@ -389,7 +389,7 @@ impl GpuCacheAddress {
#[derive(MallocSizeOf)] #[derive(MallocSizeOf)]
pub struct PrimitiveSceneData { pub struct PrimitiveSceneData {
pub prim_size: LayoutSize, pub prim_size: LayoutSize,
pub is_backface_visible: bool, pub flags: PrimitiveFlags,
} }
#[cfg_attr(feature = "capture", derive(Serialize))] #[cfg_attr(feature = "capture", derive(Serialize))]
@ -653,7 +653,7 @@ impl From<WorldPoint> for PointKey {
#[cfg_attr(feature = "replay", derive(Deserialize))] #[cfg_attr(feature = "replay", derive(Deserialize))]
#[derive(Debug, Clone, Eq, MallocSizeOf, PartialEq, Hash)] #[derive(Debug, Clone, Eq, MallocSizeOf, PartialEq, Hash)]
pub struct PrimKeyCommonData { pub struct PrimKeyCommonData {
pub is_backface_visible: bool, pub flags: PrimitiveFlags,
pub prim_size: SizeKey, pub prim_size: SizeKey,
} }
@ -662,7 +662,7 @@ impl PrimKeyCommonData {
info: &LayoutPrimitiveInfo, info: &LayoutPrimitiveInfo,
) -> Self { ) -> Self {
PrimKeyCommonData { PrimKeyCommonData {
is_backface_visible: info.is_backface_visible, flags: info.flags,
prim_size: info.rect.size.into(), prim_size: info.rect.size.into(),
} }
} }
@ -686,13 +686,13 @@ pub struct PrimitiveKey {
impl PrimitiveKey { impl PrimitiveKey {
pub fn new( pub fn new(
is_backface_visible: bool, flags: PrimitiveFlags,
prim_size: LayoutSize, prim_size: LayoutSize,
kind: PrimitiveKeyKind, kind: PrimitiveKeyKind,
) -> Self { ) -> Self {
PrimitiveKey { PrimitiveKey {
common: PrimKeyCommonData { common: PrimKeyCommonData {
is_backface_visible, flags,
prim_size: prim_size.into(), prim_size: prim_size.into(),
}, },
kind, kind,
@ -736,7 +736,7 @@ impl From<PrimitiveKeyKind> for PrimitiveTemplateKind {
#[cfg_attr(feature = "replay", derive(Deserialize))] #[cfg_attr(feature = "replay", derive(Deserialize))]
#[derive(MallocSizeOf)] #[derive(MallocSizeOf)]
pub struct PrimTemplateCommonData { pub struct PrimTemplateCommonData {
pub is_backface_visible: bool, pub flags: PrimitiveFlags,
pub may_need_repetition: bool, pub may_need_repetition: bool,
pub prim_size: LayoutSize, pub prim_size: LayoutSize,
pub opacity: PrimitiveOpacity, pub opacity: PrimitiveOpacity,
@ -750,7 +750,7 @@ pub struct PrimTemplateCommonData {
impl PrimTemplateCommonData { impl PrimTemplateCommonData {
pub fn with_key_common(common: PrimKeyCommonData) -> Self { pub fn with_key_common(common: PrimKeyCommonData) -> Self {
PrimTemplateCommonData { PrimTemplateCommonData {
is_backface_visible: common.is_backface_visible, flags: common.flags,
may_need_repetition: true, may_need_repetition: true,
prim_size: common.prim_size.into(), prim_size: common.prim_size.into(),
gpu_cache_handle: GpuCacheHandle::new(), gpu_cache_handle: GpuCacheHandle::new(),
@ -853,7 +853,7 @@ impl InternablePrimitive for PrimitiveKeyKind {
info: &LayoutPrimitiveInfo, info: &LayoutPrimitiveInfo,
) -> PrimitiveKey { ) -> PrimitiveKey {
PrimitiveKey::new( PrimitiveKey::new(
info.is_backface_visible, info.flags,
info.rect.size, info.rect.size,
self, self,
) )

Просмотреть файл

@ -4,7 +4,7 @@
use api::{ use api::{
ColorU, MixBlendMode, FilterPrimitiveInput, FilterPrimitiveKind, ColorSpace, ColorU, MixBlendMode, FilterPrimitiveInput, FilterPrimitiveKind, ColorSpace,
PropertyBinding, PropertyBindingId, CompositeOperator, PropertyBinding, PropertyBindingId, CompositeOperator, PrimitiveFlags,
}; };
use api::units::{Au, LayoutSize, LayoutVector2D}; use api::units::{Au, LayoutSize, LayoutVector2D};
use crate::scene_building::IsVisible; use crate::scene_building::IsVisible;
@ -239,14 +239,14 @@ pub type PictureKey = PrimKey<Picture>;
impl PictureKey { impl PictureKey {
pub fn new( pub fn new(
is_backface_visible: bool, flags: PrimitiveFlags,
prim_size: LayoutSize, prim_size: LayoutSize,
pic: Picture, pic: Picture,
) -> Self { ) -> Self {
PictureKey { PictureKey {
common: PrimKeyCommonData { common: PrimKeyCommonData {
is_backface_visible, flags,
prim_size: prim_size.into(), prim_size: prim_size.into(),
}, },
kind: pic, kind: pic,
@ -288,7 +288,7 @@ impl InternablePrimitive for Picture {
info: &LayoutPrimitiveInfo, info: &LayoutPrimitiveInfo,
) -> PictureKey { ) -> PictureKey {
PictureKey::new( PictureKey::new(
info.is_backface_visible, info.flags,
info.rect.size, info.rect.size,
self, self,
) )

Просмотреть файл

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use api::{AlphaType, BorderDetails, BorderDisplayItem, BuiltDisplayListIter}; use api::{AlphaType, BorderDetails, BorderDisplayItem, BuiltDisplayListIter, PrimitiveFlags};
use api::{ClipId, ColorF, CommonItemProperties, ComplexClipRegion, ComponentTransferFuncType, RasterSpace}; use api::{ClipId, ColorF, CommonItemProperties, ComplexClipRegion, ComponentTransferFuncType, RasterSpace};
use api::{DisplayItem, DisplayItemRef, ExtendMode, ExternalScrollId, FilterData}; use api::{DisplayItem, DisplayItemRef, ExtendMode, ExternalScrollId, FilterData};
use api::{FilterOp, FilterPrimitive, FontInstanceKey, GlyphInstance, GlyphOptions, GradientStop}; use api::{FilterOp, FilterPrimitive, FontInstanceKey, GlyphInstance, GlyphOptions, GradientStop};
@ -668,7 +668,7 @@ impl<'a> SceneBuilder<'a> {
), ),
LayoutSize::zero(), LayoutSize::zero(),
clip_chain_instance.spatial_node_index, clip_chain_instance.spatial_node_index,
true, PrimitiveFlags::IS_BACKFACE_VISIBLE,
); );
remaining_prims.add_prim_to_start( remaining_prims.add_prim_to_start(
@ -678,7 +678,7 @@ impl<'a> SceneBuilder<'a> {
), ),
LayoutSize::zero(), LayoutSize::zero(),
clip_chain_instance.spatial_node_index, clip_chain_instance.spatial_node_index,
true, PrimitiveFlags::IS_BACKFACE_VISIBLE,
); );
} }
} }
@ -688,7 +688,7 @@ impl<'a> SceneBuilder<'a> {
// Now, create a picture with tile caching enabled that will hold all // Now, create a picture with tile caching enabled that will hold all
// of the primitives selected as belonging to the main scroll root. // of the primitives selected as belonging to the main scroll root.
let pic_key = PictureKey::new( let pic_key = PictureKey::new(
true, PrimitiveFlags::IS_BACKFACE_VISIBLE,
LayoutSize::zero(), LayoutSize::zero(),
Picture { Picture {
composite_mode_key: PictureCompositeKey::Identity, composite_mode_key: PictureCompositeKey::Identity,
@ -700,7 +700,7 @@ impl<'a> SceneBuilder<'a> {
.intern(&pic_key, || { .intern(&pic_key, || {
PrimitiveSceneData { PrimitiveSceneData {
prim_size: LayoutSize::zero(), prim_size: LayoutSize::zero(),
is_backface_visible: true, flags: PrimitiveFlags::IS_BACKFACE_VISIBLE,
} }
} }
); );
@ -732,7 +732,7 @@ impl<'a> SceneBuilder<'a> {
Picture3DContext::Out, Picture3DContext::Out,
None, None,
true, true,
true, PrimitiveFlags::IS_BACKFACE_VISIBLE,
RasterSpace::Screen, RasterSpace::Screen,
prim_list, prim_list,
main_scroll_root, main_scroll_root,
@ -758,7 +758,7 @@ impl<'a> SceneBuilder<'a> {
instance, instance,
LayoutSize::zero(), LayoutSize::zero(),
main_scroll_root, main_scroll_root,
true, PrimitiveFlags::IS_BACKFACE_VISIBLE,
); );
} }
@ -1110,7 +1110,7 @@ impl<'a> SceneBuilder<'a> {
let layout = LayoutPrimitiveInfo { let layout = LayoutPrimitiveInfo {
rect: snap_to_device.snap_rect(&rect), rect: snap_to_device.snap_rect(&rect),
clip_rect: snap_to_device.snap_rect(&clip_rect), clip_rect: snap_to_device.snap_rect(&clip_rect),
is_backface_visible: common.is_backface_visible, flags: common.flags,
hit_info: common.hit_info, hit_info: common.hit_info,
}; };
@ -1594,7 +1594,7 @@ impl<'a> SceneBuilder<'a> {
.intern(&prim_key, || { .intern(&prim_key, || {
PrimitiveSceneData { PrimitiveSceneData {
prim_size: info.rect.size, prim_size: info.rect.size,
is_backface_visible: info.is_backface_visible, flags: info.flags,
} }
}); });
@ -1659,7 +1659,7 @@ impl<'a> SceneBuilder<'a> {
prim_instance: PrimitiveInstance, prim_instance: PrimitiveInstance,
prim_size: LayoutSize, prim_size: LayoutSize,
spatial_node_index: SpatialNodeIndex, spatial_node_index: SpatialNodeIndex,
is_backface_visible: bool, flags: PrimitiveFlags,
) { ) {
// Add primitive to the top-most stacking context on the stack. // Add primitive to the top-most stacking context on the stack.
if prim_instance.is_chased() { if prim_instance.is_chased() {
@ -1671,7 +1671,7 @@ impl<'a> SceneBuilder<'a> {
prim_instance, prim_instance,
prim_size, prim_size,
spatial_node_index, spatial_node_index,
is_backface_visible, flags,
); );
} }
@ -1762,7 +1762,7 @@ impl<'a> SceneBuilder<'a> {
prim_instance, prim_instance,
info.rect.size, info.rect.size,
clip_and_scroll.spatial_node_index, clip_and_scroll.spatial_node_index,
info.is_backface_visible, info.flags,
); );
} }
@ -1821,7 +1821,7 @@ impl<'a> SceneBuilder<'a> {
ExtendedPrimitiveInstance { ExtendedPrimitiveInstance {
instance, instance,
spatial_node_index: sc.spatial_node_index, spatial_node_index: sc.spatial_node_index,
is_backface_visible: sc.is_backface_visible, flags: sc.prim_flags,
} }
}); });
(true, extra_instance) (true, extra_instance)
@ -1895,12 +1895,18 @@ impl<'a> SceneBuilder<'a> {
|sc| sc.snap_to_device.clone(), |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 // Push the SC onto the stack, so we know how to handle things in
// pop_stacking_context. // pop_stacking_context.
self.sc_stack.push(FlattenedStackingContext { self.sc_stack.push(FlattenedStackingContext {
prim_list: PrimitiveList::empty(), prim_list: PrimitiveList::empty(),
pipeline_id, pipeline_id,
is_backface_visible, prim_flags,
requested_raster_space, requested_raster_space,
spatial_node_index, spatial_node_index,
clip_chain_id, clip_chain_id,
@ -1939,7 +1945,7 @@ impl<'a> SceneBuilder<'a> {
prim, prim,
LayoutSize::zero(), LayoutSize::zero(),
stacking_context.spatial_node_index, stacking_context.spatial_node_index,
true, PrimitiveFlags::IS_BACKFACE_VISIBLE,
); );
} }
@ -1961,7 +1967,7 @@ impl<'a> SceneBuilder<'a> {
prim, prim,
LayoutSize::zero(), LayoutSize::zero(),
stacking_context.spatial_node_index, stacking_context.spatial_node_index,
true, PrimitiveFlags::IS_BACKFACE_VISIBLE,
); );
} }
@ -2018,7 +2024,7 @@ impl<'a> SceneBuilder<'a> {
// Now, create a picture with tile caching enabled that will hold all // Now, create a picture with tile caching enabled that will hold all
// of the primitives selected as belonging to the main scroll root. // of the primitives selected as belonging to the main scroll root.
let pic_key = PictureKey::new( let pic_key = PictureKey::new(
true, PrimitiveFlags::IS_BACKFACE_VISIBLE,
LayoutSize::zero(), LayoutSize::zero(),
Picture { Picture {
composite_mode_key: PictureCompositeKey::Identity, composite_mode_key: PictureCompositeKey::Identity,
@ -2030,7 +2036,7 @@ impl<'a> SceneBuilder<'a> {
.intern(&pic_key, || { .intern(&pic_key, || {
PrimitiveSceneData { PrimitiveSceneData {
prim_size: LayoutSize::zero(), prim_size: LayoutSize::zero(),
is_backface_visible: true, flags: PrimitiveFlags::IS_BACKFACE_VISIBLE,
} }
} }
); );
@ -2054,7 +2060,7 @@ impl<'a> SceneBuilder<'a> {
Picture3DContext::Out, Picture3DContext::Out,
None, None,
true, true,
true, PrimitiveFlags::IS_BACKFACE_VISIBLE,
RasterSpace::Screen, RasterSpace::Screen,
stacking_context.prim_list, stacking_context.prim_list,
scroll_root, scroll_root,
@ -2078,7 +2084,7 @@ impl<'a> SceneBuilder<'a> {
instance, instance,
LayoutSize::zero(), LayoutSize::zero(),
scroll_root, scroll_root,
true, PrimitiveFlags::IS_BACKFACE_VISIBLE,
); );
stacking_context.prim_list = prim_list; stacking_context.prim_list = prim_list;
} }
@ -2091,7 +2097,7 @@ impl<'a> SceneBuilder<'a> {
leaf_context_3d, leaf_context_3d,
leaf_output_pipeline_id, leaf_output_pipeline_id,
true, true,
stacking_context.is_backface_visible, stacking_context.prim_flags,
stacking_context.requested_raster_space, stacking_context.requested_raster_space,
stacking_context.prim_list, stacking_context.prim_list,
stacking_context.spatial_node_index, stacking_context.spatial_node_index,
@ -2107,7 +2113,7 @@ impl<'a> SceneBuilder<'a> {
let mut cur_instance = create_prim_instance( let mut cur_instance = create_prim_instance(
leaf_pic_index, leaf_pic_index,
leaf_composite_mode.into(), leaf_composite_mode.into(),
stacking_context.is_backface_visible, stacking_context.prim_flags,
ClipChainId::NONE, ClipChainId::NONE,
&mut self.interners, &mut self.interners,
); );
@ -2123,7 +2129,7 @@ impl<'a> SceneBuilder<'a> {
prims.push(ExtendedPrimitiveInstance { prims.push(ExtendedPrimitiveInstance {
instance: cur_instance, instance: cur_instance,
spatial_node_index: stacking_context.spatial_node_index, spatial_node_index: stacking_context.spatial_node_index,
is_backface_visible: stacking_context.is_backface_visible, flags: stacking_context.prim_flags,
}); });
let mut prim_list = PrimitiveList::empty(); let mut prim_list = PrimitiveList::empty();
@ -2132,7 +2138,7 @@ impl<'a> SceneBuilder<'a> {
ext_prim.instance, ext_prim.instance,
LayoutSize::zero(), LayoutSize::zero(),
ext_prim.spatial_node_index, ext_prim.spatial_node_index,
ext_prim.is_backface_visible, ext_prim.flags,
); );
} }
@ -2147,7 +2153,7 @@ impl<'a> SceneBuilder<'a> {
}, },
stacking_context.frame_output_pipeline_id, stacking_context.frame_output_pipeline_id,
true, true,
stacking_context.is_backface_visible, stacking_context.prim_flags,
stacking_context.requested_raster_space, stacking_context.requested_raster_space,
prim_list, prim_list,
stacking_context.spatial_node_index, stacking_context.spatial_node_index,
@ -2159,7 +2165,7 @@ impl<'a> SceneBuilder<'a> {
cur_instance = create_prim_instance( cur_instance = create_prim_instance(
current_pic_index, current_pic_index,
PictureCompositeKey::Identity, PictureCompositeKey::Identity,
stacking_context.is_backface_visible, stacking_context.prim_flags,
ClipChainId::NONE, ClipChainId::NONE,
&mut self.interners, &mut self.interners,
); );
@ -2171,7 +2177,7 @@ impl<'a> SceneBuilder<'a> {
stacking_context.composite_ops.filters, stacking_context.composite_ops.filters,
stacking_context.composite_ops.filter_primitives, stacking_context.composite_ops.filter_primitives,
stacking_context.composite_ops.filter_datas, stacking_context.composite_ops.filter_datas,
stacking_context.is_backface_visible, stacking_context.prim_flags,
stacking_context.requested_raster_space, stacking_context.requested_raster_space,
stacking_context.spatial_node_index, stacking_context.spatial_node_index,
true, true,
@ -2200,7 +2206,7 @@ impl<'a> SceneBuilder<'a> {
cur_instance.clone(), cur_instance.clone(),
LayoutSize::zero(), LayoutSize::zero(),
stacking_context.spatial_node_index, stacking_context.spatial_node_index,
stacking_context.is_backface_visible, stacking_context.prim_flags,
); );
let blend_pic_index = PictureIndex(self.prim_store.pictures let blend_pic_index = PictureIndex(self.prim_store.pictures
@ -2210,7 +2216,7 @@ impl<'a> SceneBuilder<'a> {
Picture3DContext::Out, Picture3DContext::Out,
None, None,
true, true,
stacking_context.is_backface_visible, stacking_context.prim_flags,
stacking_context.requested_raster_space, stacking_context.requested_raster_space,
prim_list, prim_list,
stacking_context.spatial_node_index, stacking_context.spatial_node_index,
@ -2223,7 +2229,7 @@ impl<'a> SceneBuilder<'a> {
cur_instance = create_prim_instance( cur_instance = create_prim_instance(
blend_pic_index, blend_pic_index,
composite_mode.into(), composite_mode.into(),
stacking_context.is_backface_visible, stacking_context.prim_flags,
ClipChainId::NONE, ClipChainId::NONE,
&mut self.interners, &mut self.interners,
); );
@ -2260,7 +2266,7 @@ impl<'a> SceneBuilder<'a> {
cur_instance, cur_instance,
LayoutSize::zero(), LayoutSize::zero(),
stacking_context.spatial_node_index, stacking_context.spatial_node_index,
stacking_context.is_backface_visible, stacking_context.prim_flags,
); );
None None
} }
@ -2277,7 +2283,7 @@ impl<'a> SceneBuilder<'a> {
self.add_primitive_instance_to_3d_root(ExtendedPrimitiveInstance { self.add_primitive_instance_to_3d_root(ExtendedPrimitiveInstance {
instance, instance,
spatial_node_index: stacking_context.spatial_node_index, spatial_node_index: stacking_context.spatial_node_index,
is_backface_visible: stacking_context.is_backface_visible, flags: stacking_context.prim_flags,
}); });
} }
@ -2606,7 +2612,6 @@ impl<'a> SceneBuilder<'a> {
blur_filter.sanitize(); blur_filter.sanitize();
let composite_mode = PictureCompositeMode::Filter(blur_filter); let composite_mode = PictureCompositeMode::Filter(blur_filter);
let composite_mode_key = Some(composite_mode.clone()).into(); let composite_mode_key = Some(composite_mode.clone()).into();
let is_backface_visible = true; //TODO: double check this
// Pass through configuration information about whether WR should // Pass through configuration information about whether WR should
// do the bounding rect inflation for text shadows. // do the bounding rect inflation for text shadows.
@ -2622,7 +2627,7 @@ impl<'a> SceneBuilder<'a> {
Picture3DContext::Out, Picture3DContext::Out,
None, None,
is_passthrough, is_passthrough,
is_backface_visible, PrimitiveFlags::IS_BACKFACE_VISIBLE,
raster_space, raster_space,
prim_list, prim_list,
pending_shadow.clip_and_scroll.spatial_node_index, pending_shadow.clip_and_scroll.spatial_node_index,
@ -2632,7 +2637,7 @@ impl<'a> SceneBuilder<'a> {
); );
let shadow_pic_key = PictureKey::new( let shadow_pic_key = PictureKey::new(
true, PrimitiveFlags::IS_BACKFACE_VISIBLE,
LayoutSize::zero(), LayoutSize::zero(),
Picture { composite_mode_key }, Picture { composite_mode_key },
); );
@ -2642,7 +2647,7 @@ impl<'a> SceneBuilder<'a> {
.intern(&shadow_pic_key, || { .intern(&shadow_pic_key, || {
PrimitiveSceneData { PrimitiveSceneData {
prim_size: LayoutSize::zero(), prim_size: LayoutSize::zero(),
is_backface_visible: true, flags: PrimitiveFlags::IS_BACKFACE_VISIBLE,
} }
} }
); );
@ -2664,7 +2669,7 @@ impl<'a> SceneBuilder<'a> {
shadow_prim_instance, shadow_prim_instance,
LayoutSize::zero(), LayoutSize::zero(),
pending_shadow.clip_and_scroll.spatial_node_index, pending_shadow.clip_and_scroll.spatial_node_index,
true, PrimitiveFlags::IS_BACKFACE_VISIBLE,
); );
} }
} }
@ -2742,7 +2747,7 @@ impl<'a> SceneBuilder<'a> {
shadow_prim_instance, shadow_prim_instance,
info.rect.size, info.rect.size,
pending_primitive.clip_and_scroll.spatial_node_index, pending_primitive.clip_and_scroll.spatial_node_index,
info.is_backface_visible, info.flags,
); );
} }
@ -3298,7 +3303,7 @@ impl<'a> SceneBuilder<'a> {
// a clip for each stacking context. // a clip for each stacking context.
for stacking_context in self.sc_stack.iter().rev().take_while(|sc| !sc.is_backdrop_root) { for stacking_context in self.sc_stack.iter().rev().take_while(|sc| !sc.is_backdrop_root) {
let clip_chain_id = stacking_context.clip_chain_id; let clip_chain_id = stacking_context.clip_chain_id;
let is_backface_visible = stacking_context.is_backface_visible; let prim_flags = stacking_context.prim_flags;
let composite_mode = None; let composite_mode = None;
let mut prim_list = PrimitiveList::empty(); let mut prim_list = PrimitiveList::empty();
@ -3306,7 +3311,7 @@ impl<'a> SceneBuilder<'a> {
instance, instance,
LayoutSize::zero(), LayoutSize::zero(),
backdrop_spatial_node_index, backdrop_spatial_node_index,
is_backface_visible, prim_flags,
); );
backdrop_pic_index = PictureIndex(self.prim_store.pictures backdrop_pic_index = PictureIndex(self.prim_store.pictures
@ -3316,7 +3321,7 @@ impl<'a> SceneBuilder<'a> {
Picture3DContext::Out, Picture3DContext::Out,
None, None,
true, true,
is_backface_visible, prim_flags,
requested_raster_space, requested_raster_space,
prim_list, prim_list,
backdrop_spatial_node_index, backdrop_spatial_node_index,
@ -3330,7 +3335,7 @@ impl<'a> SceneBuilder<'a> {
instance = create_prim_instance( instance = create_prim_instance(
backdrop_pic_index, backdrop_pic_index,
composite_mode.into(), composite_mode.into(),
is_backface_visible, prim_flags,
clip_chain_id, clip_chain_id,
&mut self.interners, &mut self.interners,
); );
@ -3342,7 +3347,7 @@ impl<'a> SceneBuilder<'a> {
filters, filters,
filter_primitives, filter_primitives,
filter_datas, filter_datas,
info.is_backface_visible, info.flags,
requested_raster_space, requested_raster_space,
backdrop_spatial_node_index, backdrop_spatial_node_index,
false, false,
@ -3365,7 +3370,7 @@ impl<'a> SceneBuilder<'a> {
filters, filters,
filter_primitives, filter_primitives,
filter_datas, filter_datas,
info.is_backface_visible, info.flags,
requested_raster_space, requested_raster_space,
backdrop_spatial_node_index, backdrop_spatial_node_index,
false, false,
@ -3387,7 +3392,7 @@ impl<'a> SceneBuilder<'a> {
filtered_instance, filtered_instance,
LayoutSize::zero(), LayoutSize::zero(),
backdrop_spatial_node_index, backdrop_spatial_node_index,
info.is_backface_visible, info.flags,
); );
} }
@ -3395,7 +3400,7 @@ impl<'a> SceneBuilder<'a> {
let mut flattened_items = None; let mut flattened_items = None;
let mut backdrop_root = None; let mut backdrop_root = None;
let mut spatial_node_index = SpatialNodeIndex::INVALID; let mut spatial_node_index = SpatialNodeIndex::INVALID;
let mut is_backface_visible = true; let mut prim_flags = PrimitiveFlags::default();
for sc in self.sc_stack.iter_mut().rev() { for sc in self.sc_stack.iter_mut().rev() {
// Add child contents to parent stacking context // Add child contents to parent stacking context
if let Some((_, flattened_instance)) = flattened_items.take() { if let Some((_, flattened_instance)) = flattened_items.take() {
@ -3403,7 +3408,7 @@ impl<'a> SceneBuilder<'a> {
flattened_instance, flattened_instance,
LayoutSize::zero(), LayoutSize::zero(),
spatial_node_index, spatial_node_index,
is_backface_visible, prim_flags,
); );
} }
flattened_items = sc.cut_item_sequence( flattened_items = sc.cut_item_sequence(
@ -3413,7 +3418,7 @@ impl<'a> SceneBuilder<'a> {
Picture3DContext::Out, Picture3DContext::Out,
); );
spatial_node_index = sc.spatial_node_index; spatial_node_index = sc.spatial_node_index;
is_backface_visible = sc.is_backface_visible; prim_flags = sc.prim_flags;
if sc.is_backdrop_root { if sc.is_backdrop_root {
backdrop_root = Some(sc); backdrop_root = Some(sc);
break; break;
@ -3428,7 +3433,7 @@ impl<'a> SceneBuilder<'a> {
instance, instance,
LayoutSize::zero(), LayoutSize::zero(),
spatial_node_index, spatial_node_index,
is_backface_visible, prim_flags,
); );
Some(pic_index) Some(pic_index)
@ -3441,7 +3446,7 @@ impl<'a> SceneBuilder<'a> {
mut filter_ops: Vec<Filter>, mut filter_ops: Vec<Filter>,
mut filter_primitives: Vec<FilterPrimitive>, mut filter_primitives: Vec<FilterPrimitive>,
filter_datas: Vec<FilterData>, filter_datas: Vec<FilterData>,
is_backface_visible: bool, flags: PrimitiveFlags,
requested_raster_space: RasterSpace, requested_raster_space: RasterSpace,
spatial_node_index: SpatialNodeIndex, spatial_node_index: SpatialNodeIndex,
inflate_if_required: bool, inflate_if_required: bool,
@ -3494,7 +3499,7 @@ impl<'a> SceneBuilder<'a> {
cur_instance.clone(), cur_instance.clone(),
LayoutSize::zero(), LayoutSize::zero(),
spatial_node_index, spatial_node_index,
is_backface_visible, flags,
); );
let filter_pic_index = PictureIndex(self.prim_store.pictures let filter_pic_index = PictureIndex(self.prim_store.pictures
@ -3504,7 +3509,7 @@ impl<'a> SceneBuilder<'a> {
Picture3DContext::Out, Picture3DContext::Out,
None, None,
true, true,
is_backface_visible, flags,
requested_raster_space, requested_raster_space,
prim_list, prim_list,
spatial_node_index, spatial_node_index,
@ -3519,7 +3524,7 @@ impl<'a> SceneBuilder<'a> {
cur_instance = create_prim_instance( cur_instance = create_prim_instance(
current_pic_index, current_pic_index,
composite_mode.into(), composite_mode.into(),
is_backface_visible, flags,
ClipChainId::NONE, ClipChainId::NONE,
&mut self.interners, &mut self.interners,
); );
@ -3565,7 +3570,7 @@ impl<'a> SceneBuilder<'a> {
cur_instance.clone(), cur_instance.clone(),
LayoutSize::zero(), LayoutSize::zero(),
spatial_node_index, spatial_node_index,
is_backface_visible, flags,
); );
let filter_pic_index = PictureIndex(self.prim_store.pictures let filter_pic_index = PictureIndex(self.prim_store.pictures
@ -3575,7 +3580,7 @@ impl<'a> SceneBuilder<'a> {
Picture3DContext::Out, Picture3DContext::Out,
None, None,
true, true,
is_backface_visible, flags,
requested_raster_space, requested_raster_space,
prim_list, prim_list,
spatial_node_index, spatial_node_index,
@ -3590,7 +3595,7 @@ impl<'a> SceneBuilder<'a> {
cur_instance = create_prim_instance( cur_instance = create_prim_instance(
current_pic_index, current_pic_index,
Some(composite_mode).into(), Some(composite_mode).into(),
is_backface_visible, flags,
ClipChainId::NONE, ClipChainId::NONE,
&mut self.interners, &mut self.interners,
); );
@ -3622,7 +3627,7 @@ pub trait IsVisible {
struct ExtendedPrimitiveInstance { struct ExtendedPrimitiveInstance {
instance: PrimitiveInstance, instance: PrimitiveInstance,
spatial_node_index: SpatialNodeIndex, spatial_node_index: SpatialNodeIndex,
is_backface_visible: bool, flags: PrimitiveFlags,
} }
/// Properties of a stacking context that are maintained /// Properties of a stacking context that are maintained
@ -3632,8 +3637,8 @@ struct FlattenedStackingContext {
/// The list of primitive instances added to this stacking context. /// The list of primitive instances added to this stacking context.
prim_list: PrimitiveList, prim_list: PrimitiveList,
/// Whether this stacking context is visible when backfacing /// Primitive instance flags for compositing this stacking context
is_backface_visible: bool, prim_flags: PrimitiveFlags,
/// Whether or not the caller wants this drawn in /// Whether or not the caller wants this drawn in
/// screen space (quality) or local space (performance) /// screen space (quality) or local space (performance)
@ -3714,7 +3719,7 @@ impl FlattenedStackingContext {
} }
// If backface visibility is explicitly set. // If backface visibility is explicitly set.
if !self.is_backface_visible { if !self.prim_flags.contains(PrimitiveFlags::IS_BACKFACE_VISIBLE) {
return false; return false;
} }
@ -3756,7 +3761,7 @@ impl FlattenedStackingContext {
flat_items_context_3d, flat_items_context_3d,
None, None,
true, true,
self.is_backface_visible, self.prim_flags,
self.requested_raster_space, self.requested_raster_space,
mem::replace(&mut self.prim_list, PrimitiveList::empty()), mem::replace(&mut self.prim_list, PrimitiveList::empty()),
self.spatial_node_index, self.spatial_node_index,
@ -3768,7 +3773,7 @@ impl FlattenedStackingContext {
let prim_instance = create_prim_instance( let prim_instance = create_prim_instance(
pic_index, pic_index,
composite_mode.into(), composite_mode.into(),
self.is_backface_visible, self.prim_flags,
self.clip_chain_id, self.clip_chain_id,
interners, interners,
); );
@ -3836,12 +3841,12 @@ impl From<PendingPrimitive<TextRun>> for ShadowItem {
fn create_prim_instance( fn create_prim_instance(
pic_index: PictureIndex, pic_index: PictureIndex,
composite_mode_key: PictureCompositeKey, composite_mode_key: PictureCompositeKey,
is_backface_visible: bool, flags: PrimitiveFlags,
clip_chain_id: ClipChainId, clip_chain_id: ClipChainId,
interners: &mut Interners, interners: &mut Interners,
) -> PrimitiveInstance { ) -> PrimitiveInstance {
let pic_key = PictureKey::new( let pic_key = PictureKey::new(
is_backface_visible, flags,
LayoutSize::zero(), LayoutSize::zero(),
Picture { composite_mode_key }, Picture { composite_mode_key },
); );
@ -3851,7 +3856,7 @@ fn create_prim_instance(
.intern(&pic_key, || { .intern(&pic_key, || {
PrimitiveSceneData { PrimitiveSceneData {
prim_size: LayoutSize::zero(), prim_size: LayoutSize::zero(),
is_backface_visible, flags,
} }
} }
); );

Просмотреть файл

@ -33,6 +33,22 @@ pub const MAX_BLUR_RADIUS: f32 = 300.;
/// events. /// events.
pub type ItemTag = (u64, u16); pub type ItemTag = (u64, u16);
bitflags! {
#[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;
}
}
impl Default for PrimitiveFlags {
fn default() -> Self {
PrimitiveFlags::IS_BACKFACE_VISIBLE
}
}
/// A grouping of fields a lot of display items need, just to avoid /// A grouping of fields a lot of display items need, just to avoid
/// repeating these over and over in this file. /// repeating these over and over in this file.
#[derive(Clone, Copy, Debug, Default, Deserialize, PartialEq, Serialize, PeekPoke)] #[derive(Clone, Copy, Debug, Default, Deserialize, PartialEq, Serialize, PeekPoke)]
@ -49,19 +65,22 @@ pub struct CommonItemProperties {
/// dubious "common" field, but because it's an Option, it usually only /// dubious "common" field, but because it's an Option, it usually only
/// wastes a single byte (for None). /// wastes a single byte (for None).
pub hit_info: Option<ItemTag>, pub hit_info: Option<ItemTag>,
/// The CSS backface-visibility property (yes, it can be really granular) /// Various flags describing properties of this primitive.
pub is_backface_visible: bool, pub flags: PrimitiveFlags,
} }
impl CommonItemProperties { impl CommonItemProperties {
/// Convenience for tests. /// Convenience for tests.
pub fn new(clip_rect: LayoutRect, space_and_clip: SpaceAndClipInfo) -> Self { pub fn new(
clip_rect: LayoutRect,
space_and_clip: SpaceAndClipInfo,
) -> Self {
Self { Self {
clip_rect, clip_rect,
spatial_id: space_and_clip.spatial_id, spatial_id: space_and_clip.spatial_id,
clip_id: space_and_clip.clip_id, clip_id: space_and_clip.clip_id,
hit_info: None, hit_info: None,
is_backface_visible: true, flags: PrimitiveFlags::default(),
} }
} }
} }

Просмотреть файл

@ -118,7 +118,7 @@ impl<'a> RawtestHarness<'a> {
clip_rect, clip_rect,
clip_id: space_and_clip.clip_id, clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id, spatial_id: space_and_clip.spatial_id,
is_backface_visible: true, flags: PrimitiveFlags::default(),
hit_info: None, hit_info: None,
} }
} }
@ -133,7 +133,7 @@ impl<'a> RawtestHarness<'a> {
clip_rect, clip_rect,
clip_id, clip_id,
spatial_id, spatial_id,
is_backface_visible: true, flags: PrimitiveFlags::default(),
hit_info: None, hit_info: None,
} }
} }
@ -322,7 +322,7 @@ impl<'a> RawtestHarness<'a> {
clip_rect: rect(0.0, 0.0, 800.0, 800.0), clip_rect: rect(0.0, 0.0, 800.0, 800.0),
clip_id, clip_id,
spatial_id: root_space_and_clip.spatial_id, spatial_id: root_space_and_clip.spatial_id,
is_backface_visible: true, flags: PrimitiveFlags::default(),
hit_info: None, hit_info: None,
}; };
@ -954,7 +954,7 @@ impl<'a> RawtestHarness<'a> {
clip_rect: rect(110., 110., 50., 2.), clip_rect: rect(110., 110., 50., 2.),
clip_id, clip_id,
spatial_id, spatial_id,
is_backface_visible: true, flags: PrimitiveFlags::default(),
hit_info: None, hit_info: None,
}; };
builder.push_line( builder.push_line(
@ -1209,7 +1209,7 @@ impl<'a> RawtestHarness<'a> {
clip_rect: rect, clip_rect: rect,
clip_id: temp_clip_id, clip_id: temp_clip_id,
spatial_id: space_and_clip.spatial_id, spatial_id: space_and_clip.spatial_id,
is_backface_visible: true, flags: PrimitiveFlags::default(),
}, },
ColorF::new(1.0, 1.0, 1.0, 1.0), ColorF::new(1.0, 1.0, 1.0, 1.0),
); );
@ -1229,7 +1229,7 @@ impl<'a> RawtestHarness<'a> {
clip_rect: rect, clip_rect: rect,
clip_id: ClipId::ClipChain(clip_chain_id), clip_id: ClipId::ClipChain(clip_chain_id),
spatial_id: space_and_clip.spatial_id, spatial_id: space_and_clip.spatial_id,
is_backface_visible: true, flags: PrimitiveFlags::default(),
}, },
ColorF::new(1.0, 1.0, 1.0, 1.0), ColorF::new(1.0, 1.0, 1.0, 1.0),
); );

Просмотреть файл

@ -464,7 +464,7 @@ impl YamlFrameReader {
clip_rect: LayoutRect::zero(), clip_rect: LayoutRect::zero(),
clip_id: ClipId::invalid(), clip_id: ClipId::invalid(),
spatial_id: SpatialId::new(0, PipelineId::dummy()), spatial_id: SpatialId::new(0, PipelineId::dummy()),
is_backface_visible: true, flags: PrimitiveFlags::default(),
hit_info: None, hit_info: None,
}; };
self.add_stacking_context_from_yaml(&mut builder, wrench, yaml, true, &mut info); self.add_stacking_context_from_yaml(&mut builder, wrench, yaml, true, &mut info);
@ -1643,12 +1643,21 @@ impl YamlFrameReader {
} }
let space_and_clip = self.top_space_and_clip(); let space_and_clip = self.top_space_and_clip();
let mut flags = PrimitiveFlags::default();
if let Some(is_backface_visible) = item["backface-visible"].as_bool() {
if is_backface_visible {
flags.insert(PrimitiveFlags::IS_BACKFACE_VISIBLE);
} else {
flags.remove(PrimitiveFlags::IS_BACKFACE_VISIBLE);
}
}
let mut info = CommonItemProperties { let mut info = CommonItemProperties {
clip_rect, clip_rect,
clip_id: space_and_clip.clip_id, clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id, spatial_id: space_and_clip.spatial_id,
hit_info: self.to_hit_testing_tag(&item["hit-testing-tag"]), hit_info: self.to_hit_testing_tag(&item["hit-testing-tag"]),
is_backface_visible: item["backface-visible"].as_bool().unwrap_or(true), flags,
}; };
match item_type { match item_type {
@ -2026,7 +2035,7 @@ impl YamlFrameReader {
dl.push_stacking_context( dl.push_stacking_context(
bounds.origin, bounds.origin,
*self.spatial_id_stack.last().unwrap(), *self.spatial_id_stack.last().unwrap(),
info.is_backface_visible, info.flags.contains(PrimitiveFlags::IS_BACKFACE_VISIBLE),
clip_node_id, clip_node_id,
transform_style, transform_style,
mix_blend_mode, mix_blend_mode,

Просмотреть файл

@ -203,7 +203,7 @@ fn maybe_radius_yaml(radius: &BorderRadius) -> Option<Yaml> {
fn common_node(v: &mut Table, clip_id_mapper: &mut ClipIdMapper, info: &CommonItemProperties) { fn common_node(v: &mut Table, clip_id_mapper: &mut ClipIdMapper, info: &CommonItemProperties) {
rect_node(v, "clip-rect", &info.clip_rect); rect_node(v, "clip-rect", &info.clip_rect);
bool_node(v, "backface-visible", info.is_backface_visible); bool_node(v, "backface-visible", info.flags.contains(PrimitiveFlags::IS_BACKFACE_VISIBLE));
clip_and_scroll_node(v, clip_id_mapper, info.clip_id, info.spatial_id); clip_and_scroll_node(v, clip_id_mapper, info.clip_id, info.spatial_id);