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

Side by Side 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 unified diff | Download patch
OLDNEW
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 "jni/DeviceDisplayInfo_jni.h"
5 #include "ui/gfx/android/device_display_info.h" 6 #include "ui/gfx/android/device_display_info.h"
6 7
7 #include "base/logging.h"
8 #include "ui/gfx/android/shared_device_display_info.h"
9
10 namespace gfx { 8 namespace gfx {
11 9
12 DeviceDisplayInfo::DeviceDisplayInfo() { 10 DeviceDisplayInfo::DeviceDisplayInfo(jobject context) {
11 JNIEnv* env = base::android::AttachCurrentThread();
12 j_device_info_.Reset(Java_DeviceDisplayInfo_create(env, context));
13 FetchDisplayInfoFromJava(env);
14 }
15
16 DeviceDisplayInfo::DeviceDisplayInfo()
17 : DeviceDisplayInfo(base::android::GetApplicationContext()) {
13 } 18 }
14 19
15 DeviceDisplayInfo::~DeviceDisplayInfo() { 20 DeviceDisplayInfo::~DeviceDisplayInfo() {
16 } 21 }
17 22
18 int DeviceDisplayInfo::GetDisplayHeight() { 23 void DeviceDisplayInfo::FetchDisplayInfoFromJava(JNIEnv* env) {
19 return SharedDeviceDisplayInfo::GetInstance()->GetDisplayHeight(); 24 display_height_ = static_cast<int>(
25 Java_DeviceDisplayInfo_getDisplayHeight(env, j_device_info_.obj()));
26 display_width_ = static_cast<int>(
27 Java_DeviceDisplayInfo_getDisplayWidth(env, j_device_info_.obj()));
28 physical_display_height_ =
29 static_cast<int>(Java_DeviceDisplayInfo_getPhysicalDisplayHeight(
30 env, j_device_info_.obj()));
31 physical_display_width_ =
32 static_cast<int>(Java_DeviceDisplayInfo_getPhysicalDisplayWidth(
33 env, j_device_info_.obj()));
34 bits_per_pixel_ = static_cast<int>(
35 Java_DeviceDisplayInfo_getBitsPerPixel(env, j_device_info_.obj()));
36 bits_per_component_ = static_cast<int>(
37 Java_DeviceDisplayInfo_getBitsPerComponent(env, j_device_info_.obj()));
38 dip_scale_ = static_cast<double>(
39 Java_DeviceDisplayInfo_getDIPScale(env, j_device_info_.obj()));
40 smallest_dip_width_ = static_cast<int>(
41 Java_DeviceDisplayInfo_getSmallestDIPWidth(env, j_device_info_.obj()));
42 rotation_degrees_ = static_cast<int>(
43 Java_DeviceDisplayInfo_getRotationDegrees(env, j_device_info_.obj()));
20 } 44 }
21 45
22 int DeviceDisplayInfo::GetDisplayWidth() { 46 int DeviceDisplayInfo::GetDisplayHeight() const {
23 return SharedDeviceDisplayInfo::GetInstance()->GetDisplayWidth(); 47 return display_height_;
24 } 48 }
25 49
26 int DeviceDisplayInfo::GetPhysicalDisplayHeight() { 50 int DeviceDisplayInfo::GetDisplayWidth() const {
27 return SharedDeviceDisplayInfo::GetInstance()->GetPhysicalDisplayHeight(); 51 return display_width_;
28 } 52 }
29 53
30 int DeviceDisplayInfo::GetPhysicalDisplayWidth() { 54 int DeviceDisplayInfo::GetPhysicalDisplayHeight() const {
31 return SharedDeviceDisplayInfo::GetInstance()->GetPhysicalDisplayWidth(); 55 return physical_display_height_;
32 } 56 }
33 57
34 int DeviceDisplayInfo::GetBitsPerPixel() { 58 int DeviceDisplayInfo::GetPhysicalDisplayWidth() const {
35 return SharedDeviceDisplayInfo::GetInstance()->GetBitsPerPixel(); 59 return physical_display_width_;
36 } 60 }
37 61
38 int DeviceDisplayInfo::GetBitsPerComponent() { 62 int DeviceDisplayInfo::GetBitsPerPixel() const {
39 return SharedDeviceDisplayInfo::GetInstance()->GetBitsPerComponent(); 63 return bits_per_pixel_;
40 } 64 }
41 65
42 double DeviceDisplayInfo::GetDIPScale() { 66 int DeviceDisplayInfo::GetBitsPerComponent() const {
43 return SharedDeviceDisplayInfo::GetInstance()->GetDIPScale(); 67 return bits_per_component_;
44 } 68 }
45 69
46 int DeviceDisplayInfo::GetSmallestDIPWidth() { 70 double DeviceDisplayInfo::GetDIPScale() const {
47 return SharedDeviceDisplayInfo::GetInstance()->GetSmallestDIPWidth(); 71 return dip_scale_;
48 } 72 }
49 73
50 int DeviceDisplayInfo::GetRotationDegrees() { 74 int DeviceDisplayInfo::GetSmallestDIPWidth() const {
51 return SharedDeviceDisplayInfo::GetInstance()->GetRotationDegrees(); 75 return smallest_dip_width_;
76 }
77
78 int DeviceDisplayInfo::GetRotationDegrees() const {
79 return rotation_degrees_;
80 }
81
82 // static
83 bool DeviceDisplayInfo::RegisterDeviceDisplayInfo(JNIEnv* env) {
84 return RegisterNativesImpl(env);
52 } 85 }
53 86
54 } // namespace gfx 87 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698