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

Commit 0a1b8a4

Browse files
MortimerGorobluemarvin
authored andcommitted
Enable hardware renderer and don't draw after onStop/onDestroy (#2482)
1 parent d5ce064 commit 0a1b8a4

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ protected void onCreate(Bundle savedInstanceState) {
273273

274274
protected void initializeWidgets() {
275275
UISurfaceTextureRenderer.setUseHardwareAcceleration(SettingsStore.getInstance(getBaseContext()).isUIHardwareAccelerationEnabled());
276+
UISurfaceTextureRenderer.setRenderActive(true);
276277
mWindows = new Windows(this);
277278
mWindows.setDelegate(new Windows.Delegate() {
278279
@Override
@@ -360,6 +361,7 @@ protected void onStart() {
360361
SettingsStore.getInstance(getBaseContext()).setPid(Process.myPid());
361362
super.onStart();
362363
TelemetryWrapper.start();
364+
UISurfaceTextureRenderer.setRenderActive(true);
363365
}
364366

365367
@Override
@@ -369,6 +371,7 @@ protected void onStop() {
369371

370372
TelemetryWrapper.stop();
371373
GleanMetricsService.sessionStop();
374+
UISurfaceTextureRenderer.setRenderActive(false);
372375
}
373376

374377
@Override

app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ SettingsStore getInstance(final @NonNull Context aContext) {
5151
public final static boolean CONSOLE_LOGS_DEFAULT = false;
5252
public final static boolean ENV_OVERRIDE_DEFAULT = false;
5353
public final static boolean MULTIPROCESS_DEFAULT = true;
54-
public final static boolean UI_HARDWARE_ACCELERATION_DEFAULT = false;
54+
public final static boolean UI_HARDWARE_ACCELERATION_DEFAULT = true;
5555
public final static boolean PERFORMANCE_MONITOR_DEFAULT = true;
5656
public final static boolean DRM_PLAYBACK_DEFAULT = false;
5757
public final static boolean TRACKING_DEFAULT = true;

app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/UISurfaceTextureRenderer.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,25 @@
1212
import android.graphics.SurfaceTexture;
1313
import android.view.Surface;
1414

15+
import androidx.annotation.Nullable;
16+
1517
public class UISurfaceTextureRenderer {
1618
private int mTextureWidth;
1719
private int mTextureHeight;
1820
private SurfaceTexture mSurfaceTexture;
1921
private Surface mSurface;
2022
private Canvas mSurfaceCanvas;
2123
private static boolean sUseHarwareAcceleration;
24+
private static boolean sRenderActive = true;
2225

2326
public static void setUseHardwareAcceleration(boolean aEnabled) {
2427
sUseHarwareAcceleration = aEnabled;
2528
}
2629

30+
public static void setRenderActive(boolean aActive) {
31+
sRenderActive = aActive;
32+
}
33+
2734
UISurfaceTextureRenderer(SurfaceTexture aTexture, int aWidth, int aHeight) {
2835
mTextureWidth = aWidth;
2936
mTextureHeight = aHeight;
@@ -63,8 +70,12 @@ void release() {
6370
mSurfaceTexture = null;
6471
}
6572

73+
@Nullable
6674
Canvas drawBegin() {
6775
mSurfaceCanvas = null;
76+
if (!sRenderActive) {
77+
return null;
78+
}
6879
if (mSurface != null) {
6980
try {
7081
if (sUseHarwareAcceleration) {

app/src/main/res/values/non_L10n.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<string name="settings_key_bookmarks_sync" translatable="false">settings_key_bookmarks_sync</string>
5050
<string name="settings_key_history_sync" translatable="false">settings_key_history_sync</string>
5151
<string name="settings_key_whats_new_displayed" translatable="false">settings_key_whats_new_displayed</string>
52-
<string name="settings_key_ui_hardware_acceleration" translatable="false">settings_key_ui_hardware_acceleration</string>
52+
<string name="settings_key_ui_hardware_acceleration" translatable="false">settings_key_ui_hardware_acceleration_v2</string>
5353
<string name="settings_key_fxa_last_sync" translatable="false">settings_key_fxa_last_sync</string>
5454
<string name="settings_key_restore_tabs" translatable="false">settings_key_restore_tabs</string>
5555
<string name="environment_override_help_url" translatable="false">https://github.com/MozillaReality/FirefoxReality/wiki/Environments</string>

0 commit comments

Comments
 (0)