2010-06-04 00:56:36 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-06-04 00:56:36 +04:00
|
|
|
|
2012-07-05 18:32:10 +04:00
|
|
|
#define MOZ_FATAL_ASSERTIONS_FOR_THREAD_SAFETY
|
|
|
|
|
2010-06-04 00:56:36 +04:00
|
|
|
#include "nsScreenManagerAndroid.h"
|
|
|
|
#include "nsWindow.h"
|
2010-12-22 01:34:29 +03:00
|
|
|
#include "AndroidBridge.h"
|
2010-06-04 00:56:36 +04:00
|
|
|
|
2010-12-22 01:34:29 +03:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2010-06-04 00:56:36 +04:00
|
|
|
nsScreenAndroid::nsScreenAndroid(void *nativeScreen)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsScreenAndroid::~nsScreenAndroid()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsScreenAndroid::GetRect(int32_t *outLeft, int32_t *outTop, int32_t *outWidth, int32_t *outHeight)
|
2010-06-04 00:56:36 +04:00
|
|
|
{
|
2011-01-14 23:36:19 +03:00
|
|
|
gfxIntSize sz = nsWindow::GetAndroidScreenBounds();
|
2010-06-04 00:56:36 +04:00
|
|
|
|
|
|
|
*outLeft = 0;
|
|
|
|
*outTop = 0;
|
|
|
|
|
|
|
|
*outWidth = sz.width;
|
|
|
|
*outHeight = sz.height;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsScreenAndroid::GetAvailRect(int32_t *outLeft, int32_t *outTop, int32_t *outWidth, int32_t *outHeight)
|
2010-06-04 00:56:36 +04:00
|
|
|
{
|
|
|
|
return GetRect(outLeft, outTop, outWidth, outHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsScreenAndroid::GetPixelDepth(int32_t *aPixelDepth)
|
2010-06-04 00:56:36 +04:00
|
|
|
{
|
2013-07-04 17:53:25 +04:00
|
|
|
*aPixelDepth = AndroidBridge::Bridge()->GetScreenDepth();
|
2010-06-04 00:56:36 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsScreenAndroid::GetColorDepth(int32_t *aColorDepth)
|
2010-06-04 00:56:36 +04:00
|
|
|
{
|
|
|
|
return GetPixelDepth(aColorDepth);
|
|
|
|
}
|
|
|
|
|
2010-12-22 01:34:29 +03:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsScreenAndroid::ApplyMinimumBrightness(uint32_t aBrightness)
|
2010-12-22 01:34:29 +03:00
|
|
|
{
|
|
|
|
AndroidBridge::Bridge()->SetKeepScreenOn(aBrightness == BRIGHTNESS_FULL);
|
|
|
|
}
|
|
|
|
|
2010-06-04 00:56:36 +04:00
|
|
|
NS_IMPL_ISUPPORTS1(nsScreenManagerAndroid, nsIScreenManager)
|
|
|
|
|
|
|
|
nsScreenManagerAndroid::nsScreenManagerAndroid()
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
mOneScreen = new nsScreenAndroid(nullptr);
|
2010-06-04 00:56:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsScreenManagerAndroid::~nsScreenManagerAndroid()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsScreenManagerAndroid::GetPrimaryScreen(nsIScreen **outScreen)
|
|
|
|
{
|
|
|
|
NS_IF_ADDREF(*outScreen = mOneScreen.get());
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsScreenManagerAndroid::ScreenForRect(int32_t inLeft,
|
|
|
|
int32_t inTop,
|
|
|
|
int32_t inWidth,
|
|
|
|
int32_t inHeight,
|
2010-06-04 00:56:36 +04:00
|
|
|
nsIScreen **outScreen)
|
|
|
|
{
|
|
|
|
return GetPrimaryScreen(outScreen);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsScreenManagerAndroid::ScreenForNativeWidget(void *aWidget, nsIScreen **outScreen)
|
|
|
|
{
|
|
|
|
return GetPrimaryScreen(outScreen);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsScreenManagerAndroid::GetNumberOfScreens(uint32_t *aNumberOfScreens)
|
2010-06-04 00:56:36 +04:00
|
|
|
{
|
|
|
|
*aNumberOfScreens = 1;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-04-10 01:07:02 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsScreenManagerAndroid::GetSystemDefaultScale(float *aDefaultScale)
|
|
|
|
{
|
|
|
|
*aDefaultScale = 1.0f;
|
|
|
|
return NS_OK;
|
|
|
|
}
|