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