Changeset 262299 in webkit


Ignore:
Timestamp:
May 29, 2020 9:36:52 AM (4 years ago)
Author:
svillar@igalia.com
Message:

[WebXR] Implement XRSession::requestReferenceSpace()
https://bugs.webkit.org/show_bug.cgi?id=212407

Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

Added expectations.

  • web-platform-tests/webxr/webGLCanvasContext_create_xrcompatible.https-expected.txt: Added.
  • web-platform-tests/webxr/webGLCanvasContext_makecompatible_contextlost.https-expected.txt: Added.
  • web-platform-tests/webxr/xrSession_requestReferenceSpace.https-expected.txt: Added.

Source/WebCore:

This patch implements the requestReferenceSpace() method of the XRSession which is used to
create reference spaces. A reference space establishes a space where pose data will be defined
and thus is mandatory to retrieve that pose information.

There are still some bits that have to implementated in follow up patches using platform code.

  • Modules/webxr/WebXRBoundedReferenceSpace.cpp:

(WebCore::WebXRBoundedReferenceSpace::create): Added.
(WebCore::WebXRBoundedReferenceSpace::WebXRBoundedReferenceSpace): Ditto.

  • Modules/webxr/WebXRBoundedReferenceSpace.h:
  • Modules/webxr/WebXRReferenceSpace.cpp:

(WebCore::WebXRReferenceSpace::create): Added.
(WebCore::WebXRReferenceSpace::WebXRReferenceSpace): Ditto.
(WebCore::WebXRReferenceSpace::getOffsetReferenceSpace): Use the create() method.

  • Modules/webxr/WebXRReferenceSpace.h:
  • Modules/webxr/WebXRSession.cpp:

(WebCore::WebXRSession::referenceSpaceIsSupported const): New method to check whether a reference.
space is supported by session and device.
(WebCore::WebXRSession::requestReferenceSpace): New method that creates reference spaces for pose data.

  • Modules/webxr/WebXRSession.h:
  • Modules/webxr/WebXRSpace.cpp:

(WebCore::WebXRSpace::WebXRSpace): Store a reference to the session creating the space.

  • Modules/webxr/WebXRSpace.h:

LayoutTests:

  • platform/wpe/TestExpectations: Unskipped 3 more tests that are working now.
Location:
trunk
Files:
3 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r262285 r262299  
     12020-05-27  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        [WebXR] Implement XRSession::requestReferenceSpace()
     4        https://bugs.webkit.org/show_bug.cgi?id=212407
     5
     6        Reviewed by Youenn Fablet.
     7
     8        * platform/wpe/TestExpectations: Unskipped 3 more tests that are working now.
     9
    1102020-05-29  Diego Pino Garcia  <dpino@igalia.com>
    211
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r262284 r262299  
     12020-05-27  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        [WebXR] Implement XRSession::requestReferenceSpace()
     4        https://bugs.webkit.org/show_bug.cgi?id=212407
     5
     6        Reviewed by Youenn Fablet.
     7
     8        Added expectations.
     9
     10        * web-platform-tests/webxr/webGLCanvasContext_create_xrcompatible.https-expected.txt: Added.
     11        * web-platform-tests/webxr/webGLCanvasContext_makecompatible_contextlost.https-expected.txt: Added.
     12        * web-platform-tests/webxr/xrSession_requestReferenceSpace.https-expected.txt: Added.
     13
    1142020-05-29  Javier Fernandez  <jfernandez@igalia.com>
    215
  • trunk/LayoutTests/platform/wpe/TestExpectations

    r262282 r262299  
    968968# WebXR
    969969webkit.org/b/209859 imported/w3c/web-platform-tests/webxr/idlharness.https.window.html [ Pass ]
     970webkit.org/b/209859 imported/w3c/web-platform-tests/webxr/webGLCanvasContext_create_xrcompatible.https.html [ Pass ]
     971webkit.org/b/209859 imported/w3c/web-platform-tests/webxr/webGLCanvasContext_makecompatible_contextlost.https.html [ Pass ]
    970972webkit.org/b/209859 imported/w3c/web-platform-tests/webxr/xrDevice_isSessionSupported_inline.https.html [ Pass ]
    971973webkit.org/b/209859 imported/w3c/web-platform-tests/webxr/xrDevice_isSessionSupported_immersive.https.html [ Pass ]
     
    982984webkit.org/b/209859 imported/w3c/web-platform-tests/webxr/xrSession_features_deviceSupport.https.html [ Pass ]
    983985webkit.org/b/209859 imported/w3c/web-platform-tests/webxr/xrSession_requestAnimationFrame_callback_calls.https.html [ Pass ]
     986webkit.org/b/209859 imported/w3c/web-platform-tests/webxr/xrSession_requestReferenceSpace.https.html [ Pass ]
    984987
    985988# Passing since r259532.
  • trunk/Source/WebCore/ChangeLog

    r262298 r262299  
     12020-05-27  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        [WebXR] Implement XRSession::requestReferenceSpace()
     4        https://bugs.webkit.org/show_bug.cgi?id=212407
     5
     6        Reviewed by Youenn Fablet.
     7
     8        This patch implements the requestReferenceSpace() method of the XRSession which is used to
     9        create reference spaces. A reference space establishes a space where pose data will be defined
     10        and thus is mandatory to retrieve that pose information.
     11
     12        There are still some bits that have to implementated in follow up patches using platform code.
     13
     14        * Modules/webxr/WebXRBoundedReferenceSpace.cpp:
     15        (WebCore::WebXRBoundedReferenceSpace::create): Added.
     16        (WebCore::WebXRBoundedReferenceSpace::WebXRBoundedReferenceSpace): Ditto.
     17        * Modules/webxr/WebXRBoundedReferenceSpace.h:
     18        * Modules/webxr/WebXRReferenceSpace.cpp:
     19        (WebCore::WebXRReferenceSpace::create): Added.
     20        (WebCore::WebXRReferenceSpace::WebXRReferenceSpace): Ditto.
     21        (WebCore::WebXRReferenceSpace::getOffsetReferenceSpace): Use the create() method.
     22        * Modules/webxr/WebXRReferenceSpace.h:
     23        * Modules/webxr/WebXRSession.cpp:
     24        (WebCore::WebXRSession::referenceSpaceIsSupported const): New method to check whether a reference.
     25        space is supported by session and device.
     26        (WebCore::WebXRSession::requestReferenceSpace): New method that creates reference spaces for pose data.
     27        * Modules/webxr/WebXRSession.h:
     28        * Modules/webxr/WebXRSpace.cpp:
     29        (WebCore::WebXRSpace::WebXRSpace): Store a reference to the session creating the space.
     30        * Modules/webxr/WebXRSpace.h:
     31
    1322020-05-29  Simon Fraser  <simon.fraser@apple.com>
    233
  • trunk/Source/WebCore/Modules/webxr/WebXRBoundedReferenceSpace.cpp

    r258498 r262299  
    2929#if ENABLE(WEBXR)
    3030
     31#include "DOMPointReadOnly.h"
     32#include <wtf/IsoMallocInlines.h>
     33
    3134namespace WebCore {
     35
     36WTF_MAKE_ISO_ALLOCATED_IMPL(WebXRBoundedReferenceSpace);
     37
     38Ref<WebXRBoundedReferenceSpace> WebXRBoundedReferenceSpace::create(Document& document, Ref<WebXRSession>&& session, XRReferenceSpaceType type)
     39{
     40    return adoptRef(*new WebXRBoundedReferenceSpace(document, WTFMove(session), type));
     41}
     42
     43WebXRBoundedReferenceSpace::WebXRBoundedReferenceSpace(Document& document, Ref<WebXRSession>&& session, XRReferenceSpaceType type)
     44    : WebXRReferenceSpace(document, WTFMove(session), type)
     45{
     46}
     47
     48WebXRBoundedReferenceSpace::~WebXRBoundedReferenceSpace() = default;
    3249
    3350const Vector<Ref<DOMPointReadOnly>>& WebXRBoundedReferenceSpace::boundsGeometry() const
  • trunk/Source/WebCore/Modules/webxr/WebXRBoundedReferenceSpace.h

    r258498 r262299  
    2727
    2828#include "WebXRReferenceSpace.h"
     29#include <wtf/IsoMalloc.h>
    2930#include <wtf/Ref.h>
    3031#include <wtf/Vector.h>
     
    3738
    3839class WebXRBoundedReferenceSpace : public WebXRReferenceSpace {
     40    WTF_MAKE_ISO_ALLOCATED(WebXRBoundedReferenceSpace);
    3941public:
     42    static Ref<WebXRBoundedReferenceSpace> create(Document&, Ref<WebXRSession>&&, XRReferenceSpaceType);
     43
    4044    virtual ~WebXRBoundedReferenceSpace();
    4145
     
    4347
    4448private:
     49    WebXRBoundedReferenceSpace(Document&, Ref<WebXRSession>&&, XRReferenceSpaceType);
     50
    4551    Vector<Ref<DOMPointReadOnly>> m_boundsGeometry;
    4652};
  • trunk/Source/WebCore/Modules/webxr/WebXRReferenceSpace.cpp

    r258498 r262299  
    2929#if ENABLE(WEBXR)
    3030
     31#include "Document.h"
     32#include "WebXRSession.h"
     33#include <wtf/IsoMallocInlines.h>
     34
    3135namespace WebCore {
    3236
    33 WebXRReferenceSpace::WebXRReferenceSpace(ScriptExecutionContext& context)
    34     : WebXRSpace(context)
     37WTF_MAKE_ISO_ALLOCATED_IMPL(WebXRReferenceSpace);
     38
     39Ref<WebXRReferenceSpace> WebXRReferenceSpace::create(Document& document, Ref<WebXRSession>&& session, XRReferenceSpaceType type)
     40{
     41    return adoptRef(*new WebXRReferenceSpace(document, WTFMove(session), type));
     42}
     43
     44WebXRReferenceSpace::WebXRReferenceSpace(Document& document, Ref<WebXRSession>&& session, XRReferenceSpaceType type)
     45    : WebXRSpace(document, WTFMove(session))
     46    , m_type(type)
    3547{
    3648}
     
    3850WebXRReferenceSpace::~WebXRReferenceSpace() = default;
    3951
    40 Ref<WebXRReferenceSpace> WebXRReferenceSpace::getOffsetReferenceSpace(const WebXRRigidTransform&)
     52RefPtr<WebXRReferenceSpace> WebXRReferenceSpace::getOffsetReferenceSpace(const WebXRRigidTransform&)
    4153{
    42     return adoptRef(*new WebXRReferenceSpace(*scriptExecutionContext()));
     54    if (!scriptExecutionContext())
     55        return nullptr;
     56    ASSERT(is<Document>(scriptExecutionContext()));
     57    return create(downcast<Document>(*scriptExecutionContext()), m_session.copyRef(), m_type);
    4358}
    4459
  • trunk/Source/WebCore/Modules/webxr/WebXRReferenceSpace.h

    r258498 r262299  
    2929
    3030#include "WebXRSpace.h"
    31 
     31#include "XRReferenceSpaceType.h"
     32#include <wtf/IsoMalloc.h>
    3233#include <wtf/Ref.h>
    3334
     
    3536
    3637class WebXRRigidTransform;
     38class WebXRSession;
    3739
    3840class WebXRReferenceSpace : public WebXRSpace {
     41    WTF_MAKE_ISO_ALLOCATED(WebXRReferenceSpace);
    3942public:
     43    static Ref<WebXRReferenceSpace> create(Document&, Ref<WebXRSession>&&, XRReferenceSpaceType);
     44
    4045    virtual ~WebXRReferenceSpace();
    4146
    42     Ref<WebXRReferenceSpace> getOffsetReferenceSpace(const WebXRRigidTransform&);
     47    RefPtr<WebXRReferenceSpace> getOffsetReferenceSpace(const WebXRRigidTransform&);
    4348
    44 private:
    45     WebXRReferenceSpace(ScriptExecutionContext&);
     49protected:
     50    WebXRReferenceSpace(Document&, Ref<WebXRSession>&&, XRReferenceSpaceType);
     51
     52    XRReferenceSpaceType m_type;
    4653};
    4754
  • trunk/Source/WebCore/Modules/webxr/WebXRSession.cpp

    r262292 r262299  
    2929#if ENABLE(WEBXR)
    3030
     31#include "JSWebXRReferenceSpace.h"
     32#include "WebXRBoundedReferenceSpace.h"
    3133#include "WebXRFrame.h"
    3234#include "WebXRSystem.h"
     
    8486}
    8587
    86 void WebXRSession::requestReferenceSpace(const XRReferenceSpaceType&, RequestReferenceSpacePromise&&)
    87 {
     88// https://immersive-web.github.io/webxr/#reference-space-is-supported
     89bool WebXRSession::referenceSpaceIsSupported(XRReferenceSpaceType type) const
     90{
     91    // 1. If type is not contained in session’s XR device's list of enabled features for mode return false.
     92    if (!m_device->enabledFeatures(m_mode).contains(type))
     93        return false;
     94
     95    // 2. If type is viewer, return true.
     96    if (type == XRReferenceSpaceType::Viewer)
     97        return true;
     98
     99    bool isImmersiveSession = m_mode == XRSessionMode::ImmersiveAr || m_mode == XRSessionMode::ImmersiveVr;
     100    if (type == XRReferenceSpaceType::Local || type == XRReferenceSpaceType::LocalFloor) {
     101        // 3. If type is local or local-floor, and session is an immersive session, return true.
     102        if (isImmersiveSession)
     103            return true;
     104
     105        // 4. If type is local or local-floor, and the XR device supports reporting orientation data, return true.
     106        // TODO: add API to PlatformXR::Device
     107        return true;
     108    }
     109
     110
     111    // 5. If type is bounded-floor and session is an immersive session, return the result of whether bounded
     112    //    reference spaces are supported by the XR device.
     113    // https://immersive-web.github.io/webxr/#bounded-reference-spaces-are-supported
     114    // TODO: add API to PlatformXR::Device
     115    if (type == XRReferenceSpaceType::BoundedFloor && isImmersiveSession)
     116        return true;
     117
     118    // 6. If type is unbounded, session is an immersive session, and the XR device supports stable tracking
     119    //    near the user over an unlimited distance, return true.
     120    // TODO: add API to PlatformXR::Device to check stable tracking over unlimited distance.
     121    if (type == XRReferenceSpaceType::Unbounded && isImmersiveSession)
     122        return true;
     123
     124    // 7. Return false.
     125    return false;
     126}
     127
     128// https://immersive-web.github.io/webxr/#dom-xrsession-requestreferencespace
     129void WebXRSession::requestReferenceSpace(XRReferenceSpaceType type, RequestReferenceSpacePromise&& promise)
     130{
     131    if (!scriptExecutionContext()) {
     132        promise.reject(Exception { InvalidStateError });
     133        return;
     134    }
     135    // 1. Let promise be a new Promise.
     136    // 2. Run the following steps in parallel:
     137    scriptExecutionContext()->postTask([this, promise = WTFMove(promise), type] (auto& context) mutable {
     138        //  2.1. Create a reference space, referenceSpace, with the XRReferenceSpaceType type.
     139        //  2.2. If referenceSpace is null, reject promise with a NotSupportedError and abort these steps.
     140        if (!referenceSpaceIsSupported(type)) {
     141            promise.reject(Exception { NotSupportedError });
     142            return;
     143        }
     144
     145        // https://immersive-web.github.io/webxr/#create-a-reference-space
     146        RefPtr<WebXRReferenceSpace> referenceSpace;
     147        ASSERT(is<Document>(context));
     148        if (type == XRReferenceSpaceType::BoundedFloor)
     149            referenceSpace = WebXRBoundedReferenceSpace::create(downcast<Document>(context), makeRef(*this), type);
     150        else
     151            referenceSpace = WebXRReferenceSpace::create(downcast<Document>(context), makeRef(*this), type);
     152
     153        //  2.3. Resolve promise with referenceSpace.
     154        // 3. Return promise.
     155        promise.resolve(referenceSpace.releaseNonNull());
     156    });
    88157}
    89158
  • trunk/Source/WebCore/Modules/webxr/WebXRSession.h

    r262188 r262299  
    7070
    7171    void updateRenderState(const XRRenderStateInit&);
    72     void requestReferenceSpace(const XRReferenceSpaceType&, RequestReferenceSpacePromise&&);
     72    void requestReferenceSpace(XRReferenceSpaceType, RequestReferenceSpacePromise&&);
    7373
    7474    XRFrameRequestCallback::Id requestAnimationFrame(Ref<XRFrameRequestCallback>&&);
     
    9797    void scheduleAnimation();
    9898
     99    bool referenceSpaceIsSupported(XRReferenceSpaceType) const;
     100
    99101    XREnvironmentBlendMode m_environmentBlendMode;
    100102    XRVisibilityState m_visibilityState;
  • trunk/Source/WebCore/Modules/webxr/WebXRSpace.cpp

    r258498 r262299  
    2929#if ENABLE(WEBXR)
    3030
     31#include "Document.h"
     32#include "WebXRSession.h"
    3133#include <wtf/IsoMallocInlines.h>
    3234
     
    3537WTF_MAKE_ISO_ALLOCATED_IMPL(WebXRSpace);
    3638
    37 WebXRSpace::WebXRSpace(ScriptExecutionContext& context)
    38     : ContextDestructionObserver(&context)
     39WebXRSpace::WebXRSpace(Document& document, Ref<WebXRSession>&& session)
     40    : ContextDestructionObserver(&document)
     41    , m_session(WTFMove(session))
    3942{
     43    ASSERT(context);
    4044}
    4145
  • trunk/Source/WebCore/Modules/webxr/WebXRSpace.h

    r258498 r262299  
    3434namespace WebCore {
    3535
     36class Document;
    3637class ScriptExecutionContext;
     38class WebXRSession;
    3739
    3840class WebXRSpace : public RefCounted<WebXRSpace>, public EventTargetWithInlineData, public ContextDestructionObserver {
     
    4547
    4648protected:
    47     WebXRSpace(ScriptExecutionContext&);
     49    WebXRSpace(Document&, Ref<WebXRSession>&&);
    4850
    4951    // EventTarget
    5052    ScriptExecutionContext* scriptExecutionContext() const override { return ContextDestructionObserver::scriptExecutionContext(); }
     53
     54    Ref<WebXRSession> m_session;
    5155
    5256private:
Note: See TracChangeset for help on using the changeset viewer.