• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 #include "screen_group.h"
17 
18 #include <new>
19 
20 #include "class_var_definition.h"
21 #include "display_manager_adapter.h"
22 #include "screen_group_info.h"
23 #include "screen_info.h"
24 #include "singleton_container.h"
25 #include "window_manager_hilog.h"
26 
27 namespace OHOS::Rosen {
28 namespace {
29     constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "ScreenGroup"};
30 }
31 class ScreenGroup::Impl : public RefBase {
32 public:
Impl(sptr<ScreenGroupInfo> info)33     explicit Impl(sptr<ScreenGroupInfo> info)
34     {
35         screenGroupInfo_ = info;
36     }
37     ~Impl() = default;
38 
39     DEFINE_VAR_FUNC_GET_SET_WITH_LOCK(sptr<ScreenGroupInfo>, ScreenGroupInfo, screenGroupInfo);
40 };
41 
ScreenGroup(sptr<ScreenGroupInfo> info)42 ScreenGroup::ScreenGroup(sptr<ScreenGroupInfo> info)
43     : Screen(info), pImpl_(new Impl(info))
44 {
45 }
46 
UpdateScreenGroupInfo(sptr<ScreenGroupInfo> info) const47 void ScreenGroup::UpdateScreenGroupInfo(sptr<ScreenGroupInfo> info) const
48 {
49     if (info == nullptr) {
50         WLOGFE("ScreenGroupInfo is nullptr.");
51         return;
52     }
53     Screen::UpdateScreenInfo(info);
54     pImpl_->SetScreenGroupInfo(info);
55 }
56 
UpdateScreenGroupInfo() const57 void ScreenGroup::UpdateScreenGroupInfo() const
58 {
59     auto screenInfo = SingletonContainer::Get<ScreenManagerAdapter>().GetScreenGroupInfoById(GetId());
60     UpdateScreenGroupInfo(screenInfo);
61 }
62 
~ScreenGroup()63 ScreenGroup::~ScreenGroup()
64 {
65 }
66 
GetCombination() const67 ScreenCombination ScreenGroup::GetCombination() const
68 {
69     UpdateScreenGroupInfo();
70     return pImpl_->GetScreenGroupInfo()->GetCombination();
71 }
72 
GetChildIds() const73 std::vector<ScreenId> ScreenGroup::GetChildIds() const
74 {
75     UpdateScreenGroupInfo();
76     return pImpl_->GetScreenGroupInfo()->GetChildren();
77 }
78 
GetChildPositions() const79 std::vector<Point> ScreenGroup::GetChildPositions() const
80 {
81     UpdateScreenGroupInfo();
82     return pImpl_->GetScreenGroupInfo()->GetPosition();
83 }
84 } // namespace OHOS::Rosen