2017-03-14 18:44:54 +08:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_widget_Screen_h
|
|
|
|
#define mozilla_widget_Screen_h
|
|
|
|
|
|
|
|
#include "nsIScreen.h"
|
|
|
|
|
|
|
|
#include "Units.h"
|
2022-02-15 20:22:54 +00:00
|
|
|
#include "mozilla/HalScreenConfiguration.h" // For hal::ScreenOrientation
|
2017-03-14 18:44:54 +08:00
|
|
|
|
2017-03-09 19:30:26 +08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class ScreenDetails;
|
|
|
|
} // namespace dom
|
|
|
|
|
2017-03-14 18:44:54 +08:00
|
|
|
namespace widget {
|
|
|
|
|
|
|
|
class Screen final : public nsIScreen {
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSISCREEN
|
|
|
|
|
2022-02-15 20:22:54 +00:00
|
|
|
using OrientationAngle = uint16_t;
|
2022-05-06 23:37:25 +00:00
|
|
|
enum class IsPseudoDisplay : bool { No, Yes };
|
2022-02-15 20:22:54 +00:00
|
|
|
|
2017-03-14 18:44:54 +08:00
|
|
|
Screen(LayoutDeviceIntRect aRect, LayoutDeviceIntRect aAvailRect,
|
2022-05-06 23:37:25 +00:00
|
|
|
uint32_t aPixelDepth, uint32_t aColorDepth, uint32_t aRefreshRate,
|
2017-03-14 18:44:54 +08:00
|
|
|
DesktopToLayoutDeviceScale aContentsScale,
|
2022-05-06 23:37:25 +00:00
|
|
|
CSSToLayoutDeviceScale aDefaultCssScale, float aDpi, IsPseudoDisplay,
|
2022-02-15 20:22:54 +00:00
|
|
|
hal::ScreenOrientation = hal::ScreenOrientation::None,
|
|
|
|
OrientationAngle = 0);
|
|
|
|
explicit Screen(const dom::ScreenDetails& aScreenDetails);
|
2017-03-14 18:44:54 +08:00
|
|
|
Screen(const Screen& aOther);
|
|
|
|
|
2022-02-15 20:22:54 +00:00
|
|
|
dom::ScreenDetails ToScreenDetails() const;
|
2017-03-09 19:30:26 +08:00
|
|
|
|
2022-02-15 20:22:54 +00:00
|
|
|
OrientationAngle GetOrientationAngle() const { return mOrientationAngle; }
|
|
|
|
hal::ScreenOrientation GetOrientationType() const {
|
|
|
|
return mScreenOrientation;
|
|
|
|
}
|
2021-12-30 05:09:40 +00:00
|
|
|
|
2022-11-24 15:10:15 +00:00
|
|
|
/**
|
|
|
|
* Return default orientation type that angle is 0.
|
|
|
|
* This returns LandscapePrimary or PortraitPrimary.
|
|
|
|
*/
|
|
|
|
hal::ScreenOrientation GetDefaultOrientationType() const;
|
|
|
|
|
2022-02-16 21:13:58 +00:00
|
|
|
float GetDPI() const { return mDPI; }
|
|
|
|
|
2022-05-06 23:37:25 +00:00
|
|
|
const LayoutDeviceIntRect& GetRect() const { return mRect; }
|
|
|
|
const LayoutDeviceIntRect& GetAvailRect() const { return mAvailRect; }
|
|
|
|
const DesktopToLayoutDeviceScale& GetContentsScaleFactor() const {
|
|
|
|
return mContentsScale;
|
|
|
|
}
|
|
|
|
|
2022-11-16 15:52:07 +00:00
|
|
|
enum class IncludeOSZoom : bool { No, Yes };
|
|
|
|
CSSToLayoutDeviceScale GetCSSToLayoutDeviceScale(IncludeOSZoom) const;
|
|
|
|
|
2017-03-14 18:44:54 +08:00
|
|
|
private:
|
2020-03-16 10:56:57 +00:00
|
|
|
virtual ~Screen() = default;
|
2017-03-14 18:44:54 +08:00
|
|
|
|
2022-02-15 20:22:54 +00:00
|
|
|
const LayoutDeviceIntRect mRect;
|
|
|
|
const LayoutDeviceIntRect mAvailRect;
|
|
|
|
const DesktopIntRect mRectDisplayPix;
|
|
|
|
const DesktopIntRect mAvailRectDisplayPix;
|
|
|
|
const uint32_t mPixelDepth;
|
|
|
|
const uint32_t mColorDepth;
|
2022-05-06 23:37:25 +00:00
|
|
|
const uint32_t mRefreshRate;
|
2022-02-15 20:22:54 +00:00
|
|
|
const DesktopToLayoutDeviceScale mContentsScale;
|
|
|
|
const CSSToLayoutDeviceScale mDefaultCssScale;
|
|
|
|
const float mDPI;
|
|
|
|
const hal::ScreenOrientation mScreenOrientation;
|
|
|
|
const OrientationAngle mOrientationAngle;
|
2022-05-06 23:37:25 +00:00
|
|
|
const bool mIsPseudoDisplay;
|
2017-03-14 18:44:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace widget
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif
|