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

Commit 056b3ee7 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: I5508bb9e5c138b0f2b42d8f8fab10e1915ba3cb6
parent cd87f72f
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -1062,6 +1062,7 @@ package android {
    field public static final int popupWindowStyle = 16842870; // 0x1010076
    field public static final int popupWindowStyle = 16842870; // 0x1010076
    field public static final int port = 16842793; // 0x1010029
    field public static final int port = 16842793; // 0x1010029
    field public static final int positiveButtonText = 16843253; // 0x10101f5
    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 preferenceCategoryStyle = 16842892; // 0x101008c
    field public static final int preferenceFragmentStyle = 16844038; // 0x1010506
    field public static final int preferenceFragmentStyle = 16844038; // 0x1010506
    field public static final int preferenceInformationStyle = 16842893; // 0x101008d
    field public static final int preferenceInformationStyle = 16842893; // 0x101008d
@@ -11189,6 +11190,7 @@ package android.content.pm {
    field public String parentActivityName;
    field public String parentActivityName;
    field public String permission;
    field public String permission;
    field public int persistableMode;
    field public int persistableMode;
    field public boolean preferMinimalPostProcessing;
    field public int screenOrientation;
    field public int screenOrientation;
    field public int softInputMode;
    field public int softInputMode;
    field public String targetActivity;
    field public String targetActivity;
@@ -49895,6 +49897,7 @@ package android.view {
    method @Deprecated public float[] getSupportedRefreshRates();
    method @Deprecated public float[] getSupportedRefreshRates();
    method @Deprecated public int getWidth();
    method @Deprecated public int getWidth();
    method public boolean isHdr();
    method public boolean isHdr();
    method public boolean isMinimalPostProcessingSupported();
    method public boolean isValid();
    method public boolean isValid();
    method public boolean isWideColorGamut();
    method public boolean isWideColorGamut();
    field public static final int DEFAULT_DISPLAY = 0; // 0x0
    field public static final int DEFAULT_DISPLAY = 0; // 0x0
@@ -52927,6 +52930,7 @@ package android.view {
    method public abstract void setNavigationBarColor(@ColorInt int);
    method public abstract void setNavigationBarColor(@ColorInt int);
    method public void setNavigationBarContrastEnforced(boolean);
    method public void setNavigationBarContrastEnforced(boolean);
    method public void setNavigationBarDividerColor(@ColorInt int);
    method public void setNavigationBarDividerColor(@ColorInt int);
    method public void setPreferMinimalPostProcessing(boolean);
    method public void setReenterTransition(android.transition.Transition);
    method public void setReenterTransition(android.transition.Transition);
    method public abstract void setResizingCaptionDrawable(android.graphics.drawable.Drawable);
    method public abstract void setResizingCaptionDrawable(android.graphics.drawable.Drawable);
    method public final void setRestrictedCaptionAreaListener(android.view.Window.OnRestrictedCaptionAreaChangedListener);
    method public final void setRestrictedCaptionAreaListener(android.view.Window.OnRestrictedCaptionAreaChangedListener);
@@ -53314,6 +53318,7 @@ package android.view {
    field public int layoutInDisplayCutoutMode;
    field public int layoutInDisplayCutoutMode;
    field @Deprecated public int memoryType;
    field @Deprecated public int memoryType;
    field public String packageName;
    field public String packageName;
    field public boolean preferMinimalPostProcessing;
    field public int preferredDisplayModeId;
    field public int preferredDisplayModeId;
    field @Deprecated public float preferredRefreshRate;
    field @Deprecated public float preferredRefreshRate;
    field public int rotationAnimation;
    field public int rotationAnimation;
+1 −0
Original line number Original line Diff line number Diff line
@@ -7871,6 +7871,7 @@ public class Activity extends ContextThemeWrapper
        mCurrentConfig = config;
        mCurrentConfig = config;


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


        setAutofillOptions(application.getAutofillOptions());
        setAutofillOptions(application.getAutofillOptions());
        setContentCaptureOptions(application.getContentCaptureOptions());
        setContentCaptureOptions(application.getContentCaptureOptions());
+31 −0
Original line number Original line Diff line number Diff line
@@ -289,6 +289,34 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
    @ColorMode
    @ColorMode
    public int colorMode = COLOR_MODE_DEFAULT;
    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
     * Bit in {@link #flags} indicating whether this activity is able to
     * run in multiple processes.  If
     * run in multiple processes.  If
@@ -1004,6 +1032,7 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
        requestedVrComponent = orig.requestedVrComponent;
        requestedVrComponent = orig.requestedVrComponent;
        rotationAnimation = orig.rotationAnimation;
        rotationAnimation = orig.rotationAnimation;
        colorMode = orig.colorMode;
        colorMode = orig.colorMode;
        preferMinimalPostProcessing = orig.preferMinimalPostProcessing;
        maxAspectRatio = orig.maxAspectRatio;
        maxAspectRatio = orig.maxAspectRatio;
        minAspectRatio = orig.minAspectRatio;
        minAspectRatio = orig.minAspectRatio;
    }
    }
@@ -1231,6 +1260,7 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
        dest.writeInt(colorMode);
        dest.writeInt(colorMode);
        dest.writeFloat(maxAspectRatio);
        dest.writeFloat(maxAspectRatio);
        dest.writeFloat(minAspectRatio);
        dest.writeFloat(minAspectRatio);
        dest.writeBoolean(preferMinimalPostProcessing);
    }
    }


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


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


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


    /**
    /**
     * Applies an offset to the contents of a display, for example to avoid burn-in.
     * Applies an offset to the contents of a display, for example to avoid burn-in.
+26 −0
Original line number Original line 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.IntDef;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.RequiresPermission;
import android.annotation.SuppressLint;
import android.annotation.TestApi;
import android.annotation.TestApi;
import android.app.KeyguardManager;
import android.app.KeyguardManager;
import android.compat.annotation.UnsupportedAppUsage;
import android.compat.annotation.UnsupportedAppUsage;
@@ -875,6 +876,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.
     * Request the display applies a color mode.
     * @hide
     * @hide
Loading