widget/android/nsScreenManagerAndroid.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial