| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 NOTIMPLEMENTED(); | 71 NOTIMPLEMENTED(); |
| 72 return GetPrimaryDisplay(); | 72 return GetPrimaryDisplay(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 // Methods called from Java | 75 // Methods called from Java |
| 76 | 76 |
| 77 void DisplayAndroidManager::UpdateDisplay( | 77 void DisplayAndroidManager::UpdateDisplay( |
| 78 JNIEnv* env, | 78 JNIEnv* env, |
| 79 const base::android::JavaParamRef<jobject>& jobject, | 79 const base::android::JavaParamRef<jobject>& jobject, |
| 80 jint sdkDisplayId, | 80 jint sdkDisplayId, |
| 81 jint physicalWidth, | |
| 82 jint physicalHeight, | |
| 83 jint width, | 81 jint width, |
| 84 jint height, | 82 jint height, |
| 85 jfloat dipScale, | 83 jfloat dipScale, |
| 86 jint rotationDegrees, | 84 jint rotationDegrees, |
| 87 jint bitsPerPixel, | 85 jint bitsPerPixel, |
| 88 jint bitsPerComponent) { | 86 jint bitsPerComponent) { |
| 89 gfx::Rect bounds_in_pixels = gfx::Rect(physicalWidth, physicalHeight); | 87 gfx::Rect bounds_in_pixels = gfx::Rect(width, height); |
| 90 | |
| 91 // Physical width and height might be not supported. | |
| 92 if (bounds_in_pixels.IsEmpty()) | |
| 93 bounds_in_pixels = gfx::Rect(width, height); | |
| 94 | |
| 95 const gfx::Rect bounds_in_dip = gfx::Rect( | 88 const gfx::Rect bounds_in_dip = gfx::Rect( |
| 96 gfx::ScaleToCeiledSize(bounds_in_pixels.size(), 1.0f / dipScale)); | 89 gfx::ScaleToCeiledSize(bounds_in_pixels.size(), 1.0f / dipScale)); |
| 97 | 90 |
| 98 display::Display display(sdkDisplayId, bounds_in_dip); | 91 display::Display display(sdkDisplayId, bounds_in_dip); |
| 99 if (!Display::HasForceDeviceScaleFactor()) | 92 if (!Display::HasForceDeviceScaleFactor()) |
| 100 display.set_device_scale_factor(dipScale); | 93 display.set_device_scale_factor(dipScale); |
| 101 | 94 |
| 102 display.set_size_in_pixels(bounds_in_pixels.size()); | 95 display.set_size_in_pixels(bounds_in_pixels.size()); |
| 103 display.SetRotationAsDegree(rotationDegrees); | 96 display.SetRotationAsDegree(rotationDegrees); |
| 104 display.set_color_depth(bitsPerPixel); | 97 display.set_color_depth(bitsPerPixel); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 116 } | 109 } |
| 117 | 110 |
| 118 void DisplayAndroidManager::SetPrimaryDisplayId( | 111 void DisplayAndroidManager::SetPrimaryDisplayId( |
| 119 JNIEnv* env, | 112 JNIEnv* env, |
| 120 const base::android::JavaParamRef<jobject>& jobject, | 113 const base::android::JavaParamRef<jobject>& jobject, |
| 121 jint sdkDisplayId) { | 114 jint sdkDisplayId) { |
| 122 primary_display_id_ = sdkDisplayId; | 115 primary_display_id_ = sdkDisplayId; |
| 123 } | 116 } |
| 124 | 117 |
| 125 } // namespace ui | 118 } // namespace ui |
| OLD | NEW |