Closed Bug 1148005 Opened 5 years ago Closed 5 years ago

[WebVR] Update API to latest spec changes

Categories

(Core :: DOM: Device Interfaces, defect)

35 Branch
x86
Windows 8.1
defect
Not set

Tracking

()

RESOLVED FIXED
mozilla40
Tracking Status
firefox40 --- fixed

People

(Reporter: vlad, Assigned: vlad)

Details

Attachments

(1 file, 3 obsolete files)

Assignee: nobody → vladimir
Comment on attachment 8583946 [details] [diff] [review]
Update WebVR APIs

Review of attachment 8583946 [details] [diff] [review]:
-----------------------------------------------------------------

Can you rebase your patch and submit a new one with this Constant/NewObject issue fixed? Thanks!

::: dom/vr/VRDevice.h
@@ +122,4 @@
>    nsRefPtr<DOMPoint> mAngularAcceleration;
>  };
>  
> +class VREyeParameters MOZ_FINAL : public nsWrapperCache

MOZ_FINAL is gone. Use 'final'. Update your tree.

@@ +124,5 @@
>  
> +class VREyeParameters MOZ_FINAL : public nsWrapperCache
> +{
> +public:
> +  explicit VREyeParameters(nsISupports* aParent,

explicit is not needed when we have more than 1 param.

@@ +137,5 @@
> +  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(VREyeParameters)
> +
> +  VRFieldOfView* MinimumFieldOfView();
> +  VRFieldOfView* MaximumFieldOfView();
> +  VRFieldOfView* RecommendedFieldOfView();

These should not return new objects all the time.

@@ +144,5 @@
> +  VRFieldOfView* CurrentFieldOfView();
> +  virtual already_AddRefed<DOMRect> RenderRect();
> +
> +  nsISupports* GetParentObject() const { return mParent; }
> +  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;

Yep, your tree has to be updated. This is changed and we don't have MOZ_OVERRIDE anymore.

::: dom/webidl/VRDevice.webidl
@@ +55,5 @@
> +[Pref="dom.vr.enabled",
> + HeaderFile="mozilla/dom/VRDevice.h"]
> +interface VREyeParameters {
> +  /* These values are expected to be static per-device/per-user */
> +  [Constant, NewObject] readonly attribute VRFieldOfView minimumFieldOfView;

This is wrong. An attribute cannot be a new Object and be constant.
Binding codegen should throw an error, actually.

Why do you want to have a new object all the time?
It means that if I do:

params.miniumFieldOfView === params.minimumFieldOfView, this is false.

@@ +117,4 @@
>     * will be null.
>     */
>    [NewObject]
> +  VRPositionState getState();

same line here as the other methods.

@@ +122,5 @@
> +  /*
> +   * Return the current instantaneous sensor state.
> +   */
> +  [NewObject]
> +  VRPositionState getImmediateState();

here too
Attachment #8583946 - Flags: review?(amarchesini) → review-
Attached patch Update WebV APIs, v2 (obsolete) — Splinter Review
Whoops, rebased and updated.
Attachment #8583946 - Attachment is obsolete: true
Attachment #8585041 - Flags: review?(amarchesini)
Comment on attachment 8585041 [details] [diff] [review]
Update WebV APIs, v2

Review of attachment 8585041 [details] [diff] [review]:
-----------------------------------------------------------------

No mochitests for the new VRDevice methods/attributes?
Can you add some in a separate patch?

::: dom/vr/VRDevice.cpp
@@ +57,5 @@
>  {
> +  return VRFieldOfViewBinding::Wrap(aCx, this, aGivenProto);
> +}
> +
> +NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(VREyeParameters, mParent)

mParent, mMinFOV, mMaxFOV, mRecFOV, mCurFOV, mEyeTranslation, mRenderRect

@@ +80,5 @@
> +  mRenderRect = new DOMRect(aParent, aRenderRect.x, aRenderRect.y, aRenderRect.width, aRenderRect.height);
> +}
> +
> +already_AddRefed<VRFieldOfView>
> +VREyeParameters::MinimumFieldOfView()

VRFieldOfView*
VREyeParams::MinimumFieldOfView() const
{
  return mMinFOV;
}

same for the other getters.

@@ +253,4 @@
>    {
> +    gfx::IntSize sz(mHMD->SuggestedEyeResolution());
> +    gfx::VRHMDInfo::Eye eye = aEye == VREye::Left ? gfx::VRHMDInfo::Eye_Left : gfx::VRHMDInfo::Eye_Right;
> +    return new VREyeParameters(mParent,

nsRefPtrVREyeParameters> params = new ...
return params.forget();

::: dom/vr/VRDevice.h
@@ +65,4 @@
>  class VRFieldOfView final : public VRFieldOfViewReadOnly
>  {
>  public:
> +  explicit VRFieldOfView(nsISupports* aParent, const gfx::VRFieldOfView& aSrc)

explicit is not needed here.

@@ +70,5 @@
> +                            aSrc.upDegrees, aSrc.rightDegrees,
> +                            aSrc.downDegrees, aSrc.leftDegrees)
> +  {}
> +
> +  explicit VRFieldOfView(nsISupports* aParent,

same here.

@@ +150,5 @@
> +
> +  NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(VREyeParameters)
> +  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(VREyeParameters)
> +
> +  already_AddRefed<VRFieldOfView> MinimumFieldOfView();

VRFieldOfView* MinimumFieldOfView() const;

the same for the other getters.

@@ +231,4 @@
>  class HMDVRDevice : public VRDevice
>  {
>  public:
> +  virtual VREyeParameters* GetEyeParameters(VREye aEye) = 0;

virtual already_AddRefed<DOMPoint> GetEyeTranslation(VREye aEye) = 0;
Attachment #8585041 - Flags: review?(amarchesini) → review+
Attached patch Update WebVR APIs, v3 (obsolete) — Splinter Review
Fixed up; grabbing another r+ just to make sure I've caught everything.  Still have very little experience with the new bindings.
Attachment #8585494 - Flags: review?(amarchesini)
Comment on attachment 8585494 [details] [diff] [review]
Update WebVR APIs, v3

Review of attachment 8585494 [details] [diff] [review]:
-----------------------------------------------------------------

Sorry for these new comments but yep, can you provide a new version? Thanks!

::: dom/vr/VRDevice.cpp
@@ +57,5 @@
> +{
> +  return VRFieldOfViewBinding::Wrap(aCx, this, aGivenProto);
> +}
> +
> +NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(VREyeParameters, mParent, mMinFOV, mMaxFOV, mRecFOV, mCurFOV, mEyeTranslation, mRenderRect)

80chars max.

@@ +73,5 @@
> +{
> +  mMinFOV = new VRFieldOfView(aParent, aMinFOV);
> +  mMaxFOV = new VRFieldOfView(aParent, aMaxFOV);
> +  mRecFOV = new VRFieldOfView(aParent, aRecFOV);
> +  mCurFOV = new VRFieldOfView(aParent, aCurFOV);

What about if you create these objects only when needed? Something like:

	
VRFieldOfView*
VREyeParameters::MinimumFieldOfView()
{
  if (!mMinFOV) {
    mMinFOV = new VRFieldOfView(this, mMinFOVValue);
  }

  return mMinFOV;
}

@@ +75,5 @@
> +  mMaxFOV = new VRFieldOfView(aParent, aMaxFOV);
> +  mRecFOV = new VRFieldOfView(aParent, aRecFOV);
> +  mCurFOV = new VRFieldOfView(aParent, aCurFOV);
> +
> +  mEyeTranslation = new DOMPoint(aParent, aEyeTranslation.x, aEyeTranslation.y, aEyeTranslation.z, 0.0);

max 80 chars.

@@ +248,5 @@
> +    gfx::IntSize sz(mHMD->SuggestedEyeResolution());
> +    gfx::VRHMDInfo::Eye eye = aEye == VREye::Left ? gfx::VRHMDInfo::Eye_Left : gfx::VRHMDInfo::Eye_Right;
> +    nsRefPtr<VREyeParameters> params =
> +      new VREyeParameters(mParent,
> +                          gfx::VRFieldOfView(15, 15, 15, 15), // XXX min?

Do we have a follow up for this XXX ?
File it and write the bug number here.

::: dom/vr/VRDevice.h
@@ +74,5 @@
> +  VRFieldOfView(nsISupports* aParent,
> +                double aUpDegrees = 0.0, double aRightDegrees = 0.0,
> +                double aDownDegrees = 0.0, double aLeftDegrees = 0.0)
> +    : VRFieldOfViewReadOnly(aParent,
> +                            aUpDegrees, aRightDegrees, aDownDegrees, aLeftDegrees)

Do a better indentation here:

  : VRFieldOfViewReadOnly(aParent, aUpDegrees, aRightDegrees,
                          aDownDegrees, aLeftDegrees)

::: dom/webidl/VRDevice.webidl
@@ +55,5 @@
> +[Pref="dom.vr.enabled",
> + HeaderFile="mozilla/dom/VRDevice.h"]
> +interface VREyeParameters {
> +  /* These values are expected to be static per-device/per-user */
> +  [Constant, Cached] readonly attribute VRFieldOfView minimumFieldOfView;

just do [Constant] in anyone of those.
Attachment #8585494 - Flags: review?(amarchesini) → review+
Updated patch.

> What about if you create these objects only when needed? Something like:

GetEyeParameters will be called once or twice during content startup, and then will likely not be called again; most of the fields will get used during that call.  I didn't want to create them lazily since that would require adding even more members to the class... its size is not an issue, but I figured it wasn't a big deal

> XXX

No bug number for it; it's not important to fix, and is mainly a mild question to see if we even care about providing a minimum value.  I'll just implement it and push the minimum decision down to the gfx layer in a later patch.
Attachment #8585041 - Attachment is obsolete: true
Attachment #8585494 - Attachment is obsolete: true
Attachment #8585827 - Flags: review?(amarchesini)
Comment on attachment 8585827 [details] [diff] [review]
Update WebVR APIs, v4

Review of attachment 8585827 [details] [diff] [review]:
-----------------------------------------------------------------

lgtm
Attachment #8585827 - Flags: review?(amarchesini) → review+
https://hg.mozilla.org/mozilla-central/rev/345dda450c52
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla40
You need to log in before you can comment on or make changes to this bug.