ViewRootImpl: Pass buffer to finishDrawing when requested
As the final enabler for the BLASTSyncEngine, we add a new relayout result BLAST_SYNC. If the WindowState is participating in a BLAST sync during relayout we return it to the client. If we return it to the client the client will direct it's next draw in to a BLAST transaction and report that transaction via finishDrawing. You can now observe the BLASTSyncEngine working end to end in TaskOrganizerMultiWindowTests. We do a few small clean-ups in TaskOrganizerMultiWindowTest while we are there. Bug: 153561718 Test: TaskOrganizerMultiWindowTests Change-Id: I719b731350b942aafa444a33972aaef8973422ea
This commit is contained in:
@@ -3014,6 +3014,10 @@ public final class ViewRootImpl implements ViewParent,
|
||||
if ((relayoutResult & WindowManagerGlobal.RELAYOUT_RES_FIRST_TIME) != 0) {
|
||||
reportNextDraw();
|
||||
}
|
||||
if ((relayoutResult & WindowManagerGlobal.RELAYOUT_RES_BLAST_SYNC) != 0) {
|
||||
reportNextDraw();
|
||||
setUseBLASTSyncTransaction();
|
||||
}
|
||||
|
||||
boolean cancelDraw = mAttachInfo.mTreeObserver.dispatchOnPreDraw() || !isViewVisible;
|
||||
|
||||
@@ -3722,7 +3726,7 @@ public final class ViewRootImpl implements ViewParent,
|
||||
if (needFrameCompleteCallback) {
|
||||
final Handler handler = mAttachInfo.mHandler;
|
||||
mAttachInfo.mThreadedRenderer.setFrameCompleteCallback((long frameNr) -> {
|
||||
finishBLASTSync();
|
||||
finishBLASTSync(!reportNextDraw);
|
||||
handler.postAtFrontOfQueue(() -> {
|
||||
if (reportNextDraw) {
|
||||
// TODO: Use the frame number
|
||||
@@ -3756,7 +3760,7 @@ public final class ViewRootImpl implements ViewParent,
|
||||
if (usingAsyncReport && !canUseAsync) {
|
||||
mAttachInfo.mThreadedRenderer.setFrameCompleteCallback(null);
|
||||
usingAsyncReport = false;
|
||||
finishBLASTSync();
|
||||
finishBLASTSync(true /* apply */);
|
||||
}
|
||||
} finally {
|
||||
mIsDrawing = false;
|
||||
@@ -9572,10 +9576,15 @@ public final class ViewRootImpl implements ViewParent,
|
||||
mNextDrawUseBLASTSyncTransaction = true;
|
||||
}
|
||||
|
||||
private void finishBLASTSync() {
|
||||
private void finishBLASTSync(boolean apply) {
|
||||
if (mNextReportConsumeBLAST) {
|
||||
mNextReportConsumeBLAST = false;
|
||||
mRtBLASTSyncTransaction.apply();
|
||||
|
||||
if (apply) {
|
||||
mRtBLASTSyncTransaction.apply();
|
||||
} else {
|
||||
mSurfaceChangedTransaction.merge(mRtBLASTSyncTransaction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -101,6 +101,14 @@ public final class WindowManagerGlobal {
|
||||
*/
|
||||
public static final int RELAYOUT_RES_CONSUME_ALWAYS_SYSTEM_BARS = 0x40;
|
||||
|
||||
/**
|
||||
* This flag indicates the client should not directly submit it's next frame,
|
||||
* but instead should pass it in the postDrawTransaction of
|
||||
* {@link WindowManagerService#finishDrawing}. This is used by the WM
|
||||
* BLASTSyncEngine to synchronize rendering of multiple windows.
|
||||
*/
|
||||
public static final int RELAYOUT_RES_BLAST_SYNC = 0x80;
|
||||
|
||||
/**
|
||||
* Flag for relayout: the client will be later giving
|
||||
* internal insets; as a result, the window will not impact other window
|
||||
|
||||
@@ -2575,4 +2575,8 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
|
||||
|
||||
return willSync;
|
||||
}
|
||||
|
||||
boolean useBLASTSync() {
|
||||
return mUsingBLASTSyncTransaction;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,6 +72,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
|
||||
import static android.view.WindowManager.REMOVE_CONTENT_MODE_UNDEFINED;
|
||||
import static android.view.WindowManagerGlobal.ADD_OKAY;
|
||||
import static android.view.WindowManagerGlobal.RELAYOUT_DEFER_SURFACE_DESTROY;
|
||||
import static android.view.WindowManagerGlobal.RELAYOUT_RES_BLAST_SYNC;
|
||||
import static android.view.WindowManagerGlobal.RELAYOUT_RES_SURFACE_CHANGED;
|
||||
import static android.view.WindowManagerPolicyConstants.NAV_BAR_INVALID;
|
||||
|
||||
@@ -2106,6 +2107,10 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
win.finishSeamlessRotation(false /* timeout */);
|
||||
}
|
||||
|
||||
if (win.useBLASTSync()) {
|
||||
result |= RELAYOUT_RES_BLAST_SYNC;
|
||||
}
|
||||
|
||||
int attrChanges = 0;
|
||||
int flagChanges = 0;
|
||||
int privateFlagChanges = 0;
|
||||
|
||||
@@ -53,8 +53,9 @@ public class TaskOrganizerMultiWindowTest extends Activity {
|
||||
return true;
|
||||
}
|
||||
|
||||
float x = e.getX(0);
|
||||
float x = e.getRawX(0);
|
||||
float ratio = (float) x / (float) getWidth() ;
|
||||
ratio = 1-ratio;
|
||||
|
||||
LinearLayout.LayoutParams lp1 =
|
||||
new LinearLayout.LayoutParams(0,
|
||||
@@ -172,10 +173,14 @@ public class TaskOrganizerMultiWindowTest extends Activity {
|
||||
setContentView(splitView);
|
||||
}
|
||||
|
||||
private void addFlags(Intent intent) {
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||
}
|
||||
|
||||
Intent makeSettingsIntent() {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(android.provider.Settings.ACTION_SETTINGS);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
addFlags(intent);
|
||||
return intent;
|
||||
}
|
||||
|
||||
@@ -183,7 +188,7 @@ public class TaskOrganizerMultiWindowTest extends Activity {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_MAIN);
|
||||
intent.addCategory(Intent.CATEGORY_APP_CONTACTS);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
addFlags(intent);
|
||||
return intent;
|
||||
}
|
||||
|
||||
|
||||
@@ -80,8 +80,10 @@ class TaskView extends SurfaceView implements SurfaceHolder.Callback {
|
||||
} catch (Exception e) {
|
||||
// System server died.. oh well
|
||||
}
|
||||
|
||||
t.reparent(leash, getSurfaceControl())
|
||||
.setPosition(leash, 0, 0)
|
||||
.show(leash)
|
||||
.apply();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user