Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: fbd06f9be9076f8c623add8448271c98ef6076ec
https://github.com/WebKit/WebKit/commit/fbd06f9be9076f8c623add8448271c98ef6076ec
Author: Sergio Villar Senin <[email protected]>
Date: 2026-06-02 (Tue, 02 Jun 2026)
Changed paths:
M Source/WebCore/Headers.cmake
M Source/WebCore/Modules/webxr/XRCompositionLayer.cpp
M Source/WebCore/Modules/webxr/XRCompositionLayer.h
A Source/WebCore/Modules/webxr/XRCompositionLayerPose.h
M Source/WebCore/Modules/webxr/XRCylinderLayer.cpp
M Source/WebCore/Modules/webxr/XRCylinderLayer.h
M Source/WebCore/Modules/webxr/XREquirectLayer.cpp
M Source/WebCore/Modules/webxr/XREquirectLayer.h
M Source/WebCore/Modules/webxr/XRProjectionLayer.cpp
M Source/WebCore/Modules/webxr/XRProjectionLayer.h
M Source/WebCore/Modules/webxr/XRQuadLayer.cpp
M Source/WebCore/Modules/webxr/XRQuadLayer.h
M Source/WebCore/WebCore.xcodeproj/project.pbxproj
M Tools/TestWebKitAPI/CMakeLists.txt
M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
A Tools/TestWebKitAPI/Tests/WebCore/XRCompositionLayer.cpp
Log Message:
-----------
[WebXR Layers] Refactor startFrame/endFrame/recomputePose in composition
layers
https://bugs.webkit.org/show_bug.cgi?id=315511
Reviewed by Dan Glastonbury.
XRQuadLayer, XRCylinderLayer and XREquirectLayer were carrying three
near identical copies of:
* m_space / m_transform / m_poseInLocalSpace members and accessors
* startFrame()/endFrame()/recomputePose() implementations
This was already a maintenance hazard (the recent b9704aae@main for the
recomputePose() sign error had to be triplicated) and would have kept
diverging as new shared behavior was added.
Move all of the above to XRCompositionLayer. The members mentioned above
became base members and the accessors were moved there too.
* startFrame() and endFrame() are concrete on the base (still
declared override, not final, because XRProjectionLayer has its
own implementation).
* endFrame() calls a new virtual method after computing the common
DeviceLayer fields and recomputing the pose. Quad/Cylinder/Equirect
override this hook to assign their respective LayerData field on
the DeviceLayer. The base method has an empty default so
XRProjectionLayer does not have to provide a stub.
Each subclass now keeps only its own type-specific properties (size
for Quad, radius/centralAngle/aspectRatio for Cylinder, etc.) and the
override for the new method. Apart from that XRProjectionLayer's private
m_transform was renamed to m_deltaPose to match its meaning and avoid
shadowing XRCompositionLayer::m_transform.
No behavior change and we save ~150 lines of code.
Added a new unit test that would detect regressions in the code fixed by
the aforementioned b9704aae@main. This unit test requires a new class
in order not to export way too many headers just for testing purposes.
Tests: Tools/TestWebKitAPI/CMakeLists.txt
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebCore/XRCompositionLayer.cpp
* Source/WebCore/Headers.cmake:
* Source/WebCore/Modules/webxr/XRCompositionLayer.cpp:
(WebCore::XRCompositionLayer::XRCompositionLayer):
(WebCore::XRCompositionLayer::space const):
(WebCore::XRCompositionLayer::setSpace):
(WebCore::XRCompositionLayer::transform const):
(WebCore::XRCompositionLayer::setTransform):
(WebCore::XRCompositionLayer::startFrame):
(WebCore::computeXRCompositionLayerPose):
(WebCore::XRCompositionLayer::recomputePose):
(WebCore::XRCompositionLayer::endFrame):
* Source/WebCore/Modules/webxr/XRCompositionLayer.h:
(WebCore::XRCompositionLayer::fillInTypeSpecificDeviceLayerData const):
(WebCore::XRCompositionLayer::poseInLocalSpace const):
* Source/WebCore/Modules/webxr/XRCompositionLayerPose.h: Added.
* Source/WebCore/Modules/webxr/XRCylinderLayer.cpp:
(WebCore::XRCylinderLayer::XRCylinderLayer):
(WebCore::XRCylinderLayer::fillInTypeSpecificDeviceLayerData const):
(WebCore::XRCylinderLayer::space const): Deleted.
(WebCore::XRCylinderLayer::setSpace): Deleted.
(WebCore::XRCylinderLayer::transform const): Deleted.
(WebCore::XRCylinderLayer::setTransform): Deleted.
(WebCore::XRCylinderLayer::startFrame): Deleted.
(WebCore::XRCylinderLayer::recomputePose): Deleted.
(WebCore::XRCylinderLayer::endFrame): Deleted.
* Source/WebCore/Modules/webxr/XRCylinderLayer.h:
* Source/WebCore/Modules/webxr/XREquirectLayer.cpp:
(WebCore::XREquirectLayer::XREquirectLayer):
(WebCore::XREquirectLayer::fillInTypeSpecificDeviceLayerData const):
(WebCore::XREquirectLayer::space const): Deleted.
(WebCore::XREquirectLayer::setSpace): Deleted.
(WebCore::XREquirectLayer::transform const): Deleted.
(WebCore::XREquirectLayer::setTransform): Deleted.
(WebCore::XREquirectLayer::startFrame): Deleted.
(WebCore::XREquirectLayer::recomputePose): Deleted.
(WebCore::XREquirectLayer::endFrame): Deleted.
* Source/WebCore/Modules/webxr/XREquirectLayer.h:
* Source/WebCore/Modules/webxr/XRProjectionLayer.cpp:
(WebCore::XRProjectionLayer::deltaPose const):
(WebCore::XRProjectionLayer::setDeltaPose):
* Source/WebCore/Modules/webxr/XRProjectionLayer.h:
* Source/WebCore/Modules/webxr/XRQuadLayer.cpp:
(WebCore::XRQuadLayer::XRQuadLayer):
(WebCore::XRQuadLayer::fillInTypeSpecificDeviceLayerData const):
(WebCore::XRQuadLayer::space const): Deleted.
(WebCore::XRQuadLayer::setSpace): Deleted.
(WebCore::XRQuadLayer::transform const): Deleted.
(WebCore::XRQuadLayer::setTransform): Deleted.
(WebCore::XRQuadLayer::startFrame): Deleted.
(WebCore::XRQuadLayer::recomputePose): Deleted.
(WebCore::XRQuadLayer::endFrame): Deleted.
* Source/WebCore/Modules/webxr/XRQuadLayer.h:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/CMakeLists.txt:
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WebCore/XRCompositionLayer.cpp: Added.
(TestWebKitAPI::TEST(XRCompositionLayer,
LocalFloorSpaceTranslatesLayerToFloor)):
(TestWebKitAPI::TEST(XRCompositionLayer,
ComposesSpaceAndLayerTranslationsInTheRightOrder)):
Canonical link: https://commits.webkit.org/314348@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications