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

Commit 1ed23da6 authored by Nader Jawad's avatar Nader Jawad Committed by Automerger Merge Worker
Browse files

Merge "Update hole punch logic in HWUI" into sc-dev am: 603d6127

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

Change-Id: I167528340051cf2bc5dc6598de9ca0bffcc0316c
parents 9f9e7add 603d6127
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -146,8 +146,9 @@ public final class SurfaceControl implements Parcelable {
    private static native void nativeSetBlurRegions(long transactionObj, long nativeObj,
            float[][] regions, int length);
    private static native void nativeSetStretchEffect(long transactionObj, long nativeObj,
            float left, float top, float right, float bottom, float vecX, float vecY,
            float maxStretchAmount);
            float width, float height, float vecX, float vecY,
            float maxStretchAmountX, float maxStretchAmountY, float childRelativeLeft,
            float childRelativeTop, float childRelativeRight, float childRelativeBottom);

    private static native boolean nativeClearContentFrameStats(long nativeObject);
    private static native boolean nativeGetContentFrameStats(long nativeObject, WindowContentFrameStats outStats);
@@ -3038,11 +3039,14 @@ public final class SurfaceControl implements Parcelable {
        /**
         * @hide
         */
        public Transaction setStretchEffect(SurfaceControl sc, float left, float top, float right,
                float bottom, float vecX, float vecY, float maxStretchAmount) {
        public Transaction setStretchEffect(SurfaceControl sc, float width, float height,
                float vecX, float vecY, float maxStretchAmountX,
                float maxStretchAmountY, float childRelativeLeft, float childRelativeTop, float childRelativeRight,
                float childRelativeBottom) {
            checkPreconditions(sc);
            nativeSetStretchEffect(mNativeObject, sc.mNativeObject, left, top, right, bottom,
                    vecX, vecY, maxStretchAmount);
            nativeSetStretchEffect(mNativeObject, sc.mNativeObject, width, height,
                    vecX, vecY, maxStretchAmountX, maxStretchAmountY, childRelativeLeft, childRelativeTop,
                    childRelativeRight, childRelativeBottom);
            return this;
        }

+7 −4
Original line number Diff line number Diff line
@@ -1471,10 +1471,13 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
        }

        @Override
        public void applyStretch(long frameNumber, float left, float top, float right,
                float bottom, float vecX, float vecY, float maxStretch) {
            mRtTransaction.setStretchEffect(mSurfaceControl, left, top, right, bottom, vecX, vecY,
                    maxStretch);
        public void applyStretch(long frameNumber, float width, float height,
                float vecX, float vecY, float maxStretchX, float maxStretchY,
                float childRelativeLeft, float childRelativeTop, float childRelativeRight,
                float childRelativeBottom) {
            mRtTransaction.setStretchEffect(mSurfaceControl, width, height, vecX, vecY,
                    maxStretchX, maxStretchY, childRelativeLeft, childRelativeTop,
                    childRelativeRight, childRelativeBottom);
            applyOrMergeTransaction(mRtTransaction, frameNumber);
        }

+4 −8
Original line number Diff line number Diff line
@@ -594,14 +594,10 @@ public class EdgeEffect {
            boolean hasValidVectors = Float.isFinite(vecX) && Float.isFinite(vecY);
            if (right > left && bottom > top && mWidth > 0 && mHeight > 0 && hasValidVectors) {
                renderNode.stretch(
                        left,
                        top,
                        right,
                        bottom,
                        vecX,
                        vecY,
                        mWidth,
                        mHeight
                        vecX, // horizontal stretch intensity
                        vecY, // vertical stretch intensity
                        mWidth, // max horizontal stretch in pixels
                        mHeight // max vertical stretch in pixels
                );
            }
        } else {
+18 −6
Original line number Diff line number Diff line
@@ -626,12 +626,24 @@ static void nativeSetBlurRegions(JNIEnv* env, jclass clazz, jlong transactionObj
}

static void nativeSetStretchEffect(JNIEnv* env, jclass clazz, jlong transactionObj,
                                   jlong nativeObject, jfloat left, jfloat top, jfloat right,
                                   jfloat bottom, jfloat vecX, jfloat vecY,
                                   jfloat maxStretchAmount) {
                                   jlong nativeObject, jfloat width, jfloat height,
                                   jfloat vecX, jfloat vecY,
                                   jfloat maxStretchAmountX, jfloat maxStretchAmountY,
                                   jfloat childRelativeLeft, jfloat childRelativeTop,
                                   jfloat childRelativeRight, jfloat childRelativeBottom) {
    auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
    SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl*>(nativeObject);
    transaction->setStretchEffect(ctrl, left, top, right, bottom, vecX, vecY, maxStretchAmount);
    auto* const ctrl = reinterpret_cast<SurfaceControl*>(nativeObject);
    auto stretch = StretchEffect{
      .width = width,
      .height = height,
      .vectorX = vecX,
      .vectorY = vecY,
      .maxAmountX = maxStretchAmountX,
      .maxAmountY = maxStretchAmountY,
      .mappedChildBounds = FloatRect(
          childRelativeLeft, childRelativeTop, childRelativeRight, childRelativeBottom)
    };
    transaction->setStretchEffect(ctrl, stretch);
}

static void nativeSetSize(JNIEnv* env, jclass clazz, jlong transactionObj,
@@ -1829,7 +1841,7 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
            (void*)nativeSetLayerStack },
    {"nativeSetBlurRegions", "(JJ[[FI)V",
            (void*)nativeSetBlurRegions },
    {"nativeSetStretchEffect", "(JJFFFFFFF)V",
    {"nativeSetStretchEffect", "(JJFFFFFFFFFF)V",
            (void*) nativeSetStretchEffect },
    {"nativeSetShadowRadius", "(JJF)V",
            (void*)nativeSetShadowRadius },
+15 −18
Original line number Diff line number Diff line
@@ -280,8 +280,10 @@ public final class RenderNode {
         *
         * @hide
         */
        default void applyStretch(long frameNumber, float left, float top, float right,
                float bottom, float vecX, float vecY, float maxStretch) { }
        default void applyStretch(long frameNumber, float width, float height,
                float vecX, float vecY,
                float maxStretchX, float maxStretchY, float childRelativeLeft,
                float childRelativeTop, float childRelativeRight, float childRelativeBottom) { }

        /**
         * Called by native on RenderThread to notify that the view is no longer in the
@@ -326,10 +328,13 @@ public final class RenderNode {
        }

        @Override
        public void applyStretch(long frameNumber, float left, float top, float right, float bottom,
                float vecX, float vecY, float maxStretch) {
        public void applyStretch(long frameNumber, float width, float height,
                float vecX, float vecY, float maxStretchX, float maxStretchY, float childRelativeLeft,
                float childRelativeTop, float childRelativeRight, float childRelativeBottom) {
            for (PositionUpdateListener pul : mListeners) {
                pul.applyStretch(frameNumber, left, top, right, bottom, vecX, vecY, maxStretch);
                pul.applyStretch(frameNumber, width, height, vecX, vecY, maxStretchX,
                        maxStretchY, childRelativeLeft, childRelativeTop, childRelativeRight,
                        childRelativeBottom);
            }
        }
    }
@@ -719,19 +724,15 @@ public final class RenderNode {
    }

    /** @hide */
    public boolean stretch(float left, float top, float right, float bottom,
            float vecX, float vecY, float maxStretchAmountX, float maxStretchAmountY) {
    public boolean stretch(float vecX, float vecY,
        float maxStretchAmountX, float maxStretchAmountY) {
        if (Float.isInfinite(vecX) || Float.isNaN(vecX)) {
            throw new IllegalArgumentException("vecX must be a finite, non-NaN value " + vecX);
        }
        if (Float.isInfinite(vecY) || Float.isNaN(vecY)) {
            throw new IllegalArgumentException("vecY must be a finite, non-NaN value " + vecY);
        }
        if (top >= bottom || left >= right) {
            throw new IllegalArgumentException(
                    "Stretch region must not be empty, got "
                            + new RectF(left, top, right, bottom).toString());
        }

        if (maxStretchAmountX <= 0.0f) {
            throw new IllegalArgumentException(
                    "The max horizontal stretch amount must be >0, got " + maxStretchAmountX);
@@ -742,10 +743,6 @@ public final class RenderNode {
        }
        return nStretch(
                mNativeRenderNode,
                left,
                top,
                right,
                bottom,
                vecX,
                vecY,
                maxStretchAmountX,
@@ -1701,8 +1698,8 @@ public final class RenderNode {
    private static native boolean nClearStretch(long renderNode);

    @CriticalNative
    private static native boolean nStretch(long renderNode, float left, float top, float right,
            float bottom, float vecX, float vecY, float maxStretchX, float maxStretchY);
    private static native boolean nStretch(long renderNode, float vecX, float vecY,
            float maxStretchX, float maxStretchY);

    @CriticalNative
    private static native boolean nHasShadow(long renderNode);
Loading