Merge "Stack APPLICATION_MEDIA_OVERLAY windows with relative layering." into oc-dev

am: 9d5ac93cc3

Change-Id: I34c773700cb3dbb73803df1085034c3ac246943d
This commit is contained in:
Robert Carr
2017-04-13 07:22:01 +00:00
committed by android-build-merger
5 changed files with 50 additions and 32 deletions

View File

@@ -55,6 +55,8 @@ public class SurfaceControl {
private static native void nativeSetAnimationTransaction();
private static native void nativeSetLayer(long nativeObject, int zorder);
private static native void nativeSetRelativeLayer(long nativeObject, IBinder relativeTo,
int zorder);
private static native void nativeSetPosition(long nativeObject, float x, float y);
private static native void nativeSetGeometryAppliesWithResize(long nativeObject);
private static native void nativeSetSize(long nativeObject, int w, int h);
@@ -461,6 +463,11 @@ public class SurfaceControl {
nativeSetLayer(mNativeObject, zorder);
}
public void setRelativeLayer(IBinder relativeTo, int zorder) {
checkNotReleased();
nativeSetRelativeLayer(mNativeObject, relativeTo, zorder);
}
public void setPosition(float x, float y) {
checkNotReleased();
nativeSetPosition(mNativeObject, x, y);

View File

@@ -289,6 +289,14 @@ static void nativeSetLayer(JNIEnv* env, jclass clazz, jlong nativeObject, jint z
}
}
static void nativeSetRelativeLayer(JNIEnv* env, jclass clazz, jlong nativeObject,
jobject relativeTo, jint zorder) {
auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
sp<IBinder> handle = ibinderForJavaObject(env, relativeTo);
ctrl->setRelativeLayer(handle, zorder);
}
static void nativeSetPosition(JNIEnv* env, jclass clazz, jlong nativeObject, jfloat x, jfloat y) {
SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
status_t err = ctrl->setPosition(x, y);
@@ -774,6 +782,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
(void*)nativeSetAnimationTransaction },
{"nativeSetLayer", "(JI)V",
(void*)nativeSetLayer },
{"nativeSetRelativeLayer", "(JLandroid/os/IBinder;I)V",
(void*)nativeSetRelativeLayer },
{"nativeSetPosition", "(JFF)V",
(void*)nativeSetPosition },
{"nativeSetGeometryAppliesWithResize", "(J)V",

View File

@@ -50,6 +50,7 @@ import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_WILL_NOT_REPL
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER;
@@ -4411,4 +4412,14 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
nowGone = true;
}
}
boolean usesRelativeZOrdering() {
if (!isChildWindow()) {
return false;
} else if (mAttrs.type == TYPE_APPLICATION_MEDIA_OVERLAY) {
return true;
} else {
return false;
}
}
}

View File

@@ -714,7 +714,16 @@ class WindowStateAnimator {
}
// Start a new transaction and apply position & offset.
mSurfaceController.setPositionAndLayer(mTmpSize.left, mTmpSize.top, getLayerStack(), mAnimLayer);
mService.openSurfaceTransaction();
try {
mSurfaceController.setPositionInTransaction(mTmpSize.left, mTmpSize.top, false);
mSurfaceController.setLayerStackInTransaction(getLayerStack());
mSurfaceController.setLayer(mAnimLayer);
} finally {
mService.closeSurfaceTransaction();
}
mLastHidden = true;
if (WindowManagerService.localLOGV) Slog.v(TAG, "Created surface " + this);
@@ -1521,12 +1530,13 @@ class WindowStateAnimator {
+ "," + mDsDy + "*" + w.mVScale + "]", false);
boolean prepared =
mSurfaceController.prepareToShowInTransaction(mShownAlpha, mAnimLayer,
mSurfaceController.prepareToShowInTransaction(mShownAlpha,
mDsDx * w.mHScale * mExtraHScale,
mDtDx * w.mVScale * mExtraVScale,
mDtDy * w.mHScale * mExtraHScale,
mDsDy * w.mVScale * mExtraVScale,
recoveringMemory);
mSurfaceController.setLayer(mAnimLayer);
if (prepared && mLastHidden && mDrawState == HAS_DRAWN) {
if (showSurfaceRobustlyLocked()) {

View File

@@ -163,32 +163,6 @@ class WindowSurfaceController {
}
}
void setPositionAndLayer(float left, float top, int layerStack, int layer) {
mService.openSurfaceTransaction();
try {
mSurfaceX = left;
mSurfaceY = top;
try {
if (SHOW_TRANSACTIONS) logSurface(
"POS (setPositionAndLayer) @ (" + left + "," + top + ")", null);
mSurfaceControl.setPosition(left, top);
mSurfaceControl.setLayerStack(layerStack);
mSurfaceControl.setLayer(layer);
mSurfaceControl.setAlpha(0);
setShown(false);
} catch (RuntimeException e) {
Slog.w(TAG, "Error creating surface in " + this, e);
mAnimator.reclaimSomeSurfaceMemory("create-init", true);
}
} finally {
mService.closeSurfaceTransaction();
if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
"<<< CLOSE TRANSACTION setPositionAndLayer");
}
}
void destroyInTransaction() {
if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) {
Slog.i(TAG, "Destroying surface " + this + " called by " + Debug.getCallers(8));
@@ -269,7 +243,15 @@ class WindowSurfaceController {
if (mSurfaceControl != null) {
mService.openSurfaceTransaction();
try {
mSurfaceControl.setLayer(layer);
if (mAnimator.mWin.usesRelativeZOrdering()) {
mSurfaceControl.setRelativeLayer(
mAnimator.mWin.getParentWindow()
.mWinAnimator.mSurfaceController.mSurfaceControl.getHandle(),
-1);
} else {
mSurfaceLayer = layer;
mSurfaceControl.setLayer(layer);
}
} finally {
mService.closeSurfaceTransaction();
}
@@ -363,15 +345,13 @@ class WindowSurfaceController {
return false;
}
boolean prepareToShowInTransaction(float alpha, int layer,
boolean prepareToShowInTransaction(float alpha,
float dsdx, float dtdx, float dsdy,
float dtdy, boolean recoveringMemory) {
if (mSurfaceControl != null) {
try {
mSurfaceAlpha = alpha;
mSurfaceControl.setAlpha(alpha);
mSurfaceLayer = layer;
mSurfaceControl.setLayer(layer);
mLastDsdx = dsdx;
mLastDtdx = dtdx;
mLastDsdy = dsdy;