Chromium Code Reviews| 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 088c9c2476e7f2781572be7a56e1482965716dd3..1a460b060d0a92e60d01e20d7e4f31be39f2baa3 100644 |
| --- a/ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java |
| +++ b/ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java |
| @@ -5,6 +5,8 @@ |
| package org.chromium.ui.gfx; |
| import android.content.Context; |
| +import android.content.ComponentCallbacks; |
| +import android.content.res.Configuration; |
| import android.graphics.PixelFormat; |
| import android.os.Build; |
| import android.util.DisplayMetrics; |
| @@ -36,7 +38,6 @@ public class DeviceDisplayInfo { |
| /** |
| * @return Display height in physical pixels. |
| */ |
| - @CalledByNative |
| public int getDisplayHeight() { |
| return getMetrics().heightPixels; |
| } |
| @@ -44,7 +45,6 @@ public class DeviceDisplayInfo { |
| /** |
| * @return Display width in physical pixels. |
| */ |
| - @CalledByNative |
| public int getDisplayWidth() { |
| return getMetrics().widthPixels; |
| } |
| @@ -61,7 +61,6 @@ public class DeviceDisplayInfo { |
| /** |
| * @return Bits per pixel. |
| */ |
| - @CalledByNative |
| public int getBitsPerPixel() { |
| int format = getPixelFormat(); |
| PixelFormat info = new PixelFormat(); |
| @@ -73,7 +72,6 @@ public class DeviceDisplayInfo { |
| * @return Bits per component. |
| */ |
| @SuppressWarnings("deprecation") |
| - @CalledByNative |
| public int getBitsPerComponent() { |
| int format = getPixelFormat(); |
| switch (format) { |
| @@ -110,11 +108,31 @@ public class DeviceDisplayInfo { |
| * @return A scaling factor for the Density Independent Pixel unit. |
| * 1.0 is 160dpi, 0.75 is 120dpi, 2.0 is 320dpi. |
| */ |
| - @CalledByNative |
| public double getDIPScale() { |
| return getMetrics().density; |
| } |
| + @CalledByNative |
| + public void registerListener() { |
| + mAppContext.registerComponentCallbacks( |
|
Yaron
2013/10/10 11:52:46
nit: indent 4 (also below)
|
| + new ComponentCallbacks() { |
| + @Override |
| + public void onConfigurationChanged(Configuration configuration) { |
| + updateNativeSharedDisplayInfo(); |
| + } |
|
Yaron
2013/10/10 11:52:46
nit: add linebreak below
|
| + @Override |
| + public void onLowMemory() { |
| + } |
| + }); |
| + |
| + updateNativeSharedDisplayInfo(); |
| + } |
| + |
| + private void updateNativeSharedDisplayInfo() { |
| + nativeUpdateSharedDisplayInfo(getDisplayHeight(), getDisplayWidth(), |
| + getBitsPerPixel(), getBitsPerComponent(), getDIPScale()); |
| + } |
| + |
| private Display getDisplay() { |
| return mWinManager.getDefaultDisplay(); |
| } |
| @@ -123,6 +141,7 @@ public class DeviceDisplayInfo { |
| return mAppContext.getResources().getDisplayMetrics(); |
| } |
| + |
| /** |
| * Creates DeviceDisplayInfo for a given Context. |
| * @param context A context to use. |
| @@ -132,4 +151,9 @@ public class DeviceDisplayInfo { |
| public static DeviceDisplayInfo create(Context context) { |
| return new DeviceDisplayInfo(context); |
| } |
| + |
| + private native void nativeUpdateSharedDisplayInfo(int display_height, |
|
Yaron
2013/10/10 11:52:46
java style should be displayHeight. Please update
|
| + int display_width, int bits_per_pixel, |
| + int bits_per_component, double dip_scale); |
| + |
| } |