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

Commit cbf7ab09 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Update ColorFade to use BLAST" into sc-dev am: d943571a

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14441404

Change-Id: I5dd3ae357f6d72ffa398a964de8094eb89868d6d
parents d6d311d2 d943571a
Loading
Loading
Loading
Loading
+30 −11
Original line number Original line Diff line number Diff line
@@ -19,6 +19,8 @@ package com.android.server.display;
import static com.android.server.wm.utils.RotationAnimationUtils.hasProtectedContent;
import static com.android.server.wm.utils.RotationAnimationUtils.hasProtectedContent;


import android.content.Context;
import android.content.Context;
import android.graphics.BLASTBufferQueue;
import android.graphics.PixelFormat;
import android.graphics.SurfaceTexture;
import android.graphics.SurfaceTexture;
import android.hardware.display.DisplayManagerInternal;
import android.hardware.display.DisplayManagerInternal;
import android.hardware.display.DisplayManagerInternal.DisplayTransactionListener;
import android.hardware.display.DisplayManagerInternal.DisplayTransactionListener;
@@ -91,6 +93,7 @@ final class ColorFade {
    private int mDisplayHeight;     // real height, not rotated
    private int mDisplayHeight;     // real height, not rotated
    private SurfaceControl mSurfaceControl;
    private SurfaceControl mSurfaceControl;
    private Surface mSurface;
    private Surface mSurface;
    private BLASTBufferQueue mBLASTBufferQueue;
    private NaturalSurfaceLayout mSurfaceLayout;
    private NaturalSurfaceLayout mSurfaceLayout;
    private EGLDisplay mEglDisplay;
    private EGLDisplay mEglDisplay;
    private EGLConfig mEglConfig;
    private EGLConfig mEglConfig;
@@ -165,21 +168,30 @@ final class ColorFade {
                    "Failed to take screenshot because internal display is disconnected");
                    "Failed to take screenshot because internal display is disconnected");
            return false;
            return false;
        }
        }
        boolean isWideColor = SurfaceControl.getDynamicDisplayInfo(token).activeColorMode
        final boolean isWideColor = SurfaceControl.getDynamicDisplayInfo(token).activeColorMode
                == Display.COLOR_MODE_DISPLAY_P3;
                == Display.COLOR_MODE_DISPLAY_P3;


        // Set mPrepared here so if initialization fails, resources can be cleaned up.
        // Set mPrepared here so if initialization fails, resources can be cleaned up.
        mPrepared = true;
        mPrepared = true;


        SurfaceControl.ScreenshotHardwareBuffer hardwareBuffer = captureScreen();
        final SurfaceControl.ScreenshotHardwareBuffer hardwareBuffer = captureScreen();
        if (hardwareBuffer == null) {
        if (hardwareBuffer == null) {
            dismiss();
            dismiss();
            return false;
            return false;
        }
        }


        boolean isProtected = hasProtectedContent(hardwareBuffer.getHardwareBuffer());
        final boolean isProtected = hasProtectedContent(hardwareBuffer.getHardwareBuffer());
        if (!(createSurfaceControl(hardwareBuffer.containsSecureLayers())
        if (!createSurfaceControl(hardwareBuffer.containsSecureLayers())) {
                && createEglContext(isProtected) && createEglSurface(isProtected, isWideColor)
            dismiss();
            return false;
        }

        // MODE_FADE use ColorLayer to implement.
        if (mMode == MODE_FADE) {
            return true;
        }

        if (!(createEglContext(isProtected) && createEglSurface(isProtected, isWideColor)
                && setScreenshotTextureAndSetViewport(hardwareBuffer))) {
                && setScreenshotTextureAndSetViewport(hardwareBuffer))) {
            dismiss();
            dismiss();
            return false;
            return false;
@@ -564,7 +576,7 @@ final class ColorFade {
            if (mMode == MODE_FADE) {
            if (mMode == MODE_FADE) {
                builder.setColorLayer();
                builder.setColorLayer();
            } else {
            } else {
                builder.setBufferSize(mDisplayWidth, mDisplayHeight);
                builder.setBLASTLayer();
            }
            }
            mSurfaceControl = builder.build();
            mSurfaceControl = builder.build();
        } catch (OutOfResourcesException ex) {
        } catch (OutOfResourcesException ex) {
@@ -579,9 +591,11 @@ final class ColorFade {
        mSurfaceLayout.onDisplayTransaction(mTransaction);
        mSurfaceLayout.onDisplayTransaction(mTransaction);
        mTransaction.apply();
        mTransaction.apply();


        mSurface = new Surface();
        if (mMode != MODE_FADE) {
        mSurface.copyFrom(mSurfaceControl);
            mBLASTBufferQueue = new BLASTBufferQueue("ColorFade", mSurfaceControl,

                    mDisplayWidth, mDisplayHeight, PixelFormat.TRANSLUCENT);
            mSurface = mBLASTBufferQueue.createSurface();
        }
        return true;
        return true;
    }
    }


@@ -707,7 +721,12 @@ final class ColorFade {
            mSurfaceLayout.dispose();
            mSurfaceLayout.dispose();
            mSurfaceLayout = null;
            mSurfaceLayout = null;
            mTransaction.remove(mSurfaceControl).apply();
            mTransaction.remove(mSurfaceControl).apply();
            if (mSurface != null) {
                mSurface.release();
                mSurface.release();
                mBLASTBufferQueue.destroy();
                mSurface = null;
                mBLASTBufferQueue = null;
            }
            mSurfaceControl = null;
            mSurfaceControl = null;
            mSurfaceVisible = false;
            mSurfaceVisible = false;
            mSurfaceAlpha = 0f;
            mSurfaceAlpha = 0f;