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

Remote foveation level settings #2917

Merged
merged 1 commit into from
Mar 4, 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
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@ protected void onCreate(Bundle savedInstanceState) {
});
final String tempPath = getCacheDir().getAbsolutePath();
queueRunnable(() -> setTemporaryFilePath(tempPath));
updateFoveatedLevel();

initializeWidgets();

Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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);

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
11 changes: 0 additions & 11 deletions app/src/main/cpp/BrowserWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
1 change: 0 additions & 1 deletion app/src/main/cpp/BrowserWorld.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion app/src/main/cpp/DeviceDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 0 additions & 18 deletions app/src/main/res/layout/options_display.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,6 @@
app:description="@string/developer_options_homepage"
app:highlightedTextColor="@color/fog" />

<org.mozilla.vrbrowser.ui.views.settings.RadioGroupSetting
android:id="@+id/foveated_app_radio"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
app:description="@string/developer_options_foveated_app"
app:options="@array/developer_options_foveated_options"
app:values="@array/developer_options_foveated_values" />

<org.mozilla.vrbrowser.ui.views.settings.RadioGroupSetting
android:id="@+id/foveated_webvr_radio"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
app:description="@string/developer_options_foveated_webvr"
app:options="@array/developer_options_foveated_options"
app:values="@array/developer_options_foveated_values" />

<org.mozilla.vrbrowser.ui.views.settings.SingleEditSetting
android:id="@+id/density_edit"
android:layout_width="match_parent"
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values/non_L10n.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
<string name="settings_key_display_language" translatable="false">settings_display_language</string>
<string name="settings_key_content_languages" translatable="false">settings_content_languages</string>
<string name="settings_key_cylinder_density" translatable="false">settings_cylinder_density</string>
<string name="settings_key_foveated_app" translatable="false">settings_foveated_in_app</string>
<string name="settings_key_foveated_webvr" translatable="false">settings_foveated_webvr</string>
<string name="settings_key_keyboard_locale" translatable="false">settings_key_keyboard_locale</string>
<string name="settings_key_crash_restart_count" translatable="false">settings_key_crash_restart_count</string>
<string name="settings_key_crash_restart_count_timestamp" translatable="false">settings_key_crash_restart_count_timestamp</string>
Expand Down
15 changes: 0 additions & 15 deletions app/src/main/res/values/options_values.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,6 @@
<item>2</item>
</integer-array>

<!-- Foveated Levels -->
<string-array name="developer_options_foveated_options" translatable="false">
<item>@string/developer_options_foveated_disabled</item>
<item>@string/developer_options_foveated_1</item>
<item>@string/developer_options_foveated_2</item>
<item>@string/developer_options_foveated_3</item>
</string-array>

<integer-array name="developer_options_foveated_values" translatable="false">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
</integer-array>

<!-- Clear Cache Options -->
<string-array name="clear_cache_options" translatable="false">
<item>@string/history_clear_range_today</item>
Expand Down
16 changes: 0 additions & 16 deletions app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -205,13 +204,6 @@ struct DeviceDelegateOculusVR::State {
}
}

void UpdateFoveatedLevel() {
if (!ovr) {
return;
}
vrapi_SetPropertyInt(&java, VRAPI_FOVEATION_LEVEL, standaloneFoveatedLevel);
}

void UpdateClockLevels() {
if (!ovr) {
return;
Expand Down Expand Up @@ -648,7 +640,6 @@ DeviceDelegateOculusVR::SetRenderMode(const device::RenderMode aMode) {
}

m.UpdateTrackingMode();
m.UpdateFoveatedLevel();
m.UpdateDisplayRefreshRate();
m.UpdateClockLevels();

Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -1193,7 +1178,6 @@ DeviceDelegateOculusVR::EnterVR(const crow::BrowserEGLContext& aEGLContext) {
m.UpdateDisplayRefreshRate();
m.UpdateClockLevels();
m.UpdateTrackingMode();
m.UpdateFoveatedLevel();
}

// Reset reorientation after Enter VR
Expand Down
1 change: 0 additions & 1 deletion app/src/oculusvr/cpp/DeviceDelegateOculusVR.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
38 changes: 0 additions & 38 deletions app/src/wavevr/cpp/DeviceDelegateWaveVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -107,7 +106,6 @@ struct DeviceDelegateWaveVR::State {
, rightTextureQueue(nullptr)
, renderWidth(0)
, renderHeight(0)
, standaloneFoveatedLevel(0)
, devicePairs {}
, controllers {}
, lastSubmitDiscarded(false)
Expand Down Expand Up @@ -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>(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.");
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion app/src/wavevr/cpp/DeviceDelegateWaveVR.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down