• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef DISPLAY_MANAGER_ADAPTER_H
17 #define DISPLAY_MANAGER_ADAPTER_H
18 
19 #include <memory>
20 
21 namespace OHOS::NWeb {
22 using DisplayId = uint64_t;
23 enum class RotationType : uint32_t {
24     ROTATION_0,
25     ROTATION_90,
26     ROTATION_180,
27     ROTATION_270,
28     ROTATION_BUTT,
29 };
30 
31 enum class OrientationType : uint32_t {
32     UNSPECIFIED = 0,
33     VERTICAL = 1,
34     HORIZONTAL = 2,
35     REVERSE_VERTICAL = 3,
36     REVERSE_HORIZONTAL = 4,
37     SENSOR = 5,
38     SENSOR_VERTICAL = 6,
39     SENSOR_HORIZONTAL = 7,
40     BUTT,
41 };
42 
43 class DisplayListenerAdapter {
44 public:
45     DisplayListenerAdapter() = default;
46 
47     virtual ~DisplayListenerAdapter() = default;
48 
49     virtual void OnCreate(DisplayId) = 0;
50 
51     virtual void OnDestroy(DisplayId) = 0;
52 
53     virtual void OnChange(DisplayId) = 0;
54 };
55 
56 class DisplayAdapter {
57 public:
58     DisplayAdapter() = default;
59 
60     virtual ~DisplayAdapter() = default;
61 
62     virtual DisplayId GetId() = 0;
63 
64     virtual int32_t GetWidth() = 0;
65 
66     virtual int32_t GetHeight() = 0;
67 
68     virtual float GetVirtualPixelRatio() = 0;
69 
70     virtual RotationType GetRotation() = 0;
71 
72     virtual OrientationType GetOrientation() = 0;
73 };
74 
75 class DisplayManagerAdapter {
76 public:
77     DisplayManagerAdapter() = default;
78 
79     virtual ~DisplayManagerAdapter() = default;
80 
81     virtual DisplayId GetDefaultDisplayId() = 0;
82 
83     virtual std::shared_ptr<DisplayAdapter> GetDefaultDisplay() = 0;
84 
85     virtual bool RegisterDisplayListener(std::shared_ptr<DisplayListenerAdapter> listener) = 0;
86 
87     virtual bool UnregisterDisplayListener(std::shared_ptr<DisplayListenerAdapter> listener) = 0;
88 
89     virtual bool IsDefaultPortrait() = 0;
90 };
91 }  // namespace OHOS::NWeb
92 
93 #endif  // DISPLAY_MANAGER_ADAPTER_H