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 #include "ui/gfx/android/device_display_info.h" | 5 #include "ui/gfx/android/device_display_info.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | |
8 #include "base/android/jni_string.h" | |
9 #include "base/logging.h" | 7 #include "base/logging.h" |
10 #include "jni/DeviceDisplayInfo_jni.h" | 8 #include "ui/gfx/android/shared_device_display_info.h" |
11 | |
12 using base::android::AttachCurrentThread; | |
13 using base::android::ScopedJavaLocalRef; | |
14 | 9 |
15 namespace gfx { | 10 namespace gfx { |
16 | 11 |
17 DeviceDisplayInfo::DeviceDisplayInfo() { | 12 DeviceDisplayInfo::DeviceDisplayInfo() { |
18 JNIEnv* env = AttachCurrentThread(); | |
19 j_device_info_.Reset(Java_DeviceDisplayInfo_create(env, | |
20 base::android::GetApplicationContext())); | |
21 } | 13 } |
22 | 14 |
23 DeviceDisplayInfo::~DeviceDisplayInfo() { | 15 DeviceDisplayInfo::~DeviceDisplayInfo() { |
24 } | 16 } |
25 | 17 |
26 int DeviceDisplayInfo::GetDisplayHeight() { | 18 int DeviceDisplayInfo::GetDisplayHeight() { |
27 JNIEnv* env = AttachCurrentThread(); | 19 return SharedDeviceDisplayInfo::GetInstance()->GetDisplayHeight(); |
28 jint result = | |
29 Java_DeviceDisplayInfo_getDisplayHeight(env, j_device_info_.obj()); | |
30 return static_cast<int>(result); | |
31 } | 20 } |
32 | 21 |
33 int DeviceDisplayInfo::GetDisplayWidth() { | 22 int DeviceDisplayInfo::GetDisplayWidth() { |
34 JNIEnv* env = AttachCurrentThread(); | 23 return SharedDeviceDisplayInfo::GetInstance()->GetDisplayWidth(); |
35 jint result = | |
36 Java_DeviceDisplayInfo_getDisplayWidth(env, j_device_info_.obj()); | |
37 return static_cast<int>(result); | |
38 } | 24 } |
39 | 25 |
40 int DeviceDisplayInfo::GetBitsPerPixel() { | 26 int DeviceDisplayInfo::GetBitsPerPixel() { |
41 JNIEnv* env = AttachCurrentThread(); | 27 return SharedDeviceDisplayInfo::GetInstance()->GetBitsPerPixel(); |
42 jint result = | |
43 Java_DeviceDisplayInfo_getBitsPerPixel(env, j_device_info_.obj()); | |
44 return static_cast<int>(result); | |
45 } | 28 } |
46 | 29 |
47 int DeviceDisplayInfo::GetBitsPerComponent() { | 30 int DeviceDisplayInfo::GetBitsPerComponent() { |
48 JNIEnv* env = AttachCurrentThread(); | 31 return SharedDeviceDisplayInfo::GetInstance()->GetBitsPerComponent(); |
49 jint result = | |
50 Java_DeviceDisplayInfo_getBitsPerComponent(env, j_device_info_.obj()); | |
51 return static_cast<int>(result); | |
52 } | 32 } |
53 | 33 |
54 double DeviceDisplayInfo::GetDIPScale() { | 34 double DeviceDisplayInfo::GetDIPScale() { |
55 JNIEnv* env = AttachCurrentThread(); | 35 return SharedDeviceDisplayInfo::GetInstance()->GetDIPScale(); |
56 jdouble result = | |
57 Java_DeviceDisplayInfo_getDIPScale(env, j_device_info_.obj()); | |
58 return static_cast<double>(result); | |
59 } | 36 } |
60 | 37 |
61 int DeviceDisplayInfo::GetSmallestDIPWidth() { | 38 int DeviceDisplayInfo::GetSmallestDIPWidth() { |
62 JNIEnv* env = AttachCurrentThread(); | 39 return SharedDeviceDisplayInfo::GetInstance()->GetSmallestDIPWidth(); |
63 jint result = | |
64 Java_DeviceDisplayInfo_getSmallestDIPWidth(env, j_device_info_.obj()); | |
65 return static_cast<int>(result); | |
66 } | |
67 | |
68 // static | |
69 bool DeviceDisplayInfo::RegisterDeviceDisplayInfo(JNIEnv* env) { | |
70 return RegisterNativesImpl(env); | |
71 } | 40 } |
72 | 41 |
73 } // namespace gfx | 42 } // namespace gfx |
OLD | NEW |