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/scoped_java_ref.h" | 11 #include "base/android/scoped_java_ref.h" |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/memory/scoped_ptr.h" | |
|
Yaron
2013/10/10 11:52:46
You'll be able to remove by changing to LazyInstan
| |
| 13 #include "ui/gfx/gfx_export.h" | 14 #include "ui/gfx/gfx_export.h" |
| 14 | 15 |
| 15 namespace gfx { | 16 namespace gfx { |
| 16 | 17 |
| 17 // Facilitates access to device information typically only | 18 // Facilitates access to device information typically only |
| 18 // available using the Android SDK, including Display properties. | 19 // available using the Android SDK, including Display properties. |
| 19 class GFX_EXPORT DeviceDisplayInfo { | 20 class GFX_EXPORT DeviceDisplayInfo { |
| 20 public: | 21 public: |
| 21 DeviceDisplayInfo(); | 22 DeviceDisplayInfo(); |
| 22 ~DeviceDisplayInfo(); | 23 ~DeviceDisplayInfo(); |
| 23 | 24 |
| 24 // Returns display height in physical pixels. | 25 // Returns display height in physical pixels. |
| 25 int GetDisplayHeight(); | 26 int GetDisplayHeight(); |
| 26 | 27 |
| 27 // Returns display width in physical pixels. | 28 // Returns display width in physical pixels. |
| 28 int GetDisplayWidth(); | 29 int GetDisplayWidth(); |
| 29 | 30 |
| 30 // Returns number of bits per pixel. | 31 // Returns number of bits per pixel. |
| 31 int GetBitsPerPixel(); | 32 int GetBitsPerPixel(); |
| 32 | 33 |
| 33 // Returns number of bits per component. | 34 // Returns number of bits per component. |
| 34 int GetBitsPerComponent(); | 35 int GetBitsPerComponent(); |
| 35 | 36 |
| 36 // Returns a scaling factor for Density Independent Pixel unit | 37 // Returns a scaling factor for Density Independent Pixel unit |
| 37 // (1.0 is 160dpi, 0.75 is 120dpi, 2.0 is 320dpi). | 38 // (1.0 is 160dpi, 0.75 is 120dpi, 2.0 is 320dpi). |
| 38 double GetDIPScale(); | 39 double GetDIPScale(); |
| 39 | 40 |
| 41 private: | |
| 42 DISALLOW_COPY_AND_ASSIGN(DeviceDisplayInfo); | |
| 43 }; | |
| 44 | |
| 45 class GFX_EXPORT SharedDisplayInfo { | |
| 46 public: | |
| 47 static int GetDisplayHeight(); | |
| 48 static int GetDisplayWidth(); | |
| 49 static int GetBitsPerPixel(); | |
| 50 static int GetBitsPerComponent(); | |
| 51 static double GetDIPScale(); | |
| 52 | |
| 53 static void UpdateDisplayInfo(JNIEnv*, jobject, jint display_height, | |
| 54 jint display_width, jint bits_per_pixel, jint bits_per_component, | |
| 55 jdouble dip_scale); | |
| 56 | |
| 40 // Registers methods with JNI and returns true if succeeded. | 57 // Registers methods with JNI and returns true if succeeded. |
| 41 static bool RegisterDeviceDisplayInfo(JNIEnv* env); | 58 static bool RegisterSharedDeviceDisplayInfo(JNIEnv* env); |
| 42 | 59 |
| 43 private: | 60 private: |
| 61 static SharedDisplayInfo* Instance(); | |
| 62 SharedDisplayInfo(); | |
| 63 | |
| 64 void InvokeUpdate(); | |
|
Yaron
2013/10/10 11:52:46
never called
| |
| 65 void RegisterListener(); | |
| 66 | |
| 67 static scoped_ptr<SharedDisplayInfo> instance_; | |
| 68 | |
| 44 base::android::ScopedJavaGlobalRef<jobject> j_device_info_; | 69 base::android::ScopedJavaGlobalRef<jobject> j_device_info_; |
| 45 | 70 |
| 46 DISALLOW_COPY_AND_ASSIGN(DeviceDisplayInfo); | 71 int display_height_; |
| 72 int display_width_; | |
| 73 int bits_per_pixel_; | |
| 74 int bits_per_component_; | |
| 75 double dip_scale_; | |
| 47 }; | 76 }; |
| 48 | 77 |
| 78 | |
| 79 | |
| 49 } // namespace gfx | 80 } // namespace gfx |
| 50 | 81 |
| 51 #endif // UI_GFX_ANDROID_DEVICE_DISPLAY_INFO_H_ | 82 #endif // UI_GFX_ANDROID_DEVICE_DISPLAY_INFO_H_ |
| OLD | NEW |