Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(653)

Unified Diff: ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java

Issue 2300463002: Add observers for DIP scale change. (Closed)
Patch Set: An attempt to fix tests compilation Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java
diff --git a/ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java b/ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java
index 44c599042ef3956501203b767b69873a743b6b4d..90fea20f34e14990c1fb25d2a00974c704501594 100644
--- a/ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java
+++ b/ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java
@@ -14,6 +14,7 @@ import android.view.Display;
import android.view.Surface;
import android.view.WindowManager;
+import org.chromium.base.CommandLine;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
@@ -32,6 +33,19 @@ public class DeviceDisplayInfo {
private Point mTempPoint = new Point();
private DisplayMetrics mTempMetrics = new DisplayMetrics();
+ private static float sForcedDIPScale = -1.0f;
+
+ private static boolean hasForcedDIPScale() {
+ if (sForcedDIPScale < 0) {
+ String forcedScaleAsString = CommandLine.getInstance().getSwitchValue(
+ DisplaySwitches.FORCE_DEVICE_SCALE_FACTOR);
+ sForcedDIPScale = forcedScaleAsString == null
+ ? 0.0f
+ : Math.abs(Float.valueOf(forcedScaleAsString));
boliu 2016/09/14 04:35:33 what if there are exceptions? and document the se
Tima Vaisburd 2016/09/15 00:05:04 Thanks, I missed that. Added try/catch for valueOf
+ }
+ return sForcedDIPScale > 0;
+ }
+
private DeviceDisplayInfo(Context context) {
mAppContext = context.getApplicationContext();
mWinManager = (WindowManager) mAppContext.getSystemService(Context.WINDOW_SERVICE);
@@ -144,6 +158,8 @@ public class DeviceDisplayInfo {
*/
@CalledByNative
public double getDIPScale() {
+ if (hasForcedDIPScale()) return sForcedDIPScale;
+
getDisplay().getMetrics(mTempMetrics);
return mTempMetrics.density;
}

Powered by Google App Engine
This is Rietveld 408576698