Skip to content

Commit

Permalink
Bug 1630290 - Update VRManager VRLayer instead of recreating it. r=da…
Browse files Browse the repository at this point in the history
…oshengmu,kip

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

--HG--
extra : moz-landing-system : lando
  • Loading branch information
MortimerGoro committed Apr 15, 2020
1 parent c3114c1 commit e3dd202
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions gfx/vr/VRDisplayPresentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ void VRDisplayPresentation::UpdateLayers(
}

void VRDisplayPresentation::UpdateXRWebGLLayer(dom::XRWebGLLayer* aLayer) {
DestroyLayers();
VRManagerChild* manager = VRManagerChild::Get();
if (!manager) {
// This should not happen, but let's log it and avoid a crash in case
Expand All @@ -41,16 +40,20 @@ void VRDisplayPresentation::UpdateXRWebGLLayer(dom::XRWebGLLayer* aLayer) {
nsCOMPtr<nsIEventTarget> target =
canvasElement->OwnerDoc()->EventTargetFor(TaskCategory::Other);

RefPtr<VRLayerChild> vrLayer =
static_cast<VRLayerChild*>(manager->CreateVRLayer(
mDisplayClient->GetDisplayInfo().GetDisplayID(), target, mGroup));
if (mLayers.Length() == 0) {
// WebXR uses a single layer for now.
RefPtr<VRLayerChild> vrLayer =
static_cast<VRLayerChild*>(manager->CreateVRLayer(
mDisplayClient->GetDisplayInfo().GetDisplayID(), target, mGroup));
mLayers.AppendElement(vrLayer);
}
RefPtr<VRLayerChild> vrLayer = mLayers[0];

Rect leftBounds(0.0, 0.0, 0.5, 1.0);
Rect rightBounds(0.5, 0.0, 0.5, 1.0);

vrLayer->Initialize(canvasElement, leftBounds, rightBounds);
vrLayer->SetXRFramebuffer(aLayer->GetFramebuffer());
mLayers.AppendElement(vrLayer);
}

uint32_t VRDisplayPresentation::GetGroup() const { return mGroup; }
Expand Down

0 comments on commit e3dd202

Please sign in to comment.