| 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" |
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "jni/DisplayAndroidManager_jni.h" | 12 #include "jni/DisplayAndroidManager_jni.h" |
| 13 #include "ui/android/screen_android.h" | 13 #include "ui/android/screen_android.h" |
| 14 #include "ui/android/window_android.h" | 14 #include "ui/android/window_android.h" |
| 15 #include "ui/display/display.h" | 15 #include "ui/display/display.h" |
| 16 #include "ui/gfx/icc_profile.h" |
| 16 | 17 |
| 17 namespace ui { | 18 namespace ui { |
| 18 | 19 |
| 19 using base::android::AttachCurrentThread; | 20 using base::android::AttachCurrentThread; |
| 20 using display::Display; | 21 using display::Display; |
| 21 using display::DisplayList; | 22 using display::DisplayList; |
| 22 | 23 |
| 23 void SetScreenAndroid() { | 24 void SetScreenAndroid() { |
| 24 // Do not override existing Screen. | 25 // Do not override existing Screen. |
| 25 DCHECK_EQ(display::Screen::GetScreen(), nullptr); | 26 DCHECK_EQ(display::Screen::GetScreen(), nullptr); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 jint rotationDegrees, | 85 jint rotationDegrees, |
| 85 jint bitsPerPixel, | 86 jint bitsPerPixel, |
| 86 jint bitsPerComponent) { | 87 jint bitsPerComponent) { |
| 87 gfx::Rect bounds_in_pixels = gfx::Rect(width, height); | 88 gfx::Rect bounds_in_pixels = gfx::Rect(width, height); |
| 88 const gfx::Rect bounds_in_dip = gfx::Rect( | 89 const gfx::Rect bounds_in_dip = gfx::Rect( |
| 89 gfx::ScaleToCeiledSize(bounds_in_pixels.size(), 1.0f / dipScale)); | 90 gfx::ScaleToCeiledSize(bounds_in_pixels.size(), 1.0f / dipScale)); |
| 90 | 91 |
| 91 display::Display display(sdkDisplayId, bounds_in_dip); | 92 display::Display display(sdkDisplayId, bounds_in_dip); |
| 92 if (!Display::HasForceDeviceScaleFactor()) | 93 if (!Display::HasForceDeviceScaleFactor()) |
| 93 display.set_device_scale_factor(dipScale); | 94 display.set_device_scale_factor(dipScale); |
| 95 // TODO(ccameron): Know the ideal color profile to use here. |
| 96 // https://crbug.com/735658 |
| 97 if (!gfx::ICCProfile::HasForcedProfile()) |
| 98 display.set_color_space(gfx::ColorSpace::CreateSRGB()); |
| 94 | 99 |
| 95 display.set_size_in_pixels(bounds_in_pixels.size()); | 100 display.set_size_in_pixels(bounds_in_pixels.size()); |
| 96 display.SetRotationAsDegree(rotationDegrees); | 101 display.SetRotationAsDegree(rotationDegrees); |
| 97 display.set_color_depth(bitsPerPixel); | 102 display.set_color_depth(bitsPerPixel); |
| 98 display.set_depth_per_component(bitsPerComponent); | 103 display.set_depth_per_component(bitsPerComponent); |
| 99 display.set_is_monochrome(bitsPerComponent == 0); | 104 display.set_is_monochrome(bitsPerComponent == 0); |
| 100 | 105 |
| 101 ProcessDisplayChanged(display, sdkDisplayId == primary_display_id_); | 106 ProcessDisplayChanged(display, sdkDisplayId == primary_display_id_); |
| 102 } | 107 } |
| 103 | 108 |
| 104 void DisplayAndroidManager::RemoveDisplay( | 109 void DisplayAndroidManager::RemoveDisplay( |
| 105 JNIEnv* env, | 110 JNIEnv* env, |
| 106 const base::android::JavaParamRef<jobject>& jobject, | 111 const base::android::JavaParamRef<jobject>& jobject, |
| 107 jint sdkDisplayId) { | 112 jint sdkDisplayId) { |
| 108 display_list().RemoveDisplay(sdkDisplayId); | 113 display_list().RemoveDisplay(sdkDisplayId); |
| 109 } | 114 } |
| 110 | 115 |
| 111 void DisplayAndroidManager::SetPrimaryDisplayId( | 116 void DisplayAndroidManager::SetPrimaryDisplayId( |
| 112 JNIEnv* env, | 117 JNIEnv* env, |
| 113 const base::android::JavaParamRef<jobject>& jobject, | 118 const base::android::JavaParamRef<jobject>& jobject, |
| 114 jint sdkDisplayId) { | 119 jint sdkDisplayId) { |
| 115 primary_display_id_ = sdkDisplayId; | 120 primary_display_id_ = sdkDisplayId; |
| 116 } | 121 } |
| 117 | 122 |
| 118 } // namespace ui | 123 } // namespace ui |
| OLD | NEW |