mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-04 15:51:37 +00:00
Bug 1642629 - Recycle FrameVisibilityState's clip_chain_stack and surface_stack. r=kvark
Differential Revision: https://phabricator.services.mozilla.com/D80193
This commit is contained in:
parent
6bbff60830
commit
470f80670a
@ -108,7 +108,7 @@ use crate::prim_store::{ClipData, ImageMaskData, SpaceMapper, VisibleMaskImageTi
|
||||
use crate::prim_store::{PointKey, SizeKey, RectangleKey};
|
||||
use crate::render_task_cache::to_cache_size;
|
||||
use crate::resource_cache::{ImageRequest, ResourceCache};
|
||||
use crate::util::{clamp_to_scale_factor, extract_inner_rect_safe, project_rect, ScaleOffset};
|
||||
use crate::util::{clamp_to_scale_factor, extract_inner_rect_safe, project_rect, ScaleOffset, VecHelper};
|
||||
use euclid::approxeq::ApproxEq;
|
||||
use std::{iter, ops, u32};
|
||||
use smallvec::SmallVec;
|
||||
@ -836,6 +836,25 @@ impl ClipChainStack {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn clear(&mut self) {
|
||||
self.clips.clear();
|
||||
self.clip_counts.clear();
|
||||
self.levels.clear();
|
||||
self.levels.push(ClipChainLevel {
|
||||
shared_clips: Vec::new(),
|
||||
first_clip_index: 0,
|
||||
initial_clip_counts_len: 0,
|
||||
});
|
||||
}
|
||||
|
||||
pub fn take(&mut self) -> Self {
|
||||
ClipChainStack {
|
||||
levels: self.levels.take(),
|
||||
clips: self.clips.take(),
|
||||
clip_counts: self.clip_counts.take(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Push a clip chain root onto the currently active list.
|
||||
pub fn push_clip(
|
||||
&mut self,
|
||||
|
@ -120,6 +120,8 @@ impl FrameGlobalResources {
|
||||
pub struct FrameScratchBuffer {
|
||||
surfaces: Vec<SurfaceInfo>,
|
||||
dirty_region_stack: Vec<DirtyRegion>,
|
||||
surface_stack: Vec<SurfaceIndex>,
|
||||
clip_chain_stack: ClipChainStack,
|
||||
}
|
||||
|
||||
impl Default for FrameScratchBuffer {
|
||||
@ -127,6 +129,8 @@ impl Default for FrameScratchBuffer {
|
||||
FrameScratchBuffer {
|
||||
surfaces: Vec::new(),
|
||||
dirty_region_stack: Vec::new(),
|
||||
surface_stack: Vec::new(),
|
||||
clip_chain_stack: ClipChainStack::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -135,6 +139,8 @@ impl FrameScratchBuffer {
|
||||
pub fn begin_frame(&mut self) {
|
||||
self.surfaces.clear();
|
||||
self.dirty_region_stack.clear();
|
||||
self.surface_stack.clear();
|
||||
self.clip_chain_stack.clear();
|
||||
}
|
||||
|
||||
pub fn recycle(&mut self, recycler: &mut Recycler) {
|
||||
@ -359,6 +365,8 @@ impl FrameBuilder {
|
||||
};
|
||||
|
||||
let mut visibility_state = FrameVisibilityState {
|
||||
clip_chain_stack: scratch.frame.clip_chain_stack.take(),
|
||||
surface_stack: scratch.frame.surface_stack.take(),
|
||||
resource_cache,
|
||||
gpu_cache,
|
||||
clip_store: &mut scene.clip_store,
|
||||
@ -366,12 +374,8 @@ impl FrameBuilder {
|
||||
tile_cache: None,
|
||||
retained_tiles: &mut retained_tiles,
|
||||
data_stores,
|
||||
clip_chain_stack: ClipChainStack::new(),
|
||||
render_tasks,
|
||||
composite_state,
|
||||
/// Try to avoid allocating during frame traversal - it's unlikely to have a
|
||||
/// surface stack depth of > 16 in most cases.
|
||||
surface_stack: Vec::with_capacity(16),
|
||||
};
|
||||
|
||||
update_primitive_visibility(
|
||||
@ -409,6 +413,9 @@ impl FrameBuilder {
|
||||
visibility_state.resource_cache.destroy_compositor_surface(external_surface.native_surface_id)
|
||||
}
|
||||
}
|
||||
|
||||
visibility_state.scratch.frame.clip_chain_stack = visibility_state.clip_chain_stack.take();
|
||||
visibility_state.scratch.frame.surface_stack = visibility_state.surface_stack.take();
|
||||
}
|
||||
|
||||
let mut frame_state = FrameBuildingState {
|
||||
|
Loading…
x
Reference in New Issue
Block a user