Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 44ca28c5 authored by John Reck's avatar John Reck
Browse files

Remove some dead code

Simplify state by deleting unused & always true stuff

Test: builds
Change-Id: Idf679aff5e809e567dac21a127cb9d6ace894f0e
parent 6b634145
Loading
Loading
Loading
Loading
+2 −9
Original line number Diff line number Diff line
@@ -3631,7 +3631,7 @@ public final class ActivityThread extends ClientTransactionHandler {
            TAG, "Handling launch of " + r);

        // Initialize before creating the activity
        if (!ThreadedRenderer.sRendererDisabled
        if (ThreadedRenderer.sRendererEnabled
                && (r.activityInfo.flags & ActivityInfo.FLAG_HARDWARE_ACCELERATED) != 0) {
            HardwareRenderer.preload();
        }
@@ -7417,14 +7417,7 @@ public final class ActivityThread extends ClientTransactionHandler {

    @UnsupportedAppUsage
    public static ActivityThread systemMain() {
        // The system process on low-memory devices do not get to use hardware
        // accelerated drawing, since this can add too much overhead to the
        // process.
        if (!ActivityManager.isHighEndGfx()) {
            ThreadedRenderer.disable(true);
        } else {
            ThreadedRenderer.enableForegroundTrimming();
        }
        ThreadedRenderer.initForSystemProcess();
        ActivityThread thread = new ActivityThread();
        thread.attach(true, 0);
        return thread;
+14 −40
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.view;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityManager;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.HardwareRenderer;
@@ -26,7 +27,6 @@ import android.graphics.Point;
import android.graphics.RecordingCanvas;
import android.graphics.Rect;
import android.graphics.RenderNode;
import android.os.SystemProperties;
import android.os.Trace;
import android.util.Log;
import android.view.Surface.OutOfResourcesException;
@@ -186,37 +186,12 @@ public final class ThreadedRenderer extends HardwareRenderer {
    public static int EGL_CONTEXT_PRIORITY_MEDIUM_IMG = 0x3102;
    public static int EGL_CONTEXT_PRIORITY_LOW_IMG = 0x3103;

    static {
        // Try to check OpenGL support early if possible.
        isAvailable();
    }

    /**
     * A process can set this flag to false to prevent the use of threaded
     * rendering.
     *
     * @hide
     */
    public static boolean sRendererDisabled = false;

    /**
     * Further threaded renderer disabling for the system process.
     *
     * @hide
     */
    public static boolean sSystemRendererDisabled = false;

    /**
     * Invoke this method to disable threaded rendering in the current process.
     *
     * @hide
     */
    public static void disable(boolean system) {
        sRendererDisabled = true;
        if (system) {
            sSystemRendererDisabled = true;
        }
    }
    public static boolean sRendererEnabled = true;

    public static boolean sTrimForeground = false;

@@ -230,16 +205,19 @@ public final class ThreadedRenderer extends HardwareRenderer {
        sTrimForeground = true;
    }


    /**
     * Indicates whether threaded rendering is available under any form for
     * the view hierarchy.
     *
     * @return True if the view hierarchy can potentially be defer rendered,
     *         false otherwise
     * Initialize HWUI for being in a system process like system_server
     * Should not be called in non-system processes
     */
    public static boolean isAvailable() {
        return true;
    public static void initForSystemProcess() {
        // The system process on low-memory devices do not get to use hardware
        // accelerated drawing, since this can add too much overhead to the
        // process.
        if (!ActivityManager.isHighEndGfx()) {
            sRendererEnabled = false;
        } else {
            enableForegroundTrimming();
        }
    }

    /**
@@ -250,11 +228,7 @@ public final class ThreadedRenderer extends HardwareRenderer {
     * @return A threaded renderer backed by OpenGL.
     */
    public static ThreadedRenderer create(Context context, boolean translucent, String name) {
        ThreadedRenderer renderer = null;
        if (isAvailable()) {
            renderer = new ThreadedRenderer(context, translucent, name);
        }
        return renderer;
        return new ThreadedRenderer(context, translucent, name);
    }

    private static final String[] VISUALIZERS = {
+1 −2
Original line number Diff line number Diff line
@@ -23573,8 +23573,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        if ((privateFlags & PFLAG_SELECTED) != 0) viewStateIndex |= StateSet.VIEW_STATE_SELECTED;
        if (hasWindowFocus()) viewStateIndex |= StateSet.VIEW_STATE_WINDOW_FOCUSED;
        if ((privateFlags & PFLAG_ACTIVATED) != 0) viewStateIndex |= StateSet.VIEW_STATE_ACTIVATED;
        if (mAttachInfo != null && mAttachInfo.mHardwareAccelerationRequested &&
                ThreadedRenderer.isAvailable()) {
        if (mAttachInfo != null && mAttachInfo.mHardwareAccelerationRequested) {
            // This is set if HW acceleration is requested, even if the current
            // process doesn't allow it.  This is just to allow app preview
            // windows to better match their app.
+1 −6
Original line number Diff line number Diff line
@@ -1291,10 +1291,6 @@ public final class ViewRootImpl implements ViewParent,
                (attrs.flags & WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) != 0;

        if (hardwareAccelerated) {
            if (!ThreadedRenderer.isAvailable()) {
                return;
            }

            // Persistent processes (including the system) should not do
            // accelerated rendering on low-end devices.  In that case,
            // sRendererDisabled will be set.  In addition, the system process
@@ -1314,8 +1310,7 @@ public final class ViewRootImpl implements ViewParent,
                // shows for launching applications, so they will look more like
                // the app being launched.
                mAttachInfo.mHardwareAccelerationRequested = true;
            } else if (!ThreadedRenderer.sRendererDisabled
                    || (ThreadedRenderer.sSystemRendererDisabled && forceHwAccelerated)) {
            } else if (ThreadedRenderer.sRendererEnabled || forceHwAccelerated) {
                if (mAttachInfo.mThreadedRenderer != null) {
                    mAttachInfo.mThreadedRenderer.destroy();
                }
+15 −16
Original line number Diff line number Diff line
@@ -527,7 +527,7 @@ public final class WindowManagerGlobal {
            }
            allViewsRemoved = mRoots.isEmpty();
        }
        if (ThreadedRenderer.sTrimForeground && ThreadedRenderer.isAvailable()) {
        if (ThreadedRenderer.sTrimForeground) {
            doTrimForeground();
        }

@@ -561,7 +561,7 @@ public final class WindowManagerGlobal {

    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
    public void trimMemory(int level) {
        if (ThreadedRenderer.isAvailable()) {

        if (shouldDestroyEglContext(level)) {
            // Destroy all hardware surfaces and resources associated to
            // known windows
@@ -580,10 +580,9 @@ public final class WindowManagerGlobal {
            doTrimForeground();
        }
    }
    }

    public static void trimForeground() {
        if (ThreadedRenderer.sTrimForeground && ThreadedRenderer.isAvailable()) {
        if (ThreadedRenderer.sTrimForeground) {
            WindowManagerGlobal wm = WindowManagerGlobal.getInstance();
            wm.doTrimForeground();
        }