Loading core/java/android/view/SurfaceControl.java +34 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ import android.graphics.Point; import android.graphics.Rect; import android.graphics.Region; import android.gui.BorderSettings; import android.gui.BoxShadowSettings; import android.gui.DropInputMode; import android.gui.StalledTransactionInfo; import android.gui.TrustedOverlay; Loading Loading @@ -263,6 +264,9 @@ public final class SurfaceControl implements Parcelable { private static native void nativeSetShadowRadius(long transactionObj, long nativeObject, float shadowRadius); private static native void nativeSetBoxShadowSettings(long transactionObj, long nativeObject, Parcel settings); private static native void nativeSetBorderSettings(long transactionObj, long nativeObject, Parcel settings); Loading Loading @@ -4138,6 +4142,36 @@ public final class SurfaceControl implements Parcelable { "setShadowRadius", this, sc, "radius=" + shadowRadius); } nativeSetShadowRadius(mNativeObject, sc.mNativeObject, shadowRadius); return this; } /** * Sets the box shadow settings on this SurfaceControl. If any box shadows are set, * the box shadows will be immediately drawn after the elevation shadow and before * any outline. The box shadow will use the same bounds as elevation shadows. * * @hide */ public Transaction setBoxShadowSettings(SurfaceControl sc, @NonNull BoxShadowSettings settings) { checkPreconditions(sc); if (SurfaceControlRegistry.sCallStackDebuggingEnabled) { SurfaceControlRegistry.getProcessInstance().checkCallStackDebugging( "setBoxShadowSettings", this, sc, "settings=" + settings); } if (!Flags.enableBoxShadowSettings()) { Log.w(TAG, "setBoxShadowSettings was called but" + "enable_box_shadow_settings flag is disabled"); return this; } Parcel settingsParcel = Parcel.obtain(); settings.writeToParcel(settingsParcel, 0); settingsParcel.setDataPosition(0); nativeSetBoxShadowSettings(mNativeObject, sc.mNativeObject, settingsParcel); return this; } Loading core/java/android/window/flags/window_surfaces.aconfig +8 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,14 @@ flag { is_fixed_read_only: true } flag { name: "enable_box_shadow_settings" namespace: "window_surfaces" description: "Enable SurfaceControl box shadow 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 nativeSetBoxShadowSettings(JNIEnv* env, jclass clazz, jlong transactionObj, jlong nativeObject, jobject settingsObj) { Parcel* settingsParcel = parcelForJavaObject(env, settingsObj); if (settingsParcel == NULL) { doThrowNPE(env); return; } gui::BoxShadowSettings settings; status_t err = settings.readFromParcel(settingsParcel); if (err != NO_ERROR) { jniThrowException(env, "java/lang/IllegalArgumentException", "BoxShadowSettings parcel has wrong format"); return; } auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); const auto ctrl = reinterpret_cast<SurfaceControl*>(nativeObject); transaction->setBoxShadowSettings(ctrl, settings); } static void nativeSetBorderSettings(JNIEnv* env, jclass clazz, jlong transactionObj, jlong nativeObject, jobject settingsObj) { Parcel* settingsParcel = parcelForJavaObject(env, settingsObj); Loading Loading @@ -2591,6 +2612,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = { (void*) nativeSetEdgeExtensionEffect }, {"nativeSetShadowRadius", "(JJF)V", (void*)nativeSetShadowRadius }, {"nativeSetBoxShadowSettings", "(JJLandroid/os/Parcel;)V", (void*)nativeSetBoxShadowSettings }, {"nativeSetBorderSettings", "(JJLandroid/os/Parcel;)V", (void*)nativeSetBorderSettings }, {"nativeSetFrameRate", "(JJFII)V", Loading Loading
core/java/android/view/SurfaceControl.java +34 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ import android.graphics.Point; import android.graphics.Rect; import android.graphics.Region; import android.gui.BorderSettings; import android.gui.BoxShadowSettings; import android.gui.DropInputMode; import android.gui.StalledTransactionInfo; import android.gui.TrustedOverlay; Loading Loading @@ -263,6 +264,9 @@ public final class SurfaceControl implements Parcelable { private static native void nativeSetShadowRadius(long transactionObj, long nativeObject, float shadowRadius); private static native void nativeSetBoxShadowSettings(long transactionObj, long nativeObject, Parcel settings); private static native void nativeSetBorderSettings(long transactionObj, long nativeObject, Parcel settings); Loading Loading @@ -4138,6 +4142,36 @@ public final class SurfaceControl implements Parcelable { "setShadowRadius", this, sc, "radius=" + shadowRadius); } nativeSetShadowRadius(mNativeObject, sc.mNativeObject, shadowRadius); return this; } /** * Sets the box shadow settings on this SurfaceControl. If any box shadows are set, * the box shadows will be immediately drawn after the elevation shadow and before * any outline. The box shadow will use the same bounds as elevation shadows. * * @hide */ public Transaction setBoxShadowSettings(SurfaceControl sc, @NonNull BoxShadowSettings settings) { checkPreconditions(sc); if (SurfaceControlRegistry.sCallStackDebuggingEnabled) { SurfaceControlRegistry.getProcessInstance().checkCallStackDebugging( "setBoxShadowSettings", this, sc, "settings=" + settings); } if (!Flags.enableBoxShadowSettings()) { Log.w(TAG, "setBoxShadowSettings was called but" + "enable_box_shadow_settings flag is disabled"); return this; } Parcel settingsParcel = Parcel.obtain(); settings.writeToParcel(settingsParcel, 0); settingsParcel.setDataPosition(0); nativeSetBoxShadowSettings(mNativeObject, sc.mNativeObject, settingsParcel); return this; } Loading
core/java/android/window/flags/window_surfaces.aconfig +8 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,14 @@ flag { is_fixed_read_only: true } flag { name: "enable_box_shadow_settings" namespace: "window_surfaces" description: "Enable SurfaceControl box shadow 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 nativeSetBoxShadowSettings(JNIEnv* env, jclass clazz, jlong transactionObj, jlong nativeObject, jobject settingsObj) { Parcel* settingsParcel = parcelForJavaObject(env, settingsObj); if (settingsParcel == NULL) { doThrowNPE(env); return; } gui::BoxShadowSettings settings; status_t err = settings.readFromParcel(settingsParcel); if (err != NO_ERROR) { jniThrowException(env, "java/lang/IllegalArgumentException", "BoxShadowSettings parcel has wrong format"); return; } auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); const auto ctrl = reinterpret_cast<SurfaceControl*>(nativeObject); transaction->setBoxShadowSettings(ctrl, settings); } static void nativeSetBorderSettings(JNIEnv* env, jclass clazz, jlong transactionObj, jlong nativeObject, jobject settingsObj) { Parcel* settingsParcel = parcelForJavaObject(env, settingsObj); Loading Loading @@ -2591,6 +2612,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = { (void*) nativeSetEdgeExtensionEffect }, {"nativeSetShadowRadius", "(JJF)V", (void*)nativeSetShadowRadius }, {"nativeSetBoxShadowSettings", "(JJLandroid/os/Parcel;)V", (void*)nativeSetBoxShadowSettings }, {"nativeSetBorderSettings", "(JJLandroid/os/Parcel;)V", (void*)nativeSetBorderSettings }, {"nativeSetFrameRate", "(JJFII)V", Loading