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

Commit 5233920a authored by Romain Guy's avatar Romain Guy
Browse files

Prevent the system process from using the HardwareRenderer.

This change allows applications with the system UID to use the hardware
renderer.

Change-Id: I3c5d776ee9c07bb14933dbe3060cad4175e4fc95
parent f52faefc
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ import android.util.EventLog;
import android.util.Log;
import android.util.Slog;
import android.view.Display;
import android.view.HardwareRenderer;
import android.view.View;
import android.view.ViewDebug;
import android.view.ViewManager;
@@ -3632,6 +3633,7 @@ public final class ActivityThread {
    }

    public static final ActivityThread systemMain() {
        HardwareRenderer.disable();
        ActivityThread thread = new ActivityThread();
        thread.attach(true);
        return thread;
+17 −2
Original line number Diff line number Diff line
@@ -37,9 +37,26 @@ import javax.microedition.khronos.opengles.GL;
public abstract class HardwareRenderer {
    private static final String LOG_TAG = "HardwareRenderer";

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

    private boolean mEnabled;
    private boolean mRequested = true;

    /**
     * Indicates that the current process cannot use hardware rendering.
     * 
     * @hide
     */
    public static void disable() {
        sRendererDisabled = true;
    }

    /**
     * Indicates whether hardware acceleration is available under any form for
     * the view hierarchy.
@@ -377,7 +394,6 @@ public abstract class HardwareRenderer {
         * @param glVersion
         */
        EglConfigChooser getConfigChooser(int glVersion) {
            // TODO: Check for mTranslucent here, which means at least 2 EGL contexts
            return new ComponentSizeChooser(glVersion, 8, 8, 8, 8, 0, 0);
        }

@@ -546,7 +562,6 @@ public abstract class HardwareRenderer {

        @Override
        GLES20Canvas createCanvas() {
            // TODO: Pass mTranslucent instead of true
            return mGlCanvas = new GLES20Canvas(mGl, true);
        }

+1 −1
Original line number Diff line number Diff line
@@ -464,7 +464,7 @@ public final class ViewRoot extends Handler implements ViewParent, View.AttachIn
        // Only enable hardware acceleration if we are not in the system process
        // The window manager creates ViewRoots to display animated preview windows
        // of launching apps and we don't want those to be hardware accelerated
        if (Process.myUid() != Process.SYSTEM_UID) {
        if (!HardwareRenderer.sRendererDisabled) {
            // Try to enable hardware acceleration if requested
            if (attrs != null &&
                    (attrs.flags & WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) != 0) {