Bug 1852740: add tests for the `fetchpriority` attribute in Link headers. r=necko...
[gecko.git] / dom / vr / XRReferenceSpace.cpp
blob9ed73003cd7a01a8aa9ebe50e41dc368430cdde9
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "mozilla/dom/XRReferenceSpace.h"
8 #include "mozilla/dom/XRRigidTransform.h"
9 #include "VRDisplayClient.h"
11 namespace mozilla::dom {
13 XRReferenceSpace::XRReferenceSpace(nsIGlobalObject* aParent,
14 XRSession* aSession,
15 XRNativeOrigin* aNativeOrigin,
16 XRReferenceSpaceType aType)
17 : XRSpace(aParent, aSession, aNativeOrigin), mType(aType) {}
19 already_AddRefed<XRReferenceSpace> XRReferenceSpace::GetOffsetReferenceSpace(
20 const XRRigidTransform& aOriginOffset) {
21 RefPtr<XRReferenceSpace> offsetReferenceSpace =
22 new XRReferenceSpace(GetParentObject(), mSession, mNativeOrigin, mType);
24 // https://immersive-web.github.io/webxr/#multiply-transforms
25 // An XRRigidTransform is essentially a rotation followed by a translation
26 gfx::QuaternionDouble otherOrientation = aOriginOffset.RawOrientation();
27 // The resulting rotation is the two combined
28 offsetReferenceSpace->mOriginOffsetOrientation =
29 mOriginOffsetOrientation * otherOrientation;
30 // We first apply the rotation of aOriginOffset to
31 // mOriginOffsetPosition offset, then translate by the offset of
32 // aOriginOffset
33 offsetReferenceSpace->mOriginOffsetPosition =
34 otherOrientation.RotatePoint(mOriginOffsetPosition) +
35 aOriginOffset.RawPosition();
37 return offsetReferenceSpace.forget();
40 JSObject* XRReferenceSpace::WrapObject(JSContext* aCx,
41 JS::Handle<JSObject*> aGivenProto) {
42 return XRReferenceSpace_Binding::Wrap(aCx, this, aGivenProto);
45 } // namespace mozilla::dom