• 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 #include <refbase.h>
21 
22 namespace OHOS::NWeb {
23 using DisplayId = uint64_t;
24 enum class RotationType : uint32_t {
25     ROTATION_0,
26     ROTATION_90,
27     ROTATION_180,
28     ROTATION_270,
29     ROTATION_BUTT,
30 };
31 
32 enum class OrientationType : uint32_t {
33     UNSPECIFIED = 0,
34     VERTICAL = 1,
35     HORIZONTAL = 2,
36     REVERSE_VERTICAL = 3,
37     REVERSE_HORIZONTAL = 4,
38     SENSOR = 5,
39     SENSOR_VERTICAL = 6,
40     SENSOR_HORIZONTAL = 7,
41     BUTT,
42 };
43 
44 class DisplayListenerAdapter {
45 public:
46     DisplayListenerAdapter() = default;
47 
48     virtual ~DisplayListenerAdapter() = default;
49 
50     virtual void OnCreate(DisplayId) = 0;
51 
52     virtual void OnDestroy(DisplayId) = 0;
53 
54     virtual void OnChange(DisplayId) = 0;
55 };
56 
57 class DisplayAdapter {
58 public:
59     DisplayAdapter() = default;
60 
61     virtual ~DisplayAdapter() = default;
62 
63     virtual DisplayId GetId() = 0;
64 
65     virtual int32_t GetWidth() = 0;
66 
67     virtual int32_t GetHeight() = 0;
68 
69     virtual float GetVirtualPixelRatio() = 0;
70 
71     virtual RotationType GetRotation() = 0;
72 
73     virtual OrientationType GetOrientation() = 0;
74 };
75 
76 class DisplayManagerAdapter {
77 public:
78     DisplayManagerAdapter() = default;
79 
80     virtual ~DisplayManagerAdapter() = default;
81 
82     virtual DisplayId GetDefaultDisplayId() = 0;
83 
84     virtual std::shared_ptr<DisplayAdapter> GetDefaultDisplay() = 0;
85 
86     virtual bool RegisterDisplayListener(std::shared_ptr<DisplayListenerAdapter> listener) = 0;
87 
88     virtual bool UnregisterDisplayListener(std::shared_ptr<DisplayListenerAdapter> listener) = 0;
89 
90     virtual bool IsDefaultPortrait() = 0;
91 };
92 }  // namespace OHOS::NWeb
93 
94 #endif  // DISPLAY_MANAGER_ADAPTER_H