Fix typo in 9b54bd30006c008b4a951331b273613d5bac3abf
[pm.git] / widget / nsBaseScreen.cpp
blobeafb52f97aa478a59068fc2690a5cf1898f6cdea
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: sw=2 ts=8 et :
3 */
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #define MOZ_FATAL_ASSERTIONS_FOR_THREAD_SAFETY
10 #include "nsBaseScreen.h"
12 NS_IMPL_ISUPPORTS(nsBaseScreen, nsIScreen)
14 nsBaseScreen::nsBaseScreen()
16 for (uint32_t i = 0; i < nsIScreen::BRIGHTNESS_LEVELS; i++)
17 mBrightnessLocks[i] = 0;
20 nsBaseScreen::~nsBaseScreen() { }
22 NS_IMETHODIMP
23 nsBaseScreen::GetRectDisplayPix(int32_t *outLeft, int32_t *outTop,
24 int32_t *outWidth, int32_t *outHeight)
26 return GetRect(outLeft, outTop, outWidth, outHeight);
29 NS_IMETHODIMP
30 nsBaseScreen::GetAvailRectDisplayPix(int32_t *outLeft, int32_t *outTop,
31 int32_t *outWidth, int32_t *outHeight)
33 return GetAvailRect(outLeft, outTop, outWidth, outHeight);
36 NS_IMETHODIMP
37 nsBaseScreen::LockMinimumBrightness(uint32_t aBrightness)
39 MOZ_ASSERT(aBrightness < nsIScreen::BRIGHTNESS_LEVELS,
40 "Invalid brightness level to lock");
41 mBrightnessLocks[aBrightness]++;
42 MOZ_ASSERT(mBrightnessLocks[aBrightness] > 0,
43 "Overflow after locking brightness level");
45 CheckMinimumBrightness();
47 return NS_OK;
50 NS_IMETHODIMP
51 nsBaseScreen::UnlockMinimumBrightness(uint32_t aBrightness)
53 MOZ_ASSERT(aBrightness < nsIScreen::BRIGHTNESS_LEVELS,
54 "Invalid brightness level to lock");
55 MOZ_ASSERT(mBrightnessLocks[aBrightness] > 0,
56 "Unlocking a brightness level with no corresponding lock");
57 mBrightnessLocks[aBrightness]--;
59 CheckMinimumBrightness();
61 return NS_OK;
64 void
65 nsBaseScreen::CheckMinimumBrightness()
67 uint32_t brightness = nsIScreen::BRIGHTNESS_LEVELS;
68 for (int32_t i = nsIScreen::BRIGHTNESS_LEVELS - 1; i >=0; i--) {
69 if (mBrightnessLocks[i] > 0) {
70 brightness = i;
71 break;
75 ApplyMinimumBrightness(brightness);
78 NS_IMETHODIMP
79 nsBaseScreen::GetContentsScaleFactor(double* aContentsScaleFactor)
81 *aContentsScaleFactor = 1.0;
82 return NS_OK;