Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ui/gfx/android/shared_device_display_info.h" | |
| 6 | |
| 7 #include "base/android/jni_android.h" | |
| 8 #include "base/android/jni_string.h" | |
| 9 #include "base/logging.h" | |
| 10 #include "jni/DeviceDisplayInfo_jni.h" | |
| 11 | |
| 12 using base::android::AttachCurrentThread; | |
|
Alexei Svitkine (slow)
2013/10/22 19:15:24
Nit: You only use this once below, just inline it.
ostap
2013/10/22 20:48:03
Done.
| |
| 13 using base::android::ScopedJavaLocalRef; | |
|
Alexei Svitkine (slow)
2013/10/22 19:15:24
Nit: You don't seem to be using this, remove it.
ostap
2013/10/22 20:48:03
Done.
| |
| 14 | |
| 15 namespace gfx { | |
|
Alexei Svitkine (slow)
2013/10/22 19:15:24
Nit: Add a blank line after this.
ostap
2013/10/22 20:48:03
Done.
| |
| 16 void UpdateSharedDeviceDisplayInfo(JNIEnv* env, | |
| 17 jobject obj, | |
| 18 jint display_height, | |
| 19 jint display_width, | |
| 20 jint bits_per_pixel, | |
| 21 jint bits_per_component, | |
| 22 jdouble dip_scale, | |
| 23 jint smallest_dip_width) { | |
| 24 SharedDeviceDisplayInfo::GetInstance()->InvokeUpdate(env, obj, | |
| 25 display_height, display_width, bits_per_pixel, bits_per_component, | |
| 26 dip_scale, smallest_dip_width); | |
| 27 } | |
| 28 | |
| 29 int SharedDeviceDisplayInfo::GetDisplayHeight() { | |
| 30 base::AutoLock(lock()); | |
| 31 return display_height_; | |
| 32 } | |
| 33 | |
| 34 int SharedDeviceDisplayInfo::GetDisplayWidth() { | |
| 35 base::AutoLock(lock()); | |
| 36 return display_width_; | |
| 37 } | |
| 38 | |
| 39 int SharedDeviceDisplayInfo::GetBitsPerPixel() { | |
| 40 base::AutoLock(lock()); | |
| 41 return bits_per_pixel_; | |
| 42 } | |
| 43 | |
| 44 int SharedDeviceDisplayInfo::GetBitsPerComponent() { | |
| 45 base::AutoLock(lock()); | |
| 46 return bits_per_component_; | |
| 47 } | |
| 48 | |
| 49 double SharedDeviceDisplayInfo::GetDIPScale() { | |
| 50 base::AutoLock(lock()); | |
| 51 return dip_scale_; | |
| 52 } | |
| 53 | |
| 54 int SharedDeviceDisplayInfo::GetSmallestDIPWidth() { | |
| 55 base::AutoLock(lock()); | |
| 56 return smallest_dip_width_; | |
| 57 } | |
| 58 | |
| 59 void SharedDeviceDisplayInfo::InvokeUpdate(JNIEnv* env, | |
| 60 jobject obj, | |
| 61 jint display_height, | |
| 62 jint display_width, | |
| 63 jint bits_per_pixel, | |
| 64 jint bits_per_component, | |
| 65 jdouble dip_scale, | |
| 66 jint smallest_dip_width) { | |
| 67 base::AutoLock(lock()); | |
| 68 | |
| 69 UpdateDisplayInfo(env, obj, display_height, | |
| 70 display_width, bits_per_pixel, bits_per_component, dip_scale, | |
| 71 smallest_dip_width); | |
| 72 } | |
| 73 | |
| 74 void SharedDeviceDisplayInfo::UpdateDisplayInfo(JNIEnv* env, | |
| 75 jobject jobj, | |
| 76 jint display_height, | |
| 77 jint display_width, | |
| 78 jint bits_per_pixel, | |
| 79 jint bits_per_component, | |
| 80 jdouble dip_scale, | |
| 81 jint smallest_dip_width) { | |
| 82 display_height_ = static_cast<int>(display_height); | |
| 83 display_width_ = static_cast<int>(display_width); | |
| 84 bits_per_pixel_ = static_cast<int>(bits_per_pixel); | |
| 85 bits_per_component_ = static_cast<int>(bits_per_component); | |
| 86 dip_scale_ = static_cast<double>(dip_scale); | |
| 87 smallest_dip_width_ = static_cast<int>(smallest_dip_width); | |
| 88 } | |
| 89 | |
| 90 SharedDeviceDisplayInfo* SharedDeviceDisplayInfo::GetInstance() { | |
|
Alexei Svitkine (slow)
2013/10/22 19:15:24
Order this consistently between .cc and .h file (i
ostap
2013/10/22 20:48:03
Done.
| |
| 91 return Singleton<SharedDeviceDisplayInfo>::get(); | |
| 92 } | |
| 93 | |
| 94 SharedDeviceDisplayInfo::SharedDeviceDisplayInfo() { | |
|
Alexei Svitkine (slow)
2013/10/22 19:15:24
Please init all the instance variables to default
ostap
2013/10/22 20:48:03
Done.
ostap
2013/10/22 20:48:03
Done.
| |
| 95 JNIEnv* env = AttachCurrentThread(); | |
| 96 j_device_info_.Reset( | |
| 97 Java_DeviceDisplayInfo_createWithListener(env, | |
| 98 base::android::GetApplicationContext())); | |
| 99 UpdateDisplayInfo(env, j_device_info_.obj(), | |
| 100 Java_DeviceDisplayInfo_getDisplayHeight(env, j_device_info_.obj()), | |
| 101 Java_DeviceDisplayInfo_getDisplayWidth(env, j_device_info_.obj()), | |
| 102 Java_DeviceDisplayInfo_getBitsPerPixel(env, j_device_info_.obj()), | |
| 103 Java_DeviceDisplayInfo_getBitsPerComponent(env, j_device_info_.obj()), | |
| 104 Java_DeviceDisplayInfo_getDIPScale(env, j_device_info_.obj()), | |
| 105 Java_DeviceDisplayInfo_getSmallestDIPWidth(env, j_device_info_.obj())); | |
| 106 } | |
| 107 | |
| 108 bool SharedDeviceDisplayInfo::RegisterSharedDeviceDisplayInfo(JNIEnv* env) { | |
| 109 return RegisterNativesImpl(env); | |
| 110 } | |
| 111 | |
| 112 } // namespace gfx | |
| OLD | NEW |