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

Commit 4a76e99c authored by Cairn Overturf's avatar Cairn Overturf Committed by Android (Google) Code Review
Browse files

Merge "Add border API to surface control" into main

parents 75bf7d5d be940c85
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Region;
import android.gui.BorderSettings;
import android.gui.DropInputMode;
import android.gui.StalledTransactionInfo;
import android.gui.TrustedOverlay;
@@ -261,6 +262,10 @@ public final class SurfaceControl implements Parcelable {
    private static native void nativeWriteTransactionToParcel(long nativeObject, Parcel out);
    private static native void nativeSetShadowRadius(long transactionObj, long nativeObject,
            float shadowRadius);

    private static native void nativeSetBorderSettings(long transactionObj, long nativeObject,
            Parcel settings);

    private static native void nativeSetGlobalShadowSettings(@Size(4) float[] ambientColor,
            @Size(4) float[] spotColor, float lightPosY, float lightPosZ, float lightRadius);
    private static native DisplayDecorationSupport nativeGetDisplayDecorationSupport(
@@ -4132,6 +4137,36 @@ public final class SurfaceControl implements Parcelable {
            return this;
        }

        /**
         * Sets the outline settings on this SurfaceControl. If a shadow radius is set,
         * the outline will be drawn after the shadow and before any buffers.
         * The outline will be drawn on the border (outside) of the rounded rectangle
         * that is used for shadow casting. I.e. for an opaque layer,
         * the outline begins where shadow is visible.
         *
         * @hide
         */
        public Transaction setBorderSettings(SurfaceControl sc,
                @NonNull BorderSettings settings) {
            checkPreconditions(sc);
            if (SurfaceControlRegistry.sCallStackDebuggingEnabled) {
                SurfaceControlRegistry.getProcessInstance().checkCallStackDebugging(
                        "setBorderSettings", this, sc, "settings=" + settings);
            }

            if (!Flags.enableBorderSettings()) {
                Log.w(TAG, "setBorderSettings was called but"
                            + "enable_border_settings flag is disabled");
                return this;
            }

            Parcel settingsParcel = Parcel.obtain();
            settings.writeToParcel(settingsParcel, 0);
            settingsParcel.setDataPosition(0);
            nativeSetBorderSettings(mNativeObject, sc.mNativeObject, settingsParcel);
            return this;
        }

        /**
         * Sets the intended frame rate for this surface. Any switching of refresh rates is
         * most probably going to be seamless.
+8 −0
Original line number Diff line number Diff line
@@ -98,6 +98,14 @@ flag {
  is_fixed_read_only: true
} # ignore_corner_radius_and_shadows

flag {
  name: "enable_border_settings"
  namespace: "window_surfaces"
  description: "Enable SurfaceControl outline settings."
  bug: "367464660"
  is_fixed_read_only: true
}

flag {
    name: "jank_api"
    namespace: "window_surfaces"
+23 −0
Original line number Diff line number Diff line
@@ -1146,6 +1146,27 @@ static void nativeSetShadowRadius(JNIEnv* env, jclass clazz, jlong transactionOb
    transaction->setShadowRadius(ctrl, shadowRadius);
}

static void nativeSetBorderSettings(JNIEnv* env, jclass clazz, jlong transactionObj,
                                    jlong nativeObject, jobject settingsObj) {
    Parcel* settingsParcel = parcelForJavaObject(env, settingsObj);
    if (settingsParcel == NULL) {
        doThrowNPE(env);
        return;
    }
    gui::BorderSettings settings;
    status_t err = settings.readFromParcel(settingsParcel);
    if (err != NO_ERROR) {
        jniThrowException(env, "java/lang/IllegalArgumentException",
                          "BorderSettings parcel has wrong format");
        return;
    }

    auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
    const auto ctrl = reinterpret_cast<SurfaceControl*>(nativeObject);

    transaction->setBorderSettings(ctrl, settings);
}

static void nativeSetTrustedOverlay(JNIEnv* env, jclass clazz, jlong transactionObj,
                                    jlong nativeObject, jint trustedOverlay) {
    auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
@@ -2570,6 +2591,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
            (void*) nativeSetEdgeExtensionEffect },
    {"nativeSetShadowRadius", "(JJF)V",
            (void*)nativeSetShadowRadius },
    {"nativeSetBorderSettings", "(JJLandroid/os/Parcel;)V",
            (void*)nativeSetBorderSettings },
    {"nativeSetFrameRate", "(JJFII)V",
            (void*)nativeSetFrameRate },
    {"nativeSetDefaultFrameRateCompatibility", "(JJI)V",