summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Evan Laird <evanlaird@google.com> 2024-05-22 20:55:08 -0400
committer Evan Laird <evanlaird@google.com> 2024-05-28 19:54:37 +0000
commit1bd662453b41f64bcafdb125aae73782bdc40a4c (patch)
treedd67d1afd28badfba7acc8701f03b07c8c665401
parent939bd52b0f14d6a88c6a9cc78672f44c4ff08724 (diff)
Add pixel scaling to ScreenDecorationUtils
SreenDecorationUtils was querying rounded_corner_radius directly using static methods defined in RoundedCorners.java, and was not taking into consideration the potential for physical pixel scaling. This CL replicates the logic that exists in RoundedCorners.java and ScreenDecorations.java to implement similar scaling in the static getter. Test: manual Flag: NONE Bug: 335357341 Change-Id: I3ce403510b3ca35970685fc97a4fbcedaeb79151
-rw-r--r--core/java/com/android/internal/policy/ScreenDecorationsUtils.java23
1 files changed, 23 insertions, 0 deletions
diff --git a/core/java/com/android/internal/policy/ScreenDecorationsUtils.java b/core/java/com/android/internal/policy/ScreenDecorationsUtils.java
index ec6283922807..067e5e8813a7 100644
--- a/core/java/com/android/internal/policy/ScreenDecorationsUtils.java
+++ b/core/java/com/android/internal/policy/ScreenDecorationsUtils.java
@@ -18,6 +18,9 @@ package com.android.internal.policy;
import android.content.Context;
import android.content.res.Resources;
+import android.util.DisplayUtils;
+import android.view.Display;
+import android.view.DisplayInfo;
import android.view.RoundedCorners;
import com.android.internal.R;
@@ -57,11 +60,31 @@ public class ScreenDecorationsUtils {
bottomRadius = defaultRadius;
}
+ // If the physical pixels are scaled, apply it here
+ float scale = getPhysicalPixelDisplaySizeRatio(context);
+ if (scale != 1f) {
+ topRadius = topRadius * scale;
+ bottomRadius = bottomRadius * scale;
+ }
+
// Always use the smallest radius to make sure the rounded corners will
// completely cover the display.
return Math.min(topRadius, bottomRadius);
}
+ static float getPhysicalPixelDisplaySizeRatio(Context context) {
+ DisplayInfo displayInfo = new DisplayInfo();
+ context.getDisplay().getDisplayInfo(displayInfo);
+ final Display.Mode maxDisplayMode =
+ DisplayUtils.getMaximumResolutionDisplayMode(displayInfo.supportedModes);
+ if (maxDisplayMode == null) {
+ return 1f;
+ }
+ return DisplayUtils.getPhysicalPixelDisplaySizeRatio(
+ maxDisplayMode.getPhysicalWidth(), maxDisplayMode.getPhysicalHeight(),
+ displayInfo.getNaturalWidth(), displayInfo.getNaturalHeight());
+ }
+
/**
* If live rounded corners are supported on windows.
*/