Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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/. */
6 #define MOZ_FATAL_ASSERTIONS_FOR_THREAD_SAFETY
8 #include "nsScreenManagerAndroid.h"
9 #include "nsWindow.h"
10 #include "AndroidBridge.h"
12 using namespace mozilla;
14 nsScreenAndroid::nsScreenAndroid(void *nativeScreen)
15 {
16 }
18 nsScreenAndroid::~nsScreenAndroid()
19 {
20 }
22 NS_IMETHODIMP
23 nsScreenAndroid::GetRect(int32_t *outLeft, int32_t *outTop, int32_t *outWidth, int32_t *outHeight)
24 {
25 gfxIntSize sz = nsWindow::GetAndroidScreenBounds();
27 *outLeft = 0;
28 *outTop = 0;
30 *outWidth = sz.width;
31 *outHeight = sz.height;
33 return NS_OK;
34 }
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 }
45 NS_IMETHODIMP
46 nsScreenAndroid::GetPixelDepth(int32_t *aPixelDepth)
47 {
48 *aPixelDepth = AndroidBridge::Bridge()->GetScreenDepth();
49 return NS_OK;
50 }
53 NS_IMETHODIMP
54 nsScreenAndroid::GetColorDepth(int32_t *aColorDepth)
55 {
56 return GetPixelDepth(aColorDepth);
57 }
59 void
60 nsScreenAndroid::ApplyMinimumBrightness(uint32_t aBrightness)
61 {
62 mozilla::widget::android::GeckoAppShell::SetKeepScreenOn(aBrightness == BRIGHTNESS_FULL);
63 }
65 NS_IMPL_ISUPPORTS(nsScreenManagerAndroid, nsIScreenManager)
67 nsScreenManagerAndroid::nsScreenManagerAndroid()
68 {
69 mOneScreen = new nsScreenAndroid(nullptr);
70 }
72 nsScreenManagerAndroid::~nsScreenManagerAndroid()
73 {
74 }
76 NS_IMETHODIMP
77 nsScreenManagerAndroid::GetPrimaryScreen(nsIScreen **outScreen)
78 {
79 NS_IF_ADDREF(*outScreen = mOneScreen.get());
80 return NS_OK;
81 }
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 }
93 NS_IMETHODIMP
94 nsScreenManagerAndroid::ScreenForNativeWidget(void *aWidget, nsIScreen **outScreen)
95 {
96 return GetPrimaryScreen(outScreen);
97 }
99 NS_IMETHODIMP
100 nsScreenManagerAndroid::GetNumberOfScreens(uint32_t *aNumberOfScreens)
101 {
102 *aNumberOfScreens = 1;
103 return NS_OK;
104 }
106 NS_IMETHODIMP
107 nsScreenManagerAndroid::GetSystemDefaultScale(float *aDefaultScale)
108 {
109 *aDefaultScale = 1.0f;
110 return NS_OK;
111 }