| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "ui/android/display_android_manager.h" | 5 #include "ui/android/display_android_manager.h" |
| 6 | 6 |
| 7 #include <jni.h> | 7 #include <jni.h> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 JNIEnv* env, | 74 JNIEnv* env, |
| 75 const base::android::JavaParamRef<jobject>& jobject, | 75 const base::android::JavaParamRef<jobject>& jobject, |
| 76 jint sdkDisplayId, | 76 jint sdkDisplayId, |
| 77 jint physicalWidth, | 77 jint physicalWidth, |
| 78 jint physicalHeight, | 78 jint physicalHeight, |
| 79 jint width, | 79 jint width, |
| 80 jint height, | 80 jint height, |
| 81 jfloat dipScale, | 81 jfloat dipScale, |
| 82 jint rotationDegrees, | 82 jint rotationDegrees, |
| 83 jint bitsPerPixel, | 83 jint bitsPerPixel, |
| 84 jint bitsPerComponent) { | 84 jint bitsPerComponent, |
| 85 jboolean isVirtual) { |
| 85 gfx::Rect bounds_in_pixels = gfx::Rect(physicalWidth, physicalHeight); | 86 gfx::Rect bounds_in_pixels = gfx::Rect(physicalWidth, physicalHeight); |
| 86 | 87 |
| 87 // Physical width and height might be not supported. | 88 // Physical width and height might be not supported. |
| 88 if (bounds_in_pixels.IsEmpty()) | 89 if (bounds_in_pixels.IsEmpty()) |
| 89 bounds_in_pixels = gfx::Rect(width, height); | 90 bounds_in_pixels = gfx::Rect(width, height); |
| 90 | 91 |
| 91 const gfx::Rect bounds_in_dip = gfx::Rect( | 92 const gfx::Rect bounds_in_dip = gfx::Rect( |
| 92 gfx::ScaleToCeiledSize(bounds_in_pixels.size(), 1.0f / dipScale)); | 93 gfx::ScaleToCeiledSize(bounds_in_pixels.size(), 1.0f / dipScale)); |
| 93 | 94 |
| 94 display::Display display(sdkDisplayId, bounds_in_dip); | 95 display::Display display(sdkDisplayId, bounds_in_dip); |
| 95 if (!Display::HasForceDeviceScaleFactor()) | 96 if (!Display::HasForceDeviceScaleFactor()) |
| 96 display.set_device_scale_factor(dipScale); | 97 display.set_device_scale_factor(dipScale); |
| 97 | 98 |
| 98 display.SetRotationAsDegree(rotationDegrees); | 99 display.SetRotationAsDegree(rotationDegrees); |
| 99 display.set_color_depth(bitsPerPixel); | 100 display.set_color_depth(bitsPerPixel); |
| 100 display.set_depth_per_component(bitsPerComponent); | 101 display.set_depth_per_component(bitsPerComponent); |
| 101 display.set_is_monochrome(bitsPerComponent == 0); | 102 display.set_is_monochrome(bitsPerComponent == 0); |
| 103 display.set_is_virtual(static_cast<bool>(isVirtual)); |
| 102 | 104 |
| 103 ProcessDisplayChanged(display, sdkDisplayId == primary_display_id_); | 105 ProcessDisplayChanged(display, sdkDisplayId == primary_display_id_); |
| 104 } | 106 } |
| 105 | 107 |
| 106 void DisplayAndroidManager::RemoveDisplay( | 108 void DisplayAndroidManager::RemoveDisplay( |
| 107 JNIEnv* env, | 109 JNIEnv* env, |
| 108 const base::android::JavaParamRef<jobject>& jobject, | 110 const base::android::JavaParamRef<jobject>& jobject, |
| 109 jint sdkDisplayId) { | 111 jint sdkDisplayId) { |
| 110 display_list().RemoveDisplay(sdkDisplayId); | 112 display_list().RemoveDisplay(sdkDisplayId); |
| 111 } | 113 } |
| 112 | 114 |
| 113 void DisplayAndroidManager::SetPrimaryDisplayId( | 115 void DisplayAndroidManager::SetPrimaryDisplayId( |
| 114 JNIEnv* env, | 116 JNIEnv* env, |
| 115 const base::android::JavaParamRef<jobject>& jobject, | 117 const base::android::JavaParamRef<jobject>& jobject, |
| 116 jint sdkDisplayId) { | 118 jint sdkDisplayId) { |
| 117 primary_display_id_ = sdkDisplayId; | 119 primary_display_id_ = sdkDisplayId; |
| 118 } | 120 } |
| 119 | 121 |
| 120 } // namespace ui | 122 } // namespace ui |
| OLD | NEW |