Chromium Code Reviews| Index: ui/android/display_android.cc |
| diff --git a/ui/android/display_android.cc b/ui/android/display_android.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..691d9ed6133f8449278d944182c01591b6e0115d |
| --- /dev/null |
| +++ b/ui/android/display_android.cc |
| @@ -0,0 +1,61 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "ui/android/display_android.h" |
|
boliu
2016/10/26 17:24:19
ui/display/android pls
Tima Vaisburd
2016/10/27 07:55:58
This file is gone, JNI is handled by ui/display/an
|
| + |
| +#include "base/logging.h" |
| +#include "jni/DisplayAndroid_jni.h" |
| +#include "ui/android/window_android.h" |
| +#include "ui/display/android/screen_android.h" |
| +#include "ui/display/display.h" |
| + |
| +namespace ui { |
| + |
| +static void UpdateDisplayAndroid( |
| + JNIEnv* env, |
| + const base::android::JavaParamRef<jclass>& jcaller, |
| + jint sdkDisplayId, |
| + jint physicalWidth, |
| + jint physicalHeight, |
| + jint width, |
| + jint height, |
| + jfloat dipScale, |
| + jint rotationDegrees, |
| + jint bitsPerPixel, |
| + jint bitsPerComponent) { |
| + gfx::Rect bounds_in_pixels = gfx::Rect(physicalWidth, physicalHeight); |
| + |
| + // Physical width and height might be not supported. |
| + if (bounds_in_pixels.IsEmpty()) |
| + bounds_in_pixels = gfx::Rect(width, height); |
| + |
| + const gfx::Rect bounds_in_dip = gfx::Rect( |
| + gfx::ScaleToCeiledSize(bounds_in_pixels.size(), 1.0f / dipScale)); |
| + |
| + display::Display display = display::Display(0, bounds_in_dip); |
| + |
| + display.set_device_scale_factor(dipScale); |
| + display.SetRotationAsDegree(rotationDegrees); |
| + display.set_color_depth(bitsPerPixel); |
| + display.set_depth_per_component(bitsPerComponent); |
| + display.set_is_monochrome(bitsPerComponent == 0); |
| + |
| + static_cast<display::ScreenAndroid*>(display::Screen::GetScreen()) |
| + ->UpdateDisplay(sdkDisplayId, display); |
| +} |
| + |
| +static void RemoveDisplayAndroid( |
| + JNIEnv* env, |
| + const base::android::JavaParamRef<jclass>& jcaller, |
| + jint sdkDisplayId) { |
| + static_cast<display::ScreenAndroid*>(display::Screen::GetScreen()) |
| + ->RemoveDisplay(sdkDisplayId); |
| +} |
| + |
| +// static |
| +bool DisplayAndroid::RegisterDisplayAndroid(JNIEnv* env) { |
| + return RegisterNativesImpl(env); |
| +} |
| + |
| +} // namespace ui |