|
1 /* -*- Mode: C++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #define MOZ_FATAL_ASSERTIONS_FOR_THREAD_SAFETY |
|
7 |
|
8 #include "nsScreenManagerAndroid.h" |
|
9 #include "nsWindow.h" |
|
10 #include "AndroidBridge.h" |
|
11 |
|
12 using namespace mozilla; |
|
13 |
|
14 nsScreenAndroid::nsScreenAndroid(void *nativeScreen) |
|
15 { |
|
16 } |
|
17 |
|
18 nsScreenAndroid::~nsScreenAndroid() |
|
19 { |
|
20 } |
|
21 |
|
22 NS_IMETHODIMP |
|
23 nsScreenAndroid::GetRect(int32_t *outLeft, int32_t *outTop, int32_t *outWidth, int32_t *outHeight) |
|
24 { |
|
25 gfxIntSize sz = nsWindow::GetAndroidScreenBounds(); |
|
26 |
|
27 *outLeft = 0; |
|
28 *outTop = 0; |
|
29 |
|
30 *outWidth = sz.width; |
|
31 *outHeight = sz.height; |
|
32 |
|
33 return NS_OK; |
|
34 } |
|
35 |
|
36 |
|
37 NS_IMETHODIMP |
|
38 nsScreenAndroid::GetAvailRect(int32_t *outLeft, int32_t *outTop, int32_t *outWidth, int32_t *outHeight) |
|
39 { |
|
40 return GetRect(outLeft, outTop, outWidth, outHeight); |
|
41 } |
|
42 |
|
43 |
|
44 |
|
45 NS_IMETHODIMP |
|
46 nsScreenAndroid::GetPixelDepth(int32_t *aPixelDepth) |
|
47 { |
|
48 *aPixelDepth = AndroidBridge::Bridge()->GetScreenDepth(); |
|
49 return NS_OK; |
|
50 } |
|
51 |
|
52 |
|
53 NS_IMETHODIMP |
|
54 nsScreenAndroid::GetColorDepth(int32_t *aColorDepth) |
|
55 { |
|
56 return GetPixelDepth(aColorDepth); |
|
57 } |
|
58 |
|
59 void |
|
60 nsScreenAndroid::ApplyMinimumBrightness(uint32_t aBrightness) |
|
61 { |
|
62 mozilla::widget::android::GeckoAppShell::SetKeepScreenOn(aBrightness == BRIGHTNESS_FULL); |
|
63 } |
|
64 |
|
65 NS_IMPL_ISUPPORTS(nsScreenManagerAndroid, nsIScreenManager) |
|
66 |
|
67 nsScreenManagerAndroid::nsScreenManagerAndroid() |
|
68 { |
|
69 mOneScreen = new nsScreenAndroid(nullptr); |
|
70 } |
|
71 |
|
72 nsScreenManagerAndroid::~nsScreenManagerAndroid() |
|
73 { |
|
74 } |
|
75 |
|
76 NS_IMETHODIMP |
|
77 nsScreenManagerAndroid::GetPrimaryScreen(nsIScreen **outScreen) |
|
78 { |
|
79 NS_IF_ADDREF(*outScreen = mOneScreen.get()); |
|
80 return NS_OK; |
|
81 } |
|
82 |
|
83 NS_IMETHODIMP |
|
84 nsScreenManagerAndroid::ScreenForRect(int32_t inLeft, |
|
85 int32_t inTop, |
|
86 int32_t inWidth, |
|
87 int32_t inHeight, |
|
88 nsIScreen **outScreen) |
|
89 { |
|
90 return GetPrimaryScreen(outScreen); |
|
91 } |
|
92 |
|
93 NS_IMETHODIMP |
|
94 nsScreenManagerAndroid::ScreenForNativeWidget(void *aWidget, nsIScreen **outScreen) |
|
95 { |
|
96 return GetPrimaryScreen(outScreen); |
|
97 } |
|
98 |
|
99 NS_IMETHODIMP |
|
100 nsScreenManagerAndroid::GetNumberOfScreens(uint32_t *aNumberOfScreens) |
|
101 { |
|
102 *aNumberOfScreens = 1; |
|
103 return NS_OK; |
|
104 } |
|
105 |
|
106 NS_IMETHODIMP |
|
107 nsScreenManagerAndroid::GetSystemDefaultScale(float *aDefaultScale) |
|
108 { |
|
109 *aDefaultScale = 1.0f; |
|
110 return NS_OK; |
|
111 } |