1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/widget/xpwidgets/nsBaseScreen.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,85 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- 1.5 + * vim: sw=2 ts=8 et : 1.6 + */ 1.7 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.8 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.9 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.10 + 1.11 +#define MOZ_FATAL_ASSERTIONS_FOR_THREAD_SAFETY 1.12 + 1.13 +#include "nsBaseScreen.h" 1.14 + 1.15 +NS_IMPL_ISUPPORTS(nsBaseScreen, nsIScreen) 1.16 + 1.17 +nsBaseScreen::nsBaseScreen() 1.18 +{ 1.19 + for (uint32_t i = 0; i < nsIScreen::BRIGHTNESS_LEVELS; i++) 1.20 + mBrightnessLocks[i] = 0; 1.21 +} 1.22 + 1.23 +nsBaseScreen::~nsBaseScreen() { } 1.24 + 1.25 +NS_IMETHODIMP 1.26 +nsBaseScreen::GetRectDisplayPix(int32_t *outLeft, int32_t *outTop, 1.27 + int32_t *outWidth, int32_t *outHeight) 1.28 +{ 1.29 + return GetRect(outLeft, outTop, outWidth, outHeight); 1.30 +} 1.31 + 1.32 +NS_IMETHODIMP 1.33 +nsBaseScreen::GetAvailRectDisplayPix(int32_t *outLeft, int32_t *outTop, 1.34 + int32_t *outWidth, int32_t *outHeight) 1.35 +{ 1.36 + return GetAvailRect(outLeft, outTop, outWidth, outHeight); 1.37 +} 1.38 + 1.39 +NS_IMETHODIMP 1.40 +nsBaseScreen::LockMinimumBrightness(uint32_t aBrightness) 1.41 +{ 1.42 + NS_ABORT_IF_FALSE( 1.43 + aBrightness < nsIScreen::BRIGHTNESS_LEVELS, 1.44 + "Invalid brightness level to lock"); 1.45 + mBrightnessLocks[aBrightness]++; 1.46 + NS_ABORT_IF_FALSE(mBrightnessLocks[aBrightness] > 0, 1.47 + "Overflow after locking brightness level"); 1.48 + 1.49 + CheckMinimumBrightness(); 1.50 + 1.51 + return NS_OK; 1.52 +} 1.53 + 1.54 +NS_IMETHODIMP 1.55 +nsBaseScreen::UnlockMinimumBrightness(uint32_t aBrightness) 1.56 +{ 1.57 + NS_ABORT_IF_FALSE( 1.58 + aBrightness < nsIScreen::BRIGHTNESS_LEVELS, 1.59 + "Invalid brightness level to lock"); 1.60 + NS_ABORT_IF_FALSE(mBrightnessLocks[aBrightness] > 0, 1.61 + "Unlocking a brightness level with no corresponding lock"); 1.62 + mBrightnessLocks[aBrightness]--; 1.63 + 1.64 + CheckMinimumBrightness(); 1.65 + 1.66 + return NS_OK; 1.67 +} 1.68 + 1.69 +void 1.70 +nsBaseScreen::CheckMinimumBrightness() 1.71 +{ 1.72 + uint32_t brightness = nsIScreen::BRIGHTNESS_LEVELS; 1.73 + for (int32_t i = nsIScreen::BRIGHTNESS_LEVELS - 1; i >=0; i--) { 1.74 + if (mBrightnessLocks[i] > 0) { 1.75 + brightness = i; 1.76 + break; 1.77 + } 1.78 + } 1.79 + 1.80 + ApplyMinimumBrightness(brightness); 1.81 +} 1.82 + 1.83 +NS_IMETHODIMP 1.84 +nsBaseScreen::GetContentsScaleFactor(double* aContentsScaleFactor) 1.85 +{ 1.86 + *aContentsScaleFactor = 1.0; 1.87 + return NS_OK; 1.88 +}