Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Unified Diff: ui/gfx/android/device_display_info.cc

Issue 1144333004: Make WebView work for external displays (over Presentations). Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor fixes according to boliu/jdduke's comments Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..8a91b828ef31b37937e3a0c62d3e4898df628015 100644
--- a/ui/gfx/android/device_display_info.cc
+++ b/ui/gfx/android/device_display_info.cc
@@ -2,53 +2,86 @@
// 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() {
+DeviceDisplayInfo::DeviceDisplayInfo(jobject context) {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ j_device_info_.Reset(Java_DeviceDisplayInfo_create(env, context));
+ FetchDisplayInfoFromJava(env);
+}
+
+DeviceDisplayInfo::DeviceDisplayInfo()
+ : DeviceDisplayInfo(base::android::GetApplicationContext()) {
}
DeviceDisplayInfo::~DeviceDisplayInfo() {
}
-int DeviceDisplayInfo::GetDisplayHeight() {
- return SharedDeviceDisplayInfo::GetInstance()->GetDisplayHeight();
+void DeviceDisplayInfo::FetchDisplayInfoFromJava(JNIEnv* env) {
+ display_height_ = static_cast<int>(
+ Java_DeviceDisplayInfo_getDisplayHeight(env, j_device_info_.obj()));
+ display_width_ = static_cast<int>(
+ Java_DeviceDisplayInfo_getDisplayWidth(env, j_device_info_.obj()));
+ physical_display_height_ =
+ static_cast<int>(Java_DeviceDisplayInfo_getPhysicalDisplayHeight(
+ env, j_device_info_.obj()));
+ physical_display_width_ =
+ static_cast<int>(Java_DeviceDisplayInfo_getPhysicalDisplayWidth(
+ env, j_device_info_.obj()));
+ bits_per_pixel_ = static_cast<int>(
+ Java_DeviceDisplayInfo_getBitsPerPixel(env, j_device_info_.obj()));
+ bits_per_component_ = static_cast<int>(
+ Java_DeviceDisplayInfo_getBitsPerComponent(env, j_device_info_.obj()));
+ dip_scale_ = static_cast<double>(
+ Java_DeviceDisplayInfo_getDIPScale(env, j_device_info_.obj()));
+ smallest_dip_width_ = static_cast<int>(
+ Java_DeviceDisplayInfo_getSmallestDIPWidth(env, j_device_info_.obj()));
+ rotation_degrees_ = static_cast<int>(
+ Java_DeviceDisplayInfo_getRotationDegrees(env, j_device_info_.obj()));
+}
+
+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

Powered by Google App Engine
This is Rietveld 408576698