Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable hardware renderer and don't draw after onStop/onDestroy #2482

Merged
merged 1 commit into from
Jan 10, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,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 @@ -360,6 +361,7 @@ protected void onStart() {
SettingsStore.getInstance(getBaseContext()).setPid(Process.myPid());
super.onStart();
TelemetryWrapper.start();
UISurfaceTextureRenderer.setRenderActive(true);
}

@Override
Expand All @@ -369,6 +371,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 @@ -51,7 +51,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 = true;
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="settings_key_restore_tabs" translatable="false">settings_key_restore_tabs</string>
<string name="environment_override_help_url" translatable="false">https://github.com/MozillaReality/FirefoxReality/wiki/Environments</string>
Expand Down