1 /* 2 * Copyright (C) 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package android.view; 17 18 import android.annotation.NonNull; 19 import android.annotation.Nullable; 20 import android.annotation.UiThread; 21 22 /** 23 * Provides an interface to the root-Surface of a View Hierarchy or Window. This 24 * is used in combination with the {@link android.view.SurfaceControl} API to enable 25 * attaching app created SurfaceControl to the SurfaceControl hierarchy used 26 * by the app, and enable SurfaceTransactions to be performed in sync with the 27 * View hierarchy drawing. 28 * 29 * This object is obtained from {@link android.view.View#getRootSurfaceControl} and 30 * {@link android.view.Window#getRootSurfaceControl}. It must be used from the UI thread of 31 * the object it was obtained from. 32 */ 33 @UiThread 34 public interface AttachedSurfaceControl { 35 /** 36 * Create a transaction which will reparent {@param child} to the View hierarchy 37 * root SurfaceControl. See 38 * {@link SurfaceControl.Transaction#reparent}. This transacton must be applied 39 * or merged in to another transaction by the caller, otherwise it will have 40 * no effect. 41 * 42 * @param child The SurfaceControl to reparent. 43 * @return A new transaction which performs the reparent operation when applied. 44 */ buildReparentTransaction(@onNull SurfaceControl child)45 @Nullable SurfaceControl.Transaction buildReparentTransaction(@NonNull SurfaceControl child); 46 47 /** 48 * Consume the passed in transaction, and request the View hierarchy to apply it atomically 49 * with the next draw. This transaction will be merged with the buffer transaction from the 50 * ViewRoot and they will show up on-screen atomically synced. 51 * 52 * This will not cause a draw to be scheduled, and if there are no other changes 53 * to the View hierarchy you may need to call {@link android.view.View#invalidate} 54 */ applyTransactionOnDraw(@onNull SurfaceControl.Transaction t)55 boolean applyTransactionOnDraw(@NonNull SurfaceControl.Transaction t); 56 } 57