Skip to content

Commit

Permalink
Enable hardware renderer and don't draw after onStop/onDestroy
Browse files Browse the repository at this point in the history
  • Loading branch information
MortimerGoro committed Dec 16, 2019
1 parent 6ba3881 commit 62b0dd8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ protected void onCreate(Bundle savedInstanceState) {

protected void initializeWidgets() {
UISurfaceTextureRenderer.setUseHardwareAcceleration(SettingsStore.getInstance(getBaseContext()).isUIHardwareAccelerationEnabled());
UISurfaceTextureRenderer.setRenderActive(true);
mWindows = new Windows(this);
mWindows.setDelegate(new Windows.Delegate() {
@Override
Expand Down Expand Up @@ -383,6 +384,7 @@ protected void onStart() {
SettingsStore.getInstance(getBaseContext()).setPid(Process.myPid());
super.onStart();
TelemetryWrapper.start();
UISurfaceTextureRenderer.setRenderActive(true);
}

@Override
Expand All @@ -392,6 +394,7 @@ protected void onStop() {

TelemetryWrapper.stop();
GleanMetricsService.sessionStop();
UISurfaceTextureRenderer.setRenderActive(false);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ SettingsStore getInstance(final @NonNull Context aContext) {
public final static boolean CONSOLE_LOGS_DEFAULT = false;
public final static boolean ENV_OVERRIDE_DEFAULT = false;
public final static boolean MULTIPROCESS_DEFAULT = false;
public final static boolean UI_HARDWARE_ACCELERATION_DEFAULT = false;
public final static boolean UI_HARDWARE_ACCELERATION_DEFAULT = true;
public final static boolean PERFORMANCE_MONITOR_DEFAULT = true;
public final static boolean DRM_PLAYBACK_DEFAULT = false;
public final static boolean TRACKING_DEFAULT = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,25 @@
import android.graphics.SurfaceTexture;
import android.view.Surface;

import androidx.annotation.Nullable;

public class UISurfaceTextureRenderer {
private int mTextureWidth;
private int mTextureHeight;
private SurfaceTexture mSurfaceTexture;
private Surface mSurface;
private Canvas mSurfaceCanvas;
private static boolean sUseHarwareAcceleration;
private static boolean sRenderActive = true;

public static void setUseHardwareAcceleration(boolean aEnabled) {
sUseHarwareAcceleration = aEnabled;
}

public static void setRenderActive(boolean aActive) {
sRenderActive = aActive;
}

UISurfaceTextureRenderer(SurfaceTexture aTexture, int aWidth, int aHeight) {
mTextureWidth = aWidth;
mTextureHeight = aHeight;
Expand Down Expand Up @@ -63,8 +70,12 @@ void release() {
mSurfaceTexture = null;
}

@Nullable
Canvas drawBegin() {
mSurfaceCanvas = null;
if (!sRenderActive) {
return null;
}
if (mSurface != null) {
try {
if (sUseHarwareAcceleration) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/non_L10n.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<string name="settings_key_bookmarks_sync" translatable="false">settings_key_bookmarks_sync</string>
<string name="settings_key_history_sync" translatable="false">settings_key_history_sync</string>
<string name="settings_key_whats_new_displayed" translatable="false">settings_key_whats_new_displayed</string>
<string name="settings_key_ui_hardware_acceleration" translatable="false">settings_key_ui_hardware_acceleration</string>
<string name="settings_key_ui_hardware_acceleration" translatable="false">settings_key_ui_hardware_acceleration_v2</string>
<string name="settings_key_fxa_last_sync" translatable="false">settings_key_fxa_last_sync</string>
<string name="environment_override_help_url" translatable="false">https://github.com/MozillaReality/FirefoxReality/wiki/Environments</string>
<string name="private_policy_url" translatable="false">https://www.mozilla.org/privacy/firefox/</string>
Expand Down

0 comments on commit 62b0dd8

Please sign in to comment.