Bug 1728720 - Remove ROOT_SPATIAL_NODE_INDEX and TOPMOST_SCROLL_NODE_INDEX. r=nical

Add a real root node that is not based on the root pipeline. Remove
the constant for the root spatial node, and retrieve it from the
spatial tree.

Although this doesn't achieve anything useful right now, it will be
needed when spatial nodes are retained between display list and are
referenced by handle.

Differential Revision: https://phabricator.services.mozilla.com/D124310
This commit is contained in:
Glenn Watson 2021-09-06 20:04:19 +00:00
Родитель 4b886741c8
Коммит c043405180
12 изменённых файлов: 212 добавлений и 183 удалений

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

@ -5,8 +5,8 @@
use api::{AlphaType, ClipMode, ImageRendering, ImageBufferKind};
use api::{FontInstanceFlags, YuvColorSpace, YuvFormat, ColorDepth, ColorRange, PremultipliedColorF};
use api::units::*;
use crate::clip::{ClipDataStore, ClipNodeFlags, ClipNodeRange, ClipItemKind, ClipStore};
use crate::spatial_tree::{SpatialTree, ROOT_SPATIAL_NODE_INDEX, SpatialNodeIndex, CoordinateSystemId};
use crate::clip::{ClipNodeFlags, ClipNodeRange, ClipItemKind, ClipStore};
use crate::spatial_tree::{SpatialTree, SpatialNodeIndex, CoordinateSystemId};
use crate::composite::{CompositeState};
use crate::glyph_rasterizer::{GlyphFormat, SubpixelDirection};
use crate::gpu_cache::{GpuBlockData, GpuCache, GpuCacheAddress};
@ -27,7 +27,7 @@ use crate::render_task_graph::{RenderTaskId, RenderTaskGraph};
use crate::render_task::RenderTaskAddress;
use crate::renderer::{BlendMode, ShaderColorMode};
use crate::renderer::MAX_VERTEX_TEXTURE_WIDTH;
use crate::resource_cache::{GlyphFetchResult, ImageProperties, ImageRequest, ResourceCache};
use crate::resource_cache::{GlyphFetchResult, ImageProperties, ImageRequest};
use crate::space::SpaceMapper;
use crate::visibility::{PrimitiveVisibilityFlags, VisibilityState};
use smallvec::SmallVec;
@ -3485,30 +3485,26 @@ impl ClipBatcher {
clip_node_range: ClipNodeRange,
root_spatial_node_index: SpatialNodeIndex,
render_tasks: &RenderTaskGraph,
resource_cache: &ResourceCache,
gpu_cache: &GpuCache,
clip_store: &ClipStore,
spatial_tree: &SpatialTree,
transforms: &mut TransformPalette,
clip_data_store: &ClipDataStore,
actual_rect: DeviceRect,
world_rect: &WorldRect,
surface_device_pixel_scale: DevicePixelScale,
global_device_pixel_scale: DevicePixelScale,
task_origin: DevicePoint,
screen_origin: DevicePoint,
ctx: &RenderTargetContext,
) -> bool {
let mut is_first_clip = true;
let mut clear_to_one = false;
for i in 0 .. clip_node_range.count {
let clip_instance = clip_store.get_instance_from_range(&clip_node_range, i);
let clip_node = &clip_data_store[clip_instance.handle];
let clip_node = &ctx.data_stores.clip[clip_instance.handle];
let clip_transform_id = transforms.get_id(
clip_instance.spatial_node_index,
ROOT_SPATIAL_NODE_INDEX,
spatial_tree,
ctx.root_spatial_node_index,
ctx.spatial_tree,
);
// For clip mask images, we need to map from the primitive's layout space to
@ -3520,14 +3516,14 @@ impl ClipBatcher {
transforms.get_id(
clip_instance.spatial_node_index,
root_spatial_node_index,
spatial_tree,
ctx.spatial_tree,
)
}
_ => {
transforms.get_id(
root_spatial_node_index,
ROOT_SPATIAL_NODE_INDEX,
spatial_tree,
ctx.root_spatial_node_index,
ctx.spatial_tree,
)
}
};
@ -3553,11 +3549,11 @@ impl ClipBatcher {
root_spatial_node_index,
clip_instance.spatial_node_index,
WorldRect::max_rect(),
spatial_tree,
ctx.spatial_tree,
);
let mut add_image = |request: ImageRequest, tile_rect: LayoutRect, sub_rect: DeviceRect| {
let cache_item = match resource_cache.get_cached_image(request) {
let cache_item = match ctx.resource_cache.get_cached_image(request) {
Ok(item) => item,
Err(..) => {
warn!("Warnings: skip a image mask");
@ -3611,7 +3607,7 @@ impl ClipBatcher {
});
};
let clip_spatial_node = &spatial_tree.spatial_nodes[clip_instance.spatial_node_index.0 as usize];
let clip_spatial_node = &ctx.spatial_tree.spatial_nodes[clip_instance.spatial_node_index.0 as usize];
let clip_is_axis_aligned = clip_spatial_node.coordinate_system_id == CoordinateSystemId::root();
if clip_instance.has_visible_tiles() {
@ -3698,9 +3694,9 @@ impl ClipBatcher {
actual_rect,
rect,
clip_instance.spatial_node_index,
spatial_tree,
world_rect,
global_device_pixel_scale,
ctx.spatial_tree,
&ctx.screen_world_rect,
ctx.global_device_pixel_scale,
&common,
is_first_clip,
) {

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

@ -98,7 +98,7 @@ use api::units::*;
use crate::image_tiling::{self, Repetition};
use crate::border::{ensure_no_corner_overlap, BorderRadiusAu};
use crate::box_shadow::{BLUR_SAMPLE_SCALE, BoxShadowClipSource, BoxShadowCacheKey};
use crate::spatial_tree::{ROOT_SPATIAL_NODE_INDEX, SpatialTree, SpatialNodeIndex, CoordinateSystemId};
use crate::spatial_tree::{SpatialTree, SpatialNodeIndex, CoordinateSystemId};
use crate::ellipse::Ellipse;
use crate::gpu_cache::GpuCache;
use crate::gpu_types::{BoxShadowStretchMode};
@ -818,7 +818,7 @@ impl ClipChainInstance {
has_non_local_clips: false,
needs_mask: false,
pic_clip_rect: PictureRect::zero(),
pic_spatial_node_index: ROOT_SPATIAL_NODE_INDEX,
pic_spatial_node_index: SpatialNodeIndex::INVALID,
}
}
}

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

@ -6,7 +6,7 @@ use api::{ColorF, DebugFlags, FontRenderMode, PremultipliedColorF};
use api::units::*;
use crate::batch::{BatchBuilder, AlphaBatchBuilder, AlphaBatchContainer};
use crate::clip::{ClipStore, ClipChainStack};
use crate::spatial_tree::{SpatialTree, ROOT_SPATIAL_NODE_INDEX, SpatialNodeIndex};
use crate::spatial_tree::{SpatialTree, SpatialNodeIndex};
use crate::composite::{CompositorKind, CompositeState, CompositeStatePreallocator};
use crate::debug_item::DebugItem;
use crate::gpu_cache::{GpuCache, GpuCacheHandle};
@ -178,6 +178,7 @@ pub struct FrameBuildingContext<'a> {
pub max_local_clip: LayoutRect,
pub debug_flags: DebugFlags,
pub fb_config: &'a FrameBuilderConfig,
pub root_spatial_node_index: SpatialNodeIndex,
}
pub struct FrameBuildingState<'a> {
@ -355,13 +356,14 @@ impl FrameBuilder {
},
debug_flags,
fb_config: &scene.config,
root_spatial_node_index: scene.spatial_tree.root_reference_frame_index(),
};
// Construct a dummy root surface, that represents the
// main framebuffer surface.
let root_surface = SurfaceInfo::new(
ROOT_SPATIAL_NODE_INDEX,
ROOT_SPATIAL_NODE_INDEX,
root_spatial_node_index,
root_spatial_node_index,
0.0,
global_screen_world_rect,
&scene.spatial_tree,
@ -403,6 +405,7 @@ impl FrameBuilder {
debug_flags,
scene_properties,
config: scene.config,
root_spatial_node_index,
};
let mut visibility_state = FrameVisibilityState {
@ -456,7 +459,7 @@ impl FrameBuilder {
// against the screen world rect, in absence of any
// other dirty regions.
let mut default_dirty_region = DirtyRegion::new(
ROOT_SPATIAL_NODE_INDEX,
root_spatial_node_index,
);
default_dirty_region.add_dirty_region(
frame_context.global_screen_world_rect.cast_unit(),
@ -632,6 +635,7 @@ impl FrameBuilder {
screen_world_rect,
globals: &self.globals,
tile_caches,
root_spatial_node_index: scene.spatial_tree.root_reference_frame_index(),
};
let pass = build_render_pass(
@ -670,6 +674,7 @@ impl FrameBuilder {
screen_world_rect,
globals: &self.globals,
tile_caches,
root_spatial_node_index: scene.spatial_tree.root_reference_frame_index(),
};
self.build_composite_pass(
@ -730,7 +735,7 @@ impl FrameBuilder {
// present modes during render, such as partial present etc.
let tile_cache = &ctx.tile_caches[&slice_id];
let map_local_to_world = SpaceMapper::new_with_target(
ROOT_SPATIAL_NODE_INDEX,
ctx.root_spatial_node_index,
tile_cache.spatial_node_index,
ctx.screen_world_rect,
ctx.spatial_tree,

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

@ -6,7 +6,7 @@ use api::{AlphaType, PremultipliedColorF, YuvFormat, YuvRangedColorSpace};
use api::units::*;
use crate::composite::CompositeFeatures;
use crate::segment::EdgeAaSegmentMask;
use crate::spatial_tree::{SpatialTree, ROOT_SPATIAL_NODE_INDEX, SpatialNodeIndex};
use crate::spatial_tree::{SpatialTree, SpatialNodeIndex};
use crate::gpu_cache::{GpuCacheAddress, GpuDataRequest};
use crate::internal_types::FastHashMap;
use crate::prim_store::ClipData;
@ -692,15 +692,20 @@ pub struct TransformPalette {
transforms: Vec<TransformData>,
metadata: Vec<TransformMetadata>,
map: FastHashMap<RelativeTransformKey, usize>,
root_spatial_node_index: SpatialNodeIndex,
}
impl TransformPalette {
pub fn new(count: usize) -> Self {
pub fn new(
count: usize,
root_spatial_node_index: SpatialNodeIndex,
) -> Self {
let _ = VECS_PER_TRANSFORM;
TransformPalette {
transforms: vec![TransformData::invalid(); count],
metadata: vec![TransformMetadata::invalid(); count],
map: FastHashMap::default(),
root_spatial_node_index,
}
}
@ -717,9 +722,10 @@ impl TransformPalette {
&mut self.metadata,
&mut self.transforms,
index,
ROOT_SPATIAL_NODE_INDEX,
self.root_spatial_node_index,
// We know the root picture space == world space
transform.with_destination::<PicturePixel>(),
self.root_spatial_node_index,
);
}
@ -729,7 +735,7 @@ impl TransformPalette {
parent_index: SpatialNodeIndex,
spatial_tree: &SpatialTree,
) -> usize {
if parent_index == ROOT_SPATIAL_NODE_INDEX {
if parent_index == self.root_spatial_node_index {
child_index.0 as usize
} else if child_index == parent_index {
0
@ -741,6 +747,7 @@ impl TransformPalette {
let metadata = &mut self.metadata;
let transforms = &mut self.transforms;
let root_spatial_node_index = self.root_spatial_node_index;
*self.map
.entry(key)
@ -758,6 +765,7 @@ impl TransformPalette {
child_index,
parent_index,
transform,
root_spatial_node_index,
)
})
}
@ -855,6 +863,7 @@ fn register_transform(
from_index: SpatialNodeIndex,
to_index: SpatialNodeIndex,
transform: LayoutToPictureTransform,
root_spatial_node_index: SpatialNodeIndex,
) -> usize {
// TODO: refactor the calling code to not even try
// registering a non-invertible transform.
@ -870,7 +879,7 @@ fn register_transform(
inv_transform,
};
if to_index == ROOT_SPATIAL_NODE_INDEX {
if to_index == root_spatial_node_index {
let index = from_index.0 as usize;
metadatas[index] = metadata;
transforms[index] = data;

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

@ -102,9 +102,7 @@ use api::units::*;
use crate::batch::BatchFilter;
use crate::box_shadow::BLUR_SAMPLE_SCALE;
use crate::clip::{ClipStore, ClipChainInstance, ClipChainId, ClipInstance};
use crate::spatial_tree::{ROOT_SPATIAL_NODE_INDEX,
SpatialTree, CoordinateSpaceMapping, SpatialNodeIndex, VisibleFace
};
use crate::spatial_tree::{SpatialTree, CoordinateSpaceMapping, SpatialNodeIndex, VisibleFace};
use crate::composite::{CompositorKind, CompositeState, NativeSurfaceId, NativeTileId, CompositeTileSurface, tile_kind};
use crate::composite::{ExternalSurfaceDescriptor, ExternalSurfaceDependency, CompositeTileDescriptor, CompositeTile};
use crate::composite::{CompositorTransformIndex};
@ -424,7 +422,7 @@ impl SpatialNodeComparer {
/// Construct a new comparer
fn new() -> Self {
SpatialNodeComparer {
ref_spatial_node_index: ROOT_SPATIAL_NODE_INDEX,
ref_spatial_node_index: SpatialNodeIndex::INVALID,
spatial_nodes: FastHashMap::default(),
compare_cache: FastHashMap::default(),
referenced_frames: FastHashSet::default(),
@ -1697,7 +1695,7 @@ impl DirtyRegion {
spatial_tree: &SpatialTree,
) {
let map_pic_to_world = SpaceMapper::new_with_target(
ROOT_SPATIAL_NODE_INDEX,
spatial_tree.root_reference_frame_index(),
self.spatial_node_index,
WorldRect::max_rect(),
spatial_tree,
@ -1724,7 +1722,7 @@ impl DirtyRegion {
spatial_tree: &SpatialTree,
) -> DirtyRegion {
let map_pic_to_world = SpaceMapper::new_with_target(
ROOT_SPATIAL_NODE_INDEX,
spatial_tree.root_reference_frame_index(),
self.spatial_node_index,
WorldRect::max_rect(),
spatial_tree,
@ -2509,7 +2507,7 @@ impl TileCacheInstance {
self.backdrop = BackdropInfo::empty();
let pic_to_world_mapper = SpaceMapper::new_with_target(
ROOT_SPATIAL_NODE_INDEX,
frame_context.root_spatial_node_index,
self.spatial_node_index,
frame_context.global_screen_world_rect,
frame_context.spatial_tree,
@ -2631,7 +2629,7 @@ impl TileCacheInstance {
// Get the complete scale-offset from local space to device space
let local_to_device = get_relative_scale_offset(
self.spatial_node_index,
ROOT_SPATIAL_NODE_INDEX,
frame_context.root_spatial_node_index,
frame_context.spatial_tree,
);
@ -2938,7 +2936,7 @@ impl TileCacheInstance {
}
let mapper : SpaceMapper<PicturePixel, WorldPixel> = SpaceMapper::new_with_target(
ROOT_SPATIAL_NODE_INDEX,
frame_context.root_spatial_node_index,
prim_spatial_node_index,
frame_context.global_screen_world_rect,
&frame_context.spatial_tree);
@ -3103,7 +3101,7 @@ impl TileCacheInstance {
}
let pic_to_world_mapper = SpaceMapper::new_with_target(
ROOT_SPATIAL_NODE_INDEX,
frame_context.root_spatial_node_index,
self.spatial_node_index,
frame_context.global_screen_world_rect,
frame_context.spatial_tree,
@ -3122,7 +3120,7 @@ impl TileCacheInstance {
let local_prim_to_device = get_relative_scale_offset(
prim_spatial_node_index,
ROOT_SPATIAL_NODE_INDEX,
frame_context.root_spatial_node_index,
frame_context.spatial_tree,
);
@ -3883,7 +3881,7 @@ impl TileCacheInstance {
);
let map_pic_to_world = SpaceMapper::new_with_target(
ROOT_SPATIAL_NODE_INDEX,
frame_context.root_spatial_node_index,
self.spatial_node_index,
frame_context.global_screen_world_rect,
frame_context.spatial_tree,
@ -3904,7 +3902,7 @@ impl TileCacheInstance {
});
let pic_to_world_mapper = SpaceMapper::new_with_target(
ROOT_SPATIAL_NODE_INDEX,
frame_context.root_spatial_node_index,
self.spatial_node_index,
frame_context.global_screen_world_rect,
frame_context.spatial_tree,
@ -4095,7 +4093,7 @@ impl SurfaceInfo {
scale_factors: (f32, f32),
) -> Self {
let map_surface_to_world = SpaceMapper::new_with_target(
ROOT_SPATIAL_NODE_INDEX,
spatial_tree.root_reference_frame_index(),
surface_spatial_node_index,
world_rect,
spatial_tree,
@ -4724,7 +4722,7 @@ impl PicturePrimitive {
};
let map_pic_to_world = SpaceMapper::new_with_target(
ROOT_SPATIAL_NODE_INDEX,
frame_context.root_spatial_node_index,
surface_spatial_node_index,
frame_context.global_screen_world_rect,
frame_context.spatial_tree,
@ -4779,7 +4777,7 @@ impl PicturePrimitive {
match world_draw_rect {
Some(world_draw_rect) => {
// Only check for occlusion on visible tiles that are fixed position.
if tile_cache.spatial_node_index == ROOT_SPATIAL_NODE_INDEX &&
if tile_cache.spatial_node_index == frame_context.root_spatial_node_index &&
frame_state.composite_state.occluders.is_tile_occluded(tile.z_id, world_draw_rect) {
// If this tile has an allocated native surface, free it, since it's completely
// occluded. We will need to re-allocate this surface if it becomes visible,
@ -6138,7 +6136,7 @@ impl PicturePrimitive {
// Get the complete scale-offset from local space to device space
let local_to_device = get_relative_scale_offset(
tile_cache.spatial_node_index,
ROOT_SPATIAL_NODE_INDEX,
frame_context.root_spatial_node_index,
frame_context.spatial_tree,
);
@ -6303,7 +6301,7 @@ impl PicturePrimitive {
// with information available during frame building.
if cluster.flags.contains(ClusterFlags::IS_BACKDROP_FILTER) {
let backdrop_to_world_mapper = SpaceMapper::new_with_target(
ROOT_SPATIAL_NODE_INDEX,
frame_context.root_spatial_node_index,
cluster.spatial_node_index,
LayoutRect::max_rect(),
frame_context.spatial_tree,
@ -6324,7 +6322,7 @@ impl PicturePrimitive {
// proper bounding box where the backdrop-filter needs to be processed.
let prim_to_world_mapper = SpaceMapper::new_with_target(
ROOT_SPATIAL_NODE_INDEX,
frame_context.root_spatial_node_index,
spatial_node_index,
LayoutRect::max_rect(),
frame_context.spatial_tree,
@ -6575,7 +6573,7 @@ fn create_raster_mappers(
spatial_tree: &SpatialTree,
) -> (SpaceMapper<RasterPixel, WorldPixel>, SpaceMapper<PicturePixel, RasterPixel>) {
let map_raster_to_world = SpaceMapper::new_with_target(
ROOT_SPATIAL_NODE_INDEX,
spatial_tree.root_reference_frame_index(),
raster_spatial_node_index,
world_rect,
spatial_tree,

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

@ -17,7 +17,7 @@ use crate::renderer::{MAX_VERTEX_TEXTURE_WIDTH};
use crate::resource_cache::{ResourceCache};
use crate::util::{MatrixHelpers};
use crate::prim_store::{InternablePrimitive, PrimitiveInstanceKind};
use crate::spatial_tree::{SpatialTree, SpatialNodeIndex, ROOT_SPATIAL_NODE_INDEX};
use crate::spatial_tree::{SpatialTree, SpatialNodeIndex};
use crate::space::SpaceSnapper;
use crate::util::PrimaryArc;
@ -408,12 +408,14 @@ impl TextRunPrimitive {
// the end of a pinch-zoom.
RasterSpace::Local(1.0)
} else {
let root_spatial_node_index = spatial_tree.root_reference_frame_index();
// For high-quality mode, we quantize the exact scale factor as before. However,
// we want to _undo_ the effect of the device-pixel scale on the picture cache
// tiles (which changes now that they are raster roots). Divide the rounded value
// by the device-pixel scale so that the local -> device conversion has no effect.
let scale_factors = spatial_tree
.get_relative_transform(prim_spatial_node_index, ROOT_SPATIAL_NODE_INDEX)
.get_relative_transform(prim_spatial_node_index, root_spatial_node_index)
.scale_factors();
// Round the scale up to the nearest power of 2, but don't exceed 8.

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

@ -7,7 +7,7 @@ use api::units::*;
use api::{ColorF, ImageFormat, LineOrientation, BorderStyle};
use crate::batch::{AlphaBatchBuilder, AlphaBatchContainer, BatchTextures};
use crate::batch::{ClipBatcher, BatchBuilder};
use crate::spatial_tree::{SpatialTree, ROOT_SPATIAL_NODE_INDEX};
use crate::spatial_tree::SpatialTree;
use crate::clip::ClipStore;
use crate::composite::CompositeState;
use crate::frame_builder::{FrameGlobalResources};
@ -26,6 +26,8 @@ use crate::render_task::{RenderTaskKind, RenderTaskAddress};
use crate::render_task::{RenderTask, ScalingTask, SvgFilterInfo};
use crate::render_task_graph::{RenderTaskGraph, RenderTaskId};
use crate::resource_cache::ResourceCache;
use crate::spatial_tree::SpatialNodeIndex;
const STYLE_SOLID: i32 = ((BorderStyle::Solid as i32) << 8) | ((BorderStyle::Solid as i32) << 16);
const STYLE_MASK: i32 = 0x00FF_FF00;
@ -60,6 +62,7 @@ pub struct RenderTargetContext<'a, 'rc> {
pub screen_world_rect: WorldRect,
pub globals: &'a FrameGlobalResources,
pub tile_caches: &'a FastHashMap<SliceId, Box<TileCacheInstance>>,
pub root_spatial_node_index: SpatialNodeIndex,
}
/// Represents a number of rendering operations on a surface.
@ -272,7 +275,7 @@ impl RenderTarget for ColorRenderTarget {
}
None => {
// This must be the main framebuffer
ROOT_SPATIAL_NODE_INDEX
ctx.root_spatial_node_index
}
};
@ -533,18 +536,14 @@ impl RenderTarget for AlphaRenderTarget {
task_info.clip_node_range,
task_info.root_spatial_node_index,
render_tasks,
ctx.resource_cache,
gpu_cache,
clip_store,
ctx.spatial_tree,
transforms,
&ctx.data_stores.clip,
task_info.actual_rect,
&ctx.screen_world_rect,
task_info.device_pixel_scale,
ctx.global_device_pixel_scale,
target_rect.min.to_f32(),
task_info.actual_rect.min,
ctx,
);
if task_info.clear_to_one || clear_to_one {
self.one_clears.push(task_id);

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

@ -50,7 +50,7 @@ use crate::image_tiling::simplify_repeated_primitive;
use crate::clip::{ClipChainId, ClipItemKey, ClipStore, ClipItemKeyKind};
use crate::clip::{ClipInternData, ClipNodeKind, ClipInstance, SceneClipInstance};
use crate::clip::{PolygonDataHandle};
use crate::spatial_tree::{ROOT_SPATIAL_NODE_INDEX, SpatialTree, SpatialNodeIndex, StaticCoordinateSystemId};
use crate::spatial_tree::{SpatialTree, SpatialNodeIndex, StaticCoordinateSystemId};
use crate::frame_builder::{ChasePrimitive, FrameBuilderConfig};
use crate::glyph_rasterizer::FontInstance;
use crate::hit_test::HitTestingScene;
@ -474,10 +474,11 @@ impl<'a> SceneBuilder<'a> {
.and_then(|color| if color.a > 0.0 { Some(color) } else { None });
let spatial_tree = SpatialTree::new();
let root_reference_frame_index = spatial_tree.root_reference_frame_index();
// During scene building, we assume a 1:1 picture -> raster pixel scale
let snap_to_device = SpaceSnapper::new(
ROOT_SPATIAL_NODE_INDEX,
root_reference_frame_index,
RasterPixelScale::new(1.0),
);
@ -500,7 +501,7 @@ impl<'a> SceneBuilder<'a> {
iframe_size: Vec::new(),
root_iframe_clip: None,
quality_settings: view.quality_settings,
tile_cache_builder: TileCacheBuilder::new(),
tile_cache_builder: TileCacheBuilder::new(root_reference_frame_index),
snap_to_device,
picture_graph: PictureGraph::new(),
plane_splitters: Vec::new(),
@ -846,7 +847,7 @@ impl<'a> SceneBuilder<'a> {
self.push_reference_frame(
info.reference_frame.id,
Some(parent_space),
parent_space,
pipeline_id,
info.reference_frame.transform_style,
transform,
@ -916,13 +917,13 @@ impl<'a> SceneBuilder<'a> {
let spatial_node_index = self.push_reference_frame(
SpatialId::root_reference_frame(iframe_pipeline_id),
Some(spatial_node_index),
spatial_node_index,
iframe_pipeline_id,
TransformStyle::Flat,
PropertyBinding::Value(LayoutTransform::identity()),
ReferenceFrameKind::Transform {
is_2d_scale_translation: false,
should_snap: false
is_2d_scale_translation: true,
should_snap: true,
},
bounds.min.to_vector(),
SpatialNodeUid::root_reference_frame(iframe_pipeline_id),
@ -1896,7 +1897,7 @@ impl<'a> SceneBuilder<'a> {
let ancestor_index = self.containing_block_stack
.last()
.cloned()
.unwrap_or(ROOT_SPATIAL_NODE_INDEX);
.unwrap_or(self.spatial_tree.root_reference_frame_index());
let plane_splitter_index = plane_splitter_index.unwrap_or_else(|| {
let index = self.plane_splitters.len();
@ -2328,7 +2329,7 @@ impl<'a> SceneBuilder<'a> {
pub fn push_reference_frame(
&mut self,
reference_frame_id: SpatialId,
parent_index: Option<SpatialNodeIndex>,
parent_index: SpatialNodeIndex,
pipeline_id: PipelineId,
transform_style: TransformStyle,
source_transform: PropertyBinding<LayoutTransform>,
@ -2362,13 +2363,13 @@ impl<'a> SceneBuilder<'a> {
let spatial_node_index = self.push_reference_frame(
SpatialId::root_reference_frame(pipeline_id),
None,
self.spatial_tree.root_reference_frame_index(),
pipeline_id,
TransformStyle::Flat,
PropertyBinding::Value(LayoutTransform::identity()),
ReferenceFrameKind::Transform {
is_2d_scale_translation: false,
should_snap: false,
is_2d_scale_translation: true,
should_snap: true,
},
LayoutVector2D::zero(),
SpatialNodeUid::root_reference_frame(pipeline_id),

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

@ -19,6 +19,8 @@ use crate::util::{LayoutFastTransform, MatrixHelpers, ScaleOffset, TransformedRe
// them completely.
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub enum SpatialNodeUidKind {
/// The root node of the entire spatial tree
Root,
/// Internal scroll frame created during scene building for each iframe
InternalScrollFrame {
pipeline_id: PipelineId,
@ -41,6 +43,12 @@ pub struct SpatialNodeUid {
}
impl SpatialNodeUid {
pub fn root() -> Self {
SpatialNodeUid {
kind: SpatialNodeUidKind::Root,
}
}
pub fn root_scroll_frame(
pipeline_id: PipelineId,
) -> Self {
@ -992,7 +1000,7 @@ fn test_cst_perspective_relative_scroll() {
let transform = LayoutTransform::perspective(100.0);
let root = cst.add_reference_frame(
None,
cst.root_reference_frame_index(),
TransformStyle::Flat,
PropertyBinding::Value(LayoutTransform::identity()),
ReferenceFrameKind::Transform {
@ -1029,7 +1037,7 @@ fn test_cst_perspective_relative_scroll() {
);
let ref_frame = cst.add_reference_frame(
Some(scroll_frame_2),
scroll_frame_2,
TransformStyle::Preserve3D,
PropertyBinding::Value(transform),
ReferenceFrameKind::Perspective {

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

@ -63,10 +63,6 @@ impl SpatialNodeIndex {
pub const INVALID: SpatialNodeIndex = SpatialNodeIndex(u32::MAX);
}
//Note: these have to match ROOT_REFERENCE_FRAME_SPATIAL_ID and ROOT_SCROLL_NODE_SPATIAL_ID
pub const ROOT_SPATIAL_NODE_INDEX: SpatialNodeIndex = SpatialNodeIndex(0);
const TOPMOST_SCROLL_NODE_INDEX: SpatialNodeIndex = SpatialNodeIndex(1);
// In some cases, the conversion from CSS pixels to device pixels can result in small
// rounding errors when calculating the scrollable distance of a scroll frame. Apply
// a small epsilon so that we don't detect these frames as "real" scroll frames.
@ -135,6 +131,8 @@ pub struct SpatialTree {
/// A set of the uids we've encountered for spatial nodes, used to assert that
/// we're not seeing duplicates. Likely to be removed once we rely on this feature.
spatial_node_uids: FastHashSet<SpatialNodeUid>,
root_reference_frame_index: SpatialNodeIndex,
}
#[derive(Clone)]
@ -233,15 +231,33 @@ enum TransformScroll {
impl SpatialTree {
pub fn new() -> Self {
SpatialTree {
let node = SpatialNode::new_reference_frame(
None,
TransformStyle::Flat,
PropertyBinding::Value(LayoutTransform::identity()),
ReferenceFrameKind::Transform {
should_snap: true,
is_2d_scale_translation: true,
},
LayoutVector2D::zero(),
PipelineId::dummy(),
StaticCoordinateSystemId::ROOT,
);
let mut tree = SpatialTree {
spatial_nodes: Vec::new(),
coord_systems: Vec::new(),
pending_scroll_offsets: FastHashMap::default(),
pipelines_to_discard: FastHashSet::default(),
nodes_to_update: Vec::new(),
next_static_coord_system_id: 0,
next_static_coord_system_id: 1,
spatial_node_uids: FastHashSet::default(),
}
root_reference_frame_index: SpatialNodeIndex(0),
};
tree.add_spatial_node(node, SpatialNodeUid::root());
tree
}
/// Calculate the accumulated external scroll offset for
@ -393,7 +409,7 @@ impl SpatialTree {
let child = &self.spatial_nodes[index.0 as usize];
if child.coordinate_system_id.0 == 0 {
if index == ROOT_SPATIAL_NODE_INDEX {
if index == self.root_reference_frame_index {
CoordinateSpaceMapping::Local
} else {
CoordinateSpaceMapping::ScaleOffset(child.content_transform)
@ -429,20 +445,9 @@ impl SpatialTree {
self.get_world_transform_impl(index, TransformScroll::Unscrolled)
}
/// The root reference frame, which is the true root of the SpatialTree. Initially
/// this ID is not valid, which is indicated by ```spatial_nodes``` being empty.
/// The root reference frame, which is the true root of the SpatialTree.
pub fn root_reference_frame_index(&self) -> SpatialNodeIndex {
// TODO(mrobinson): We should eventually make this impossible to misuse.
debug_assert!(!self.spatial_nodes.is_empty());
ROOT_SPATIAL_NODE_INDEX
}
/// The root scroll node which is the first child of the root reference frame.
/// Initially this ID is not valid, which is indicated by ```spatial_nodes``` being empty.
pub fn topmost_scroll_node_index(&self) -> SpatialNodeIndex {
// TODO(mrobinson): We should eventually make this impossible to misuse.
debug_assert!(self.spatial_nodes.len() >= 1);
TOPMOST_SCROLL_NODE_INDEX
self.root_reference_frame_index
}
pub fn get_scroll_node_state(&self) -> Vec<ScrollNodeState> {
@ -542,7 +547,10 @@ impl SpatialTree {
pub fn build_transform_palette(&self) -> TransformPalette {
profile_scope!("build_transform_palette");
let mut palette = TransformPalette::new(self.spatial_nodes.len());
let mut palette = TransformPalette::new(
self.spatial_nodes.len(),
self.root_reference_frame_index(),
);
//Note: getting the world transform of a node is O(1) operation
for i in 0 .. self.spatial_nodes.len() {
let index = SpatialNodeIndex(i as u32);
@ -605,7 +613,7 @@ impl SpatialTree {
pub fn add_reference_frame(
&mut self,
parent_index: Option<SpatialNodeIndex>,
parent_index: SpatialNodeIndex,
transform_style: TransformStyle,
source_transform: PropertyBinding<LayoutTransform>,
kind: ReferenceFrameKind,
@ -615,33 +623,25 @@ impl SpatialTree {
) -> SpatialNodeIndex {
// Determine if this reference frame creates a new static coordinate system
let new_static_coord_system = match parent_index {
Some(..) => {
match kind {
ReferenceFrameKind::Transform { is_2d_scale_translation: true, .. } => {
// Client has guaranteed this transform will only be axis-aligned
false
let new_static_coord_system = match kind {
ReferenceFrameKind::Transform { is_2d_scale_translation: true, .. } => {
// Client has guaranteed this transform will only be axis-aligned
false
}
ReferenceFrameKind::Transform { is_2d_scale_translation: false, .. } | ReferenceFrameKind::Perspective { .. } => {
// Even if client hasn't promised it's an axis-aligned transform, we can still
// check this so long as the transform isn't animated (and thus could change to
// anything by APZ during frame building)
match source_transform {
PropertyBinding::Value(m) => {
!m.is_2d_scale_translation()
}
ReferenceFrameKind::Transform { is_2d_scale_translation: false, .. } | ReferenceFrameKind::Perspective { .. } => {
// Even if client hasn't promised it's an axis-aligned transform, we can still
// check this so long as the transform isn't animated (and thus could change to
// anything by APZ during frame building)
match source_transform {
PropertyBinding::Value(m) => {
!m.is_2d_scale_translation()
}
PropertyBinding::Binding(..) => {
// Animated, so assume it may introduce a complex transform
true
}
}
PropertyBinding::Binding(..) => {
// Animated, so assume it may introduce a complex transform
true
}
}
}
None => {
// The root reference frame always creates a new static coord system
true
}
};
let static_coordinate_system_id = if new_static_coord_system {
@ -649,11 +649,11 @@ impl SpatialTree {
self.next_static_coord_system_id += 1;
id
} else {
self.get_static_coordinate_system_id(parent_index.unwrap())
self.get_static_coordinate_system_id(parent_index)
};
let node = SpatialNode::new_reference_frame(
parent_index,
Some(parent_index),
transform_style,
source_transform,
kind,
@ -726,7 +726,7 @@ impl SpatialTree {
let mut current_node = maybe_child;
while current_node != ROOT_SPATIAL_NODE_INDEX {
while current_node != self.root_reference_frame_index {
let node = &self.spatial_nodes[current_node.0 as usize];
current_node = node.parent.expect("bug: no parent");
@ -745,11 +745,11 @@ impl SpatialTree {
&self,
spatial_node_index: SpatialNodeIndex,
) -> SpatialNodeIndex {
let mut real_scroll_root = ROOT_SPATIAL_NODE_INDEX;
let mut outermost_scroll_root = ROOT_SPATIAL_NODE_INDEX;
let mut real_scroll_root = self.root_reference_frame_index;
let mut outermost_scroll_root = self.root_reference_frame_index;
let mut node_index = spatial_node_index;
while node_index != ROOT_SPATIAL_NODE_INDEX {
while node_index != self.root_reference_frame_index {
let node = &self.spatial_nodes[node_index.0 as usize];
match node.node_type {
SpatialNodeType::ReferenceFrame(ref info) => {
@ -761,8 +761,8 @@ impl SpatialTree {
ReferenceFrameKind::Perspective { .. } => {
// When a reference frame is encountered, forget any scroll roots
// we have encountered, as they may end up with a non-axis-aligned transform.
real_scroll_root = ROOT_SPATIAL_NODE_INDEX;
outermost_scroll_root = ROOT_SPATIAL_NODE_INDEX;
real_scroll_root = self.root_reference_frame_index;
outermost_scroll_root = self.root_reference_frame_index;
}
}
}
@ -812,7 +812,7 @@ impl SpatialTree {
// the clips defined on the content which should be handled when drawing the
// picture cache tiles (by definition these clips are ancestors of the
// scroll root selected for the picture cache).
if real_scroll_root == ROOT_SPATIAL_NODE_INDEX {
if real_scroll_root == self.root_reference_frame_index {
outermost_scroll_root
} else {
real_scroll_root
@ -881,7 +881,7 @@ impl SpatialTree {
}
// If running in Gecko, set RUST_LOG=webrender::spatial_tree=debug
// to get this logging to be emitted to stderr/logcat.
debug!("{}", std::str::from_utf8(&buf).unwrap_or("(Tree printer emitted non-utf8)"));
println!("{}", std::str::from_utf8(&buf).unwrap_or("(Tree printer emitted non-utf8)"));
}
}
}
@ -897,7 +897,7 @@ impl PrintableTree for SpatialTree {
#[cfg(test)]
fn add_reference_frame(
cst: &mut SpatialTree,
parent: Option<SpatialNodeIndex>,
parent: SpatialNodeIndex,
transform: LayoutTransform,
origin_in_parent_reference_frame: LayoutVector2D,
key: SpatialTreeItemKey,
@ -944,10 +944,11 @@ fn test_cst_simple_translation() {
// Basic translations only
let mut cst = SpatialTree::new();
let root_reference_frame_index = cst.root_reference_frame_index();
let root = add_reference_frame(
&mut cst,
None,
root_reference_frame_index,
LayoutTransform::identity(),
LayoutVector2D::zero(),
SpatialTreeItemKey::new(0, 0),
@ -955,7 +956,7 @@ fn test_cst_simple_translation() {
let child1 = add_reference_frame(
&mut cst,
Some(root),
root,
LayoutTransform::translation(100.0, 0.0, 0.0),
LayoutVector2D::zero(),
SpatialTreeItemKey::new(0, 1),
@ -963,7 +964,7 @@ fn test_cst_simple_translation() {
let child2 = add_reference_frame(
&mut cst,
Some(child1),
child1,
LayoutTransform::translation(0.0, 50.0, 0.0),
LayoutVector2D::zero(),
SpatialTreeItemKey::new(0, 2),
@ -971,7 +972,7 @@ fn test_cst_simple_translation() {
let child3 = add_reference_frame(
&mut cst,
Some(child2),
child2,
LayoutTransform::translation(200.0, 200.0, 0.0),
LayoutVector2D::zero(),
SpatialTreeItemKey::new(0, 3),
@ -990,10 +991,11 @@ fn test_cst_simple_scale() {
// Basic scale only
let mut cst = SpatialTree::new();
let root_reference_frame_index = cst.root_reference_frame_index();
let root = add_reference_frame(
&mut cst,
None,
root_reference_frame_index,
LayoutTransform::identity(),
LayoutVector2D::zero(),
SpatialTreeItemKey::new(0, 0),
@ -1001,7 +1003,7 @@ fn test_cst_simple_scale() {
let child1 = add_reference_frame(
&mut cst,
Some(root),
root,
LayoutTransform::scale(4.0, 1.0, 1.0),
LayoutVector2D::zero(),
SpatialTreeItemKey::new(0, 1),
@ -1009,7 +1011,7 @@ fn test_cst_simple_scale() {
let child2 = add_reference_frame(
&mut cst,
Some(child1),
child1,
LayoutTransform::scale(1.0, 2.0, 1.0),
LayoutVector2D::zero(),
SpatialTreeItemKey::new(0, 2),
@ -1017,7 +1019,7 @@ fn test_cst_simple_scale() {
let child3 = add_reference_frame(
&mut cst,
Some(child2),
child2,
LayoutTransform::scale(2.0, 2.0, 1.0),
LayoutVector2D::zero(),
SpatialTreeItemKey::new(0, 3),
@ -1037,10 +1039,11 @@ fn test_cst_scale_translation() {
// Scale + translation
let mut cst = SpatialTree::new();
let root_reference_frame_index = cst.root_reference_frame_index();
let root = add_reference_frame(
&mut cst,
None,
root_reference_frame_index,
LayoutTransform::identity(),
LayoutVector2D::zero(),
SpatialTreeItemKey::new(0, 0),
@ -1048,7 +1051,7 @@ fn test_cst_scale_translation() {
let child1 = add_reference_frame(
&mut cst,
Some(root),
root,
LayoutTransform::translation(100.0, 50.0, 0.0),
LayoutVector2D::zero(),
SpatialTreeItemKey::new(0, 1),
@ -1056,7 +1059,7 @@ fn test_cst_scale_translation() {
let child2 = add_reference_frame(
&mut cst,
Some(child1),
child1,
LayoutTransform::scale(2.0, 4.0, 1.0),
LayoutVector2D::zero(),
SpatialTreeItemKey::new(0, 2),
@ -1064,7 +1067,7 @@ fn test_cst_scale_translation() {
let child3 = add_reference_frame(
&mut cst,
Some(child2),
child2,
LayoutTransform::translation(200.0, -100.0, 0.0),
LayoutVector2D::zero(),
SpatialTreeItemKey::new(0, 3),
@ -1072,7 +1075,7 @@ fn test_cst_scale_translation() {
let child4 = add_reference_frame(
&mut cst,
Some(child3),
child3,
LayoutTransform::scale(3.0, 2.0, 1.0),
LayoutVector2D::zero(),
SpatialTreeItemKey::new(0, 4),
@ -1097,10 +1100,11 @@ fn test_cst_translation_rotate() {
use euclid::Angle;
let mut cst = SpatialTree::new();
let root_reference_frame_index = cst.root_reference_frame_index();
let root = add_reference_frame(
&mut cst,
None,
root_reference_frame_index,
LayoutTransform::identity(),
LayoutVector2D::zero(),
SpatialTreeItemKey::new(0, 0),
@ -1108,7 +1112,7 @@ fn test_cst_translation_rotate() {
let child1 = add_reference_frame(
&mut cst,
Some(root),
root,
LayoutTransform::rotation(0.0, 0.0, 1.0, Angle::degrees(-90.0)),
LayoutVector2D::zero(),
SpatialTreeItemKey::new(0, 1),
@ -1122,10 +1126,11 @@ fn test_cst_translation_rotate() {
#[test]
fn test_is_ancestor1() {
let mut st = SpatialTree::new();
let root_reference_frame_index = st.root_reference_frame_index();
let root = add_reference_frame(
&mut st,
None,
root_reference_frame_index,
LayoutTransform::identity(),
LayoutVector2D::zero(),
SpatialTreeItemKey::new(0, 0),
@ -1133,7 +1138,7 @@ fn test_is_ancestor1() {
let child1_0 = add_reference_frame(
&mut st,
Some(root),
root,
LayoutTransform::identity(),
LayoutVector2D::zero(),
SpatialTreeItemKey::new(0, 1),
@ -1141,7 +1146,7 @@ fn test_is_ancestor1() {
let child1_1 = add_reference_frame(
&mut st,
Some(child1_0),
child1_0,
LayoutTransform::identity(),
LayoutVector2D::zero(),
SpatialTreeItemKey::new(0, 2),
@ -1149,7 +1154,7 @@ fn test_is_ancestor1() {
let child2 = add_reference_frame(
&mut st,
Some(root),
root,
LayoutTransform::identity(),
LayoutVector2D::zero(),
SpatialTreeItemKey::new(0, 3),
@ -1185,12 +1190,12 @@ fn test_find_scroll_root_simple() {
let mut st = SpatialTree::new();
let root = st.add_reference_frame(
None,
st.root_reference_frame_index(),
TransformStyle::Flat,
PropertyBinding::Value(LayoutTransform::identity()),
ReferenceFrameKind::Transform {
is_2d_scale_translation: false,
should_snap: false,
is_2d_scale_translation: true,
should_snap: true,
},
LayoutVector2D::new(0.0, 0.0),
PipelineId::dummy(),
@ -1218,12 +1223,12 @@ fn test_find_scroll_root_sub_scroll_frame() {
let mut st = SpatialTree::new();
let root = st.add_reference_frame(
None,
st.root_reference_frame_index(),
TransformStyle::Flat,
PropertyBinding::Value(LayoutTransform::identity()),
ReferenceFrameKind::Transform {
is_2d_scale_translation: false,
should_snap: false,
is_2d_scale_translation: true,
should_snap: true,
},
LayoutVector2D::new(0.0, 0.0),
PipelineId::dummy(),
@ -1263,12 +1268,12 @@ fn test_find_scroll_root_not_scrollable() {
let mut st = SpatialTree::new();
let root = st.add_reference_frame(
None,
st.root_reference_frame_index(),
TransformStyle::Flat,
PropertyBinding::Value(LayoutTransform::identity()),
ReferenceFrameKind::Transform {
is_2d_scale_translation: false,
should_snap: false,
is_2d_scale_translation: true,
should_snap: true,
},
LayoutVector2D::new(0.0, 0.0),
PipelineId::dummy(),
@ -1308,12 +1313,12 @@ fn test_find_scroll_root_too_small() {
let mut st = SpatialTree::new();
let root = st.add_reference_frame(
None,
st.root_reference_frame_index(),
TransformStyle::Flat,
PropertyBinding::Value(LayoutTransform::identity()),
ReferenceFrameKind::Transform {
is_2d_scale_translation: false,
should_snap: false,
is_2d_scale_translation: true,
should_snap: true,
},
LayoutVector2D::new(0.0, 0.0),
PipelineId::dummy(),
@ -1354,12 +1359,12 @@ fn test_find_scroll_root_perspective() {
let mut st = SpatialTree::new();
let root = st.add_reference_frame(
None,
st.root_reference_frame_index(),
TransformStyle::Flat,
PropertyBinding::Value(LayoutTransform::identity()),
ReferenceFrameKind::Transform {
is_2d_scale_translation: false,
should_snap: false,
is_2d_scale_translation: true,
should_snap: true,
},
LayoutVector2D::new(0.0, 0.0),
PipelineId::dummy(),
@ -1379,7 +1384,7 @@ fn test_find_scroll_root_perspective() {
);
let perspective = st.add_reference_frame(
Some(root_scroll),
root_scroll,
TransformStyle::Flat,
PropertyBinding::Value(LayoutTransform::identity()),
ReferenceFrameKind::Perspective {
@ -1412,12 +1417,12 @@ fn test_find_scroll_root_2d_scale() {
let mut st = SpatialTree::new();
let root = st.add_reference_frame(
None,
st.root_reference_frame_index(),
TransformStyle::Flat,
PropertyBinding::Value(LayoutTransform::identity()),
ReferenceFrameKind::Transform {
is_2d_scale_translation: false,
should_snap: false,
is_2d_scale_translation: true,
should_snap: true,
},
LayoutVector2D::new(0.0, 0.0),
PipelineId::dummy(),
@ -1437,7 +1442,7 @@ fn test_find_scroll_root_2d_scale() {
);
let scale = st.add_reference_frame(
Some(root_scroll),
root_scroll,
TransformStyle::Flat,
PropertyBinding::Value(LayoutTransform::identity()),
ReferenceFrameKind::Transform {

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

@ -12,7 +12,7 @@ use crate::picture::{Picture3DContext, TileCacheParams, TileOffset};
use crate::prim_store::{PrimitiveInstance, PrimitiveStore, PictureIndex};
use crate::scene_building::SliceFlags;
use crate::scene_builder_thread::Interners;
use crate::spatial_tree::{ROOT_SPATIAL_NODE_INDEX, SpatialNodeIndex, SpatialTree};
use crate::spatial_tree::{SpatialNodeIndex, SpatialTree};
use crate::util::VecHelper;
/*
@ -53,6 +53,8 @@ pub struct TileCacheBuilder {
prim_clips_buffer: Vec<ClipInstance>,
/// Cache the last clip-chain that was added to the shared clips as it's often the same between prims.
last_checked_clip_chain: ClipChainId,
/// Handle to the root reference frame
root_spatial_node_index: SpatialNodeIndex,
}
/// The output of a tile cache builder, containing all details needed to construct the
@ -84,13 +86,14 @@ impl TileCacheConfig {
impl TileCacheBuilder {
/// Construct a new tile cache builder.
pub fn new() -> Self {
pub fn new(root_spatial_node_index: SpatialNodeIndex) -> Self {
TileCacheBuilder {
force_new_tile_cache: None,
pending_tile_caches: Vec::new(),
prev_scroll_root_cache: (ROOT_SPATIAL_NODE_INDEX, ROOT_SPATIAL_NODE_INDEX),
prev_scroll_root_cache: (SpatialNodeIndex::INVALID, SpatialNodeIndex::INVALID),
prim_clips_buffer: Vec::new(),
last_checked_clip_chain: ClipChainId::INVALID,
root_spatial_node_index,
}
}
@ -170,7 +173,7 @@ impl TileCacheBuilder {
.iter()
.max_by_key(|entry | entry.1)
.map(|(spatial_node_index, _)| *spatial_node_index)
.unwrap_or(ROOT_SPATIAL_NODE_INDEX);
.unwrap_or(self.root_spatial_node_index);
let mut first = true;
let prim_clips_buffer = &mut self.prim_clips_buffer;
@ -290,15 +293,15 @@ impl TileCacheBuilder {
if let Some(current_scroll_root) = current_scroll_root {
want_new_tile_cache |= match (current_scroll_root, scroll_root) {
(ROOT_SPATIAL_NODE_INDEX, ROOT_SPATIAL_NODE_INDEX) => {
(_, _) if current_scroll_root == self.root_spatial_node_index && scroll_root == self.root_spatial_node_index => {
// Both current slice and this cluster are fixed position, no need to cut
false
}
(ROOT_SPATIAL_NODE_INDEX, _) => {
(_, _) if current_scroll_root == self.root_spatial_node_index => {
// A real scroll root is being established, so create a cache slice
true
}
(_, ROOT_SPATIAL_NODE_INDEX) => {
(_, _) if scroll_root == self.root_spatial_node_index => {
// If quality settings force subpixel AA over performance, skip creating
// a slice for the fixed position element(s) here.
if quality_settings.force_subpixel_aa_where_possible {
@ -317,7 +320,7 @@ impl TileCacheBuilder {
while current_clip_chain_id != ClipChainId::NONE {
let clip_chain_node = &clip_store.clip_chain_nodes[current_clip_chain_id.0 as usize];
let spatial_root = self.find_scroll_root(clip_chain_node.spatial_node_index, spatial_tree);
if spatial_root != ROOT_SPATIAL_NODE_INDEX {
if spatial_root != self.root_spatial_node_index {
create_slice = false;
break;
}
@ -382,7 +385,7 @@ impl TileCacheBuilder {
let params = TileCacheParams {
slice,
slice_flags: SliceFlags::empty(),
spatial_node_index: ROOT_SPATIAL_NODE_INDEX,
spatial_node_index: self.root_spatial_node_index,
background_color: None,
shared_clips: Vec::new(),
shared_clip_chain: ClipChainId::NONE,

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

@ -14,7 +14,7 @@ use std::{usize, mem};
use crate::batch::BatchFilter;
use crate::clip::{ClipStore, ClipChainStack};
use crate::composite::CompositeState;
use crate::spatial_tree::{ROOT_SPATIAL_NODE_INDEX, SpatialTree, SpatialNodeIndex};
use crate::spatial_tree::{SpatialTree, SpatialNodeIndex};
use crate::clip::{ClipInstance, ClipChainInstance};
use crate::debug_colors;
use crate::frame_builder::FrameBuilderConfig;
@ -39,6 +39,7 @@ pub struct FrameVisibilityContext<'a> {
pub debug_flags: DebugFlags,
pub scene_properties: &'a SceneProperties,
pub config: FrameBuilderConfig,
pub root_spatial_node_index: SpatialNodeIndex,
}
pub struct FrameVisibilityState<'a> {
@ -238,7 +239,7 @@ pub fn update_primitive_visibility(
.clone();
let map_surface_to_world = SpaceMapper::new_with_target(
ROOT_SPATIAL_NODE_INDEX,
frame_context.root_spatial_node_index,
surface.surface_spatial_node_index,
frame_context.global_screen_world_rect,
frame_context.spatial_tree,
@ -674,9 +675,11 @@ pub fn compute_conservative_visible_rect(
prim_spatial_node_index: SpatialNodeIndex,
spatial_tree: &SpatialTree,
) -> LayoutRect {
let root_spatial_node_index = spatial_tree.root_reference_frame_index();
// Mapping from picture space -> world space
let map_pic_to_world: SpaceMapper<PicturePixel, WorldPixel> = SpaceMapper::new_with_target(
ROOT_SPATIAL_NODE_INDEX,
root_spatial_node_index,
clip_chain.pic_spatial_node_index,
world_culling_rect,
spatial_tree,