OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #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
| |
6 | |
7 #include "base/logging.h" | |
8 #include "jni/DisplayAndroid_jni.h" | |
9 #include "ui/android/window_android.h" | |
10 #include "ui/display/android/screen_android.h" | |
11 #include "ui/display/display.h" | |
12 | |
13 namespace ui { | |
14 | |
15 static void UpdateDisplayAndroid( | |
16 JNIEnv* env, | |
17 const base::android::JavaParamRef<jclass>& jcaller, | |
18 jint sdkDisplayId, | |
19 jint physicalWidth, | |
20 jint physicalHeight, | |
21 jint width, | |
22 jint height, | |
23 jfloat dipScale, | |
24 jint rotationDegrees, | |
25 jint bitsPerPixel, | |
26 jint bitsPerComponent) { | |
27 gfx::Rect bounds_in_pixels = gfx::Rect(physicalWidth, physicalHeight); | |
28 | |
29 // Physical width and height might be not supported. | |
30 if (bounds_in_pixels.IsEmpty()) | |
31 bounds_in_pixels = gfx::Rect(width, height); | |
32 | |
33 const gfx::Rect bounds_in_dip = gfx::Rect( | |
34 gfx::ScaleToCeiledSize(bounds_in_pixels.size(), 1.0f / dipScale)); | |
35 | |
36 display::Display display = display::Display(0, bounds_in_dip); | |
37 | |
38 display.set_device_scale_factor(dipScale); | |
39 display.SetRotationAsDegree(rotationDegrees); | |
40 display.set_color_depth(bitsPerPixel); | |
41 display.set_depth_per_component(bitsPerComponent); | |
42 display.set_is_monochrome(bitsPerComponent == 0); | |
43 | |
44 static_cast<display::ScreenAndroid*>(display::Screen::GetScreen()) | |
45 ->UpdateDisplay(sdkDisplayId, display); | |
46 } | |
47 | |
48 static void RemoveDisplayAndroid( | |
49 JNIEnv* env, | |
50 const base::android::JavaParamRef<jclass>& jcaller, | |
51 jint sdkDisplayId) { | |
52 static_cast<display::ScreenAndroid*>(display::Screen::GetScreen()) | |
53 ->RemoveDisplay(sdkDisplayId); | |
54 } | |
55 | |
56 // static | |
57 bool DisplayAndroid::RegisterDisplayAndroid(JNIEnv* env) { | |
58 return RegisterNativesImpl(env); | |
59 } | |
60 | |
61 } // namespace ui | |
OLD | NEW |