XRView.h (1773B)
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_XRView_h_ 8 #define mozilla_dom_XRView_h_ 9 10 #include "gfxVR.h" 11 #include "mozilla/DOMEventTargetHelper.h" 12 #include "mozilla/dom/WebXRBinding.h" 13 14 namespace mozilla::dom { 15 16 enum class XREye : uint8_t; 17 class XRRigidTransform; 18 19 class XRView final : public nsWrapperCache { 20 public: 21 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(XRView) 22 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(XRView) 23 24 explicit XRView(nsISupports* aParent, const XREye& aEye); 25 26 void Update(const gfx::PointDouble3D& aPosition, 27 const gfx::QuaternionDouble& aOrientation, 28 const gfx::Matrix4x4& aProjectionMatrix); 29 // WebIDL Boilerplate 30 nsISupports* GetParentObject() const { return mParent; } 31 JSObject* WrapObject(JSContext* aCx, 32 JS::Handle<JSObject*> aGivenProto) override; 33 34 // WebIDL Members 35 XREye Eye() const; 36 void GetProjectionMatrix(JSContext* aCx, JS::MutableHandle<JSObject*> aRetval, 37 ErrorResult& aRv); 38 already_AddRefed<XRRigidTransform> GetTransform(ErrorResult& aRv); 39 40 protected: 41 virtual ~XRView(); 42 43 nsCOMPtr<nsISupports> mParent; 44 XREye mEye; 45 gfx::PointDouble3D mPosition; 46 gfx::QuaternionDouble mOrientation; 47 gfx::Matrix4x4 mProjectionMatrix; 48 JS::Heap<JSObject*> mJSProjectionMatrix; 49 bool mProjectionNeedsUpdate = true; 50 RefPtr<XRRigidTransform> mTransform; 51 }; 52 53 } // namespace mozilla::dom 54 55 #endif // mozilla_dom_XRView_h_