Fix Servo IOSurface orientation and resize identity

This commit is contained in:
2026-05-13 10:21:50 -04:00
parent 9212b0be24
commit f4c650c4d8
6 changed files with 277 additions and 55 deletions
+12 -5
View File
@@ -16,10 +16,11 @@
/// a Metal texture without copying pixels.
///
/// `surface_id` is the stable surfman `SurfaceID` (a pointer-shaped
/// `usize` widened to `u64` for the wire). It lets the receiver dedup:
/// when two consecutive frames carry the same `surface_id` the
/// imported `MTLTexture` is reused without re-importing. `width` and
/// `height` are reported in surface pixels (post-DPR).
/// `usize` widened to `u64` for the wire). Together with `width` and
/// `height` it lets the receiver dedup imported IOSurfaces. The pixel
/// dimensions are part of the identity because a resize can reuse the
/// same surfman id for a newly-sized IOSurface. `width` and `height`
/// are reported in surface pixels (post-DPR).
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "servo-engine", derive(serde::Serialize, serde::Deserialize))]
pub struct IOSurfaceHandle {
@@ -33,9 +34,15 @@ pub struct IOSurfaceHandle {
/// "same surface as last frame" from "resize/swap rotated to a new
/// surface" without minting a fresh mach port (mach ports are a scarce
/// kernel resource and `IOSurfaceCreateMachPort` is not cheap).
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct IOSurfaceIdentity {
pub surface_id: u64,
pub width: u32,
pub height: u32,
}
impl IOSurfaceIdentity {
pub fn from_handle(handle: IOSurfaceHandle) -> Self {
Self { surface_id: handle.surface_id, width: handle.width, height: handle.height }
}
}