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

Add support for MSAA selection in dev setting. Default MSAA to 2x. #579

Merged
merged 1 commit into from
Sep 27, 2018
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
4 changes: 4 additions & 0 deletions app/src/common/shared/org/mozilla/vrbrowser/SessionStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,10 @@ private void vrPrefsWorkAround(Context aContext) {
out.write("pref(\"webgl.enable-surface-texture\", true);\n".getBytes());
out.write("pref(\"apz.allow_double_tap_zooming\", false);\n".getBytes());
out.write("pref(\"dom.webcomponents.customelements.enabled\", false);\n".getBytes());
int mssaLevel = SettingsStore.getInstance(aContext).getMSAALevel();
if (mssaLevel > 1) {
out.write(("pref(\"gl.msaa-level\"," + mssaLevel + ");\n").getBytes());
}
} catch (FileNotFoundException e) {
Log.e(LOGTAG, "Unable to create file: '" + prefFileName + "' got exception: " + e.toString());
} catch (IOException e) {
Expand Down
12 changes: 12 additions & 0 deletions app/src/common/shared/org/mozilla/vrbrowser/SettingsStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ SettingsStore getInstance(final @NonNull Context aContext) {
public final static String ENV_DEFAULT = "cave";
public final static float BROWSER_WORLD_WIDTH_DEFAULT = 4.0f;
public final static float BROWSER_WORLD_HEIGHT_DEFAULT = 2.25f;
public final static int MSAA_DEFAULT_LEVEL = 2;

// Enable telemetry by default (opt-out).
private final static boolean enableCrashReportingByDefault = false;
Expand Down Expand Up @@ -280,4 +281,15 @@ public void setPointerColor(int color) {
editor.commit();
}

public int getMSAALevel() {
return mPrefs.getInt(
mContext.getString(R.string.settings_key_msaa), MSAA_DEFAULT_LEVEL);
}

public void setMSAALevel(int level) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putInt(mContext.getString(R.string.settings_key_msaa), level);
editor.commit();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ public enum UaMode {
private RadioButton mDesktopRadio;
private RadioButton mRadioMobile;
private RadioButton mVrRadio;
private RadioGroup mMSAARadio;
private RadioButton mMSAARadioDisabled;
private RadioButton mMSAARadio2;
private RadioButton mMSAARadio4;
private UIButton mBackButton;
private RadioGroup mEventsRadio;
private RadioButton mTouchRadio;
Expand Down Expand Up @@ -169,6 +173,18 @@ public void onClick(View view) {
mUaModeRadio.setOnCheckedChangeListener(mUaModeListener);
setUaMode(uaMode, false);

int mssaLevel = SettingsStore.getInstance(getContext()).getMSAALevel();
mMSAARadio = findViewById(R.id.radioMSAAMode);
mMSAARadio.setSoundEffectsEnabled(false);
mMSAARadioDisabled = findViewById(R.id.radioMSAADisabled);
mMSAARadioDisabled.setSoundEffectsEnabled(false);
mMSAARadio2 = findViewById(R.id.radioMSAA2);
mMSAARadio2.setSoundEffectsEnabled(false);
mMSAARadio4 = findViewById(R.id.radioMSAA4);
mMSAARadio4.setSoundEffectsEnabled(false);
mUaModeRadio.setOnCheckedChangeListener(mUaModeListener);
setMSAAMode(mssaLevel, false);

InputMode inputMode = InputMode.values()[SettingsStore.getInstance(getContext()).getInputMode()];
mEventsRadio = findViewById(R.id.radioEvents);
mEventsRadio.setSoundEffectsEnabled(false);
Expand Down Expand Up @@ -384,6 +400,17 @@ public void onCheckedChanged(RadioGroup radioGroup, int checkedId) {
}
};

private RadioGroup.OnCheckedChangeListener mMSSAChangeListener = new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup radioGroup, int checkedId) {
if (mAudio != null) {
mAudio.playSound(AudioEngine.Sound.CLICK);
}

setMSAAMode(getMSSAModeFromRadio(checkedId), true);
}
};

private RadioGroup.OnCheckedChangeListener mInputModeListener = new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup radioGroup, int checkedId) {
Expand Down Expand Up @@ -623,6 +650,24 @@ private UaMode getUaModeFromRadio(int checkedId) {
return uaMode;
}

private int getMSSAModeFromRadio(int checkedId) {
int level = 0;
switch (checkedId) {
case R.id.radioMSAADisabled:
level = 0;
break;
case R.id.radioMSAA4:
level = 4;
break;
default:
level = 2;
break;
}

return level;
}


private void setUaMode(UaMode uaMode, boolean doApply) {
mUaModeRadio.setOnCheckedChangeListener(null);

Expand Down Expand Up @@ -651,6 +696,34 @@ private void setUaMode(UaMode uaMode, boolean doApply) {
}
}

private void setMSAAMode(int level, boolean doApply) {
mMSAARadio.setOnCheckedChangeListener(null);

if (level > 2) {
mMSAARadioDisabled.setChecked(false);
mMSAARadio2.setChecked(false);
mMSAARadio4.setChecked(true);

} else if (level > 1) {
mMSAARadioDisabled.setChecked(false);
mMSAARadio2.setChecked(true);
mMSAARadio4.setChecked(false);

} else {
mMSAARadioDisabled.setChecked(true);
mMSAARadio2.setChecked(false);
mMSAARadio4.setChecked(false);
}

mMSAARadio.setOnCheckedChangeListener(mMSSAChangeListener);


if (doApply) {
SettingsStore.getInstance(getContext()).setMSAALevel(level);
showRestartDialog();
}
}

private String getEnvFromRadio(int checkedId) {
String env;
switch (checkedId) {
Expand Down
52 changes: 50 additions & 2 deletions app/src/main/res/layout/developer_options.xml
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,56 @@
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="@color/fog"
android:visibility="gone"/>
android:background="@color/fog"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/developer_options_msaa"
android:textSize="14sp"
android:textColor="@color/fog"
android:layout_alignParentStart="true"
android:layout_toStartOf="@id/radioMSAAMode"/>
<RadioGroup
android:id="@+id/radioMSAAMode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentEnd="true">
<RadioButton android:id="@+id/radioMSAADisabled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:button="@drawable/radio"
android:text="@string/developer_options_msaa_disabled"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:checked="true"/>
<RadioButton android:id="@+id/radioMSAA2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:button="@drawable/radio"
android:text="@string/developer_options_msaa_2"
android:paddingStart="10dp"
android:paddingEnd="10dp"/>
<RadioButton android:id="@+id/radioMSAA4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:button="@drawable/radio"
android:text="@string/developer_options_msaa_4"
android:paddingStart="10dp"/>
</RadioGroup>
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="@color/fog"
android:visibility="gone"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="60dp"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/non_L10n.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<string name="settings_key_max_window_height" translatable="false">settings_max_window_height</string>
<string name="settings_key_env" translatable="false">settings_env</string>
<string name="settings_key_pointer_color" translatable="false">settings_pointer_color</string>
<string name="settings_key_msaa" translatable="false">settings_msaa</string>
<string name="private_browsing_support_url" translatable="false">https://support.mozilla.org/kb/private-mode-firefox-reality</string>
<string name="settings_key_browser_world_width" translatable="false">settings_browser_world_width</string>
<string name="settings_key_browser_world_height" translatable="false">settings_browser_world_height</string>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
<string name="developer_options_save">Save</string>
<string name="developer_options_display_dpi">Display DPI:</string>
<string name="developer_options_max_window_size">Max. Window Size:</string>
<string name="developer_options_msaa">MSAA</string>
<string name="developer_options_msaa_disabled">Disabled</string>
<string name="developer_options_msaa_2">2x</string>
<string name="developer_options_msaa_4">4x</string>
<string name="developer_options_ua_desktop">Desktop</string>
<string name="developer_options_ua_mobile">Mobile</string>
<string name="developer_options_ua_vr">VR</string>
Expand Down