gfx::CALayerParams: Make move-only, add fence mach port
Major
提交哈希:
750af5da1538bb36053450ad16a4fee71d9b6527
提交时间: 2026-04-28 21:15:09
影响等级: Major
生成工具: chromium-watcher
上游审核链接:
查看上游审核 🔗
📋 摘要
This commit makes major refactoring changes to gfx::CALayerParams:
1. Makes CALayerParams and gpu::SwapBuffersCompleteParams move-only by deleting copy constructors and copy assignment operators.
2. Adds a ca_context_fence_mach_port field to CALayerParams, which can stall WindowServer updates to an individual CAContext while kept alive — needed for synchronizing NSWindow resizes with viz-side CALayer changes when using remote CoreAnimation.
3. Replaces the is_empty boolean field with an IsEmpty() method.
4. Changes the entire rendering chain's interface signatures: CALayerFrameSink::UpdateCALayerTree, AcceleratedWidgetMacNSView::AcceleratedWidgetCALayerParamsUpdated, NativeWidgetNSWindowBridge::SetCALayerParams, etc. all change from const reference to pass-by-value (to support move semantics).
5. Refactors Mojo serialization: replaces ca_context_id in the mojom CALayerContent union with a new CAContext struct (containing id and fence_mach_port), and makes content nullable.
6. Removes legacy IPC support for CALayerParams from gfx_param_traits_macros.h and gpu_param_traits_macros.h.
1. Makes CALayerParams and gpu::SwapBuffersCompleteParams move-only by deleting copy constructors and copy assignment operators.
2. Adds a ca_context_fence_mach_port field to CALayerParams, which can stall WindowServer updates to an individual CAContext while kept alive — needed for synchronizing NSWindow resizes with viz-side CALayer changes when using remote CoreAnimation.
3. Replaces the is_empty boolean field with an IsEmpty() method.
4. Changes the entire rendering chain's interface signatures: CALayerFrameSink::UpdateCALayerTree, AcceleratedWidgetMacNSView::AcceleratedWidgetCALayerParamsUpdated, NativeWidgetNSWindowBridge::SetCALayerParams, etc. all change from const reference to pass-by-value (to support move semantics).
5. Refactors Mojo serialization: replaces ca_context_id in the mojom CALayerContent union with a new CAContext struct (containing id and fence_mach_port), and makes content nullable.
6. Removes legacy IPC support for CALayerParams from gfx_param_traits_macros.h and gpu_param_traits_macros.h.
🎯 影响分析
This commit has a direct compile-breaking impact on WebView2Mac that must be fixed when merging upstream:
**Compile Break (must fix):**
-
- Fix: Change the parameter type in
**Rendering Chain Impact:**
- The WebView2Mac rendering path
- AcceleratedWidgetCALayerParamsUpdated() interface changed: from a no-argument notification callback to directly passing the CALayerParams. NativeWidgetMacNSWindowHost no longer indirectly fetches params from the compositor widget.
**Mojo Serialization Impact:**
- The Mojo structure for CALayerParams changed (new CAContext struct, nullable content). This affects serialization/deserialization of CALayerParams across mojo channels. Since WebView2Mac transmits SetCALayerParams over per-window mojo channels, the Mojo layer changes will apply automatically, but any custom serialization code would need updating.
**New Fence Port Functionality:**
- The new ca_context_fence_mach_port is designed to synchronize CAContext updates during NSWindow resizes. WebView2Mac uses the host's NSView rather than its own window, so resize behavior is host-controlled. This feature may positively impact WebView2Mac resize synchronization, but verification is needed to ensure the fence port is properly released in the embedded scenario to avoid accidental rendering freezes.
**Compile Break (must fix):**
-
HostingNSWindowBridge::SetCALayerParams(const gfx::CALayerParams& ca_layer_params) overrides the base class NativeWidgetNSWindowBridge::SetCALayerParams, but the base class signature changed from const gfx::CALayerParams& to gfx::CALayerParams (pass-by-value). This will cause a compile error because the override signature no longer matches.- Fix: Change the parameter type in
hosting_ns_window_bridge.h:99 and hosting_ns_window_bridge.mm:392-393 from const gfx::CALayerParams& to gfx::CALayerParams, and use std::move(ca_layer_params) when calling the base class method.**Rendering Chain Impact:**
- The WebView2Mac rendering path
GPU → HostDisplayClient → AcceleratedWidgetMac → NativeWidgetMacNSWindowHost → HostingNSWindowBridge::SetCALayerParams → DisplayCALayerTree has been fully converted to move semantics. CALayerParams is no longer copyable; all transfers must use std::move.- AcceleratedWidgetCALayerParamsUpdated() interface changed: from a no-argument notification callback to directly passing the CALayerParams. NativeWidgetMacNSWindowHost no longer indirectly fetches params from the compositor widget.
**Mojo Serialization Impact:**
- The Mojo structure for CALayerParams changed (new CAContext struct, nullable content). This affects serialization/deserialization of CALayerParams across mojo channels. Since WebView2Mac transmits SetCALayerParams over per-window mojo channels, the Mojo layer changes will apply automatically, but any custom serialization code would need updating.
**New Fence Port Functionality:**
- The new ca_context_fence_mach_port is designed to synchronize CAContext updates during NSWindow resizes. WebView2Mac uses the host's NSView rather than its own window, so resize behavior is host-controlled. This feature may positively impact WebView2Mac resize synchronization, but verification is needed to ensure the fence port is properly released in the embedded scenario to avoid accidental rendering freezes.
受影响的类:
HostingNSWindowBridge (compile break: SetCALayerParams signature mismatch)
NativeWidgetNSWindowBridge (base class signature changed)
NativeWidgetMacNSWindowHost (AcceleratedWidgetCALayerParamsUpdated signature changed)
AcceleratedWidgetMacNSView (virtual interface changed)
CALayerFrameSink (UpdateCALayerTree signature changed)
gfx::CALayerParams (move-only, new fence port, is_empty removed)
gpu::SwapBuffersCompleteParams (move-only)
DisplayCALayerTree (UpdateCALayerTree signature changed)
HostDisplayClient (OnDisplayReceivedCALayerParams signature changed)