Skip to content

Commit

Permalink
Bug 1630170 - Delete XRWebGLLayer Framebuffer on XRSession presentati…
Browse files Browse the repository at this point in the history
…on end r=kip,jgilbert,daoshengmu

Differential Revision: https://phabricator.services.mozilla.com/D71063

--HG--
extra : moz-landing-system : lando
  • Loading branch information
MortimerGoro committed Apr 15, 2020
1 parent e3dd202 commit 025f4b6
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
9 changes: 8 additions & 1 deletion dom/canvas/XRWebGLLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,15 @@ XRWebGLLayer::XRWebGLLayer(
}

XRWebGLLayer::~XRWebGLLayer() {
DeleteFramebuffer();
mozilla::DropJSObjects(this);
}

void XRWebGLLayer::DeleteFramebuffer() {
if (mFramebuffer) {
mWebGL->DeleteFramebuffer(mFramebuffer.get(), true);
mFramebuffer = nullptr;
}
mozilla::DropJSObjects(this);
}

/* static */
Expand Down Expand Up @@ -246,5 +251,7 @@ HTMLCanvasElement* XRWebGLLayer::GetCanvas() {
return mWebGL->GetParentObject();
}

void XRWebGLLayer::SessionEnded() { DeleteFramebuffer(); }

} // namespace dom
} // namespace mozilla
2 changes: 2 additions & 0 deletions dom/canvas/XRWebGLLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ class XRWebGLLayer final : public nsWrapperCache {
void StartAnimationFrame();
void EndAnimationFrame();
HTMLCanvasElement* GetCanvas();
void SessionEnded();

private:
void DeleteFramebuffer();
virtual ~XRWebGLLayer();
nsCOMPtr<nsISupports> mParent;

Expand Down
8 changes: 8 additions & 0 deletions dom/vr/XRRenderState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,13 @@ bool XRRenderState::IsCompositionDisabled() const {
return mCompositionDisabled;
}

void XRRenderState::SessionEnded() {
if (mBaseLayer) {
mBaseLayer->SessionEnded();
mBaseLayer = nullptr;
}
mOutputCanvas = nullptr;
}

} // namespace dom
} // namespace mozilla
1 change: 1 addition & 0 deletions dom/vr/XRRenderState.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class XRRenderState final : public nsWrapperCache {
HTMLCanvasElement* GetOutputCanvas() const;
void SetCompositionDisabled(bool aCompositionDisabled);
bool IsCompositionDisabled() const;
void SessionEnded();

protected:
virtual ~XRRenderState() = default;
Expand Down
8 changes: 8 additions & 0 deletions dom/vr/XRSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,14 @@ void XRSession::ExitPresentInternal() {
mXRSystem->SessionEnded(this);
}

if (mActiveRenderState) {
mActiveRenderState->SessionEnded();
}

if (mPendingRenderState) {
mPendingRenderState->SessionEnded();
}

mDisplayPresentation = nullptr;
if (!mEnded) {
mEnded = true;
Expand Down

0 comments on commit 025f4b6

Please sign in to comment.