1e0dac50fSopenharmony_ci/*
2e0dac50fSopenharmony_ci * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3e0dac50fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4e0dac50fSopenharmony_ci * you may not use this file except in compliance with the License.
5e0dac50fSopenharmony_ci * You may obtain a copy of the License at
6e0dac50fSopenharmony_ci *
7e0dac50fSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8e0dac50fSopenharmony_ci *
9e0dac50fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10e0dac50fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11e0dac50fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12e0dac50fSopenharmony_ci * See the License for the specific language governing permissions and
13e0dac50fSopenharmony_ci * limitations under the License.
14e0dac50fSopenharmony_ci */
15e0dac50fSopenharmony_ci
16e0dac50fSopenharmony_ci#ifndef FOUNDATION_DMSERVER_ABSTRACT_DISPLAY_CONTROLLER_H
17e0dac50fSopenharmony_ci#define FOUNDATION_DMSERVER_ABSTRACT_DISPLAY_CONTROLLER_H
18e0dac50fSopenharmony_ci
19e0dac50fSopenharmony_ci#include "abstract_screen_controller.h"
20e0dac50fSopenharmony_ci
21e0dac50fSopenharmony_ci#include <map>
22e0dac50fSopenharmony_ci#include <pixel_map.h>
23e0dac50fSopenharmony_ci#include <surface.h>
24e0dac50fSopenharmony_ci#include <transaction/rs_interfaces.h>
25e0dac50fSopenharmony_ci
26e0dac50fSopenharmony_ci#include "screen.h"
27e0dac50fSopenharmony_ci#include "abstract_display.h"
28e0dac50fSopenharmony_ci#include "display_change_listener.h"
29e0dac50fSopenharmony_ci#include "future.h"
30e0dac50fSopenharmony_ci
31e0dac50fSopenharmony_cinamespace OHOS::Rosen {
32e0dac50fSopenharmony_ciclass AbstractDisplayController : public RefBase {
33e0dac50fSopenharmony_ciusing DisplayStateChangeListener = std::function<void(DisplayId, sptr<DisplayInfo>,
34e0dac50fSopenharmony_ci    const std::map<DisplayId, sptr<DisplayInfo>>&, DisplayStateChangeType)>;
35e0dac50fSopenharmony_cipublic:
36e0dac50fSopenharmony_ci    AbstractDisplayController(std::recursive_mutex& mutex, DisplayStateChangeListener);
37e0dac50fSopenharmony_ci    ~AbstractDisplayController();
38e0dac50fSopenharmony_ci    WM_DISALLOW_COPY_AND_MOVE(AbstractDisplayController);
39e0dac50fSopenharmony_ci
40e0dac50fSopenharmony_ci    void Init(sptr<AbstractScreenController> abstractScreenController);
41e0dac50fSopenharmony_ci    ScreenId GetDefaultScreenId();
42e0dac50fSopenharmony_ci    RSScreenModeInfo GetScreenActiveMode(ScreenId id);
43e0dac50fSopenharmony_ci
44e0dac50fSopenharmony_ci    std::shared_ptr<Media::PixelMap> GetScreenSnapshot(DisplayId displayId);
45e0dac50fSopenharmony_ci    sptr<AbstractDisplay> GetAbstractDisplay(DisplayId displayId) const;
46e0dac50fSopenharmony_ci    sptr<AbstractDisplay> GetAbstractDisplayByScreen(ScreenId screenId) const;
47e0dac50fSopenharmony_ci    std::vector<DisplayId> GetAllDisplayIds() const;
48e0dac50fSopenharmony_ci    void SetFreeze(std::vector<DisplayId> displayIds, bool isFreeze);
49e0dac50fSopenharmony_ci
50e0dac50fSopenharmony_ciprivate:
51e0dac50fSopenharmony_ci    void OnAbstractScreenConnect(sptr<AbstractScreen> absScreen);
52e0dac50fSopenharmony_ci    void OnAbstractScreenDisconnect(sptr<AbstractScreen> absScreen);
53e0dac50fSopenharmony_ci    void OnAbstractScreenChange(sptr<AbstractScreen> absScreen, DisplayChangeEvent event);
54e0dac50fSopenharmony_ci    void ProcessDisplayUpdateOrientation(sptr<AbstractScreen> absScreen, DisplayStateChangeType type);
55e0dac50fSopenharmony_ci    void ProcessDisplaySizeChange(sptr<AbstractScreen> absScreen);
56e0dac50fSopenharmony_ci    void ProcessVirtualPixelRatioChange(sptr<AbstractScreen> absScreen);
57e0dac50fSopenharmony_ci    void ProcessDisplayRotationChange(sptr<AbstractScreen> absScreen, DisplayStateChangeType type);
58e0dac50fSopenharmony_ci    void ProcessDisplayCompression(sptr<AbstractScreen> absScreen);
59e0dac50fSopenharmony_ci    sptr<AbstractDisplay> GetAbstractDisplayByAbsScreen(sptr<AbstractScreen> absScreen);
60e0dac50fSopenharmony_ci    void BindAloneScreenLocked(sptr<AbstractScreen> absScreen);
61e0dac50fSopenharmony_ci    void AddScreenToMirrorLocked(sptr<AbstractScreen> absScreen);
62e0dac50fSopenharmony_ci    void AddScreenToExpandLocked(sptr<AbstractScreen> absScreen);
63e0dac50fSopenharmony_ci    std::map<DisplayId, sptr<DisplayInfo>> GetAllDisplayInfoOfGroup(sptr<DisplayInfo> info);
64e0dac50fSopenharmony_ci    DisplayId ProcessNormalScreenDisconnected(
65e0dac50fSopenharmony_ci        sptr<AbstractScreen> absScreen, sptr<AbstractScreenGroup> screenGroup, sptr<AbstractDisplay>& absDisplay);
66e0dac50fSopenharmony_ci    DisplayId ProcessExpandScreenDisconnected(
67e0dac50fSopenharmony_ci        sptr<AbstractScreen> absScreen, sptr<AbstractScreenGroup> screenGroup, sptr<AbstractDisplay>& absDisplay);
68e0dac50fSopenharmony_ci    bool UpdateDisplaySize(sptr<AbstractDisplay> absDisplay, sptr<SupportedScreenModes> info,
69e0dac50fSopenharmony_ci        Point offset = Point(0, 0));
70e0dac50fSopenharmony_ci    void SetDisplayStateChangeListener(sptr<AbstractDisplay> abstractDisplay, DisplayStateChangeType type);
71e0dac50fSopenharmony_ci    DisplayId GetDefaultDisplayId();
72e0dac50fSopenharmony_ci
73e0dac50fSopenharmony_ci    std::recursive_mutex& mutex_;
74e0dac50fSopenharmony_ci    std::atomic<DisplayId> displayCount_ { 0 };
75e0dac50fSopenharmony_ci    sptr<AbstractDisplay> dummyDisplay_;
76e0dac50fSopenharmony_ci    std::map<DisplayId, sptr<AbstractDisplay>> abstractDisplayMap_;
77e0dac50fSopenharmony_ci    sptr<AbstractScreenController> abstractScreenController_;
78e0dac50fSopenharmony_ci    sptr<AbstractScreenController::AbstractScreenCallback> abstractScreenCallback_;
79e0dac50fSopenharmony_ci    OHOS::Rosen::RSInterfaces& rsInterface_;
80e0dac50fSopenharmony_ci    DisplayStateChangeListener displayStateChangeListener_;
81e0dac50fSopenharmony_ci};
82e0dac50fSopenharmony_ci} // namespace OHOS::Rosen
83e0dac50fSopenharmony_ci#endif // FOUNDATION_DMSERVER_ABSTRACT_DISPLAY_CONTROLLER_H