Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_GFX_ANDROID_DEVICE_DISPLAY_INFO_H_ | 5 #ifndef UI_GFX_ANDROID_DEVICE_DISPLAY_INFO_H_ |
| 6 #define UI_GFX_ANDROID_DEVICE_DISPLAY_INFO_H_ | 6 #define UI_GFX_ANDROID_DEVICE_DISPLAY_INFO_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/android/jni_android.h" | |
| 11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 12 #include "ui/gfx/gfx_export.h" | 13 #include "ui/gfx/gfx_export.h" |
| 13 | 14 |
| 14 namespace gfx { | 15 namespace gfx { |
| 15 | 16 |
| 16 // Facilitates access to device information typically only | 17 // Facilitates access to device information typically only |
| 17 // available using the Android SDK, including Display properties. | 18 // available using the Android SDK, including Display properties. |
| 18 class GFX_EXPORT DeviceDisplayInfo { | 19 class GFX_EXPORT DeviceDisplayInfo { |
| 19 public: | 20 public: |
| 20 DeviceDisplayInfo(); | 21 DeviceDisplayInfo(); |
| 22 explicit DeviceDisplayInfo( | |
| 23 base::android::ScopedJavaLocalRef<jobject> context); | |
| 21 ~DeviceDisplayInfo(); | 24 ~DeviceDisplayInfo(); |
| 22 | 25 |
| 26 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.
| |
| 27 | |
| 23 // Returns display height in physical pixels. | 28 // Returns display height in physical pixels. |
| 24 int GetDisplayHeight(); | 29 int GetDisplayHeight() const; |
| 25 | 30 |
| 26 // Returns display width in physical pixels. | 31 // Returns display width in physical pixels. |
| 27 int GetDisplayWidth(); | 32 int GetDisplayWidth() const; |
| 28 | 33 |
| 29 // Returns real display height in physical pixels. | 34 // Returns real display height in physical pixels. |
| 30 // This version does not subtract window decorations etc. | 35 // This version does not subtract window decorations etc. |
| 31 // WARNING: This is only supported on JB-MR1 (sdk >= 17). Either | 36 // WARNING: This is only supported on JB-MR1 (sdk >= 17). Either |
| 32 // check the SDK-level, or check for '0' being returned. | 37 // check the SDK-level, or check for '0' being returned. |
| 33 int GetPhysicalDisplayHeight(); | 38 int GetPhysicalDisplayHeight() const; |
| 34 | 39 |
| 35 // Returns real display width in physical pixels. | 40 // Returns real display width in physical pixels. |
| 36 // This version does not subtract window decorations etc. | 41 // This version does not subtract window decorations etc. |
| 37 // WARNING: This is only supported on JB-MR1 (sdk >= 17). Either | 42 // WARNING: This is only supported on JB-MR1 (sdk >= 17). Either |
| 38 // check the SDK-level, or check for '0' being returned. | 43 // check the SDK-level, or check for '0' being returned. |
| 39 int GetPhysicalDisplayWidth(); | 44 int GetPhysicalDisplayWidth() const; |
| 40 | 45 |
| 41 // Returns number of bits per pixel. | 46 // Returns number of bits per pixel. |
| 42 int GetBitsPerPixel(); | 47 int GetBitsPerPixel() const; |
| 43 | 48 |
| 44 // Returns number of bits per component. | 49 // Returns number of bits per component. |
| 45 int GetBitsPerComponent(); | 50 int GetBitsPerComponent() const; |
| 46 | 51 |
| 47 // Returns a scaling factor for Density Independent Pixel unit | 52 // Returns a scaling factor for Density Independent Pixel unit |
| 48 // (1.0 is 160dpi, 0.75 is 120dpi, 2.0 is 320dpi). | 53 // (1.0 is 160dpi, 0.75 is 120dpi, 2.0 is 320dpi). |
| 49 double GetDIPScale(); | 54 double GetDIPScale() const; |
| 50 | 55 |
| 51 // Smallest possible screen size in density-independent pixels. | 56 // Smallest possible screen size in density-independent pixels. |
| 52 int GetSmallestDIPWidth(); | 57 int GetSmallestDIPWidth() const; |
| 53 | 58 |
| 54 // Returns the display rotation angle from its natural orientation. Expected | 59 // Returns the display rotation angle from its natural orientation. Expected |
| 55 // values are one of { 0, 90, 180, 270 }. | 60 // values are one of { 0, 90, 180, 270 }. |
| 56 // See DeviceDispayInfo.java for more information. | 61 // See DeviceDispayInfo.java for more information. |
| 57 int GetRotationDegrees(); | 62 int GetRotationDegrees() const; |
| 63 | |
| 64 // Registers methods with JNI and returns true if succeeded. | |
| 65 static bool RegisterDeviceDisplayInfo(JNIEnv* env); | |
| 66 | |
| 67 private: | |
| 68 void UpdateDisplayInfo(jint display_height, | |
| 69 jint display_width, | |
| 70 jint physical_display_height, | |
| 71 jint physical_display_width, | |
| 72 jint bits_per_pixel, | |
| 73 jint bits_per_component, | |
| 74 jdouble dip_scale, | |
| 75 jint smallest_dip_width, | |
| 76 jint rotation_degrees); | |
| 77 | |
| 78 base::android::ScopedJavaGlobalRef<jobject> j_device_info_; | |
| 79 | |
| 80 int display_height_; | |
| 81 int display_width_; | |
| 82 int physical_display_height_; | |
| 83 int physical_display_width_; | |
| 84 int bits_per_pixel_; | |
| 85 int bits_per_component_; | |
| 86 double dip_scale_; | |
| 87 int smallest_dip_width_; | |
| 88 int rotation_degrees_; | |
| 58 | 89 |
| 59 private: | 90 private: |
| 60 DISALLOW_COPY_AND_ASSIGN(DeviceDisplayInfo); | 91 DISALLOW_COPY_AND_ASSIGN(DeviceDisplayInfo); |
| 61 }; | 92 }; |
| 62 | 93 |
| 63 } // namespace gfx | 94 } // namespace gfx |
| 64 | 95 |
| 65 #endif // UI_GFX_ANDROID_DEVICE_DISPLAY_INFO_H_ | 96 #endif // UI_GFX_ANDROID_DEVICE_DISPLAY_INFO_H_ |
| OLD | NEW |