Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ class OculusLayer {
virtual void SetBindDelegate(const BindDelegate& aDelegate) = 0;
virtual jobject GetSurface() const = 0;
virtual SurfaceChangedTargetPtr GetSurfaceChangedTarget() const = 0;
virtual void HandleResize(ovrTextureSwapChain * newSwapChain, jobject newSurface, vrb::FBOPtr newFBO) = 0;
virtual ~OculusLayer() {}
};

Expand Down Expand Up @@ -246,6 +247,8 @@ class OculusLayerBase: public OculusLayer {
return surfaceChangedTarget;
}

void HandleResize(ovrTextureSwapChain * newSwapChain, jobject newSurface, vrb::FBOPtr newFBO) override {}

virtual ~OculusLayerBase() {}
};

Expand Down Expand Up @@ -286,20 +289,29 @@ class OculusLayerSurface: public OculusLayerBase<T, U> {
vrb::FBOPtr newFBO;
InitSwapChain(newSwapChain, newSurface, newFBO);
this->layer->SetSurface(newSurface);

SurfaceChangedTargetWeakPtr weakTarget = this->surfaceChangedTarget;
this->layer->NotifySurfaceChanged(VRLayer::SurfaceChange::Create, [=]() {
if (this->swapChain) {
vrapi_DestroyTextureSwapChain(this->swapChain);
}
if (this->surface) {
jniEnv->DeleteGlobalRef(this->surface);
SurfaceChangedTargetPtr target = weakTarget.lock();
if (target && target->layer) {
target->layer->HandleResize(newSwapChain, newSurface, newFBO);
}
this->swapChain = newSwapChain;
this->surface = newSurface;
this->fbo = newFBO;
this->composited = true;
});
}

void HandleResize(ovrTextureSwapChain * newSwapChain, jobject newSurface, vrb::FBOPtr newFBO) override {
if (this->swapChain) {
vrapi_DestroyTextureSwapChain(this->swapChain);
}
if (this->surface) {
jniEnv->DeleteGlobalRef(this->surface);
}
this->swapChain = newSwapChain;
this->surface = newSurface;
this->fbo = newFBO;
this->composited = true;
}

void Destroy() override {
this->fbo = nullptr;
if (this->surface) {
Expand Down