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; |
} |