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
3 // found in the LICENSE file.
5 #ifndef UI_GFX_ANDROID_SHARED_DEVICE_DISPLAY_INFO_H_
6 #define UI_GFX_ANDROID_SHARED_DEVICE_DISPLAY_INFO_H_
8 #include "base/android/scoped_java_ref.h"
9 #include "base/basictypes.h"
10 #include "base/memory/singleton.h"
11 #include "base/synchronization/lock.h"
15 // Facilitates access to device information typically only
16 // available using the Android SDK, including Display properties.
17 class SharedDeviceDisplayInfo
{
19 static SharedDeviceDisplayInfo
* GetInstance();
21 // See documentation in DeviceDisplayInfo.java
22 int GetDisplayHeight();
23 int GetDisplayWidth();
24 int GetPhysicalDisplayHeight();
25 int GetPhysicalDisplayWidth();
26 int GetBitsPerPixel();
27 int GetBitsPerComponent();
29 int GetSmallestDIPWidth();
30 int GetRotationDegrees();
32 // Registers methods with JNI and returns true if succeeded.
33 static bool RegisterSharedDeviceDisplayInfo(JNIEnv
* env
);
35 void InvokeUpdate(JNIEnv
* env
,
39 jint physical_display_height
,
40 jint physical_display_width
,
42 jint bits_per_component
,
44 jint smallest_dip_width
,
45 jint rotation_degrees
);
47 friend struct DefaultSingletonTraits
<SharedDeviceDisplayInfo
>;
49 SharedDeviceDisplayInfo();
50 ~SharedDeviceDisplayInfo();
51 void UpdateDisplayInfo(JNIEnv
* env
,
55 jint physical_display_height
,
56 jint physical_display_width
,
58 jint bits_per_component
,
60 jint smallest_dip_width
,
61 jint rotation_degrees
);
64 base::android::ScopedJavaGlobalRef
<jobject
> j_device_info_
;
68 int physical_display_height_
;
69 int physical_display_width_
;
71 int bits_per_component_
;
73 int smallest_dip_width_
;
74 int rotation_degrees_
;
76 DISALLOW_COPY_AND_ASSIGN(SharedDeviceDisplayInfo
);
81 #endif // UI_GFX_ANDROID_SHARED_DEVICE_DISPLAY_INFO_H_