/* * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef FOUNDATION_DMSERVER_ABSTRACT_DISPLAY_CONTROLLER_H #define FOUNDATION_DMSERVER_ABSTRACT_DISPLAY_CONTROLLER_H #include "abstract_screen_controller.h" #include #include #include #include #include "screen.h" #include "abstract_display.h" #include "display_change_listener.h" #include "future.h" namespace OHOS::Rosen { class AbstractDisplayController : public RefBase { using DisplayStateChangeListener = std::function, const std::map>&, DisplayStateChangeType)>; public: AbstractDisplayController(std::recursive_mutex& mutex, DisplayStateChangeListener); ~AbstractDisplayController(); WM_DISALLOW_COPY_AND_MOVE(AbstractDisplayController); void Init(sptr abstractScreenController); ScreenId GetDefaultScreenId(); RSScreenModeInfo GetScreenActiveMode(ScreenId id); std::shared_ptr GetScreenSnapshot(DisplayId displayId); sptr GetAbstractDisplay(DisplayId displayId) const; sptr GetAbstractDisplayByScreen(ScreenId screenId) const; std::vector GetAllDisplayIds() const; void SetFreeze(std::vector displayIds, bool isFreeze); private: void OnAbstractScreenConnect(sptr absScreen); void OnAbstractScreenDisconnect(sptr absScreen); void OnAbstractScreenChange(sptr absScreen, DisplayChangeEvent event); void ProcessDisplayUpdateOrientation(sptr absScreen, DisplayStateChangeType type); void ProcessDisplaySizeChange(sptr absScreen); void ProcessVirtualPixelRatioChange(sptr absScreen); void ProcessDisplayRotationChange(sptr absScreen, DisplayStateChangeType type); void ProcessDisplayCompression(sptr absScreen); sptr GetAbstractDisplayByAbsScreen(sptr absScreen); void BindAloneScreenLocked(sptr absScreen); void AddScreenToMirrorLocked(sptr absScreen); void AddScreenToExpandLocked(sptr absScreen); std::map> GetAllDisplayInfoOfGroup(sptr info); DisplayId ProcessNormalScreenDisconnected( sptr absScreen, sptr screenGroup, sptr& absDisplay); DisplayId ProcessExpandScreenDisconnected( sptr absScreen, sptr screenGroup, sptr& absDisplay); bool UpdateDisplaySize(sptr absDisplay, sptr info, Point offset = Point(0, 0)); void SetDisplayStateChangeListener(sptr abstractDisplay, DisplayStateChangeType type); DisplayId GetDefaultDisplayId(); std::recursive_mutex& mutex_; std::atomic displayCount_ { 0 }; sptr dummyDisplay_; std::map> abstractDisplayMap_; sptr abstractScreenController_; sptr abstractScreenCallback_; OHOS::Rosen::RSInterfaces& rsInterface_; DisplayStateChangeListener displayStateChangeListener_; }; } // namespace OHOS::Rosen #endif // FOUNDATION_DMSERVER_ABSTRACT_DISPLAY_CONTROLLER_H