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

Commit c86b564b authored by Haofan Wang's avatar Haofan Wang Committed by Cherrypicker Worker
Browse files

Handle apply default picture profile for Tv Input[2/2]

Add a hide setPictureProfileHandle for TvView to use to send the picture
profile handle to the composer HAL.

Bug: 420934125
Test: Tested on Gambit and check the log. Discover that the handle is
correct and succrddfully send to the Composer HAL.
Flag: EXEMPT bugfix
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:c5ad75f9bbe9a38782335ef73de104eead25c1cc)
Merged-In: I42c00a27251108d8eb586bb866644be5e02aef58
Change-Id: I42c00a27251108d8eb586bb866644be5e02aef58
parent f794ef9e
Loading
Loading
Loading
Loading
+41 −3
Original line number Original line Diff line number Diff line
@@ -45,6 +45,7 @@ import android.graphics.RectF;
import android.graphics.Region;
import android.graphics.Region;
import android.graphics.RenderNode;
import android.graphics.RenderNode;
import android.hardware.input.InputManager;
import android.hardware.input.InputManager;
import android.media.quality.PictureProfileHandle;
import android.os.Build;
import android.os.Build;
import android.os.Handler;
import android.os.Handler;
import android.os.IBinder;
import android.os.IBinder;
@@ -210,6 +211,8 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
    private float mRequestedHdrHeadroom = 0.f;
    private float mRequestedHdrHeadroom = 0.f;
    private float mHdrHeadroom = 0.f;
    private float mHdrHeadroom = 0.f;


    private PictureProfileHandle mRequestedPictureProfileHandle = null;

    /**
    /**
     * We use this lock to protect access to mSurfaceControl. Both are accessed on the UI
     * We use this lock to protect access to mSurfaceControl. Both are accessed on the UI
     * thread and the render thread via RenderNode.PositionUpdateListener#positionLost.
     * thread and the render thread via RenderNode.PositionUpdateListener#positionLost.
@@ -1014,6 +1017,29 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
        invalidate();
        invalidate();
    }
    }


    /**
     * Sends the picture profile handle to the Composer HAL for application on the surface.
     * <p>
     * This method allows a system application to specify a picture profile handle.
     * The provided {@link PictureProfileHandle} will be propagated to the Composer HAL,
     * which is then responsible for applying the corresponding display adjustments.
     * <p>
     *
     * <p><b>Example Usage:</b></p>
     * This is used by TvView to apply a picture profile handle obtained for the current TV input.
     *
     * @param handle The non-null {@link PictureProfileHandle} to send to the layer.
     * @throws IllegalArgumentException if the provided handle is null.
     * @hide
     */
    public void sendPictureProfileHandle(PictureProfileHandle handle) {
        if (handle == null) {
            throw new IllegalArgumentException("PictureProfileHandle is null");
        }
        mRequestedPictureProfileHandle = handle;
        updateSurface();
    }

    private void updateOpaqueFlag() {
    private void updateOpaqueFlag() {
        if (!PixelFormat.formatHasAlpha(mRequestedFormat)) {
        if (!PixelFormat.formatHasAlpha(mRequestedFormat)) {
            mSurfaceFlags |= SurfaceControl.OPAQUE;
            mSurfaceFlags |= SurfaceControl.OPAQUE;
@@ -1094,7 +1120,8 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall


    private boolean performSurfaceTransaction(ViewRootImpl viewRoot, Translator translator,
    private boolean performSurfaceTransaction(ViewRootImpl viewRoot, Translator translator,
            boolean creating, boolean sizeChanged, boolean hintChanged, boolean relativeZChanged,
            boolean creating, boolean sizeChanged, boolean hintChanged, boolean relativeZChanged,
            boolean hdrHeadroomChanged, Transaction surfaceUpdateTransaction) {
            boolean hdrHeadroomChanged, PictureProfileHandle pictureProfileHandle,
            Transaction surfaceUpdateTransaction) {
        boolean realSizeChanged = false;
        boolean realSizeChanged = false;


        mSurfaceLock.lock();
        mSurfaceLock.lock();
@@ -1133,6 +1160,10 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
                surfaceUpdateTransaction.setDesiredHdrHeadroom(
                surfaceUpdateTransaction.setDesiredHdrHeadroom(
                        mBlastSurfaceControl, mHdrHeadroom);
                        mBlastSurfaceControl, mHdrHeadroom);
            }
            }
            if (pictureProfileHandle != null) {
                surfaceUpdateTransaction.setPictureProfileHandle(
                        mBlastSurfaceControl, pictureProfileHandle);
            }
            if (isAboveParent()) {
            if (isAboveParent()) {
                float alpha = getAlpha();
                float alpha = getAlpha();
                surfaceUpdateTransaction.setAlpha(mSurfaceControl, alpha);
                surfaceUpdateTransaction.setAlpha(mSurfaceControl, alpha);
@@ -1278,11 +1309,12 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
        final boolean surfaceLifecycleStrategyChanged =
        final boolean surfaceLifecycleStrategyChanged =
                mSurfaceLifecycleStrategy != mRequestedSurfaceLifecycleStrategy;
                mSurfaceLifecycleStrategy != mRequestedSurfaceLifecycleStrategy;
        final boolean hdrHeadroomChanged = mHdrHeadroom != mRequestedHdrHeadroom;
        final boolean hdrHeadroomChanged = mHdrHeadroom != mRequestedHdrHeadroom;
        final boolean pictureProfileChanged = mRequestedPictureProfileHandle != null;


        if (creating || formatChanged || sizeChanged || visibleChanged
        if (creating || formatChanged || sizeChanged || visibleChanged
                || alphaChanged || windowVisibleChanged || positionChanged
                || alphaChanged || windowVisibleChanged || positionChanged
                || layoutSizeChanged || hintChanged || relativeZChanged || !mAttachedToWindow
                || layoutSizeChanged || hintChanged || relativeZChanged || !mAttachedToWindow
                || surfaceLifecycleStrategyChanged || hdrHeadroomChanged) {
                || surfaceLifecycleStrategyChanged || hdrHeadroomChanged || pictureProfileChanged) {


            if (DEBUG) Log.i(TAG, System.identityHashCode(this) + " "
            if (DEBUG) Log.i(TAG, System.identityHashCode(this) + " "
                    + "Changes: creating=" + creating
                    + "Changes: creating=" + creating
@@ -1321,6 +1353,12 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
                mSurfaceLifecycleStrategy = mRequestedSurfaceLifecycleStrategy;
                mSurfaceLifecycleStrategy = mRequestedSurfaceLifecycleStrategy;
                mHdrHeadroom = mRequestedHdrHeadroom;
                mHdrHeadroom = mRequestedHdrHeadroom;


                // Picture profiles operate a bit differently. Since the picture profiles can also
                // be changed when queueing buffers, SurfaceView can't be the single source
                // of truth for the picture profile.
                PictureProfileHandle pictureProfileHandle = mRequestedPictureProfileHandle;
                mRequestedPictureProfileHandle = null;

                mScreenRect.left = mWindowSpaceLeft;
                mScreenRect.left = mWindowSpaceLeft;
                mScreenRect.top = mWindowSpaceTop;
                mScreenRect.top = mWindowSpaceTop;
                mScreenRect.right = mWindowSpaceLeft + getWidth();
                mScreenRect.right = mWindowSpaceLeft + getWidth();
@@ -1357,7 +1395,7 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall


                final boolean realSizeChanged = performSurfaceTransaction(viewRoot, translator,
                final boolean realSizeChanged = performSurfaceTransaction(viewRoot, translator,
                        creating, sizeChanged, hintChanged, relativeZChanged, hdrHeadroomChanged,
                        creating, sizeChanged, hintChanged, relativeZChanged, hdrHeadroomChanged,
                        surfaceUpdateTransaction);
                        pictureProfileHandle, surfaceUpdateTransaction);


                try {
                try {
                    SurfaceHolder.Callback[] callbacks = null;
                    SurfaceHolder.Callback[] callbacks = null;