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

Commit ea945758 authored by Galia Peycheva's avatar Galia Peycheva
Browse files

Add minimal post processing API to framework

This API allows applications to instruct the connected display to do minimal
post processing on the produced image or video frames. This will switch the
display to a low latency mode (ALLM, Game mode or some other custom
implementation thereof), reducing lag in the final images. Thus, minimal post
processing would greatly enhance performance for gaming and video
conferencing applications. It would not, however, suit applications that
prioritise image quality over performance.

This CL adds 2 public method:
 - Window.setPreferMinimalPostProcessing()
(this can also be set in WindowManager.LayoutParams.preferMinimalPostProcessing)
If minimal post processing is preferred, the connected display will be requested
to go into low latency mode, which reduces image processing, resulting in better
performance for gaming applications. If the Display sink is connected via HDMI,
the device will begin to send infoframes with Auto Low Latency Mode enabled and
Game Content Type. This will switch the connected display to a lower latency
mode (if available).
For more information, see HDMI 2.1 specification.

If the Display sink has an internal connection or uses some other protocol than
HDMI, effects may be similar but implementation-defined.

 - Display.isMinimalPostProcessingPreferred()
Returns true if the connected display supports either Low Latency Mode (ALLM or
some other custom low latency implementation) or Game content type.

Bug: 135116095

Test: make -> flash on ATV OTT device -> open an activity which requests minimal
post processing -> check SurfaceControl logs -> verify correct signals are
passed to native

Change-Id: Id09160ba1513fef4dac979162bcda3bfeaace0e6
parent 2b204642
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1059,6 +1059,7 @@ package android {
    field public static final int popupWindowStyle = 16842870; // 0x1010076
    field public static final int port = 16842793; // 0x1010029
    field public static final int positiveButtonText = 16843253; // 0x10101f5
    field public static final int preferMinimalPostProcessing = 16844300; // 0x101060c
    field public static final int preferenceCategoryStyle = 16842892; // 0x101008c
    field public static final int preferenceFragmentStyle = 16844038; // 0x1010506
    field public static final int preferenceInformationStyle = 16842893; // 0x101008d
@@ -11174,6 +11175,7 @@ package android.content.pm {
    field public String parentActivityName;
    field public String permission;
    field public int persistableMode;
    field public boolean preferMinimalPostProcessing;
    field public int screenOrientation;
    field public int softInputMode;
    field public String targetActivity;
@@ -49125,6 +49127,7 @@ package android.view {
    method @Deprecated public float[] getSupportedRefreshRates();
    method @Deprecated public int getWidth();
    method public boolean isHdr();
    method public boolean isMinimalPostProcessingSupported();
    method public boolean isValid();
    method public boolean isWideColorGamut();
    field public static final int DEFAULT_DISPLAY = 0; // 0x0
@@ -52150,6 +52153,7 @@ package android.view {
    method public abstract void setNavigationBarColor(@ColorInt int);
    method public void setNavigationBarContrastEnforced(boolean);
    method public void setNavigationBarDividerColor(@ColorInt int);
    method public void setPreferMinimalPostProcessing(boolean);
    method public void setReenterTransition(android.transition.Transition);
    method public abstract void setResizingCaptionDrawable(android.graphics.drawable.Drawable);
    method public final void setRestrictedCaptionAreaListener(android.view.Window.OnRestrictedCaptionAreaChangedListener);
@@ -52467,6 +52471,7 @@ package android.view {
    field public int layoutInDisplayCutoutMode;
    field @Deprecated public int memoryType;
    field public String packageName;
    field public boolean preferMinimalPostProcessing;
    field public int preferredDisplayModeId;
    field @Deprecated public float preferredRefreshRate;
    field public int rotationAnimation;
+1 −0
Original line number Diff line number Diff line
@@ -7853,6 +7853,7 @@ public class Activity extends ContextThemeWrapper
        mCurrentConfig = config;

        mWindow.setColorMode(info.colorMode);
        mWindow.setPreferMinimalPostProcessing(info.preferMinimalPostProcessing);

        setAutofillOptions(application.getAutofillOptions());
        setContentCaptureOptions(application.getContentCaptureOptions());
+31 −0
Original line number Diff line number Diff line
@@ -289,6 +289,34 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
    @ColorMode
    public int colorMode = COLOR_MODE_DEFAULT;

    /**
     * Indicates whether the activity wants the connected display to do minimal post processing on
     * the produced image or video frames. This will only be requested if this activity's main
     * window is visible on the screen.
     *
     * <p>This setting should be used when low latency has a higher priority than image enhancement
     * processing (e.g. for games or video conferencing).
     *
     * <p>If the Display sink is connected via HDMI, the device will begin to send infoframes with
     * Auto Low Latency Mode enabled and Game Content Type. This will switch the connected display
     * to a minimal image processing mode (if available), which reduces latency, improving the user
     * experience for gaming or video conferencing applications. For more information, see HDMI 2.1
     * specification.
     *
     * <p>If the Display sink has an internal connection or uses some other protocol than HDMI,
     * effects may be similar but implementation-defined.
     *
     * <p>The ability to switch to a mode with minimal post proessing may be disabled by a user
     * setting in the system settings menu. In that case, this field is ignored and the display will
     * remain in its current mode.
     *
     * <p>Set from attribute {@link android.R.attr#preferMinimalPostProcessing}.
     *
     * @see android.view.WindowManager.LayoutParams#preferMinimalPostProcessing
     * @see android.view.Display#isMinimalPostProcessingSupported
     */
    public boolean preferMinimalPostProcessing = false;

    /**
     * Bit in {@link #flags} indicating whether this activity is able to
     * run in multiple processes.  If
@@ -1004,6 +1032,7 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
        requestedVrComponent = orig.requestedVrComponent;
        rotationAnimation = orig.rotationAnimation;
        colorMode = orig.colorMode;
        preferMinimalPostProcessing = orig.preferMinimalPostProcessing;
        maxAspectRatio = orig.maxAspectRatio;
        minAspectRatio = orig.minAspectRatio;
    }
@@ -1231,6 +1260,7 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
        dest.writeInt(colorMode);
        dest.writeFloat(maxAspectRatio);
        dest.writeFloat(minAspectRatio);
        dest.writeBoolean(preferMinimalPostProcessing);
    }

    /**
@@ -1349,6 +1379,7 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
        colorMode = source.readInt();
        maxAspectRatio = source.readFloat();
        minAspectRatio = source.readFloat();
        preferMinimalPostProcessing = source.readBoolean();
    }

    /**
+4 −2
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import android.util.IntArray;
import android.util.SparseArray;
import android.view.Display;
import android.view.DisplayInfo;
import android.view.Surface;
import android.view.SurfaceControl;
import android.view.SurfaceControl.Transaction;

@@ -151,11 +150,14 @@ public abstract class DisplayManagerInternal {
     * has a preference.
     * @param requestedModeId The preferred mode id for the top-most visible window that has a
     * preference.
     * @param preferMinimalPostProcessing Whether there is a visible window on the screen that wants
     * minimal post processing.
     * @param inTraversal True if called from WindowManagerService during a window traversal
     * prior to call to performTraversalInTransactionFromWindowManager.
     */
    public abstract void setDisplayProperties(int displayId, boolean hasContent,
            float requestedRefreshRate, int requestedModeId, boolean inTraversal);
            float requestedRefreshRate, int requestedModeId, boolean preferMinimalPostProcessing,
            boolean inTraversal);

    /**
     * Applies an offset to the contents of a display, for example to avoid burn-in.
+26 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.Manifest.permission.CONFIGURE_DISPLAY_COLOR_MODE;
import android.annotation.IntDef;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SuppressLint;
import android.annotation.TestApi;
import android.annotation.UnsupportedAppUsage;
import android.app.KeyguardManager;
@@ -856,6 +857,31 @@ public final class Display {
        }
    }

    /**
     * <p> Returns true if the connected display can be switched into a mode with minimal
     * post processing. </p>
     *
     * <p> If the Display sink is connected via HDMI, this method will return true if the
     * display supports either Auto Low Latency Mode or Game Content Type.
     *
     * <p> If the Display sink has an internal connection or uses some other protocol than
     * HDMI, this method will return true if the sink can be switched into an
     * implementation-defined low latency image processing mode. </p>
     *
     * <p> The ability to switch to a mode with minimal post processing may be disabled
     * by a user setting in the system settings menu. In that case, this method returns
     * false. </p>
     *
     * @see android.view.Window#setPreferMinimalPostProcessing
     */
    @SuppressLint("VisiblySynchronized")
    public boolean isMinimalPostProcessingSupported() {
        synchronized (this) {
            updateDisplayInfoLocked();
            return mDisplayInfo.minimalPostProcessingSupported;
        }
    }

    /**
     * Request the display applies a color mode.
     * @hide
Loading