Loading core/java/android/view/SurfaceControl.java +35 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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( Loading Loading @@ -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. Loading core/java/android/window/flags/window_surfaces.aconfig +8 −0 Original line number Diff line number Diff line Loading @@ -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" Loading core/jni/android_view_SurfaceControl.cpp +23 −0 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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", Loading Loading
core/java/android/view/SurfaceControl.java +35 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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( Loading Loading @@ -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. Loading
core/java/android/window/flags/window_surfaces.aconfig +8 −0 Original line number Diff line number Diff line Loading @@ -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" Loading
core/jni/android_view_SurfaceControl.cpp +23 −0 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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", Loading