2012-01-04 18:12:48 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* vim: sw=2 ts=8 et :
|
|
|
|
*/
|
2012-05-21 04:12:37 -07: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/. */
|
2012-01-04 18:12:48 -08:00
|
|
|
|
2012-07-05 07:32:10 -07:00
|
|
|
#define MOZ_FATAL_ASSERTIONS_FOR_THREAD_SAFETY
|
|
|
|
|
2012-01-04 18:12:48 -08:00
|
|
|
#include "nsBaseScreen.h"
|
|
|
|
|
2014-04-27 00:06:00 -07:00
|
|
|
NS_IMPL_ISUPPORTS(nsBaseScreen, nsIScreen)
|
2012-01-04 18:12:48 -08:00
|
|
|
|
|
|
|
nsBaseScreen::nsBaseScreen()
|
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
for (uint32_t i = 0; i < nsIScreen::BRIGHTNESS_LEVELS; i++)
|
2012-01-04 18:12:48 -08:00
|
|
|
mBrightnessLocks[i] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsBaseScreen::~nsBaseScreen() { }
|
|
|
|
|
2012-10-16 12:41:19 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseScreen::GetRectDisplayPix(int32_t *outLeft, int32_t *outTop,
|
|
|
|
int32_t *outWidth, int32_t *outHeight)
|
|
|
|
{
|
|
|
|
return GetRect(outLeft, outTop, outWidth, outHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseScreen::GetAvailRectDisplayPix(int32_t *outLeft, int32_t *outTop,
|
|
|
|
int32_t *outWidth, int32_t *outHeight)
|
|
|
|
{
|
|
|
|
return GetAvailRect(outLeft, outTop, outWidth, outHeight);
|
|
|
|
}
|
|
|
|
|
2012-01-04 18:12:48 -08:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsBaseScreen::LockMinimumBrightness(uint32_t aBrightness)
|
2012-01-04 18:12:48 -08:00
|
|
|
{
|
2015-02-06 15:04:32 -08:00
|
|
|
NS_ABORT_IF_FALSE(
|
|
|
|
aBrightness < nsIScreen::BRIGHTNESS_LEVELS,
|
|
|
|
"Invalid brightness level to lock");
|
2012-01-04 18:12:48 -08:00
|
|
|
mBrightnessLocks[aBrightness]++;
|
2015-02-06 15:04:32 -08:00
|
|
|
NS_ABORT_IF_FALSE(mBrightnessLocks[aBrightness] > 0,
|
|
|
|
"Overflow after locking brightness level");
|
2012-01-04 18:12:48 -08:00
|
|
|
|
|
|
|
CheckMinimumBrightness();
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsBaseScreen::UnlockMinimumBrightness(uint32_t aBrightness)
|
2012-01-04 18:12:48 -08:00
|
|
|
{
|
2015-02-06 15:04:32 -08:00
|
|
|
NS_ABORT_IF_FALSE(
|
|
|
|
aBrightness < nsIScreen::BRIGHTNESS_LEVELS,
|
|
|
|
"Invalid brightness level to lock");
|
|
|
|
NS_ABORT_IF_FALSE(mBrightnessLocks[aBrightness] > 0,
|
|
|
|
"Unlocking a brightness level with no corresponding lock");
|
2012-01-04 18:12:48 -08:00
|
|
|
mBrightnessLocks[aBrightness]--;
|
|
|
|
|
|
|
|
CheckMinimumBrightness();
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBaseScreen::CheckMinimumBrightness()
|
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t brightness = nsIScreen::BRIGHTNESS_LEVELS;
|
2013-08-09 11:36:32 -07:00
|
|
|
for (int32_t i = nsIScreen::BRIGHTNESS_LEVELS - 1; i >=0; i--) {
|
2013-08-01 18:21:32 -07:00
|
|
|
if (mBrightnessLocks[i] > 0) {
|
2012-01-04 18:12:48 -08:00
|
|
|
brightness = i;
|
2013-08-01 18:21:32 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-01-04 18:12:48 -08:00
|
|
|
|
|
|
|
ApplyMinimumBrightness(brightness);
|
|
|
|
}
|
2012-10-02 12:48:05 -07:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBaseScreen::GetContentsScaleFactor(double* aContentsScaleFactor)
|
|
|
|
{
|
|
|
|
*aContentsScaleFactor = 1.0;
|
|
|
|
return NS_OK;
|
|
|
|
}
|