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"
13 #include "mozilla/HalScreenConfiguration.h" // For hal::ScreenOrientation
22 class Screen final
: public nsIScreen
{
27 using OrientationAngle
= uint16_t;
28 enum class IsPseudoDisplay
: bool { No
, Yes
};
30 Screen(LayoutDeviceIntRect aRect
, LayoutDeviceIntRect aAvailRect
,
31 uint32_t aPixelDepth
, uint32_t aColorDepth
, uint32_t aRefreshRate
,
32 DesktopToLayoutDeviceScale aContentsScale
,
33 CSSToLayoutDeviceScale aDefaultCssScale
, float aDpi
, IsPseudoDisplay
,
34 hal::ScreenOrientation
= hal::ScreenOrientation::None
,
35 OrientationAngle
= 0);
36 explicit Screen(const dom::ScreenDetails
& aScreenDetails
);
37 Screen(const Screen
& aOther
);
39 dom::ScreenDetails
ToScreenDetails() const;
41 OrientationAngle
GetOrientationAngle() const { return mOrientationAngle
; }
42 hal::ScreenOrientation
GetOrientationType() const {
43 return mScreenOrientation
;
47 * Return default orientation type that angle is 0.
48 * This returns LandscapePrimary or PortraitPrimary.
50 hal::ScreenOrientation
GetDefaultOrientationType() const;
52 float GetDPI() const { return mDPI
; }
54 const LayoutDeviceIntRect
& GetRect() const { return mRect
; }
55 const LayoutDeviceIntRect
& GetAvailRect() const { return mAvailRect
; }
56 const DesktopToLayoutDeviceScale
& GetContentsScaleFactor() const {
57 return mContentsScale
;
60 enum class IncludeOSZoom
: bool { No
, Yes
};
61 CSSToLayoutDeviceScale
GetCSSToLayoutDeviceScale(IncludeOSZoom
) const;
64 virtual ~Screen() = default;
66 const LayoutDeviceIntRect mRect
;
67 const LayoutDeviceIntRect mAvailRect
;
68 const DesktopIntRect mRectDisplayPix
;
69 const DesktopIntRect mAvailRectDisplayPix
;
70 const uint32_t mPixelDepth
;
71 const uint32_t mColorDepth
;
72 const uint32_t mRefreshRate
;
73 const DesktopToLayoutDeviceScale mContentsScale
;
74 const CSSToLayoutDeviceScale mDefaultCssScale
;
76 const hal::ScreenOrientation mScreenOrientation
;
77 const OrientationAngle mOrientationAngle
;
78 const bool mIsPseudoDisplay
;
82 } // namespace mozilla