Chromium Code Reviews| Index: ui/gfx/android/device_display_info.h |
| diff --git a/ui/gfx/android/device_display_info.h b/ui/gfx/android/device_display_info.h |
| index 74e0ada487507f05d3a5f8f8a9e6374eebf39654..744146b0da19714ba7fd65d5b6fb42d73c18727e 100644 |
| --- a/ui/gfx/android/device_display_info.h |
| +++ b/ui/gfx/android/device_display_info.h |
| @@ -8,6 +8,7 @@ |
| #include <jni.h> |
| #include <string> |
| +#include "base/android/jni_android.h" |
| #include "base/basictypes.h" |
| #include "ui/gfx/gfx_export.h" |
| @@ -18,43 +19,73 @@ namespace gfx { |
| class GFX_EXPORT DeviceDisplayInfo { |
| public: |
| DeviceDisplayInfo(); |
| + explicit DeviceDisplayInfo( |
| + base::android::ScopedJavaLocalRef<jobject> context); |
| ~DeviceDisplayInfo(); |
| + void FetchDisplayInfoFromJava(JNIEnv* env); |
|
boliu
2015/07/15 06:38:47
private, also this should just be merged with Upda
gsennton
2015/07/15 19:26:21
Done.
|
| + |
| // Returns display height in physical pixels. |
| - int GetDisplayHeight(); |
| + int GetDisplayHeight() const; |
| // Returns display width in physical pixels. |
| - int GetDisplayWidth(); |
| + int GetDisplayWidth() const; |
| // Returns real display height in physical pixels. |
| // This version does not subtract window decorations etc. |
| // WARNING: This is only supported on JB-MR1 (sdk >= 17). Either |
| // check the SDK-level, or check for '0' being returned. |
| - int GetPhysicalDisplayHeight(); |
| + int GetPhysicalDisplayHeight() const; |
| // Returns real display width in physical pixels. |
| // This version does not subtract window decorations etc. |
| // WARNING: This is only supported on JB-MR1 (sdk >= 17). Either |
| // check the SDK-level, or check for '0' being returned. |
| - int GetPhysicalDisplayWidth(); |
| + int GetPhysicalDisplayWidth() const; |
| // Returns number of bits per pixel. |
| - int GetBitsPerPixel(); |
| + int GetBitsPerPixel() const; |
| // Returns number of bits per component. |
| - int GetBitsPerComponent(); |
| + int GetBitsPerComponent() const; |
| // Returns a scaling factor for Density Independent Pixel unit |
| // (1.0 is 160dpi, 0.75 is 120dpi, 2.0 is 320dpi). |
| - double GetDIPScale(); |
| + double GetDIPScale() const; |
| // Smallest possible screen size in density-independent pixels. |
| - int GetSmallestDIPWidth(); |
| + int GetSmallestDIPWidth() const; |
| // Returns the display rotation angle from its natural orientation. Expected |
| // values are one of { 0, 90, 180, 270 }. |
| // See DeviceDispayInfo.java for more information. |
| - int GetRotationDegrees(); |
| + int GetRotationDegrees() const; |
| + |
| + // Registers methods with JNI and returns true if succeeded. |
| + static bool RegisterDeviceDisplayInfo(JNIEnv* env); |
| + |
| + private: |
| + void UpdateDisplayInfo(jint display_height, |
| + jint display_width, |
| + jint physical_display_height, |
| + jint physical_display_width, |
| + jint bits_per_pixel, |
| + jint bits_per_component, |
| + jdouble dip_scale, |
| + jint smallest_dip_width, |
| + jint rotation_degrees); |
| + |
| + base::android::ScopedJavaGlobalRef<jobject> j_device_info_; |
| + |
| + int display_height_; |
| + int display_width_; |
| + int physical_display_height_; |
| + int physical_display_width_; |
| + int bits_per_pixel_; |
| + int bits_per_component_; |
| + double dip_scale_; |
| + int smallest_dip_width_; |
| + int rotation_degrees_; |
| private: |
| DISALLOW_COPY_AND_ASSIGN(DeviceDisplayInfo); |