OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_SHARED_DEVICE_DISPLAY_INFO_H_ | 5 #ifndef UI_GFX_ANDROID_SHARED_DEVICE_DISPLAY_INFO_H_ |
6 #define UI_GFX_ANDROID_SHARED_DEVICE_DISPLAY_INFO_H_ | 6 #define UI_GFX_ANDROID_SHARED_DEVICE_DISPLAY_INFO_H_ |
7 | 7 |
8 #include "base/android/scoped_java_ref.h" | 8 #include "base/android/scoped_java_ref.h" |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
11 #include "base/synchronization/lock.h" | 11 #include "base/synchronization/lock.h" |
12 | 12 |
13 namespace gfx { | 13 namespace gfx { |
14 | 14 |
15 // Facilitates access to device information typically only | 15 // Facilitates access to device information typically only |
16 // available using the Android SDK, including Display properties. | 16 // available using the Android SDK, including Display properties. |
17 class SharedDeviceDisplayInfo { | 17 class SharedDeviceDisplayInfo { |
18 public: | 18 public: |
19 static SharedDeviceDisplayInfo* GetInstance(); | 19 static SharedDeviceDisplayInfo* GetInstance(); |
20 | 20 |
21 int GetDisplayHeight(); | 21 int GetDisplayHeight(); |
22 int GetDisplayWidth(); | 22 int GetDisplayWidth(); |
23 int GetPhysicalDisplayHeight(); | |
bulach
2014/01/08 10:34:57
nit: since this is the effective API via GetInstan
| |
24 int GetPhysicalDisplayWidth(); | |
23 int GetBitsPerPixel(); | 25 int GetBitsPerPixel(); |
24 int GetBitsPerComponent(); | 26 int GetBitsPerComponent(); |
25 double GetDIPScale(); | 27 double GetDIPScale(); |
26 int GetSmallestDIPWidth(); | 28 int GetSmallestDIPWidth(); |
27 | 29 |
28 // Registers methods with JNI and returns true if succeeded. | 30 // Registers methods with JNI and returns true if succeeded. |
29 static bool RegisterSharedDeviceDisplayInfo(JNIEnv* env); | 31 static bool RegisterSharedDeviceDisplayInfo(JNIEnv* env); |
30 | 32 |
31 void InvokeUpdate(JNIEnv* env, | 33 void InvokeUpdate(JNIEnv* env, |
32 jobject jobj, | 34 jobject jobj, |
33 jint display_height, | 35 jint display_height, |
34 jint display_width, | 36 jint display_width, |
37 jint physical_display_height, | |
38 jint physical_display_width, | |
35 jint bits_per_pixel, | 39 jint bits_per_pixel, |
36 jint bits_per_component, | 40 jint bits_per_component, |
37 jdouble dip_scale, | 41 jdouble dip_scale, |
38 jint smallest_dip_width); | 42 jint smallest_dip_width); |
39 private: | 43 private: |
40 friend struct DefaultSingletonTraits<SharedDeviceDisplayInfo>; | 44 friend struct DefaultSingletonTraits<SharedDeviceDisplayInfo>; |
41 | 45 |
42 SharedDeviceDisplayInfo(); | 46 SharedDeviceDisplayInfo(); |
43 ~SharedDeviceDisplayInfo(); | 47 ~SharedDeviceDisplayInfo(); |
44 void UpdateDisplayInfo(JNIEnv* env, | 48 void UpdateDisplayInfo(JNIEnv* env, |
45 jobject jobj, | 49 jobject jobj, |
46 jint display_height, | 50 jint display_height, |
47 jint display_width, | 51 jint display_width, |
52 jint physical_display_height, | |
53 jint physical_display_width, | |
48 jint bits_per_pixel, | 54 jint bits_per_pixel, |
49 jint bits_per_component, | 55 jint bits_per_component, |
50 jdouble dip_scale, | 56 jdouble dip_scale, |
51 jint smallest_dip_width); | 57 jint smallest_dip_width); |
52 | 58 |
53 base::Lock lock_; | 59 base::Lock lock_; |
54 base::android::ScopedJavaGlobalRef<jobject> j_device_info_; | 60 base::android::ScopedJavaGlobalRef<jobject> j_device_info_; |
55 | 61 |
56 int display_height_; | 62 int display_height_; |
57 int display_width_; | 63 int display_width_; |
64 int physical_display_height_; | |
65 int physical_display_width_; | |
58 int bits_per_pixel_; | 66 int bits_per_pixel_; |
59 int bits_per_component_; | 67 int bits_per_component_; |
60 double dip_scale_; | 68 double dip_scale_; |
61 int smallest_dip_width_; | 69 int smallest_dip_width_; |
62 | 70 |
63 DISALLOW_COPY_AND_ASSIGN(SharedDeviceDisplayInfo); | 71 DISALLOW_COPY_AND_ASSIGN(SharedDeviceDisplayInfo); |
64 }; | 72 }; |
65 | 73 |
66 } // namespace gfx | 74 } // namespace gfx |
67 | 75 |
68 #endif // UI_GFX_ANDROID_SHARED_DEVICE_DISPLAY_INFO_H_ | 76 #endif // UI_GFX_ANDROID_SHARED_DEVICE_DISPLAY_INFO_H_ |
OLD | NEW |