Merge "ViewRootImpl: Pass buffer to finishDrawing when requested" into rvc-dev am: 0a57530be1 am: afe03f9f46 am: f8664ea3d3

Change-Id: Ice0dbb3a053d48b2cb336d9e8e7a29b588dd4378
This commit is contained in:
Rob Carr
2020-04-09 21:36:21 +00:00
committed by Automerger Merge Worker
6 changed files with 40 additions and 7 deletions

View File

@@ -3017,6 +3017,10 @@ public final class ViewRootImpl implements ViewParent,
if ((relayoutResult & WindowManagerGlobal.RELAYOUT_RES_FIRST_TIME) != 0) { if ((relayoutResult & WindowManagerGlobal.RELAYOUT_RES_FIRST_TIME) != 0) {
reportNextDraw(); reportNextDraw();
} }
if ((relayoutResult & WindowManagerGlobal.RELAYOUT_RES_BLAST_SYNC) != 0) {
reportNextDraw();
setUseBLASTSyncTransaction();
}
boolean cancelDraw = mAttachInfo.mTreeObserver.dispatchOnPreDraw() || !isViewVisible; boolean cancelDraw = mAttachInfo.mTreeObserver.dispatchOnPreDraw() || !isViewVisible;
@@ -3725,7 +3729,7 @@ public final class ViewRootImpl implements ViewParent,
if (needFrameCompleteCallback) { if (needFrameCompleteCallback) {
final Handler handler = mAttachInfo.mHandler; final Handler handler = mAttachInfo.mHandler;
mAttachInfo.mThreadedRenderer.setFrameCompleteCallback((long frameNr) -> { mAttachInfo.mThreadedRenderer.setFrameCompleteCallback((long frameNr) -> {
finishBLASTSync(); finishBLASTSync(!reportNextDraw);
handler.postAtFrontOfQueue(() -> { handler.postAtFrontOfQueue(() -> {
if (reportNextDraw) { if (reportNextDraw) {
// TODO: Use the frame number // TODO: Use the frame number
@@ -3759,7 +3763,7 @@ public final class ViewRootImpl implements ViewParent,
if (usingAsyncReport && !canUseAsync) { if (usingAsyncReport && !canUseAsync) {
mAttachInfo.mThreadedRenderer.setFrameCompleteCallback(null); mAttachInfo.mThreadedRenderer.setFrameCompleteCallback(null);
usingAsyncReport = false; usingAsyncReport = false;
finishBLASTSync(); finishBLASTSync(true /* apply */);
} }
} finally { } finally {
mIsDrawing = false; mIsDrawing = false;
@@ -9576,10 +9580,15 @@ public final class ViewRootImpl implements ViewParent,
mNextDrawUseBLASTSyncTransaction = true; mNextDrawUseBLASTSyncTransaction = true;
} }
private void finishBLASTSync() { private void finishBLASTSync(boolean apply) {
if (mNextReportConsumeBLAST) { if (mNextReportConsumeBLAST) {
mNextReportConsumeBLAST = false; mNextReportConsumeBLAST = false;
mRtBLASTSyncTransaction.apply();
if (apply) {
mRtBLASTSyncTransaction.apply();
} else {
mSurfaceChangedTransaction.merge(mRtBLASTSyncTransaction);
}
} }
} }

View File

@@ -101,6 +101,14 @@ public final class WindowManagerGlobal {
*/ */
public static final int RELAYOUT_RES_CONSUME_ALWAYS_SYSTEM_BARS = 0x40; 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 * Flag for relayout: the client will be later giving
* internal insets; as a result, the window will not impact other window * internal insets; as a result, the window will not impact other window

View File

@@ -2577,4 +2577,8 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
return willSync; return willSync;
} }
boolean useBLASTSync() {
return mUsingBLASTSyncTransaction;
}
} }

View File

@@ -73,6 +73,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
import static android.view.WindowManager.REMOVE_CONTENT_MODE_UNDEFINED; import static android.view.WindowManager.REMOVE_CONTENT_MODE_UNDEFINED;
import static android.view.WindowManagerGlobal.ADD_OKAY; import static android.view.WindowManagerGlobal.ADD_OKAY;
import static android.view.WindowManagerGlobal.RELAYOUT_DEFER_SURFACE_DESTROY; 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.WindowManagerGlobal.RELAYOUT_RES_SURFACE_CHANGED;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_INVALID; import static android.view.WindowManagerPolicyConstants.NAV_BAR_INVALID;
@@ -2110,6 +2111,10 @@ public class WindowManagerService extends IWindowManager.Stub
win.finishSeamlessRotation(false /* timeout */); win.finishSeamlessRotation(false /* timeout */);
} }
if (win.useBLASTSync()) {
result |= RELAYOUT_RES_BLAST_SYNC;
}
int attrChanges = 0; int attrChanges = 0;
int flagChanges = 0; int flagChanges = 0;
int privateFlagChanges = 0; int privateFlagChanges = 0;

View File

@@ -53,8 +53,9 @@ public class TaskOrganizerMultiWindowTest extends Activity {
return true; return true;
} }
float x = e.getX(0); float x = e.getRawX(0);
float ratio = (float) x / (float) getWidth() ; float ratio = (float) x / (float) getWidth() ;
ratio = 1-ratio;
LinearLayout.LayoutParams lp1 = LinearLayout.LayoutParams lp1 =
new LinearLayout.LayoutParams(0, new LinearLayout.LayoutParams(0,
@@ -172,10 +173,14 @@ public class TaskOrganizerMultiWindowTest extends Activity {
setContentView(splitView); setContentView(splitView);
} }
private void addFlags(Intent intent) {
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION);
}
Intent makeSettingsIntent() { Intent makeSettingsIntent() {
Intent intent = new Intent(); Intent intent = new Intent();
intent.setAction(android.provider.Settings.ACTION_SETTINGS); intent.setAction(android.provider.Settings.ACTION_SETTINGS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); addFlags(intent);
return intent; return intent;
} }
@@ -183,7 +188,7 @@ public class TaskOrganizerMultiWindowTest extends Activity {
Intent intent = new Intent(); Intent intent = new Intent();
intent.setAction(Intent.ACTION_MAIN); intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_APP_CONTACTS); intent.addCategory(Intent.CATEGORY_APP_CONTACTS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); addFlags(intent);
return intent; return intent;
} }

View File

@@ -80,8 +80,10 @@ class TaskView extends SurfaceView implements SurfaceHolder.Callback {
} catch (Exception e) { } catch (Exception e) {
// System server died.. oh well // System server died.. oh well
} }
t.reparent(leash, getSurfaceControl()) t.reparent(leash, getSurfaceControl())
.setPosition(leash, 0, 0) .setPosition(leash, 0, 0)
.show(leash)
.apply(); .apply();
} }
} }