Loading core/java/android/view/SurfaceControl.java +78 −0 Original line number Diff line number Diff line Loading @@ -167,8 +167,14 @@ public final class SurfaceControl implements Parcelable { float l, float t, float r, float b); private static native void nativeSetCornerRadius(long transactionObj, long nativeObject, float cornerRadius); private static native void nativeSetCornerRadius( long transactionObj, long nativeObject, float topLeft, float topRight, float bottomLeft, float bottomRight); private static native void nativeSetClientDrawnCornerRadius(long transactionObj, long nativeObject, float clientDrawnCornerRadius); private static native void nativeSetClientDrawnCornerRadius( long transactionObj, long nativeObject, float topLeft, float topRight, float bottomLeft, float bottomRight); private static native void nativeSetBackgroundBlurRadius(long transactionObj, long nativeObject, int blurRadius); private static native void nativeSetBackgroundBlurScale(long transactionObj, long nativeObject, Loading Loading @@ -3804,6 +3810,43 @@ public final class SurfaceControl implements Parcelable { return this; } /** * Sets the corner radius for each corner of a {@link SurfaceControl}. This is applied to * the SurfaceControl and its children. The API expects a crop to be set on the * SurfaceControl to ensure that the corner radius is applied to the correct region. If the * crop does not intersect with the SurfaceControl's visible content, the corner radius will * not be applied. * * @param sc SurfaceControl * @hide */ @NonNull public Transaction setCornerRadius( SurfaceControl sc, float topLeft, float topRight, float bottomLeft, float bottomRight) { checkPreconditions(sc); if (SurfaceControlRegistry.sCallStackDebuggingEnabled) { SurfaceControlRegistry.getProcessInstance() .checkCallStackDebugging( "setCornerRadius", this, sc, "topLeft=" + topLeft + " , topRight=" + topRight + ", bottomLeft=" + bottomLeft + " , bottomRight=" + bottomRight); } if (!com.android.graphics.surfaceflinger.flags.Flags.setDistinctCornerRadii()) { Log.w(TAG, "setCornerRadius was called but" + "set_distinct_corner_radii flag is disabled"); return this; } nativeSetCornerRadius(mNativeObject, sc.mNativeObject, topLeft, topRight, bottomLeft, bottomRight); return this; } /** * Disables corner radius of a {@link SurfaceControl}. When the radius set by Loading Loading @@ -3835,6 +3878,41 @@ public final class SurfaceControl implements Parcelable { return this; } /** * Disables corner radius of a {@link SurfaceControl}. When the radius set by {@link * Transaction#setCornerRadius(SurfaceControl, float)} is equal to clientDrawnCornerRadius * the corner radius drawn by SurfaceFlinger is disabled. * * @hide */ @NonNull public Transaction setClientDrawnCornerRadius( @NonNull SurfaceControl sc, float topLeft, float topRight, float bottomLeft, float bottomRight) { checkPreconditions(sc); if (SurfaceControlRegistry.sCallStackDebuggingEnabled) { SurfaceControlRegistry.getProcessInstance() .checkCallStackDebugging( "setClientDrawnCornerRadius", this, sc, "topLeft=" + topLeft + " , topRight=" + topRight + ", bottomLeft=" + bottomLeft + " , bottomRight=" + bottomRight); } if (!com.android.graphics.surfaceflinger.flags.Flags.setDistinctCornerRadii()) { Log.w(TAG, "setCornerRadius was called but" + "set_distinct_corner_radii flag is disabled"); return this; } nativeSetClientDrawnCornerRadius(mNativeObject, sc.mNativeObject, topLeft, topRight, bottomLeft, bottomRight); return this; } /** * Sets the background blur radius of the {@link SurfaceControl}. * Loading core/jni/android_view_SurfaceControl.cpp +26 −2 Original line number Diff line number Diff line Loading @@ -1141,6 +1141,14 @@ static void nativeSetCornerRadius(JNIEnv* env, jclass clazz, jlong transactionOb transaction->setCornerRadius(ctrl, cornerRadius); } static void nativeSetCornerRadius(JNIEnv* env, jclass clazz, jlong transactionObj, jlong nativeObject, jfloat tl, jfloat tr, jfloat bl, jfloat br) { auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); auto ctrl = SpFromRawPtr<SurfaceControl>(nativeObject); transaction->setCornerRadius(ctrl, gui::CornerRadii(tl, tr, bl, br)); } static void nativeSetClientDrawnCornerRadius(JNIEnv* env, jclass clazz, jlong transactionObj, jlong nativeObject, jfloat clientDrawnCornerRadius) { auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); Loading @@ -1149,6 +1157,15 @@ static void nativeSetClientDrawnCornerRadius(JNIEnv* env, jclass clazz, jlong tr transaction->setClientDrawnCornerRadius(ctrl, clientDrawnCornerRadius); } static void nativeSetClientDrawnCornerRadius(JNIEnv* env, jclass clazz, jlong transactionObj, jlong nativeObject, jfloat tl, jfloat tr, jfloat bl, jfloat br) { auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); auto ctrl = SpFromRawPtr<SurfaceControl>(nativeObject); transaction->setClientDrawnCornerRadius(ctrl, gui::CornerRadii(tl, tr, bl, br)); } static void nativeSetBackgroundBlurRadius(JNIEnv* env, jclass clazz, jlong transactionObj, jlong nativeObject, jint blurRadius) { auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); Loading Loading @@ -2641,9 +2658,16 @@ static const JNINativeMethod sSurfaceControlMethods[] = { {"nativeSetCrop", "(JJFFFF)V", (void*)nativeSetCrop }, {"nativeSetCornerRadius", "(JJF)V", (void*)nativeSetCornerRadius }, (void*)(void (*)(JNIEnv*, jclass, jlong, jlong, jfloat))nativeSetCornerRadius }, {"nativeSetCornerRadius", "(JJFFFF)V", (void*)(void (*)(JNIEnv*, jclass, jlong, jlong, jfloat, jfloat, jfloat, jfloat))nativeSetCornerRadius }, {"nativeSetClientDrawnCornerRadius", "(JJF)V", (void*) nativeSetClientDrawnCornerRadius }, (void*)(void (*)(JNIEnv*, jclass, jlong, jlong, jfloat)) nativeSetClientDrawnCornerRadius }, {"nativeSetClientDrawnCornerRadius", "(JJFFFF)V", (void*)(void (*)(JNIEnv*, jclass, jlong, jlong, jfloat, jfloat, jfloat, jfloat)) nativeSetClientDrawnCornerRadius }, {"nativeSetBackgroundBlurRadius", "(JJI)V", (void*)nativeSetBackgroundBlurRadius }, {"nativeSetBackgroundBlurScale", "(JJF)V", Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/MultiDisplayDragMoveIndicatorSurfaceTest.kt +3 −1 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import org.junit.After import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.mockito.ArgumentMatchers.anyFloat import org.mockito.kotlin.any import org.mockito.kotlin.clearInvocations import org.mockito.kotlin.eq Loading Loading @@ -73,7 +74,8 @@ class MultiDisplayDragMoveIndicatorSurfaceTest : ShellTestCase() { whenever(mockTransaction.remove(any())).thenReturn(mockTransaction) whenever(mockTransaction.setCrop(any(), any())).thenReturn(mockTransaction) whenever(mockTransaction.setCornerRadius(any(), any())).thenReturn(mockTransaction) whenever(mockTransaction.setCornerRadius(any(), anyFloat())) .thenReturn(mockTransaction) whenever(mockTransaction.show(any())).thenReturn(mockTransaction) whenever(mockTransaction.hide(any())).thenReturn(mockTransaction) whenever(mockTransaction.setColor(any(), any())).thenReturn(mockTransaction) Loading Loading
core/java/android/view/SurfaceControl.java +78 −0 Original line number Diff line number Diff line Loading @@ -167,8 +167,14 @@ public final class SurfaceControl implements Parcelable { float l, float t, float r, float b); private static native void nativeSetCornerRadius(long transactionObj, long nativeObject, float cornerRadius); private static native void nativeSetCornerRadius( long transactionObj, long nativeObject, float topLeft, float topRight, float bottomLeft, float bottomRight); private static native void nativeSetClientDrawnCornerRadius(long transactionObj, long nativeObject, float clientDrawnCornerRadius); private static native void nativeSetClientDrawnCornerRadius( long transactionObj, long nativeObject, float topLeft, float topRight, float bottomLeft, float bottomRight); private static native void nativeSetBackgroundBlurRadius(long transactionObj, long nativeObject, int blurRadius); private static native void nativeSetBackgroundBlurScale(long transactionObj, long nativeObject, Loading Loading @@ -3804,6 +3810,43 @@ public final class SurfaceControl implements Parcelable { return this; } /** * Sets the corner radius for each corner of a {@link SurfaceControl}. This is applied to * the SurfaceControl and its children. The API expects a crop to be set on the * SurfaceControl to ensure that the corner radius is applied to the correct region. If the * crop does not intersect with the SurfaceControl's visible content, the corner radius will * not be applied. * * @param sc SurfaceControl * @hide */ @NonNull public Transaction setCornerRadius( SurfaceControl sc, float topLeft, float topRight, float bottomLeft, float bottomRight) { checkPreconditions(sc); if (SurfaceControlRegistry.sCallStackDebuggingEnabled) { SurfaceControlRegistry.getProcessInstance() .checkCallStackDebugging( "setCornerRadius", this, sc, "topLeft=" + topLeft + " , topRight=" + topRight + ", bottomLeft=" + bottomLeft + " , bottomRight=" + bottomRight); } if (!com.android.graphics.surfaceflinger.flags.Flags.setDistinctCornerRadii()) { Log.w(TAG, "setCornerRadius was called but" + "set_distinct_corner_radii flag is disabled"); return this; } nativeSetCornerRadius(mNativeObject, sc.mNativeObject, topLeft, topRight, bottomLeft, bottomRight); return this; } /** * Disables corner radius of a {@link SurfaceControl}. When the radius set by Loading Loading @@ -3835,6 +3878,41 @@ public final class SurfaceControl implements Parcelable { return this; } /** * Disables corner radius of a {@link SurfaceControl}. When the radius set by {@link * Transaction#setCornerRadius(SurfaceControl, float)} is equal to clientDrawnCornerRadius * the corner radius drawn by SurfaceFlinger is disabled. * * @hide */ @NonNull public Transaction setClientDrawnCornerRadius( @NonNull SurfaceControl sc, float topLeft, float topRight, float bottomLeft, float bottomRight) { checkPreconditions(sc); if (SurfaceControlRegistry.sCallStackDebuggingEnabled) { SurfaceControlRegistry.getProcessInstance() .checkCallStackDebugging( "setClientDrawnCornerRadius", this, sc, "topLeft=" + topLeft + " , topRight=" + topRight + ", bottomLeft=" + bottomLeft + " , bottomRight=" + bottomRight); } if (!com.android.graphics.surfaceflinger.flags.Flags.setDistinctCornerRadii()) { Log.w(TAG, "setCornerRadius was called but" + "set_distinct_corner_radii flag is disabled"); return this; } nativeSetClientDrawnCornerRadius(mNativeObject, sc.mNativeObject, topLeft, topRight, bottomLeft, bottomRight); return this; } /** * Sets the background blur radius of the {@link SurfaceControl}. * Loading
core/jni/android_view_SurfaceControl.cpp +26 −2 Original line number Diff line number Diff line Loading @@ -1141,6 +1141,14 @@ static void nativeSetCornerRadius(JNIEnv* env, jclass clazz, jlong transactionOb transaction->setCornerRadius(ctrl, cornerRadius); } static void nativeSetCornerRadius(JNIEnv* env, jclass clazz, jlong transactionObj, jlong nativeObject, jfloat tl, jfloat tr, jfloat bl, jfloat br) { auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); auto ctrl = SpFromRawPtr<SurfaceControl>(nativeObject); transaction->setCornerRadius(ctrl, gui::CornerRadii(tl, tr, bl, br)); } static void nativeSetClientDrawnCornerRadius(JNIEnv* env, jclass clazz, jlong transactionObj, jlong nativeObject, jfloat clientDrawnCornerRadius) { auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); Loading @@ -1149,6 +1157,15 @@ static void nativeSetClientDrawnCornerRadius(JNIEnv* env, jclass clazz, jlong tr transaction->setClientDrawnCornerRadius(ctrl, clientDrawnCornerRadius); } static void nativeSetClientDrawnCornerRadius(JNIEnv* env, jclass clazz, jlong transactionObj, jlong nativeObject, jfloat tl, jfloat tr, jfloat bl, jfloat br) { auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); auto ctrl = SpFromRawPtr<SurfaceControl>(nativeObject); transaction->setClientDrawnCornerRadius(ctrl, gui::CornerRadii(tl, tr, bl, br)); } static void nativeSetBackgroundBlurRadius(JNIEnv* env, jclass clazz, jlong transactionObj, jlong nativeObject, jint blurRadius) { auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); Loading Loading @@ -2641,9 +2658,16 @@ static const JNINativeMethod sSurfaceControlMethods[] = { {"nativeSetCrop", "(JJFFFF)V", (void*)nativeSetCrop }, {"nativeSetCornerRadius", "(JJF)V", (void*)nativeSetCornerRadius }, (void*)(void (*)(JNIEnv*, jclass, jlong, jlong, jfloat))nativeSetCornerRadius }, {"nativeSetCornerRadius", "(JJFFFF)V", (void*)(void (*)(JNIEnv*, jclass, jlong, jlong, jfloat, jfloat, jfloat, jfloat))nativeSetCornerRadius }, {"nativeSetClientDrawnCornerRadius", "(JJF)V", (void*) nativeSetClientDrawnCornerRadius }, (void*)(void (*)(JNIEnv*, jclass, jlong, jlong, jfloat)) nativeSetClientDrawnCornerRadius }, {"nativeSetClientDrawnCornerRadius", "(JJFFFF)V", (void*)(void (*)(JNIEnv*, jclass, jlong, jlong, jfloat, jfloat, jfloat, jfloat)) nativeSetClientDrawnCornerRadius }, {"nativeSetBackgroundBlurRadius", "(JJI)V", (void*)nativeSetBackgroundBlurRadius }, {"nativeSetBackgroundBlurScale", "(JJF)V", Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/MultiDisplayDragMoveIndicatorSurfaceTest.kt +3 −1 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import org.junit.After import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.mockito.ArgumentMatchers.anyFloat import org.mockito.kotlin.any import org.mockito.kotlin.clearInvocations import org.mockito.kotlin.eq Loading Loading @@ -73,7 +74,8 @@ class MultiDisplayDragMoveIndicatorSurfaceTest : ShellTestCase() { whenever(mockTransaction.remove(any())).thenReturn(mockTransaction) whenever(mockTransaction.setCrop(any(), any())).thenReturn(mockTransaction) whenever(mockTransaction.setCornerRadius(any(), any())).thenReturn(mockTransaction) whenever(mockTransaction.setCornerRadius(any(), anyFloat())) .thenReturn(mockTransaction) whenever(mockTransaction.show(any())).thenReturn(mockTransaction) whenever(mockTransaction.hide(any())).thenReturn(mockTransaction) whenever(mockTransaction.setColor(any(), any())).thenReturn(mockTransaction) Loading