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

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: Use scoped_ptr to store DeviceDisplayInfo and make DeviceDisplayInfo getters const Created 5 years, 6 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
10 DeviceDisplayInfo::DeviceDisplayInfo(
11 base::android::ScopedJavaLocalRef<jobject> context) {
12 JNIEnv* env = base::android::AttachCurrentThread();
13 j_device_info_.Reset(
14 Java_DeviceDisplayInfo_create(env, context.obj()));
15 FetchDisplayInfoFromJava(env);
16 }
17
12 DeviceDisplayInfo::DeviceDisplayInfo() { 18 DeviceDisplayInfo::DeviceDisplayInfo() {
19 JNIEnv* env = base::android::AttachCurrentThread();
20 j_device_info_.Reset(
21 Java_DeviceDisplayInfo_create(env,
22 base::android::GetApplicationContext()));
23 FetchDisplayInfoFromJava(env);
13 } 24 }
14 25
15 DeviceDisplayInfo::~DeviceDisplayInfo() { 26 DeviceDisplayInfo::~DeviceDisplayInfo() {
16 } 27 }
17 28
18 int DeviceDisplayInfo::GetDisplayHeight() { 29 void DeviceDisplayInfo::FetchDisplayInfoFromJava(JNIEnv* env) {
19 return SharedDeviceDisplayInfo::GetInstance()->GetDisplayHeight(); 30 UpdateDisplayInfo(
31 Java_DeviceDisplayInfo_getDisplayHeight(env, j_device_info_.obj()),
32 Java_DeviceDisplayInfo_getDisplayWidth(env, j_device_info_.obj()),
33 Java_DeviceDisplayInfo_getPhysicalDisplayHeight(env,
34 j_device_info_.obj()),
35 Java_DeviceDisplayInfo_getPhysicalDisplayWidth(env, j_device_info_.obj()),
36 Java_DeviceDisplayInfo_getBitsPerPixel(env, j_device_info_.obj()),
37 Java_DeviceDisplayInfo_getBitsPerComponent(env, j_device_info_.obj()),
38 Java_DeviceDisplayInfo_getDIPScale(env, j_device_info_.obj()),
39 Java_DeviceDisplayInfo_getSmallestDIPWidth(env, j_device_info_.obj()),
40 Java_DeviceDisplayInfo_getRotationDegrees(env, j_device_info_.obj()));
20 } 41 }
21 42
22 int DeviceDisplayInfo::GetDisplayWidth() { 43 void DeviceDisplayInfo::UpdateDisplayInfo(jint display_height,
23 return SharedDeviceDisplayInfo::GetInstance()->GetDisplayWidth(); 44 jint display_width,
45 jint physical_display_height,
46 jint physical_display_width,
47 jint bits_per_pixel,
48 jint bits_per_component,
49 jdouble dip_scale,
50 jint smallest_dip_width,
51 jint rotation_degrees) {
52 display_height_ = static_cast<int>(display_height);
53 display_width_ = static_cast<int>(display_width);
54 physical_display_height_ = static_cast<int>(physical_display_height);
55 physical_display_width_ = static_cast<int>(physical_display_width);
56 bits_per_pixel_ = static_cast<int>(bits_per_pixel);
57 bits_per_component_ = static_cast<int>(bits_per_component);
58 dip_scale_ = static_cast<double>(dip_scale);
59 smallest_dip_width_ = static_cast<int>(smallest_dip_width);
60 rotation_degrees_ = static_cast<int>(rotation_degrees);
24 } 61 }
25 62
26 int DeviceDisplayInfo::GetPhysicalDisplayHeight() { 63 int DeviceDisplayInfo::GetDisplayHeight() const {
27 return SharedDeviceDisplayInfo::GetInstance()->GetPhysicalDisplayHeight(); 64 return display_height_;
28 } 65 }
29 66
30 int DeviceDisplayInfo::GetPhysicalDisplayWidth() { 67 int DeviceDisplayInfo::GetDisplayWidth() const {
31 return SharedDeviceDisplayInfo::GetInstance()->GetPhysicalDisplayWidth(); 68 return display_width_;
32 } 69 }
33 70
34 int DeviceDisplayInfo::GetBitsPerPixel() { 71 int DeviceDisplayInfo::GetPhysicalDisplayHeight() const {
35 return SharedDeviceDisplayInfo::GetInstance()->GetBitsPerPixel(); 72 return physical_display_height_;
36 } 73 }
37 74
38 int DeviceDisplayInfo::GetBitsPerComponent() { 75 int DeviceDisplayInfo::GetPhysicalDisplayWidth() const {
39 return SharedDeviceDisplayInfo::GetInstance()->GetBitsPerComponent(); 76 return physical_display_width_;
40 } 77 }
41 78
42 double DeviceDisplayInfo::GetDIPScale() { 79 int DeviceDisplayInfo::GetBitsPerPixel() const {
43 return SharedDeviceDisplayInfo::GetInstance()->GetDIPScale(); 80 return bits_per_pixel_;
44 } 81 }
45 82
46 int DeviceDisplayInfo::GetSmallestDIPWidth() { 83 int DeviceDisplayInfo::GetBitsPerComponent() const {
47 return SharedDeviceDisplayInfo::GetInstance()->GetSmallestDIPWidth(); 84 return bits_per_component_;
48 } 85 }
49 86
50 int DeviceDisplayInfo::GetRotationDegrees() { 87 double DeviceDisplayInfo::GetDIPScale() const {
51 return SharedDeviceDisplayInfo::GetInstance()->GetRotationDegrees(); 88 return dip_scale_;
89 }
90
91 int DeviceDisplayInfo::GetSmallestDIPWidth() const {
92 return smallest_dip_width_;
93 }
94
95 int DeviceDisplayInfo::GetRotationDegrees() const {
96 return rotation_degrees_;
97 }
98
99 // static
100 bool DeviceDisplayInfo::RegisterDeviceDisplayInfo(JNIEnv* env) {
101 return RegisterNativesImpl(env);
52 } 102 }
53 103
54 } // namespace gfx 104 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698