Skip to content

Commit

Permalink
Bug 1581448 - Add support for specifying extra per-primitive flags in…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
gw3583 committed Sep 18, 2019
1 parent ed4c1cd commit e205255
Show file tree
Hide file tree
Showing 14 changed files with 189 additions and 144 deletions.
51 changes: 31 additions & 20 deletions gfx/webrender_bindings/src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
pub extern "C" fn wr_dp_push_rect(state: &mut WrState,
rect: LayoutRect,
Expand All @@ -2376,7 +2387,7 @@ pub extern "C" fn wr_dp_push_rect(state: &mut WrState,
clip_rect: clip_rect.unwrap_or(LayoutRect::zero()),
clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id,
is_backface_visible,
flags: prim_flags(is_backface_visible),
hit_info: state.current_tag,
};

Expand Down Expand Up @@ -2406,7 +2417,7 @@ pub extern "C" fn wr_dp_push_rect_with_parent_clip(
clip_rect: clip_rect.unwrap(),
clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id,
is_backface_visible,
flags: prim_flags(is_backface_visible),
hit_info: state.current_tag,
};

Expand Down Expand Up @@ -2458,7 +2469,7 @@ pub extern "C" fn wr_dp_push_backdrop_filter_with_parent_clip(
clip_rect: clip_rect.unwrap(),
clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id,
is_backface_visible,
flags: prim_flags(is_backface_visible),
hit_info: state.current_tag,
};

Expand Down Expand Up @@ -2486,7 +2497,7 @@ pub extern "C" fn wr_dp_push_clear_rect(state: &mut WrState,
clip_rect: clip_rect.unwrap(),
clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id,
is_backface_visible: true,
flags: prim_flags(true),
hit_info: state.current_tag,
};

Expand All @@ -2512,7 +2523,7 @@ pub extern "C" fn wr_dp_push_hit_test(state: &mut WrState,
clip_rect: clip_rect.unwrap(),
clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id,
is_backface_visible,
flags: prim_flags(is_backface_visible),
hit_info: state.current_tag,
};

Expand All @@ -2539,7 +2550,7 @@ pub extern "C" fn wr_dp_push_clear_rect_with_parent_clip(
clip_rect: clip_rect.unwrap(),
clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id,
is_backface_visible: true,
flags: prim_flags(true),
hit_info: state.current_tag,
};

Expand All @@ -2566,7 +2577,7 @@ pub extern "C" fn wr_dp_push_image(state: &mut WrState,
clip_rect: clip,
clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id,
is_backface_visible,
flags: prim_flags(is_backface_visible),
hit_info: state.current_tag,
};

Expand Down Expand Up @@ -2606,7 +2617,7 @@ pub extern "C" fn wr_dp_push_repeating_image(state: &mut WrState,
clip_rect: clip,
clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id,
is_backface_visible,
flags: prim_flags(is_backface_visible),
hit_info: state.current_tag,
};

Expand Down Expand Up @@ -2650,7 +2661,7 @@ pub extern "C" fn wr_dp_push_yuv_planar_image(state: &mut WrState,
clip_rect: clip,
clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id,
is_backface_visible,
flags: prim_flags(is_backface_visible),
hit_info: state.current_tag,
};

Expand Down Expand Up @@ -2686,7 +2697,7 @@ pub extern "C" fn wr_dp_push_yuv_NV12_image(state: &mut WrState,
clip_rect: clip,
clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id,
is_backface_visible,
flags: prim_flags(is_backface_visible),
hit_info: state.current_tag,
};

Expand Down Expand Up @@ -2721,7 +2732,7 @@ pub extern "C" fn wr_dp_push_yuv_interleaved_image(state: &mut WrState,
clip_rect: clip,
clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id,
is_backface_visible,
flags: prim_flags(is_backface_visible),
hit_info: state.current_tag,
};

Expand Down Expand Up @@ -2757,7 +2768,7 @@ pub extern "C" fn wr_dp_push_text(state: &mut WrState,
clip_rect: clip,
spatial_id: space_and_clip.spatial_id,
clip_id: space_and_clip.clip_id,
is_backface_visible,
flags: prim_flags(is_backface_visible),
hit_info: state.current_tag
};

Expand Down Expand Up @@ -2813,7 +2824,7 @@ pub extern "C" fn wr_dp_push_line(state: &mut WrState,
clip_rect: *clip,
clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id,
is_backface_visible,
flags: prim_flags(is_backface_visible),
hit_info: state.current_tag,
};

Expand Down Expand Up @@ -2858,7 +2869,7 @@ pub extern "C" fn wr_dp_push_border(state: &mut WrState,
clip_rect: clip,
clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id,
is_backface_visible,
flags: prim_flags(is_backface_visible),
hit_info: state.current_tag,
};

Expand Down Expand Up @@ -2907,7 +2918,7 @@ pub extern "C" fn wr_dp_push_border_image(state: &mut WrState,
clip_rect: clip,
clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id,
is_backface_visible,
flags: prim_flags(is_backface_visible),
hit_info: state.current_tag,
};

Expand Down Expand Up @@ -2965,7 +2976,7 @@ pub extern "C" fn wr_dp_push_border_gradient(state: &mut WrState,
clip_rect: clip,
clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id,
is_backface_visible,
flags: prim_flags(is_backface_visible),
hit_info: state.current_tag,
};

Expand Down Expand Up @@ -3027,7 +3038,7 @@ pub extern "C" fn wr_dp_push_border_radial_gradient(state: &mut WrState,
clip_rect: clip,
clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id,
is_backface_visible,
flags: prim_flags(is_backface_visible),
hit_info: state.current_tag,
};

Expand Down Expand Up @@ -3070,7 +3081,7 @@ pub extern "C" fn wr_dp_push_linear_gradient(state: &mut WrState,
clip_rect: clip,
clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id,
is_backface_visible,
flags: prim_flags(is_backface_visible),
hit_info: state.current_tag,
};

Expand Down Expand Up @@ -3114,7 +3125,7 @@ pub extern "C" fn wr_dp_push_radial_gradient(state: &mut WrState,
clip_rect: clip,
clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id,
is_backface_visible,
flags: prim_flags(is_backface_visible),
hit_info: state.current_tag,
};

Expand Down Expand Up @@ -3147,7 +3158,7 @@ pub extern "C" fn wr_dp_push_box_shadow(state: &mut WrState,
clip_rect: clip,
clip_id: space_and_clip.clip_id,
spatial_id: space_and_clip.spatial_id,
is_backface_visible,
flags: prim_flags(is_backface_visible),
hit_info: state.current_tag,
};

Expand Down
4 changes: 2 additions & 2 deletions gfx/wr/webrender/src/hit_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* 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/. */

use api::{BorderRadius, ClipMode, HitTestFlags, HitTestItem, HitTestResult, ItemTag};
use api::{BorderRadius, ClipMode, HitTestFlags, HitTestItem, HitTestResult, ItemTag, PrimitiveFlags};
use api::PipelineId;
use api::units::*;
use crate::clip::{ClipChainId, ClipDataStore, ClipNode, ClipItemKind, ClipStore};
Expand Down Expand Up @@ -104,7 +104,7 @@ impl HitTestingItem {
rect: info.rect,
clip_rect: info.clip_rect,
tag,
is_backface_visible: info.is_backface_visible,
is_backface_visible: info.flags.contains(PrimitiveFlags::IS_BACKFACE_VISIBLE),
spatial_node_index,
clip_chain_range,
}
Expand Down
6 changes: 3 additions & 3 deletions gfx/wr/webrender/src/internal_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* 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/. */

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::units::*;
use api;
Expand Down Expand Up @@ -554,7 +554,7 @@ pub struct LayoutPrimitiveInfo {
/// but that's an ongoing project, so for now it exists and is used :(
pub rect: LayoutRect,
pub clip_rect: LayoutRect,
pub is_backface_visible: bool,
pub flags: PrimitiveFlags,
pub hit_info: Option<ItemTag>,
}

Expand All @@ -563,7 +563,7 @@ impl LayoutPrimitiveInfo {
Self {
rect,
clip_rect,
is_backface_visible: true,
flags: PrimitiveFlags::default(),
hit_info: None,
}
}
Expand Down
18 changes: 9 additions & 9 deletions gfx/wr/webrender/src/picture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use api::{MixBlendMode, PipelineId, PremultipliedColorF, FilterPrimitiveKind};
use api::{PropertyBinding, PropertyBindingId, FilterPrimitive, FontRenderMode};
use api::{DebugFlags, RasterSpace, ImageKey, ColorF};
use api::{DebugFlags, RasterSpace, ImageKey, ColorF, PrimitiveFlags};
use api::units::*;
use crate::box_shadow::{BLUR_SAMPLE_SCALE};
use crate::clip::{ClipStore, ClipChainInstance, ClipDataHandle, ClipChainId};
Expand Down Expand Up @@ -2347,7 +2347,7 @@ impl PrimitiveList {
prim_instance: PrimitiveInstance,
prim_size: LayoutSize,
spatial_node_index: SpatialNodeIndex,
is_backface_visible: bool,
prim_flags: PrimitiveFlags,
insert_position: PrimitiveListPosition,
) {
let mut flags = ClusterFlags::empty();
Expand All @@ -2364,7 +2364,7 @@ impl PrimitiveList {
_ => {}
}

if is_backface_visible {
if prim_flags.contains(PrimitiveFlags::IS_BACKFACE_VISIBLE) {
flags.insert(ClusterFlags::IS_BACKFACE_VISIBLE);
}

Expand Down Expand Up @@ -2409,13 +2409,13 @@ impl PrimitiveList {
prim_instance: PrimitiveInstance,
prim_size: LayoutSize,
spatial_node_index: SpatialNodeIndex,
is_backface_visible: bool,
flags: PrimitiveFlags,
) {
self.push(
prim_instance,
prim_size,
spatial_node_index,
is_backface_visible,
flags,
PrimitiveListPosition::Begin,
)
}
Expand All @@ -2426,13 +2426,13 @@ impl PrimitiveList {
prim_instance: PrimitiveInstance,
prim_size: LayoutSize,
spatial_node_index: SpatialNodeIndex,
is_backface_visible: bool,
flags: PrimitiveFlags,
) {
self.push(
prim_instance,
prim_size,
spatial_node_index,
is_backface_visible,
flags,
PrimitiveListPosition::End,
)
}
Expand Down Expand Up @@ -2648,7 +2648,7 @@ impl PicturePrimitive {
context_3d: Picture3DContext<OrderedPictureChild>,
frame_output_pipeline_id: Option<PipelineId>,
apply_local_clip_rect: bool,
is_backface_visible: bool,
flags: PrimitiveFlags,
requested_raster_space: RasterSpace,
prim_list: PrimitiveList,
spatial_node_index: SpatialNodeIndex,
Expand All @@ -2665,7 +2665,7 @@ impl PicturePrimitive {
frame_output_pipeline_id,
extra_gpu_data_handles: SmallVec::new(),
apply_local_clip_rect,
is_backface_visible,
is_backface_visible: flags.contains(PrimitiveFlags::IS_BACKFACE_VISIBLE),
requested_raster_space,
spatial_node_index,
local_rect: LayoutRect::zero(),
Expand Down
7 changes: 4 additions & 3 deletions gfx/wr/webrender/src/prim_store/backdrop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* 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/. */

use api::PrimitiveFlags;
use api::units::*;
use crate::clip_scroll_tree::SpatialNodeIndex;
use crate::intern::{Internable, InternDebug, Handle as InternHandle};
Expand Down Expand Up @@ -34,13 +35,13 @@ pub type BackdropKey = PrimKey<Backdrop>;

impl BackdropKey {
pub fn new(
is_backface_visible: bool,
flags: PrimitiveFlags,
prim_size: LayoutSize,
backdrop: Backdrop,
) -> Self {
BackdropKey {
common: PrimKeyCommonData {
is_backface_visible,
flags,
prim_size: prim_size.into(),
},
kind: backdrop,
Expand Down Expand Up @@ -86,7 +87,7 @@ impl InternablePrimitive for Backdrop {
info: &LayoutPrimitiveInfo,
) -> BackdropKey {
BackdropKey::new(
info.is_backface_visible,
info.flags,
info.rect.size,
self
)
Expand Down
Loading

0 comments on commit e205255

Please sign in to comment.