nsBaseScreen.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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/. */
  7. #ifndef nsBaseScreen_h
  8. #define nsBaseScreen_h
  9. #include "mozilla/Attributes.h"
  10. #include "nsIScreen.h"
  11. class nsBaseScreen : public nsIScreen
  12. {
  13. public:
  14. nsBaseScreen();
  15. NS_DECL_ISUPPORTS
  16. // nsIScreen interface
  17. // These simply forward to the device-pixel versions;
  18. // implementations where desktop pixels may not correspond
  19. // to per-screen device pixels must override.
  20. NS_IMETHOD GetRectDisplayPix(int32_t *outLeft, int32_t *outTop,
  21. int32_t *outWidth, int32_t *outHeight) override;
  22. NS_IMETHOD GetAvailRectDisplayPix(int32_t *outLeft, int32_t *outTop,
  23. int32_t *outWidth, int32_t *outHeight) override;
  24. /**
  25. * Simple management of screen brightness locks. This abstract base class
  26. * allows all widget implementations to share brightness locking code.
  27. */
  28. NS_IMETHOD LockMinimumBrightness(uint32_t aBrightness) override;
  29. NS_IMETHOD UnlockMinimumBrightness(uint32_t aBrightness) override;
  30. NS_IMETHOD GetRotation(uint32_t* aRotation) override {
  31. *aRotation = nsIScreen::ROTATION_0_DEG;
  32. return NS_OK;
  33. }
  34. NS_IMETHOD SetRotation(uint32_t aRotation) override { return NS_ERROR_NOT_AVAILABLE; }
  35. NS_IMETHOD GetContentsScaleFactor(double* aContentsScaleFactor) override;
  36. NS_IMETHOD GetDefaultCSSScaleFactor(double* aScaleFactor) override;
  37. protected:
  38. virtual ~nsBaseScreen();
  39. /**
  40. * Manually set the current level of brightness locking. This is called after
  41. * we determine, based on the current active locks, what the strongest
  42. * lock is. You should normally not call this function - it will be
  43. * called automatically by this class.
  44. *
  45. * Each widget implementation should implement this in a way that
  46. * makes sense there. This is normally the only function that
  47. * contains widget-specific code.
  48. *
  49. * The default implementation does nothing.
  50. *
  51. * @param aBrightness The current brightness level to set. If this is
  52. * nsIScreen::BRIGHTNESS_LEVELS
  53. * (an impossible value for a brightness level to be),
  54. * then that signifies that there is no current
  55. * minimum brightness level, and the screen can shut off.
  56. */
  57. virtual void ApplyMinimumBrightness(uint32_t aBrightness) { }
  58. private:
  59. /**
  60. * Checks what the minimum brightness value is, and calls
  61. * ApplyMinimumBrightness.
  62. */
  63. void CheckMinimumBrightness();
  64. uint32_t mBrightnessLocks[nsIScreen::BRIGHTNESS_LEVELS];
  65. };
  66. #endif // nsBaseScreen_h