commit 6131977899274b17f4819e5d96ea24d65701d8f2
parent a9e6d6b9424af46c186d168bc3b414da8dd2240e
Author: Nicolas Silva <nical@fastmail.com>
Date: Mon, 15 Dec 2025 10:53:21 +0000
Bug 1998913 - Part 9 - Inline CompositeState::destroy_native_tiles into TileCacheInstance::pre_update. r=gfx-reviewers,jnicol
The function is small enough that it doesn't get us much, it has a single caller and it was in a lonesome impl block far from its type and its use.
Differential Revision: https://phabricator.services.mozilla.com/D276204
Diffstat:
2 files changed, 14 insertions(+), 32 deletions(-)
diff --git a/gfx/wr/webrender/src/picture.rs b/gfx/wr/webrender/src/picture.rs
@@ -102,7 +102,7 @@ use crate::renderer::GpuBufferBuilderF;
use crate::box_shadow::BLUR_SAMPLE_SCALE;
use crate::clip::{ClipNodeId, ClipTreeBuilder};
use crate::spatial_tree::{SpatialTree, CoordinateSpaceMapping, SpatialNodeIndex, VisibleFace};
-use crate::composite::{tile_kind, CompositeState, CompositeTileSurface, CompositorKind, NativeTileId};
+use crate::composite::{tile_kind, CompositeTileSurface, CompositorKind, NativeTileId};
use crate::composite::{CompositeTileDescriptor, CompositeTile};
use crate::debug_colors;
use euclid::{vec3, Scale, Vector2D, Box2D};
@@ -134,7 +134,7 @@ use crate::picture_textures::PictureCacheTextureHandle;
use crate::util::{MaxRect, Recycler, ScaleOffset};
use crate::tile_cache::{SliceDebugInfo, TileDebugInfo, DirtyTileDebugInfo};
use crate::tile_cache::{SliceId, TileCacheInstance, TileSurface, NativeSurface};
-use crate::tile_cache::{BackdropKind, BackdropSurface, Tile};
+use crate::tile_cache::{BackdropKind, BackdropSurface};
use crate::tile_cache::{TileKey, SubSliceIndex};
use crate::invalidation::InvalidationReason;
use crate::tile_cache::MAX_SURFACE_SIZE;
@@ -1627,32 +1627,6 @@ impl PicturePrimitive {
}
}
-impl CompositeState {
- // A helper function to destroy all native surfaces for a given list of tiles
- pub fn destroy_native_tiles<'a, I: Iterator<Item = &'a mut Box<Tile>>>(
- &mut self,
- tiles_iter: I,
- resource_cache: &mut ResourceCache,
- ) {
- // Any old tiles that remain after the loop above are going to be dropped. For
- // simple composite mode, the texture cache handle will expire and be collected
- // by the texture cache. For native compositor mode, we need to explicitly
- // invoke a callback to the client to destroy that surface.
- if let CompositorKind::Native { .. } = self.compositor_kind {
- for tile in tiles_iter {
- // Only destroy native surfaces that have been allocated. It's
- // possible for display port tiles to be created that never
- // come on screen, and thus never get a native surface allocated.
- if let Some(TileSurface::Texture { descriptor: SurfaceTextureDescriptor::Native { ref mut id, .. }, .. }) = tile.surface {
- if let Some(id) = id.take() {
- resource_cache.destroy_compositor_tile(id);
- }
- }
- }
- }
- }
-}
-
pub fn get_relative_scale_offset(
child_spatial_node_index: SpatialNodeIndex,
parent_spatial_node_index: SpatialNodeIndex,
diff --git a/gfx/wr/webrender/src/tile_cache/mod.rs b/gfx/wr/webrender/src/tile_cache/mod.rs
@@ -1741,10 +1741,18 @@ impl TileCacheInstance {
// simple composite mode, the texture cache handle will expire and be collected
// by the texture cache. For native compositor mode, we need to explicitly
// invoke a callback to the client to destroy that surface.
- frame_state.composite_state.destroy_native_tiles(
- old_tiles.values_mut(),
- frame_state.resource_cache,
- );
+ if let CompositorKind::Native { .. } = frame_state.composite_state.compositor_kind {
+ for tile in old_tiles.values_mut() {
+ // Only destroy native surfaces that have been allocated. It's
+ // possible for display port tiles to be created that never
+ // come on screen, and thus never get a native surface allocated.
+ if let Some(TileSurface::Texture { descriptor: SurfaceTextureDescriptor::Native { ref mut id, .. }, .. }) = tile.surface {
+ if let Some(id) = id.take() {
+ frame_state.resource_cache.destroy_compositor_tile(id);
+ }
+ }
+ }
+ }
}
}