1 /* 2 * Copyright (c) 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 OHOS_ROSEN_WINDOW_SCENE_SCREEN_CUTOUT_CONTROLLER_H 17 #define OHOS_ROSEN_WINDOW_SCENE_SCREEN_CUTOUT_CONTROLLER_H 18 19 #include <refbase.h> 20 21 #include "cutout_info.h" 22 #include "session/screen/include/screen_property.h" 23 24 namespace OHOS::Rosen { 25 enum class DeviceRotationValue: int32_t { 26 INVALID = -1, 27 ROTATION_PORTRAIT = 0, 28 ROTATION_LANDSCAPE, 29 ROTATION_PORTRAIT_INVERTED, 30 ROTATION_LANDSCAPE_INVERTED, 31 }; 32 class ScreenCutoutController : public RefBase { 33 public: ScreenCutoutController()34 ScreenCutoutController() {}; 35 sptr<CutoutInfo> GetScreenCutoutInfo(DisplayId displayId); 36 RectF CalculateCurvedCompression(const ScreenProperty& screenProperty); 37 uint32_t GetOffsetY(); 38 39 private: 40 void CalcWaterfallRects(DisplayId displayId); 41 void ProcessRotationMapping(); 42 void CalcWaterfallRectsByRotation(Rotation rotation, uint32_t displayHeight, uint32_t displayWidth, 43 std::vector<uint32_t> realNumVec); 44 void CheckBoundaryRects(std::vector<DMRect>& boundaryRects, ScreenProperty screenProperty); 45 void ConvertBoundaryRectsByRotation(std::vector<DMRect>& boundaryRects, DisplayId displayId); 46 void CurrentRotation90(const std::vector<DMRect>& displayBoundaryRects, std::vector<DMRect>& finalVector, 47 uint32_t displayWidth); 48 void CurrentRotation180(const std::vector<DMRect>& displayBoundaryRects, std::vector<DMRect>& finalVector, 49 uint32_t displayWidth, uint32_t displayHeight); 50 void CurrentRotation270(const std::vector<DMRect>& displayBoundaryRects, std::vector<DMRect>& finalVector, 51 uint32_t displayHeight); 52 bool IsDisplayRotationHorizontal(Rotation rotation); 53 DMRect CreateWaterfallRect(uint32_t left, uint32_t top, uint32_t width, uint32_t height); 54 Rotation ConvertDeviceToDisplayRotation(DeviceRotationValue deviceRotation); 55 Rotation GetCurrentDisplayRotation(DisplayId displayId); 56 DEFINE_VAR_DEFAULT_FUNC_GET_SET(bool, WaterfallDisplayCompressionStatus, waterfallDisplayCompressionStatus, false); 57 58 static uint32_t defaultDeviceRotation_; 59 static std::map<DeviceRotationValue, Rotation> deviceToDisplayRotationMap_; 60 uint32_t offsetY_ {}; 61 WaterfallDisplayAreaRects waterfallDisplayAreaRects_ = {}; 62 }; 63 } // namespace OHOS::Rosen 64 #endif // OHOS_ROSEN_WINDOW_SCENE_SCREEN_CUTOUT_CONTROLLER_H 65