diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/modules/xr/xr_space.h')
-rw-r--r-- | chromium/third_party/blink/renderer/modules/xr/xr_space.h | 92 |
1 files changed, 49 insertions, 43 deletions
diff --git a/chromium/third_party/blink/renderer/modules/xr/xr_space.h b/chromium/third_party/blink/renderer/modules/xr/xr_space.h index 1ea887c709e..889718800e0 100644 --- a/chromium/third_party/blink/renderer/modules/xr/xr_space.h +++ b/chromium/third_party/blink/renderer/modules/xr/xr_space.h @@ -31,59 +31,65 @@ class XRSpace : public EventTargetWithInlineData { public: ~XRSpace() override; - // Gets a default viewer pose appropriate for this space. This is an identity - // for viewer space, null for everything else. - virtual std::unique_ptr<TransformationMatrix> DefaultViewerPose(); - - // Gets the pose of this space's origin in mojo space. This is a transform - // that maps from this space to mojo space (aka device space). Unless noted - // otherwise, all data returned over vr_service.mojom interfaces is expressed - // in mojo space coordinates. Returns nullptr if computing a transform is not - // possible. - virtual std::unique_ptr<TransformationMatrix> MojoFromSpace(); - - // Gets the pose of the mojo origin in this reference space, corresponding - // to a transform from mojo coordinates to reference space coordinates. - virtual std::unique_ptr<TransformationMatrix> SpaceFromMojo( - const TransformationMatrix& mojo_from_viewer); - - // Gets the viewer pose in this space, corresponding to a transform from - // viewer coordinates to this space's coordinates. (The position elements of - // the transformation matrix are the viewer's location in this space's - // coordinates.) - virtual std::unique_ptr<TransformationMatrix> SpaceFromViewer( - const TransformationMatrix& mojo_from_viewer); - - // Gets an input pose in this space. This requires the viewer pose as - // an additional input since a "viewer" space needs to transform the - // input pose to headset-relative coordinates. - virtual std::unique_ptr<TransformationMatrix> SpaceFromInputForViewer( - const TransformationMatrix& mojo_from_input, - const TransformationMatrix& mojo_from_viewer); - - virtual XRPose* getPose(XRSpace* other_space, - const TransformationMatrix* mojo_from_viewer); - - // Gets the viewer pose in this space, including using an appropriate - // default pose (i.e. if tracking is lost), and applying originOffset - // as applicable. TODO(https://crbug.com/1008466): consider moving - // the originOffset handling to a separate class? - std::unique_ptr<TransformationMatrix> SpaceFromViewerWithDefaultAndOffset( + // Gets the pose of this space's native origin in mojo space. This transform + // maps from this space's native origin to mojo space (aka device space). + // Unless noted otherwise, all data returned over vr_service.mojom interfaces + // is expressed in mojo space coordinates. + // Returns nullptr if computing a transform is not possible. + virtual std::unique_ptr<TransformationMatrix> MojoFromNative() = 0; + + // Convenience method to try to get the inverse of the above. This will return + // the pose of the mojo origin in this space's native origin. + // Returns nullptr if computing a transform is not possible. + virtual std::unique_ptr<TransformationMatrix> NativeFromMojo() = 0; + + // Gets the viewer pose in the native coordinates of this space, corresponding + // to a transform from viewer coordinates to this space's native coordinates. + // (The position elements of the transformation matrix are the viewer's + // location in this space's coordinates.) + // Prefer this helper method over querying NativeFromMojo and multiplying + // on the calling side, as this allows the viewer space to return identity + // instead of something near to, but not quite, identity. + // Returns nullptr if computing a transform is not possible. + virtual std::unique_ptr<TransformationMatrix> NativeFromViewer( const TransformationMatrix* mojo_from_viewer); + // Convenience method for calling NativeFromViewer with the current + // MojoFromViewer of the session associated with this space. This also handles + // the multiplication of OffsetFromNative onto the result of NativeFromViewer. + // Returns nullptr if computing a transform is not possible. + std::unique_ptr<TransformationMatrix> OffsetFromViewer(); + + // Return origin offset matrix, aka native_origin_from_offset_space. + virtual TransformationMatrix NativeFromOffsetMatrix(); + virtual TransformationMatrix OffsetFromNativeMatrix(); + + // Returns transformation from offset space to mojo space. Convenience method, + // returns MojoFromNative() * NativeFromOffsetMatrix() or nullptr if computing + // a transform is not possible. + std::unique_ptr<TransformationMatrix> MojoFromOffsetMatrix(); + + // Indicates whether or not the position portion of the native origin of this + // space is emulated. + virtual bool EmulatedPosition() const; + + // Gets the pose of this space's origin in |other_space|. This is a transform + // that maps from this space to the other's space, or in other words: + // other_from_this. + virtual XRPose* getPose(XRSpace* other_space); XRSession* session() const { return session_; } // EventTarget overrides. ExecutionContext* GetExecutionContext() const override; const AtomicString& InterfaceName() const override; - // Return origin offset matrix, aka native_origin_from_offset_space. - virtual TransformationMatrix OriginOffsetMatrix(); - virtual TransformationMatrix InverseOriginOffsetMatrix(); - virtual base::Optional<XRNativeOriginInformation> NativeOrigin() const = 0; - void Trace(blink::Visitor* visitor) override; + void Trace(Visitor* visitor) override; + + protected: + std::unique_ptr<TransformationMatrix> TryInvert( + std::unique_ptr<TransformationMatrix> matrix); private: const Member<XRSession> session_; |