1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/widget/xpwidgets/nsBaseScreen.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,78 @@ 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 +#ifndef nsBaseScreen_h 1.12 +#define nsBaseScreen_h 1.13 + 1.14 +#include "mozilla/Attributes.h" 1.15 +#include "nsIScreen.h" 1.16 + 1.17 +class nsBaseScreen : public nsIScreen 1.18 +{ 1.19 +public: 1.20 + nsBaseScreen(); 1.21 + virtual ~nsBaseScreen(); 1.22 + 1.23 + NS_DECL_ISUPPORTS 1.24 + 1.25 + // nsIScreen interface 1.26 + 1.27 + // These simply forward to the device-pixel versions; 1.28 + // implementations where global display pixels may not correspond 1.29 + // to per-screen device pixels must override. 1.30 + NS_IMETHOD GetRectDisplayPix(int32_t *outLeft, int32_t *outTop, 1.31 + int32_t *outWidth, int32_t *outHeight); 1.32 + NS_IMETHOD GetAvailRectDisplayPix(int32_t *outLeft, int32_t *outTop, 1.33 + int32_t *outWidth, int32_t *outHeight); 1.34 + 1.35 + /** 1.36 + * Simple management of screen brightness locks. This abstract base class 1.37 + * allows all widget implementations to share brightness locking code. 1.38 + */ 1.39 + NS_IMETHOD LockMinimumBrightness(uint32_t aBrightness); 1.40 + NS_IMETHOD UnlockMinimumBrightness(uint32_t aBrightness); 1.41 + 1.42 + NS_IMETHOD GetRotation(uint32_t* aRotation) { 1.43 + *aRotation = nsIScreen::ROTATION_0_DEG; 1.44 + return NS_OK; 1.45 + } 1.46 + NS_IMETHOD SetRotation(uint32_t aRotation) { return NS_ERROR_NOT_AVAILABLE; } 1.47 + 1.48 + NS_IMETHOD GetContentsScaleFactor(double* aContentsScaleFactor); 1.49 + 1.50 +protected: 1.51 + /** 1.52 + * Manually set the current level of brightness locking. This is called after 1.53 + * we determine, based on the current active locks, what the strongest 1.54 + * lock is. You should normally not call this function - it will be 1.55 + * called automatically by this class. 1.56 + * 1.57 + * Each widget implementation should implement this in a way that 1.58 + * makes sense there. This is normally the only function that 1.59 + * contains widget-specific code. 1.60 + * 1.61 + * The default implementation does nothing. 1.62 + * 1.63 + * @param aBrightness The current brightness level to set. If this is 1.64 + * nsIScreen::BRIGHTNESS_LEVELS 1.65 + * (an impossible value for a brightness level to be), 1.66 + * then that signifies that there is no current 1.67 + * minimum brightness level, and the screen can shut off. 1.68 + */ 1.69 + virtual void ApplyMinimumBrightness(uint32_t aBrightness) { } 1.70 + 1.71 +private: 1.72 + /** 1.73 + * Checks what the minimum brightness value is, and calls 1.74 + * ApplyMinimumBrightness. 1.75 + */ 1.76 + void CheckMinimumBrightness(); 1.77 + 1.78 + uint32_t mBrightnessLocks[nsIScreen::BRIGHTNESS_LEVELS]; 1.79 +}; 1.80 + 1.81 +#endif // nsBaseScreen_h