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