Loading core/java/android/view/SurfaceView.java +4 −3 Original line number Diff line number Diff line Loading @@ -327,8 +327,9 @@ public class SurfaceView extends View { mFormat = mRequestedFormat; mType = mRequestedType; mLayout.x = mLeft; mLayout.y = mTop; // Scaling window's layout here beause mLayout is not used elsewhere. mLayout.x = (int) (mLeft * mAppScale); mLayout.y = (int) (mTop * mAppScale); mLayout.width = (int) (getWidth() * mAppScale); mLayout.height = (int) (getHeight() * mAppScale); mLayout.format = mRequestedFormat; Loading core/java/android/view/ViewRoot.java +18 −5 Original line number Diff line number Diff line Loading @@ -123,9 +123,10 @@ public final class ViewRoot extends Handler implements ViewParent, int mHeight; Rect mDirty; // will be a graphics.Region soon boolean mIsAnimating; // TODO: change these to scaler class. float mAppScale; float mAppScaleInverted; // = 1.0f / mAppScale // TODO: change these to scalar class. private float mAppScale; private float mAppScaleInverted; // = 1.0f / mAppScale private int[] mWindowLayoutParamsBackup = null; final View.AttachInfo mAttachInfo; Loading Loading @@ -384,6 +385,9 @@ public final class ViewRoot extends Handler implements ViewParent, if (mView == null) { mView = view; mAppScale = mView.getContext().getApplicationScale(); if (mAppScale != 1.0f) { mWindowLayoutParamsBackup = new int[4]; } mAppScaleInverted = 1.0f / mAppScale; mWindowAttributes.copyFrom(attrs); mSoftInputMode = attrs.softInputMode; Loading Loading @@ -473,7 +477,6 @@ public final class ViewRoot extends Handler implements ViewParent, synchronized (this) { int oldSoftInputMode = mWindowAttributes.softInputMode; mWindowAttributes.copyFrom(attrs); mWindowAttributes.scale(mAppScale); if (newView) { mSoftInputMode = attrs.softInputMode; Loading Loading @@ -2320,12 +2323,22 @@ public final class ViewRoot extends Handler implements ViewParent, private int relayoutWindow(WindowManager.LayoutParams params, int viewVisibility, boolean insetsPending) throws RemoteException { boolean restore = false; if (params != null && mAppScale != 1.0f) { restore = true; params.scale(mAppScale, mWindowLayoutParamsBackup); } int relayoutResult = sWindowSession.relayout( mWindow, params, (int) (mView.mMeasuredWidth * mAppScale), (int) (mView.mMeasuredHeight * mAppScale), viewVisibility, insetsPending, mWinFrame, mPendingContentInsets, mPendingVisibleInsets, mSurface); if (restore) { params.restore(mWindowLayoutParamsBackup); } mPendingContentInsets.scale(mAppScaleInverted); mPendingVisibleInsets.scale(mAppScaleInverted); mWinFrame.scale(mAppScaleInverted); Loading core/java/android/view/WindowManager.java +25 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.view; import android.content.pm.ActivityInfo; import android.graphics.PixelFormat; import android.graphics.Rect; import android.os.IBinder; import android.os.Parcel; import android.os.Parcelable; Loading Loading @@ -954,19 +955,42 @@ public interface WindowManager extends ViewManager { return sb.toString(); } void scale(float scale) { /** * Scale the layout params' coordinates and size. * Returns the original info as a backup so that the caller can * restore the layout params; */ void scale(float scale, int[] backup) { if (scale != 1.0f) { backup[0] = x; backup[1] = y; x *= scale; y *= scale; if (width > 0) { backup[2] = width; width *= scale; } if (height > 0) { backup[3] = height; height *= scale; } } } /** * Restore the layout params' coordinates and size. */ void restore(int[] backup) { x = backup[0]; y = backup[1]; if (width > 0) { width = backup[2]; } if (height > 0) { height = backup[3]; } } private CharSequence mTitle = ""; } } Loading
core/java/android/view/SurfaceView.java +4 −3 Original line number Diff line number Diff line Loading @@ -327,8 +327,9 @@ public class SurfaceView extends View { mFormat = mRequestedFormat; mType = mRequestedType; mLayout.x = mLeft; mLayout.y = mTop; // Scaling window's layout here beause mLayout is not used elsewhere. mLayout.x = (int) (mLeft * mAppScale); mLayout.y = (int) (mTop * mAppScale); mLayout.width = (int) (getWidth() * mAppScale); mLayout.height = (int) (getHeight() * mAppScale); mLayout.format = mRequestedFormat; Loading
core/java/android/view/ViewRoot.java +18 −5 Original line number Diff line number Diff line Loading @@ -123,9 +123,10 @@ public final class ViewRoot extends Handler implements ViewParent, int mHeight; Rect mDirty; // will be a graphics.Region soon boolean mIsAnimating; // TODO: change these to scaler class. float mAppScale; float mAppScaleInverted; // = 1.0f / mAppScale // TODO: change these to scalar class. private float mAppScale; private float mAppScaleInverted; // = 1.0f / mAppScale private int[] mWindowLayoutParamsBackup = null; final View.AttachInfo mAttachInfo; Loading Loading @@ -384,6 +385,9 @@ public final class ViewRoot extends Handler implements ViewParent, if (mView == null) { mView = view; mAppScale = mView.getContext().getApplicationScale(); if (mAppScale != 1.0f) { mWindowLayoutParamsBackup = new int[4]; } mAppScaleInverted = 1.0f / mAppScale; mWindowAttributes.copyFrom(attrs); mSoftInputMode = attrs.softInputMode; Loading Loading @@ -473,7 +477,6 @@ public final class ViewRoot extends Handler implements ViewParent, synchronized (this) { int oldSoftInputMode = mWindowAttributes.softInputMode; mWindowAttributes.copyFrom(attrs); mWindowAttributes.scale(mAppScale); if (newView) { mSoftInputMode = attrs.softInputMode; Loading Loading @@ -2320,12 +2323,22 @@ public final class ViewRoot extends Handler implements ViewParent, private int relayoutWindow(WindowManager.LayoutParams params, int viewVisibility, boolean insetsPending) throws RemoteException { boolean restore = false; if (params != null && mAppScale != 1.0f) { restore = true; params.scale(mAppScale, mWindowLayoutParamsBackup); } int relayoutResult = sWindowSession.relayout( mWindow, params, (int) (mView.mMeasuredWidth * mAppScale), (int) (mView.mMeasuredHeight * mAppScale), viewVisibility, insetsPending, mWinFrame, mPendingContentInsets, mPendingVisibleInsets, mSurface); if (restore) { params.restore(mWindowLayoutParamsBackup); } mPendingContentInsets.scale(mAppScaleInverted); mPendingVisibleInsets.scale(mAppScaleInverted); mWinFrame.scale(mAppScaleInverted); Loading
core/java/android/view/WindowManager.java +25 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.view; import android.content.pm.ActivityInfo; import android.graphics.PixelFormat; import android.graphics.Rect; import android.os.IBinder; import android.os.Parcel; import android.os.Parcelable; Loading Loading @@ -954,19 +955,42 @@ public interface WindowManager extends ViewManager { return sb.toString(); } void scale(float scale) { /** * Scale the layout params' coordinates and size. * Returns the original info as a backup so that the caller can * restore the layout params; */ void scale(float scale, int[] backup) { if (scale != 1.0f) { backup[0] = x; backup[1] = y; x *= scale; y *= scale; if (width > 0) { backup[2] = width; width *= scale; } if (height > 0) { backup[3] = height; height *= scale; } } } /** * Restore the layout params' coordinates and size. */ void restore(int[] backup) { x = backup[0]; y = backup[1]; if (width > 0) { width = backup[2]; } if (height > 0) { height = backup[3]; } } private CharSequence mTitle = ""; } }