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 #ifndef mozilla_dom_XRView_h_
8 #define mozilla_dom_XRView_h_
10 #include "mozilla/DOMEventTargetHelper.h"
11 #include "mozilla/dom/WebXRBinding.h"
15 namespace mozilla::dom
{
17 enum class XREye
: uint8_t;
18 class XRRigidTransform
;
20 class XRView final
: public nsWrapperCache
{
22 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(XRView
)
23 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(XRView
)
25 explicit XRView(nsISupports
* aParent
, const XREye
& aEye
);
27 void Update(const gfx::PointDouble3D
& aPosition
,
28 const gfx::QuaternionDouble
& aOrientation
,
29 const gfx::Matrix4x4
& aProjectionMatrix
);
31 nsISupports
* GetParentObject() const { return mParent
; }
32 JSObject
* WrapObject(JSContext
* aCx
,
33 JS::Handle
<JSObject
*> aGivenProto
) override
;
37 void GetProjectionMatrix(JSContext
* aCx
, JS::MutableHandle
<JSObject
*> aRetval
,
39 already_AddRefed
<XRRigidTransform
> GetTransform(ErrorResult
& aRv
);
44 nsCOMPtr
<nsISupports
> mParent
;
46 gfx::PointDouble3D mPosition
;
47 gfx::QuaternionDouble mOrientation
;
48 gfx::Matrix4x4 mProjectionMatrix
;
49 JS::Heap
<JSObject
*> mJSProjectionMatrix
;
50 bool mProjectionNeedsUpdate
= true;
51 RefPtr
<XRRigidTransform
> mTransform
;
54 } // namespace mozilla::dom
56 #endif // mozilla_dom_XRView_h_