1 /*
2  * Copyright (c) 2021-2023 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 RS_SCREEN_DATA
17 #define RS_SCREEN_DATA
18 
19 #include <cstdint>
20 #include <parcel.h>
21 #include <refbase.h>
22 #include <string>
23 #include <vector>
24 
25 #include "common/rs_macros.h"
26 #include "screen_manager/rs_screen_capability.h"
27 #include "screen_manager/rs_screen_mode_info.h"
28 #include "screen_manager/rs_screen_props.h"
29 #include "screen_manager/screen_types.h"
30 
31 namespace OHOS {
32 namespace Rosen {
33 class RSB_EXPORT RSScreenData : public Parcelable {
34 public:
35     RSScreenData() = default;
36     RSScreenData(RSScreenCapability capability, RSScreenModeInfo activityModeInfo,
37         const std::vector<RSScreenModeInfo>& supportModeInfo, ScreenPowerStatus powerStatus);
38     ~RSScreenData() = default;
39     [[nodiscard]] static RSScreenData* Unmarshalling(Parcel &parcel);
40     bool Marshalling(Parcel &parcel) const override;
41 
42     void SetCapability(const RSScreenCapability& capability);
43     void SetActivityModeInfo(const RSScreenModeInfo& activityModeInfo);
44     void SetSupportModeInfo(const std::vector<RSScreenModeInfo>& supportModeInfo);
45     void SetPowerStatus(ScreenPowerStatus powerStatus);
46 
47     RSScreenCapability GetCapability() const;
48     RSScreenModeInfo GetActivityModeInfo() const;
49     const std::vector<RSScreenModeInfo>& GetSupportModeInfo() const;
50     ScreenPowerStatus GetPowerStatus() const;
51 
52 private:
53     bool WriteVector(const std::vector<RSScreenModeInfo> &supportModes, Parcel &parcel) const;
54     static bool ReadVector(std::vector<RSScreenModeInfo> &unmarsupportModes, uint32_t unmarModeCount, Parcel &parcel);
55     RSScreenCapability capability_;
56     RSScreenModeInfo activityModeInfo_;
57     std::vector<RSScreenModeInfo> supportModeInfo_;
58     ScreenPowerStatus powerStatus_ = INVALID_POWER_STATUS;
59 };
60 } // namespace Rosen
61 } // namespace OHOS
62 
63 #endif // RS_SCREEN_DATA