Loading core/java/android/content/res/CompatibilityInfo.java +2 −2 Original line number Diff line number Diff line Loading @@ -342,8 +342,8 @@ public class CompatibilityInfo { public static void updateCompatibleScreenFrame(DisplayMetrics dm, int orientation, Rect outRect) { int width = dm.widthPixels; int portraitHeight = (int) (DEFAULT_PORTRAIT_HEIGHT * dm.density); int portraitWidth = (int) (DEFAULT_PORTRAIT_WIDTH * dm.density); int portraitHeight = (int) (DEFAULT_PORTRAIT_HEIGHT * dm.density + 0.5f); int portraitWidth = (int) (DEFAULT_PORTRAIT_WIDTH * dm.density + 0.5f); if (orientation == Configuration.ORIENTATION_LANDSCAPE) { int xOffset = (width - portraitHeight) / 2 ; outRect.set(xOffset, 0, xOffset + portraitHeight, portraitWidth); Loading core/java/android/util/DisplayMetrics.java +10 −6 Original line number Diff line number Diff line Loading @@ -136,15 +136,19 @@ public class DisplayMetrics { int defaultHeight; switch (orientation) { case Configuration.ORIENTATION_LANDSCAPE: { defaultWidth = (int)(CompatibilityInfo.DEFAULT_PORTRAIT_HEIGHT * density); defaultHeight = (int)(CompatibilityInfo.DEFAULT_PORTRAIT_WIDTH * density); defaultWidth = (int)(CompatibilityInfo.DEFAULT_PORTRAIT_HEIGHT * density + 0.5f); defaultHeight = (int)(CompatibilityInfo.DEFAULT_PORTRAIT_WIDTH * density + 0.5f); break; } case Configuration.ORIENTATION_PORTRAIT: case Configuration.ORIENTATION_SQUARE: default: { defaultWidth = (int)(CompatibilityInfo.DEFAULT_PORTRAIT_WIDTH * density); defaultHeight = (int)(CompatibilityInfo.DEFAULT_PORTRAIT_HEIGHT * density); defaultWidth = (int)(CompatibilityInfo.DEFAULT_PORTRAIT_WIDTH * density + 0.5f); defaultHeight = (int)(CompatibilityInfo.DEFAULT_PORTRAIT_HEIGHT * density + 0.5f); break; } case Configuration.ORIENTATION_UNDEFINED: { Loading Loading @@ -172,8 +176,8 @@ public class DisplayMetrics { scaledDensity *= invertedRatio; xdpi *= invertedRatio; ydpi *= invertedRatio; widthPixels *= invertedRatio; heightPixels *= invertedRatio; widthPixels = (int) (widthPixels * invertedRatio + 0.5f); heightPixels = (int) (heightPixels * invertedRatio + 0.5f); } } Loading core/java/android/view/SurfaceView.java +2 −2 Original line number Diff line number Diff line Loading @@ -310,8 +310,8 @@ public class SurfaceView extends View { // Use original size if the app specified the size of the view, // and let the flinger to scale up. if (mRequestedWidth <= 0 && mTranslator != null) { myWidth *= appScale; myHeight *= appScale; myWidth = (int) (myWidth * appScale + 0.5f); myHeight = (int) (myHeight * appScale + 0.5f); mScaled = true; } else { mScaled = false; Loading core/java/android/view/ViewRoot.java +7 −5 Original line number Diff line number Diff line Loading @@ -914,7 +914,8 @@ public final class ViewRoot extends Handler implements ViewParent, mHeight = frame.height(); if (initialized) { mGlCanvas.setViewport((int) (mWidth * appScale), (int) (mHeight * appScale)); mGlCanvas.setViewport((int) (mWidth * appScale + 0.5f), (int) (mHeight * appScale + 0.5f)); } boolean focusChangedDueToTouchMode = ensureTouchModeLocally( Loading Loading @@ -1244,7 +1245,7 @@ public final class ViewRoot extends Handler implements ViewParent, if (fullRedrawNeeded) { mAttachInfo.mIgnoreDirtyState = true; dirty.union(0, 0, (int) (mWidth * appScale), (int) (mHeight * appScale)); dirty.union(0, 0, (int) (mWidth * appScale + 0.5f), (int) (mHeight * appScale + 0.5f)); } if (DEBUG_ORIENTATION || DEBUG_DRAW) { Loading Loading @@ -1774,7 +1775,8 @@ public final class ViewRoot extends Handler implements ViewParent, if (mGlCanvas != null) { float appScale = mAttachInfo.mApplicationScale; mGlCanvas.setViewport( (int) (mWidth * appScale), (int) (mHeight * appScale)); (int) (mWidth * appScale + 0.5f), (int) (mHeight * appScale + 0.5f)); } } } Loading Loading @@ -2419,8 +2421,8 @@ public final class ViewRoot extends Handler implements ViewParent, } int relayoutResult = sWindowSession.relayout( mWindow, params, (int) (mView.mMeasuredWidth * appScale), (int) (mView.mMeasuredHeight * appScale), (int) (mView.mMeasuredWidth * appScale + 0.5f), (int) (mView.mMeasuredHeight * appScale + 0.5f), viewVisibility, insetsPending, mWinFrame, mPendingContentInsets, mPendingVisibleInsets, mSurface); if (restore) { Loading core/java/android/view/WindowManager.java +4 −4 Original line number Diff line number Diff line Loading @@ -991,13 +991,13 @@ public interface WindowManager extends ViewManager { * @hide */ public void scale(float scale) { x *= scale; y *= scale; x = (int) (x * scale + 0.5f); y = (int) (y * scale + 0.5f); if (width > 0) { width *= scale; width = (int) (width * scale + 0.5f); } if (height > 0) { height *= scale; height = (int) (height * scale + 0.5f); } } Loading Loading
core/java/android/content/res/CompatibilityInfo.java +2 −2 Original line number Diff line number Diff line Loading @@ -342,8 +342,8 @@ public class CompatibilityInfo { public static void updateCompatibleScreenFrame(DisplayMetrics dm, int orientation, Rect outRect) { int width = dm.widthPixels; int portraitHeight = (int) (DEFAULT_PORTRAIT_HEIGHT * dm.density); int portraitWidth = (int) (DEFAULT_PORTRAIT_WIDTH * dm.density); int portraitHeight = (int) (DEFAULT_PORTRAIT_HEIGHT * dm.density + 0.5f); int portraitWidth = (int) (DEFAULT_PORTRAIT_WIDTH * dm.density + 0.5f); if (orientation == Configuration.ORIENTATION_LANDSCAPE) { int xOffset = (width - portraitHeight) / 2 ; outRect.set(xOffset, 0, xOffset + portraitHeight, portraitWidth); Loading
core/java/android/util/DisplayMetrics.java +10 −6 Original line number Diff line number Diff line Loading @@ -136,15 +136,19 @@ public class DisplayMetrics { int defaultHeight; switch (orientation) { case Configuration.ORIENTATION_LANDSCAPE: { defaultWidth = (int)(CompatibilityInfo.DEFAULT_PORTRAIT_HEIGHT * density); defaultHeight = (int)(CompatibilityInfo.DEFAULT_PORTRAIT_WIDTH * density); defaultWidth = (int)(CompatibilityInfo.DEFAULT_PORTRAIT_HEIGHT * density + 0.5f); defaultHeight = (int)(CompatibilityInfo.DEFAULT_PORTRAIT_WIDTH * density + 0.5f); break; } case Configuration.ORIENTATION_PORTRAIT: case Configuration.ORIENTATION_SQUARE: default: { defaultWidth = (int)(CompatibilityInfo.DEFAULT_PORTRAIT_WIDTH * density); defaultHeight = (int)(CompatibilityInfo.DEFAULT_PORTRAIT_HEIGHT * density); defaultWidth = (int)(CompatibilityInfo.DEFAULT_PORTRAIT_WIDTH * density + 0.5f); defaultHeight = (int)(CompatibilityInfo.DEFAULT_PORTRAIT_HEIGHT * density + 0.5f); break; } case Configuration.ORIENTATION_UNDEFINED: { Loading Loading @@ -172,8 +176,8 @@ public class DisplayMetrics { scaledDensity *= invertedRatio; xdpi *= invertedRatio; ydpi *= invertedRatio; widthPixels *= invertedRatio; heightPixels *= invertedRatio; widthPixels = (int) (widthPixels * invertedRatio + 0.5f); heightPixels = (int) (heightPixels * invertedRatio + 0.5f); } } Loading
core/java/android/view/SurfaceView.java +2 −2 Original line number Diff line number Diff line Loading @@ -310,8 +310,8 @@ public class SurfaceView extends View { // Use original size if the app specified the size of the view, // and let the flinger to scale up. if (mRequestedWidth <= 0 && mTranslator != null) { myWidth *= appScale; myHeight *= appScale; myWidth = (int) (myWidth * appScale + 0.5f); myHeight = (int) (myHeight * appScale + 0.5f); mScaled = true; } else { mScaled = false; Loading
core/java/android/view/ViewRoot.java +7 −5 Original line number Diff line number Diff line Loading @@ -914,7 +914,8 @@ public final class ViewRoot extends Handler implements ViewParent, mHeight = frame.height(); if (initialized) { mGlCanvas.setViewport((int) (mWidth * appScale), (int) (mHeight * appScale)); mGlCanvas.setViewport((int) (mWidth * appScale + 0.5f), (int) (mHeight * appScale + 0.5f)); } boolean focusChangedDueToTouchMode = ensureTouchModeLocally( Loading Loading @@ -1244,7 +1245,7 @@ public final class ViewRoot extends Handler implements ViewParent, if (fullRedrawNeeded) { mAttachInfo.mIgnoreDirtyState = true; dirty.union(0, 0, (int) (mWidth * appScale), (int) (mHeight * appScale)); dirty.union(0, 0, (int) (mWidth * appScale + 0.5f), (int) (mHeight * appScale + 0.5f)); } if (DEBUG_ORIENTATION || DEBUG_DRAW) { Loading Loading @@ -1774,7 +1775,8 @@ public final class ViewRoot extends Handler implements ViewParent, if (mGlCanvas != null) { float appScale = mAttachInfo.mApplicationScale; mGlCanvas.setViewport( (int) (mWidth * appScale), (int) (mHeight * appScale)); (int) (mWidth * appScale + 0.5f), (int) (mHeight * appScale + 0.5f)); } } } Loading Loading @@ -2419,8 +2421,8 @@ public final class ViewRoot extends Handler implements ViewParent, } int relayoutResult = sWindowSession.relayout( mWindow, params, (int) (mView.mMeasuredWidth * appScale), (int) (mView.mMeasuredHeight * appScale), (int) (mView.mMeasuredWidth * appScale + 0.5f), (int) (mView.mMeasuredHeight * appScale + 0.5f), viewVisibility, insetsPending, mWinFrame, mPendingContentInsets, mPendingVisibleInsets, mSurface); if (restore) { Loading
core/java/android/view/WindowManager.java +4 −4 Original line number Diff line number Diff line Loading @@ -991,13 +991,13 @@ public interface WindowManager extends ViewManager { * @hide */ public void scale(float scale) { x *= scale; y *= scale; x = (int) (x * scale + 0.5f); y = (int) (y * scale + 0.5f); if (width > 0) { width *= scale; width = (int) (width * scale + 0.5f); } if (height > 0) { height *= scale; height = (int) (height * scale + 0.5f); } } Loading