From dbec62302281d28dfb925a60f6f842cd2c528ae1 Mon Sep 17 00:00:00 2001 From: Imanol Fernandez Date: Wed, 4 Mar 2020 17:13:17 +0100 Subject: [PATCH] Remote foveated level settings (#2917) --- .../mozilla/vrbrowser/VRBrowserActivity.java | 9 ---- .../vrbrowser/browser/SettingsStore.java | 24 ---------- .../ui/widgets/WidgetManagerDelegate.java | 1 - .../widgets/settings/DisplayOptionsView.java | 44 ------------------- app/src/main/cpp/BrowserWorld.cpp | 11 ----- app/src/main/cpp/BrowserWorld.h | 1 - app/src/main/cpp/DeviceDelegate.h | 1 - app/src/main/res/layout/options_display.xml | 18 -------- app/src/main/res/values/non_L10n.xml | 2 - app/src/main/res/values/options_values.xml | 15 ------- .../oculusvr/cpp/DeviceDelegateOculusVR.cpp | 16 ------- app/src/oculusvr/cpp/DeviceDelegateOculusVR.h | 1 - app/src/wavevr/cpp/DeviceDelegateWaveVR.cpp | 38 ---------------- app/src/wavevr/cpp/DeviceDelegateWaveVR.h | 1 - 14 files changed, 182 deletions(-) diff --git a/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java b/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java index b68031d8e..3598c6159 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java @@ -282,7 +282,6 @@ protected void onCreate(Bundle savedInstanceState) { }); final String tempPath = getCacheDir().getAbsolutePath(); queueRunnable(() -> setTemporaryFilePath(tempPath)); - updateFoveatedLevel(); initializeWidgets(); @@ -1409,12 +1408,6 @@ public void updateEnvironment() { queueRunnable(() -> updateEnvironmentNative()); } - @Override - public void updateFoveatedLevel() { - final int appLevel = SettingsStore.getInstance(this).getFoveatedLevelApp(); - queueRunnable(() -> updateFoveatedLevelNative(appLevel)); - } - @Override public void updatePointerColor() { queueRunnable(() -> updatePointerColorNative()); @@ -1553,6 +1546,4 @@ public void updateLocale(@NonNull Context context) { private native void setCylinderDensityNative(float aDensity); private native void setCPULevelNative(@CPULevelFlags int aCPULevel); private native void setIsServo(boolean aIsServo); - private native void updateFoveatedLevelNative(int appLevel); - } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java b/app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java index 44d428f92..a3b12f187 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java @@ -73,8 +73,6 @@ SettingsStore getInstance(final @NonNull Context aContext) { public final static int MSAA_DEFAULT_LEVEL = 1; public final static boolean AUDIO_ENABLED = false; public final static float CYLINDER_DENSITY_ENABLED_DEFAULT = 4680.0f; - public final static int FOVEATED_APP_DEFAULT_LEVEL = 0; - public final static int FOVEATED_WEBVR_DEFAULT_LEVEL = 0; private final static long CRASH_RESTART_DELTA = 2000; public final static boolean AUTOPLAY_ENABLED = false; public final static boolean DEBUG_LOGGING_DEFAULT = false; @@ -490,28 +488,6 @@ public boolean isCurvedModeEnabled() { return getCylinderDensity() > 0; } - public int getFoveatedLevelApp() { - return mPrefs.getInt( - mContext.getString(R.string.settings_key_foveated_app), FOVEATED_APP_DEFAULT_LEVEL); - } - - public int getFoveatedLevelWebVR() { - return mPrefs.getInt( - mContext.getString(R.string.settings_key_foveated_webvr), FOVEATED_WEBVR_DEFAULT_LEVEL); - } - - public void setFoveatedLevelApp(int level) { - SharedPreferences.Editor editor = mPrefs.edit(); - editor.putInt(mContext.getString(R.string.settings_key_foveated_app), level); - editor.commit(); - } - - public void setFoveatedLevelWebVR(int level) { - SharedPreferences.Editor editor = mPrefs.edit(); - editor.putInt(mContext.getString(R.string.settings_key_foveated_webvr), level); - editor.commit(); - } - public void setSelectedKeyboard(Locale aLocale) { SharedPreferences.Editor editor = mPrefs.edit(); editor.putString(mContext.getString(R.string.settings_key_keyboard_locale), aLocale.toLanguageTag()); diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WidgetManagerDelegate.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WidgetManagerDelegate.java index 0b26a0fad..a0f6cfb5e 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WidgetManagerDelegate.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WidgetManagerDelegate.java @@ -65,7 +65,6 @@ interface WorldClickListener { void setIsServoSession(boolean aIsServo); void keyboardDismissed(); void updateEnvironment(); - void updateFoveatedLevel(); void updatePointerColor(); void showVRVideo(int aWindowHandle, @VideoProjectionMenuWidget.VideoProjectionFlags int aVideoProjection); void hideVRVideo(); diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/DisplayOptionsView.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/DisplayOptionsView.java index 1610571dd..ee2120124 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/DisplayOptionsView.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/DisplayOptionsView.java @@ -75,19 +75,6 @@ protected void updateUI() { mBinding.homepageEdit.setOnClickListener(mHomepageListener); setHomepage(SettingsStore.getInstance(getContext()).getHomepage()); - if (DeviceType.isOculusBuild() || DeviceType.isWaveBuild()) { - mBinding.foveatedAppRadio.setVisibility(View.VISIBLE); - // Uncomment this when Foveated Rendering for WebVR makes more sense - // mFoveatedWebVRRadio.setVisibility(View.VISIBLE); - int level = SettingsStore.getInstance(getContext()).getFoveatedLevelApp(); - setFoveatedLevel(mBinding.foveatedAppRadio, mBinding.foveatedAppRadio.getIdForValue(level), false); - mBinding.foveatedAppRadio.setOnCheckedChangeListener((compoundButton, checkedId, apply) -> setFoveatedLevel(mBinding.foveatedAppRadio, checkedId, apply)); - - level = SettingsStore.getInstance(getContext()).getFoveatedLevelWebVR(); - setFoveatedLevel(mBinding.foveatedWebvrRadio, mBinding.foveatedWebvrRadio.getIdForValue(level), false); - mBinding.foveatedWebvrRadio.setOnCheckedChangeListener((compoundButton, checkedId, apply) -> setFoveatedLevel(mBinding.foveatedWebvrRadio, checkedId, apply)); - } - mBinding.densityEdit.setHint1(String.valueOf(SettingsStore.DISPLAY_DENSITY_DEFAULT)); mBinding.densityEdit.setDefaultFirstValue(String.valueOf(SettingsStore.DISPLAY_DENSITY_DEFAULT)); mBinding.densityEdit.setFirstText(Float.toString(SettingsStore.getInstance(getContext()).getDisplayDensity())); @@ -198,14 +185,6 @@ public boolean isEditing() { if (!mBinding.msaaRadio.getValueForId(mBinding.msaaRadio.getCheckedRadioButtonId()).equals(SettingsStore.MSAA_DEFAULT_LEVEL)) { setMSAAMode(mBinding.msaaRadio.getIdForValue(SettingsStore.MSAA_DEFAULT_LEVEL), true); } - if (DeviceType.isOculusBuild() || DeviceType.isWaveBuild()) { - if (!mBinding.foveatedAppRadio.getValueForId(mBinding.foveatedAppRadio.getCheckedRadioButtonId()).equals(SettingsStore.FOVEATED_APP_DEFAULT_LEVEL)) { - setFoveatedLevel(mBinding.foveatedAppRadio, mBinding.foveatedAppRadio.getIdForValue(SettingsStore.FOVEATED_APP_DEFAULT_LEVEL), true); - } - if (!mBinding.foveatedWebvrRadio.getValueForId(mBinding.foveatedWebvrRadio.getCheckedRadioButtonId()).equals(SettingsStore.FOVEATED_WEBVR_DEFAULT_LEVEL)) { - setFoveatedLevel(mBinding.foveatedWebvrRadio, mBinding.foveatedWebvrRadio.getIdForValue(SettingsStore.FOVEATED_WEBVR_DEFAULT_LEVEL), true); - } - } restart = restart | setDisplayDensity(SettingsStore.DISPLAY_DENSITY_DEFAULT); restart = restart | setDisplayDpi(SettingsStore.DISPLAY_DPI_DEFAULT); @@ -268,29 +247,6 @@ private void setMSAAMode(int checkedId, boolean doApply) { } } - private void setFoveatedLevel(RadioGroupSetting aSetting, int checkedId, boolean doApply) { - RadioGroupSetting.OnCheckedChangeListener listener = aSetting.getOnCheckedChangeListener(); - aSetting.setOnCheckedChangeListener(null); - aSetting.setChecked(checkedId, doApply); - aSetting.setOnCheckedChangeListener(listener); - - int level = (Integer)aSetting.getValueForId(checkedId); - - if (aSetting == mBinding.foveatedAppRadio) { - SettingsStore.getInstance(getContext()).setFoveatedLevelApp(level); - } else { - SettingsStore.getInstance(getContext()).setFoveatedLevelWebVR(level); - } - - if (doApply) { - mWidgetManager.updateFoveatedLevel(); - // "WaveVR WVR_RenderFoveation(false) doesn't work properly, we need to restart." - if (level == 0 && DeviceType.isWaveBuild()) { - showRestartDialog(); - } - } - } - private boolean setDisplayDensity(float newDensity) { mBinding.densityEdit.setOnClickListener(null); boolean restart = false; diff --git a/app/src/main/cpp/BrowserWorld.cpp b/app/src/main/cpp/BrowserWorld.cpp index f58444f36..a30b5213f 100644 --- a/app/src/main/cpp/BrowserWorld.cpp +++ b/app/src/main/cpp/BrowserWorld.cpp @@ -964,12 +964,6 @@ BrowserWorld::UpdateEnvironment() { CreateSkyBox(skyboxPath, extension); } -void -BrowserWorld::UpdateFoveatedLevel(const int aAppLevel) { - ASSERT_ON_RENDER_THREAD(); - m.device->SetFoveatedLevel(aAppLevel); -} - void BrowserWorld::UpdatePointerColor() { ASSERT_ON_RENDER_THREAD(); @@ -1623,11 +1617,6 @@ JNI_METHOD(void, updateEnvironmentNative) crow::BrowserWorld::Instance().UpdateEnvironment(); } -JNI_METHOD(void, updateFoveatedLevelNative) -(JNIEnv*, jobject, jint aAppLevel) { - crow::BrowserWorld::Instance().UpdateFoveatedLevel(aAppLevel); -} - JNI_METHOD(void, updatePointerColorNative) (JNIEnv*, jobject) { crow::BrowserWorld::Instance().UpdatePointerColor(); diff --git a/app/src/main/cpp/BrowserWorld.h b/app/src/main/cpp/BrowserWorld.h index 581cd958b..39eba4cb6 100644 --- a/app/src/main/cpp/BrowserWorld.h +++ b/app/src/main/cpp/BrowserWorld.h @@ -48,7 +48,6 @@ class BrowserWorld { void EndFrame(); void SetTemporaryFilePath(const std::string& aPath); void UpdateEnvironment(); - void UpdateFoveatedLevel(const int aAppLevel); void UpdatePointerColor(); void SetSurfaceTexture(const std::string& aName, jobject& aSurface); void AddWidget(int32_t aHandle, const WidgetPlacementPtr& placement); diff --git a/app/src/main/cpp/DeviceDelegate.h b/app/src/main/cpp/DeviceDelegate.h index d680c4015..3efab2f85 100644 --- a/app/src/main/cpp/DeviceDelegate.h +++ b/app/src/main/cpp/DeviceDelegate.h @@ -58,7 +58,6 @@ class DeviceDelegate { virtual void SetClearColor(const vrb::Color& aColor) = 0; virtual void SetClipPlanes(const float aNear, const float aFar) = 0; virtual void SetControllerDelegate(ControllerDelegatePtr& aController) = 0; - virtual void SetFoveatedLevel(const int32_t aAppLevel) {}; virtual void ReleaseControllerDelegate() = 0; virtual int32_t GetControllerModelCount() const = 0; virtual const std::string GetControllerModelName(const int32_t aModelIndex) const = 0; diff --git a/app/src/main/res/layout/options_display.xml b/app/src/main/res/layout/options_display.xml index 6e22d4be6..10c8c50be 100644 --- a/app/src/main/res/layout/options_display.xml +++ b/app/src/main/res/layout/options_display.xml @@ -75,24 +75,6 @@ app:description="@string/developer_options_homepage" app:highlightedTextColor="@color/fog" /> - - - - settings_display_language settings_content_languages settings_cylinder_density - settings_foveated_in_app - settings_foveated_webvr settings_key_keyboard_locale settings_key_crash_restart_count settings_key_crash_restart_count_timestamp diff --git a/app/src/main/res/values/options_values.xml b/app/src/main/res/values/options_values.xml index e4a2f5978..5995a04d2 100644 --- a/app/src/main/res/values/options_values.xml +++ b/app/src/main/res/values/options_values.xml @@ -73,21 +73,6 @@ 2 - - - @string/developer_options_foveated_disabled - @string/developer_options_foveated_1 - @string/developer_options_foveated_2 - @string/developer_options_foveated_3 - - - - 0 - 1 - 2 - 3 - - @string/history_clear_range_today diff --git a/app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp b/app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp index ceca1d624..54baea59b 100644 --- a/app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp +++ b/app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp @@ -95,7 +95,6 @@ struct DeviceDelegateOculusVR::State { int discardCount = 0; uint32_t renderWidth = 0; uint32_t renderHeight = 0; - int32_t standaloneFoveatedLevel = 0; vrb::Color clearColor; float near = 0.1f; float far = 100.f; @@ -205,13 +204,6 @@ struct DeviceDelegateOculusVR::State { } } - void UpdateFoveatedLevel() { - if (!ovr) { - return; - } - vrapi_SetPropertyInt(&java, VRAPI_FOVEATION_LEVEL, standaloneFoveatedLevel); - } - void UpdateClockLevels() { if (!ovr) { return; @@ -648,7 +640,6 @@ DeviceDelegateOculusVR::SetRenderMode(const device::RenderMode aMode) { } m.UpdateTrackingMode(); - m.UpdateFoveatedLevel(); m.UpdateDisplayRefreshRate(); m.UpdateClockLevels(); @@ -747,12 +738,6 @@ DeviceDelegateOculusVR::ReleaseControllerDelegate() { m.controller = nullptr; } -void -DeviceDelegateOculusVR::SetFoveatedLevel(const int32_t aAppLevel) { - m.standaloneFoveatedLevel = aAppLevel; - m.UpdateFoveatedLevel(); -} - int32_t DeviceDelegateOculusVR::GetControllerModelCount() const { if (m.IsOculusQuest()) { @@ -1193,7 +1178,6 @@ DeviceDelegateOculusVR::EnterVR(const crow::BrowserEGLContext& aEGLContext) { m.UpdateDisplayRefreshRate(); m.UpdateClockLevels(); m.UpdateTrackingMode(); - m.UpdateFoveatedLevel(); } // Reset reorientation after Enter VR diff --git a/app/src/oculusvr/cpp/DeviceDelegateOculusVR.h b/app/src/oculusvr/cpp/DeviceDelegateOculusVR.h index ae54323ec..a11783799 100644 --- a/app/src/oculusvr/cpp/DeviceDelegateOculusVR.h +++ b/app/src/oculusvr/cpp/DeviceDelegateOculusVR.h @@ -37,7 +37,6 @@ class DeviceDelegateOculusVR : public DeviceDelegate { void SetClipPlanes(const float aNear, const float aFar) override; void SetControllerDelegate(ControllerDelegatePtr& aController) override; void ReleaseControllerDelegate() override; - void SetFoveatedLevel(const int32_t aAppLevel) override; int32_t GetControllerModelCount() const override; const std::string GetControllerModelName(const int32_t aModelIndex) const override; void SetCPULevel(const device::CPULevel aLevel) override; diff --git a/app/src/wavevr/cpp/DeviceDelegateWaveVR.cpp b/app/src/wavevr/cpp/DeviceDelegateWaveVR.cpp index ddbbda41b..77839074c 100644 --- a/app/src/wavevr/cpp/DeviceDelegateWaveVR.cpp +++ b/app/src/wavevr/cpp/DeviceDelegateWaveVR.cpp @@ -81,7 +81,6 @@ struct DeviceDelegateWaveVR::State { vrb::CameraEyePtr cameras[2]; uint32_t renderWidth; uint32_t renderHeight; - uint32_t standaloneFoveatedLevel; WVR_DevicePosePair_t devicePairs[WVR_DEVICE_COUNT_LEVEL_1]; ElbowModelPtr elbow; @@ -107,7 +106,6 @@ struct DeviceDelegateWaveVR::State { , rightTextureQueue(nullptr) , renderWidth(0) , renderHeight(0) - , standaloneFoveatedLevel(0) , devicePairs {} , controllers {} , lastSubmitDiscarded(false) @@ -224,36 +222,6 @@ struct DeviceDelegateWaveVR::State { ReleaseTextureQueues(); } - void UpdateFoveatedLevel() { - if (!WVR_IsRenderFoveationSupport()) { - VRB_LOG("This Wave device doesn't support Foveation Render."); - return; - } - - if (!leftFBOIndex || !rightFBOIndex) { - return; - } - - if (standaloneFoveatedLevel == 0) { - // This is not working, we have to restart the app to reset. - WVR_RenderFoveation(false); - } else { - WVR_RenderFoveation(true); - // Mapping foveated level (1~3) to WVR_PeripheralQuality (high~low). - WVR_PeripheralQuality peripheralQuality = - static_cast(WVR_PeripheralQuality_High-(standaloneFoveatedLevel - 1)); - - WVR_RenderFoveationParams_t foveated; - foveated.focalX = foveated.focalY = 0.0f; - foveated.fovealFov = foveatedFov; - foveated.periQuality = peripheralQuality; - WVR_TextureParams_t eyeTexture = WVR_GetTexture(leftTextureQueue, leftFBOIndex); - WVR_PreRenderEye(WVR_Eye_Left, &eyeTexture, &foveated); - eyeTexture = WVR_GetTexture(rightTextureQueue, rightFBOIndex); - WVR_PreRenderEye(WVR_Eye_Right, &eyeTexture, &foveated); - } - } - void CreateController(Controller& aController) { if (!delegate) { VRB_ERROR("Failed to create controller. No ControllerDelegate has been set."); @@ -532,11 +500,6 @@ DeviceDelegateWaveVR::SetClipPlanes(const float aNear, const float aFar) { m.InitializeCameras(); } -void -DeviceDelegateWaveVR::SetFoveatedLevel(const int32_t aAppLevel) { - m.standaloneFoveatedLevel = aAppLevel; -} - void DeviceDelegateWaveVR::SetControllerDelegate(ControllerDelegatePtr& aController) { m.delegate = aController; @@ -735,7 +698,6 @@ DeviceDelegateWaveVR::StartFrame() { if (!m.lastSubmitDiscarded) { m.leftFBOIndex = WVR_GetAvailableTextureIndex(m.leftTextureQueue); m.rightFBOIndex = WVR_GetAvailableTextureIndex(m.rightTextureQueue); - m.UpdateFoveatedLevel(); } // Update cameras WVR_GetSyncPose(WVR_PoseOriginModel_OriginOnHead, m.devicePairs, WVR_DEVICE_COUNT_LEVEL_1); diff --git a/app/src/wavevr/cpp/DeviceDelegateWaveVR.h b/app/src/wavevr/cpp/DeviceDelegateWaveVR.h index ac50b2699..9461cea91 100644 --- a/app/src/wavevr/cpp/DeviceDelegateWaveVR.h +++ b/app/src/wavevr/cpp/DeviceDelegateWaveVR.h @@ -26,7 +26,6 @@ class DeviceDelegateWaveVR : public DeviceDelegate { void SetReorientTransform(const vrb::Matrix& aMatrix) override; void SetClearColor(const vrb::Color& aColor) override; void SetClipPlanes(const float aNear, const float aFar) override; - void SetFoveatedLevel(const int32_t aAppLevel) override; void SetControllerDelegate(ControllerDelegatePtr& aController) override; void ReleaseControllerDelegate() override; int32_t GetControllerModelCount() const override;