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

Commit 4e00a7a3 authored by Marzia Favaro's avatar Marzia Favaro Committed by Robin Lee
Browse files

EdgeExtension: Add SurfaceControl.Transaction API

Bug: 322036393
Test: atest TransitionAnimationTests
Flag: com.android.graphics.libgui.flags.edge_extension_shader
Change-Id: Ic4ede2185f97af433c8e523637f14aa9df4cb73f
parent bb012032
Loading
Loading
Loading
Loading
+16 −0
Original line number Original line Diff line number Diff line
@@ -164,6 +164,9 @@ public final class SurfaceControl implements Parcelable {
            float width, float height, float vecX, float vecY,
            float width, float height, float vecX, float vecY,
            float maxStretchAmountX, float maxStretchAmountY, float childRelativeLeft,
            float maxStretchAmountX, float maxStretchAmountY, float childRelativeLeft,
            float childRelativeTop, float childRelativeRight, float childRelativeBottom);
            float childRelativeTop, float childRelativeRight, float childRelativeBottom);
    private static native void nativeSetEdgeExtensionEffect(long transactionObj, long nativeObj,
                                                            boolean leftEdge, boolean rightEdge,
                                                            boolean topEdge, boolean bottomEdge);
    private static native void nativeSetTrustedOverlay(long transactionObj, long nativeObject,
    private static native void nativeSetTrustedOverlay(long transactionObj, long nativeObject,
            int isTrustedOverlay);
            int isTrustedOverlay);
    private static native void nativeSetDropInputMode(
    private static native void nativeSetDropInputMode(
@@ -3510,6 +3513,19 @@ public final class SurfaceControl implements Parcelable {
            return this;
            return this;
        }
        }


        /**
         * @hide
         */
        public Transaction setEdgeExtensionEffect(SurfaceControl sc, int edge) {
            checkPreconditions(sc);

            nativeSetEdgeExtensionEffect(
                    mNativeObject, sc.mNativeObject,
                    (edge & WindowInsets.Side.LEFT) != 0, (edge & WindowInsets.Side.RIGHT) != 0,
                    (edge & WindowInsets.Side.TOP) != 0, (edge & WindowInsets.Side.BOTTOM) != 0);
            return this;
        }

        /**
        /**
         * @hide
         * @hide
         */
         */
+17 −0
Original line number Original line Diff line number Diff line
@@ -22,6 +22,7 @@
#include <android/graphics/properties.h>
#include <android/graphics/properties.h>
#include <android/graphics/region.h>
#include <android/graphics/region.h>
#include <android/gui/BnWindowInfosReportedListener.h>
#include <android/gui/BnWindowInfosReportedListener.h>
#include <android/gui/EdgeExtensionParameters.h>
#include <android/gui/JankData.h>
#include <android/gui/JankData.h>
#include <android/hardware/display/IDeviceProductInfoConstants.h>
#include <android/hardware/display/IDeviceProductInfoConstants.h>
#include <android/os/IInputConstants.h>
#include <android/os/IInputConstants.h>
@@ -799,6 +800,20 @@ static void nativeSetStretchEffect(JNIEnv* env, jclass clazz, jlong transactionO
    transaction->setStretchEffect(ctrl, stretch);
    transaction->setStretchEffect(ctrl, stretch);
}
}


static void nativeSetEdgeExtensionEffect(JNIEnv* env, jclass clazz, jlong transactionObj,
                                         jlong nativeObj, jboolean leftEdge, jboolean rightEdge,
                                         jboolean topEdge, jboolean bottomEdge) {
    auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
    auto* const ctrl = reinterpret_cast<SurfaceControl*>(nativeObj);

    auto effect = gui::EdgeExtensionParameters();
    effect.extendLeft = leftEdge;
    effect.extendRight = rightEdge;
    effect.extendTop = topEdge;
    effect.extendBottom = bottomEdge;
    transaction->setEdgeExtensionEffect(ctrl, effect);
}

static void nativeSetFlags(JNIEnv* env, jclass clazz, jlong transactionObj,
static void nativeSetFlags(JNIEnv* env, jclass clazz, jlong transactionObj,
        jlong nativeObject, jint flags, jint mask) {
        jlong nativeObject, jint flags, jint mask) {
    auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
    auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
@@ -2340,6 +2355,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
            (void*)nativeSetBlurRegions },
            (void*)nativeSetBlurRegions },
    {"nativeSetStretchEffect", "(JJFFFFFFFFFF)V",
    {"nativeSetStretchEffect", "(JJFFFFFFFFFF)V",
            (void*) nativeSetStretchEffect },
            (void*) nativeSetStretchEffect },
    {"nativeSetEdgeExtensionEffect", "(JJZZZZ)V",
            (void*) nativeSetEdgeExtensionEffect },
    {"nativeSetShadowRadius", "(JJF)V",
    {"nativeSetShadowRadius", "(JJF)V",
            (void*)nativeSetShadowRadius },
            (void*)nativeSetShadowRadius },
    {"nativeSetFrameRate", "(JJFII)V",
    {"nativeSetFrameRate", "(JJFII)V",