XRRigidTransform.h (2437B)
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/. */ 6 7 #ifndef mozilla_dom_XRRigidTransform_h_ 8 #define mozilla_dom_XRRigidTransform_h_ 9 10 #include "gfxVR.h" 11 #include "mozilla/DOMEventTargetHelper.h" 12 #include "mozilla/dom/WebXRBinding.h" 13 14 namespace mozilla::dom { 15 16 class VRFrameData; 17 18 class XRRigidTransform final : public nsWrapperCache { 19 public: 20 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(XRRigidTransform) 21 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(XRRigidTransform) 22 23 explicit XRRigidTransform(nsISupports* aParent, 24 const gfx::PointDouble3D& aPosition, 25 const gfx::QuaternionDouble& aOrientation); 26 explicit XRRigidTransform(nsISupports* aParent, 27 const gfx::Matrix4x4Double& aTransform); 28 static already_AddRefed<XRRigidTransform> Constructor( 29 const GlobalObject& aGlobal, const DOMPointInit& aOrigin, 30 const DOMPointInit& aDirection, ErrorResult& aRv); 31 XRRigidTransform& operator=(const XRRigidTransform& aOther); 32 gfx::QuaternionDouble RawOrientation() const; 33 gfx::PointDouble3D RawPosition() const; 34 void Update(const gfx::PointDouble3D& aPosition, 35 const gfx::QuaternionDouble& aOrientation); 36 void Update(const gfx::Matrix4x4Double& aTransform); 37 // WebIDL Boilerplate 38 nsISupports* GetParentObject() const { return mParent; } 39 JSObject* WrapObject(JSContext* aCx, 40 JS::Handle<JSObject*> aGivenProto) override; 41 42 // WebIDL Members 43 DOMPoint* Position(); 44 DOMPoint* Orientation(); 45 void GetMatrix(JSContext* aCx, JS::MutableHandle<JSObject*> aRetval, 46 ErrorResult& aRv); 47 already_AddRefed<XRRigidTransform> Inverse(); 48 49 protected: 50 void UpdateInternal(); 51 virtual ~XRRigidTransform(); 52 53 nsCOMPtr<nsISupports> mParent; 54 JS::Heap<JSObject*> mMatrixArray; 55 RefPtr<DOMPoint> mPosition; 56 RefPtr<DOMPoint> mOrientation; 57 RefPtr<XRRigidTransform> mInverse; 58 gfx::Matrix4x4Double mRawTransformMatrix; 59 gfx::PointDouble3D mRawPosition; 60 gfx::QuaternionDouble mRawOrientation; 61 bool mNeedsUpdate; 62 }; 63 64 } // namespace mozilla::dom 65 66 #endif // mozilla_dom_XRRigidTransform_h_