-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rdar://124986396 https://bugs.webkit.org/show_bug.cgi?id=271208 Reviewed by Alex Christensen. Exposes the root entity transform matrix to JS side, so that developers can move the 3D object around within the <model> tag portal. HTMLModelTag has an m_entityTransform "truth" that's used to serve JS getter synchronously. ModelPlayer now has the ability to determine whether a certain transform matrix is supported. If not, HTMLModelElement::setEntityTransform will raise an Unsupported Exception. Upon model load, Model Process will send an IPC message to Web Process to update the m_entityTransform state of the HTMLModelElement to make it aware of the default applied transform. * Source/WebCore/Modules/model-element/HTMLModelElement.cpp: (WebCore::HTMLModelElement::modelPlayer const): (WebCore::HTMLModelElement::entityTransform const): * Source/WebCore/Modules/model-element/HTMLModelElement.h: * Source/WebCore/Modules/model-element/HTMLModelElement.idl: * Source/WebCore/Modules/model-element/ModelPlayer.cpp: (WebCore::ModelPlayer::entityTransform): (WebCore::ModelPlayer::setEntityTransform): (WebCore::ModelPlayer::supportsTransform): * Source/WebCore/Modules/model-element/ModelPlayer.h: * Source/WebCore/SourcesCocoa.txt: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebCore/platform/graphics/cocoa/TransformationMatrixCocoa.cpp: (WebCore::TransformationMatrix::TransformationMatrix): (WebCore::TransformationMatrix::operator simd_float4x4 const): Added convenience converter methods to/from simd_float4x4, which is the commonly used transform matrix data type on visionOS. Applicable only on Cocoa platforms. * Source/WebCore/platform/graphics/transforms/TransformationMatrix.h: * Source/WebKit/ModelProcess/cocoa/ModelProcessModelPlayerProxy.h: * Source/WebKit/ModelProcess/cocoa/ModelProcessModelPlayerProxy.messages.in: * Source/WebKit/ModelProcess/cocoa/ModelProcessModelPlayerProxy.mm: (WebKit::ModelProcessModelPlayerProxy::transformSupported): Require the transform to be a non-shear, uniform-scaling matrix, for now. (WebKit::ModelProcessModelPlayerProxy::computeTransform): (WebKit::ModelProcessModelPlayerProxy::updateTransform): (WebKit::ModelProcessModelPlayerProxy::didFinishLoading): (WebKit::ModelProcessModelPlayerProxy::entityTransform): (WebKit::ModelProcessModelPlayerProxy::setEntityTransform): * Source/WebKit/WebProcess/Model/ModelProcessModelPlayer.cpp: (WebKit::ModelProcessModelPlayer::didUpdateEntityTransform): (WebKit::ModelProcessModelPlayer::entityTransform): (WebKit::ModelProcessModelPlayer::setEntityTransform): (WebKit::ModelProcessModelPlayer::supportsTransform): * Source/WebKit/WebProcess/Model/ModelProcessModelPlayer.h: * Source/WebKit/WebProcess/Model/ModelProcessModelPlayer.messages.in: Canonical link: https://commits.webkit.org/276661@main
- Loading branch information
Showing
16 changed files
with
220 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
Source/WebCore/platform/graphics/cocoa/TransformationMatrixCocoa.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright (C) 2024 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | ||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | ||
* THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#include "config.h" | ||
#include "TransformationMatrix.h" | ||
|
||
#if PLATFORM(COCOA) | ||
|
||
#include <simd/simd.h> | ||
|
||
namespace WebCore { | ||
|
||
TransformationMatrix::TransformationMatrix(const simd_float4x4& t) | ||
: TransformationMatrix(t.columns[0][0], t.columns[0][1], t.columns[0][2], t.columns[0][3], | ||
t.columns[1][0], t.columns[1][1], t.columns[1][2], t.columns[1][3], | ||
t.columns[2][0], t.columns[2][1], t.columns[2][2], t.columns[2][3], | ||
t.columns[3][0], t.columns[3][1], t.columns[3][2], t.columns[3][3]) | ||
{ | ||
} | ||
|
||
TransformationMatrix::operator simd_float4x4() const | ||
{ | ||
return simd_float4x4 { | ||
simd_float4 { (float)m11(), (float)m12(), (float)m13(), (float)m14() }, | ||
simd_float4 { (float)m21(), (float)m22(), (float)m23(), (float)m24() }, | ||
simd_float4 { (float)m31(), (float)m32(), (float)m33(), (float)m34() }, | ||
simd_float4 { (float)m41(), (float)m42(), (float)m43(), (float)m44() } | ||
}; | ||
} | ||
|
||
} | ||
|
||
#endif // PLATFORM(COCOA) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.