Bug 1889091 - Part 4: Remove extra stack pointer move. r=jandem
[gecko.git] / widget / Screen.h
blobca2efa1f5996438db349566b6b19c20202047648
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_widget_Screen_h
8 #define mozilla_widget_Screen_h
10 #include "nsIScreen.h"
12 #include "Units.h"
13 #include "mozilla/HalScreenConfiguration.h" // For hal::ScreenOrientation
15 namespace mozilla {
16 namespace dom {
17 class ScreenDetails;
18 } // namespace dom
20 namespace widget {
22 class Screen final : public nsIScreen {
23 public:
24 NS_DECL_ISUPPORTS
25 NS_DECL_NSISCREEN
27 using OrientationAngle = uint16_t;
28 enum class IsPseudoDisplay : bool { No, Yes };
29 enum class IsHDR : bool { No, Yes };
31 Screen(LayoutDeviceIntRect aRect, LayoutDeviceIntRect aAvailRect,
32 uint32_t aPixelDepth, uint32_t aColorDepth, uint32_t aRefreshRate,
33 DesktopToLayoutDeviceScale aContentsScale,
34 CSSToLayoutDeviceScale aDefaultCssScale, float aDpi, IsPseudoDisplay,
35 IsHDR, hal::ScreenOrientation = hal::ScreenOrientation::None,
36 OrientationAngle = 0);
37 explicit Screen(const dom::ScreenDetails& aScreenDetails);
38 Screen(const Screen& aOther);
40 dom::ScreenDetails ToScreenDetails() const;
42 OrientationAngle GetOrientationAngle() const { return mOrientationAngle; }
43 hal::ScreenOrientation GetOrientationType() const {
44 return mScreenOrientation;
47 /**
48 * Return default orientation type that angle is 0.
49 * This returns LandscapePrimary or PortraitPrimary.
51 hal::ScreenOrientation GetDefaultOrientationType() const;
53 float GetDPI() const { return mDPI; }
55 const LayoutDeviceIntRect& GetRect() const { return mRect; }
56 const LayoutDeviceIntRect& GetAvailRect() const { return mAvailRect; }
57 const DesktopToLayoutDeviceScale& GetContentsScaleFactor() const {
58 return mContentsScale;
61 enum class IncludeOSZoom : bool { No, Yes };
62 CSSToLayoutDeviceScale GetCSSToLayoutDeviceScale(IncludeOSZoom) const;
64 bool GetIsHDR() const { return mIsHDR; }
66 private:
67 virtual ~Screen() = default;
69 const LayoutDeviceIntRect mRect;
70 const LayoutDeviceIntRect mAvailRect;
71 const DesktopIntRect mRectDisplayPix;
72 const DesktopIntRect mAvailRectDisplayPix;
73 const uint32_t mPixelDepth;
74 const uint32_t mColorDepth;
75 const uint32_t mRefreshRate;
76 const DesktopToLayoutDeviceScale mContentsScale;
77 const CSSToLayoutDeviceScale mDefaultCssScale;
78 const float mDPI;
79 const hal::ScreenOrientation mScreenOrientation;
80 const OrientationAngle mOrientationAngle;
81 const bool mIsPseudoDisplay;
82 const bool mIsHDR;
85 } // namespace widget
86 } // namespace mozilla
88 #endif