Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Fix jniEnv not set when layer is resized after the surface has been moved #3144

Merged
merged 1 commit into from
Apr 9, 2020
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,7 @@ DeviceDelegateOculusVR::CreateLayerQuad(int32_t aWidth, int32_t aHeight,
return nullptr;
}
VRLayerQuadPtr layer = VRLayerQuad::Create(aWidth, aHeight, aSurfaceType);
OculusLayerQuadPtr oculusLayer = OculusLayerQuad::Create(layer);
OculusLayerQuadPtr oculusLayer = OculusLayerQuad::Create(m.java.Env, layer);
m.AddUILayer(oculusLayer, aSurfaceType);
return layer;
}
Expand All @@ -1074,7 +1074,7 @@ DeviceDelegateOculusVR::CreateLayerQuad(const VRLayerSurfacePtr& aMoveLayer) {

for (int i = 0; i < m.uiLayers.size(); ++i) {
if (m.uiLayers[i]->GetLayer() == aMoveLayer) {
oculusLayer = OculusLayerQuad::Create(layer, m.uiLayers[i]);
oculusLayer = OculusLayerQuad::Create(m.java.Env, layer, m.uiLayers[i]);
m.uiLayers.erase(m.uiLayers.begin() + i);
break;
}
Expand All @@ -1092,7 +1092,7 @@ DeviceDelegateOculusVR::CreateLayerCylinder(int32_t aWidth, int32_t aHeight,
return nullptr;
}
VRLayerCylinderPtr layer = VRLayerCylinder::Create(aWidth, aHeight, aSurfaceType);
OculusLayerCylinderPtr oculusLayer = OculusLayerCylinder::Create(layer);
OculusLayerCylinderPtr oculusLayer = OculusLayerCylinder::Create(m.java.Env, layer);
m.AddUILayer(oculusLayer, aSurfaceType);
return layer;
}
Expand All @@ -1108,7 +1108,7 @@ DeviceDelegateOculusVR::CreateLayerCylinder(const VRLayerSurfacePtr& aMoveLayer)

for (int i = 0; i < m.uiLayers.size(); ++i) {
if (m.uiLayers[i]->GetLayer() == aMoveLayer) {
oculusLayer = OculusLayerCylinder::Create(layer, m.uiLayers[i]);
oculusLayer = OculusLayerCylinder::Create(m.java.Env, layer, m.uiLayers[i]);
m.uiLayers.erase(m.uiLayers.begin() + i);
break;
}
Expand Down
8 changes: 4 additions & 4 deletions app/src/oculusvr/cpp/OculusVRLayers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ bool OculusLayer::sForceClip = false;
// OculusLayerQuad

OculusLayerQuadPtr
OculusLayerQuad::Create(const VRLayerQuadPtr& aLayer, const OculusLayerPtr& aSource) {
OculusLayerQuad::Create(JNIEnv *aEnv, const VRLayerQuadPtr& aLayer, const OculusLayerPtr& aSource) {
auto result = std::make_shared<OculusLayerQuad>();
result->layer = aLayer;
if (aSource) {
result->TakeSurface(aSource);
result->TakeSurface(aEnv, aSource);
}
return result;
}
Expand Down Expand Up @@ -68,11 +68,11 @@ OculusLayerQuad::Update(const ovrTracking2& aTracking, ovrTextureSwapChain* aCle
// OculusLayerCylinder

OculusLayerCylinderPtr
OculusLayerCylinder::Create(const VRLayerCylinderPtr& aLayer, const OculusLayerPtr& aSource) {
OculusLayerCylinder::Create(JNIEnv *aEnv, const VRLayerCylinderPtr& aLayer, const OculusLayerPtr& aSource) {
auto result = std::make_shared<OculusLayerCylinder>();
result->layer = aLayer;
if (aSource) {
result->TakeSurface(aSource);
result->TakeSurface(aEnv, aSource);
}
return result;
}
Expand Down
7 changes: 4 additions & 3 deletions app/src/oculusvr/cpp/OculusVRLayers.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,9 @@ class OculusLayerSurface : public OculusLayerBase<T, U> {
}

protected:
void TakeSurface(const OculusLayerPtr &aSource) {
void TakeSurface(JNIEnv * aEnv, const OculusLayerPtr &aSource) {
this->swapChain = aSource->GetSwapChain();
this->jniEnv = aEnv;
this->surface = aSource->GetSurface();
this->surfaceChangedTarget = aSource->GetSurfaceChangedTarget();
if (this->surfaceChangedTarget) {
Expand Down Expand Up @@ -307,7 +308,7 @@ typedef std::shared_ptr<OculusLayerQuad> OculusLayerQuadPtr;
class OculusLayerQuad : public OculusLayerSurface<VRLayerQuadPtr, ovrLayerProjection2> {
public:
static OculusLayerQuadPtr
Create(const VRLayerQuadPtr &aLayer, const OculusLayerPtr &aSource = nullptr);
Create(JNIEnv *aEnv, const VRLayerQuadPtr &aLayer, const OculusLayerPtr &aSource = nullptr);
void Init(JNIEnv *aEnv, vrb::RenderContextPtr &aContext) override;
void Update(const ovrTracking2 &aTracking, ovrTextureSwapChain *aClearSwapChain) override;
};
Expand All @@ -320,7 +321,7 @@ typedef std::shared_ptr<OculusLayerCylinder> OculusLayerCylinderPtr;
class OculusLayerCylinder : public OculusLayerSurface<VRLayerCylinderPtr, ovrLayerCylinder2> {
public:
static OculusLayerCylinderPtr
Create(const VRLayerCylinderPtr &aLayer, const OculusLayerPtr &aSource = nullptr);
Create(JNIEnv *aEnv, const VRLayerCylinderPtr &aLayer, const OculusLayerPtr &aSource = nullptr);
void Init(JNIEnv *aEnv, vrb::RenderContextPtr &aContext) override;
void Update(const ovrTracking2 &aTracking, ovrTextureSwapChain *aClearSwapChain) override;
};
Expand Down