Merge mozilla-central to autoland on a CLOSED TREE
[gecko.git] / dom / vr / XRView.h
blob157e489022653e4cf0ed17308d1129ff17c955d6
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"
13 #include "gfxVR.h"
15 namespace mozilla::dom {
17 enum class XREye : uint8_t;
18 class XRRigidTransform;
20 class XRView final : public nsWrapperCache {
21 public:
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);
30 // WebIDL Boilerplate
31 nsISupports* GetParentObject() const { return mParent; }
32 JSObject* WrapObject(JSContext* aCx,
33 JS::Handle<JSObject*> aGivenProto) override;
35 // WebIDL Members
36 XREye Eye() const;
37 void GetProjectionMatrix(JSContext* aCx, JS::MutableHandle<JSObject*> aRetval,
38 ErrorResult& aRv);
39 already_AddRefed<XRRigidTransform> GetTransform(ErrorResult& aRv);
41 protected:
42 virtual ~XRView();
44 nsCOMPtr<nsISupports> mParent;
45 XREye mEye;
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_