| Index: ui/gfx/android/device_display_info.cc
|
| diff --git a/ui/gfx/android/device_display_info.cc b/ui/gfx/android/device_display_info.cc
|
| index 4d2c80c09d6c1d9c4c87102e0138901222943fb9..608dd17619db62e29f9ccce7408a718e10a848ee 100644
|
| --- a/ui/gfx/android/device_display_info.cc
|
| +++ b/ui/gfx/android/device_display_info.cc
|
| @@ -2,53 +2,103 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include "jni/DeviceDisplayInfo_jni.h"
|
| #include "ui/gfx/android/device_display_info.h"
|
|
|
| -#include "base/logging.h"
|
| -#include "ui/gfx/android/shared_device_display_info.h"
|
| -
|
| namespace gfx {
|
|
|
| +DeviceDisplayInfo::DeviceDisplayInfo(
|
| + base::android::ScopedJavaLocalRef<jobject> context) {
|
| + JNIEnv* env = base::android::AttachCurrentThread();
|
| + j_device_info_.Reset(
|
| + Java_DeviceDisplayInfo_create(env, context.obj()));
|
| + FetchDisplayInfoFromJava(env);
|
| +}
|
| +
|
| DeviceDisplayInfo::DeviceDisplayInfo() {
|
| + JNIEnv* env = base::android::AttachCurrentThread();
|
| + j_device_info_.Reset(
|
| + Java_DeviceDisplayInfo_create(env,
|
| + base::android::GetApplicationContext()));
|
| + FetchDisplayInfoFromJava(env);
|
| }
|
|
|
| DeviceDisplayInfo::~DeviceDisplayInfo() {
|
| }
|
|
|
| -int DeviceDisplayInfo::GetDisplayHeight() {
|
| - return SharedDeviceDisplayInfo::GetInstance()->GetDisplayHeight();
|
| +void DeviceDisplayInfo::FetchDisplayInfoFromJava(JNIEnv* env) {
|
| + UpdateDisplayInfo(
|
| + Java_DeviceDisplayInfo_getDisplayHeight(env, j_device_info_.obj()),
|
| + Java_DeviceDisplayInfo_getDisplayWidth(env, j_device_info_.obj()),
|
| + Java_DeviceDisplayInfo_getPhysicalDisplayHeight(env,
|
| + j_device_info_.obj()),
|
| + Java_DeviceDisplayInfo_getPhysicalDisplayWidth(env, j_device_info_.obj()),
|
| + Java_DeviceDisplayInfo_getBitsPerPixel(env, j_device_info_.obj()),
|
| + Java_DeviceDisplayInfo_getBitsPerComponent(env, j_device_info_.obj()),
|
| + Java_DeviceDisplayInfo_getDIPScale(env, j_device_info_.obj()),
|
| + Java_DeviceDisplayInfo_getSmallestDIPWidth(env, j_device_info_.obj()),
|
| + Java_DeviceDisplayInfo_getRotationDegrees(env, j_device_info_.obj()));
|
| +}
|
| +
|
| +void DeviceDisplayInfo::UpdateDisplayInfo(jint display_height,
|
| + jint display_width,
|
| + jint physical_display_height,
|
| + jint physical_display_width,
|
| + jint bits_per_pixel,
|
| + jint bits_per_component,
|
| + jdouble dip_scale,
|
| + jint smallest_dip_width,
|
| + jint rotation_degrees) {
|
| + display_height_ = static_cast<int>(display_height);
|
| + display_width_ = static_cast<int>(display_width);
|
| + physical_display_height_ = static_cast<int>(physical_display_height);
|
| + physical_display_width_ = static_cast<int>(physical_display_width);
|
| + bits_per_pixel_ = static_cast<int>(bits_per_pixel);
|
| + bits_per_component_ = static_cast<int>(bits_per_component);
|
| + dip_scale_ = static_cast<double>(dip_scale);
|
| + smallest_dip_width_ = static_cast<int>(smallest_dip_width);
|
| + rotation_degrees_ = static_cast<int>(rotation_degrees);
|
| +}
|
| +
|
| +int DeviceDisplayInfo::GetDisplayHeight() const {
|
| + return display_height_;
|
| +}
|
| +
|
| +int DeviceDisplayInfo::GetDisplayWidth() const {
|
| + return display_width_;
|
| }
|
|
|
| -int DeviceDisplayInfo::GetDisplayWidth() {
|
| - return SharedDeviceDisplayInfo::GetInstance()->GetDisplayWidth();
|
| +int DeviceDisplayInfo::GetPhysicalDisplayHeight() const {
|
| + return physical_display_height_;
|
| }
|
|
|
| -int DeviceDisplayInfo::GetPhysicalDisplayHeight() {
|
| - return SharedDeviceDisplayInfo::GetInstance()->GetPhysicalDisplayHeight();
|
| +int DeviceDisplayInfo::GetPhysicalDisplayWidth() const {
|
| + return physical_display_width_;
|
| }
|
|
|
| -int DeviceDisplayInfo::GetPhysicalDisplayWidth() {
|
| - return SharedDeviceDisplayInfo::GetInstance()->GetPhysicalDisplayWidth();
|
| +int DeviceDisplayInfo::GetBitsPerPixel() const {
|
| + return bits_per_pixel_;
|
| }
|
|
|
| -int DeviceDisplayInfo::GetBitsPerPixel() {
|
| - return SharedDeviceDisplayInfo::GetInstance()->GetBitsPerPixel();
|
| +int DeviceDisplayInfo::GetBitsPerComponent() const {
|
| + return bits_per_component_;
|
| }
|
|
|
| -int DeviceDisplayInfo::GetBitsPerComponent() {
|
| - return SharedDeviceDisplayInfo::GetInstance()->GetBitsPerComponent();
|
| +double DeviceDisplayInfo::GetDIPScale() const {
|
| + return dip_scale_;
|
| }
|
|
|
| -double DeviceDisplayInfo::GetDIPScale() {
|
| - return SharedDeviceDisplayInfo::GetInstance()->GetDIPScale();
|
| +int DeviceDisplayInfo::GetSmallestDIPWidth() const {
|
| + return smallest_dip_width_;
|
| }
|
|
|
| -int DeviceDisplayInfo::GetSmallestDIPWidth() {
|
| - return SharedDeviceDisplayInfo::GetInstance()->GetSmallestDIPWidth();
|
| +int DeviceDisplayInfo::GetRotationDegrees() const {
|
| + return rotation_degrees_;
|
| }
|
|
|
| -int DeviceDisplayInfo::GetRotationDegrees() {
|
| - return SharedDeviceDisplayInfo::GetInstance()->GetRotationDegrees();
|
| +// static
|
| +bool DeviceDisplayInfo::RegisterDeviceDisplayInfo(JNIEnv* env) {
|
| + return RegisterNativesImpl(env);
|
| }
|
|
|
| } // namespace gfx
|
|
|