1e0dac50fSopenharmony_ci/* 2e0dac50fSopenharmony_ci * Copyright (c) 2022-2023 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#include "display_cutout_controller.h" 17e0dac50fSopenharmony_ci#include <screen_manager/screen_types.h> 18e0dac50fSopenharmony_ci#include "display_manager_service_inner.h" 19e0dac50fSopenharmony_ci#include "dm_common.h" 20e0dac50fSopenharmony_ci 21e0dac50fSopenharmony_cinamespace OHOS { 22e0dac50fSopenharmony_cinamespace Rosen { 23e0dac50fSopenharmony_cinamespace { 24e0dac50fSopenharmony_ciconstexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "DisplayCutoutController"}; 25e0dac50fSopenharmony_ciconst uint32_t NO_WATERFALL_DISPLAY_COMPRESSION_SIZE = 0; 26e0dac50fSopenharmony_ci} 27e0dac50fSopenharmony_ci 28e0dac50fSopenharmony_cibool DisplayCutoutController::isWaterfallDisplay_ = false; 29e0dac50fSopenharmony_cibool DisplayCutoutController::isWaterfallAreaCompressionEnableWhenHorizontal_ = false; 30e0dac50fSopenharmony_ciuint32_t DisplayCutoutController::waterfallAreaCompressionSizeWhenHorizontal_ = 0; 31e0dac50fSopenharmony_ci 32e0dac50fSopenharmony_civoid DisplayCutoutController::SetBuiltInDisplayCutoutSvgPath(const std::string& svgPath) 33e0dac50fSopenharmony_ci{ 34e0dac50fSopenharmony_ci SetCutoutSvgPath(0, svgPath); 35e0dac50fSopenharmony_ci} 36e0dac50fSopenharmony_ci 37e0dac50fSopenharmony_civoid DisplayCutoutController::SetIsWaterfallDisplay(bool isWaterfallDisplay) 38e0dac50fSopenharmony_ci{ 39e0dac50fSopenharmony_ci WLOGFI("Set isWaterfallDisplay: %{public}u", isWaterfallDisplay); 40e0dac50fSopenharmony_ci isWaterfallDisplay_ = isWaterfallDisplay; 41e0dac50fSopenharmony_ci} 42e0dac50fSopenharmony_ci 43e0dac50fSopenharmony_cibool DisplayCutoutController::IsWaterfallDisplay() 44e0dac50fSopenharmony_ci{ 45e0dac50fSopenharmony_ci return isWaterfallDisplay_; 46e0dac50fSopenharmony_ci} 47e0dac50fSopenharmony_ci 48e0dac50fSopenharmony_civoid DisplayCutoutController::SetCurvedScreenBoundary(std::vector<int> curvedScreenBoundary) 49e0dac50fSopenharmony_ci{ 50e0dac50fSopenharmony_ci while (curvedScreenBoundary.size() < 4) { // 4 directions. 51e0dac50fSopenharmony_ci curvedScreenBoundary.emplace_back(0); 52e0dac50fSopenharmony_ci } 53e0dac50fSopenharmony_ci WLOGFI("Set curvedScreenBoundary"); 54e0dac50fSopenharmony_ci curvedScreenBoundary_ = curvedScreenBoundary; 55e0dac50fSopenharmony_ci} 56e0dac50fSopenharmony_ci 57e0dac50fSopenharmony_civoid DisplayCutoutController::SetCutoutSvgPath(DisplayId displayId, const std::string& svgPath) 58e0dac50fSopenharmony_ci{ 59e0dac50fSopenharmony_ci WLOGFI("Set SvgPath: %{public}s", svgPath.c_str()); 60e0dac50fSopenharmony_ci if (svgPaths_.count(displayId) == 1) { 61e0dac50fSopenharmony_ci svgPaths_[displayId].emplace_back(svgPath); 62e0dac50fSopenharmony_ci } else { 63e0dac50fSopenharmony_ci std::vector<std::string> pathVec; 64e0dac50fSopenharmony_ci pathVec.emplace_back(svgPath); 65e0dac50fSopenharmony_ci svgPaths_[displayId] = pathVec; 66e0dac50fSopenharmony_ci } 67e0dac50fSopenharmony_ci DMRect boundingRect = CalcCutoutBoundingRect(svgPath); 68e0dac50fSopenharmony_ci if (boundingRects_.count(displayId) == 1) { 69e0dac50fSopenharmony_ci boundingRects_[displayId].emplace_back(boundingRect); 70e0dac50fSopenharmony_ci } else { 71e0dac50fSopenharmony_ci std::vector<DMRect> rectVec; 72e0dac50fSopenharmony_ci rectVec.emplace_back(boundingRect); 73e0dac50fSopenharmony_ci boundingRects_[displayId] = rectVec; 74e0dac50fSopenharmony_ci } 75e0dac50fSopenharmony_ci} 76e0dac50fSopenharmony_ci 77e0dac50fSopenharmony_cisptr<CutoutInfo> DisplayCutoutController::GetCutoutInfo(DisplayId displayId) 78e0dac50fSopenharmony_ci{ 79e0dac50fSopenharmony_ci WLOGFD("Get Cutout Info"); 80e0dac50fSopenharmony_ci std::vector<DMRect> boundingRects; 81e0dac50fSopenharmony_ci WaterfallDisplayAreaRects waterfallDisplayAreaRects; 82e0dac50fSopenharmony_ci if (boundingRects_.count(displayId) == 1) { 83e0dac50fSopenharmony_ci TransferBoundingRectsByRotation(displayId, boundingRects); 84e0dac50fSopenharmony_ci } 85e0dac50fSopenharmony_ci if (displayId == DisplayManagerServiceInner::GetInstance().GetDefaultDisplayId()) { 86e0dac50fSopenharmony_ci CalcBuiltInDisplayWaterfallRects(); 87e0dac50fSopenharmony_ci waterfallDisplayAreaRects = waterfallDisplayAreaRects_; 88e0dac50fSopenharmony_ci } 89e0dac50fSopenharmony_ci sptr<CutoutInfo> cutoutInfo(new CutoutInfo(boundingRects, waterfallDisplayAreaRects)); 90e0dac50fSopenharmony_ci return cutoutInfo; 91e0dac50fSopenharmony_ci} 92e0dac50fSopenharmony_ci 93e0dac50fSopenharmony_civoid DisplayCutoutController::CheckBoundingRectsBoundary(DisplayId displayId, std::vector<DMRect>& boundingRects) 94e0dac50fSopenharmony_ci{ 95e0dac50fSopenharmony_ci sptr<SupportedScreenModes> modes = 96e0dac50fSopenharmony_ci DisplayManagerServiceInner::GetInstance().GetScreenModesByDisplayId(displayId); 97e0dac50fSopenharmony_ci if (modes == nullptr) { 98e0dac50fSopenharmony_ci WLOGFE("DisplayId is invalid"); 99e0dac50fSopenharmony_ci return; 100e0dac50fSopenharmony_ci } 101e0dac50fSopenharmony_ci uint32_t displayHeight = modes->height_; 102e0dac50fSopenharmony_ci uint32_t displayWidth = modes->width_; 103e0dac50fSopenharmony_ci for (auto iter = boundingRects.begin(); iter != boundingRects.end();) { 104e0dac50fSopenharmony_ci DMRect boundingRect = *iter; 105e0dac50fSopenharmony_ci if (boundingRect.posX_ < 0 || boundingRect.posY_ < 0 || 106e0dac50fSopenharmony_ci static_cast<int32_t>(boundingRect.width_) + boundingRect.posX_ > static_cast<int32_t>(displayWidth) || 107e0dac50fSopenharmony_ci static_cast<int32_t>(boundingRect.height_) + boundingRect.posY_ > static_cast<int32_t>(displayHeight) || 108e0dac50fSopenharmony_ci boundingRect.width_ > displayWidth || boundingRect.height_ > displayHeight || 109e0dac50fSopenharmony_ci boundingRect.IsUninitializedRect()) { 110e0dac50fSopenharmony_ci WLOGFE("boundingRect boundary is invalid"); 111e0dac50fSopenharmony_ci iter = boundingRects.erase(iter); 112e0dac50fSopenharmony_ci } else { 113e0dac50fSopenharmony_ci iter++; 114e0dac50fSopenharmony_ci } 115e0dac50fSopenharmony_ci } 116e0dac50fSopenharmony_ci} 117e0dac50fSopenharmony_ci 118e0dac50fSopenharmony_ciDMRect DisplayCutoutController::CalcCutoutBoundingRect(std::string svgPath) 119e0dac50fSopenharmony_ci{ 120e0dac50fSopenharmony_ci DMRect emptyRect = {0, 0, 0, 0}; 121e0dac50fSopenharmony_ci SkPath skCutoutSvgPath; 122e0dac50fSopenharmony_ci if (!SkParsePath::FromSVGString(svgPath.c_str(), &skCutoutSvgPath)) { 123e0dac50fSopenharmony_ci WLOGFE("Parse svg string path failed."); 124e0dac50fSopenharmony_ci return emptyRect; 125e0dac50fSopenharmony_ci } 126e0dac50fSopenharmony_ci SkRect skRect = skCutoutSvgPath.computeTightBounds(); 127e0dac50fSopenharmony_ci if (skRect.isEmpty()) { 128e0dac50fSopenharmony_ci WLOGFW("Get empty skRect"); 129e0dac50fSopenharmony_ci return emptyRect; 130e0dac50fSopenharmony_ci } 131e0dac50fSopenharmony_ci SkIRect skiRect = skRect.roundOut(); 132e0dac50fSopenharmony_ci if (skiRect.isEmpty()) { 133e0dac50fSopenharmony_ci WLOGFW("Get empty skiRect"); 134e0dac50fSopenharmony_ci return emptyRect; 135e0dac50fSopenharmony_ci } 136e0dac50fSopenharmony_ci int32_t left = static_cast<int32_t>(skiRect.left()); 137e0dac50fSopenharmony_ci int32_t top = static_cast<int32_t>(skiRect.top()); 138e0dac50fSopenharmony_ci uint32_t width = static_cast<uint32_t>(skiRect.width()); 139e0dac50fSopenharmony_ci uint32_t height = static_cast<uint32_t>(skiRect.height()); 140e0dac50fSopenharmony_ci WLOGFI("calc rect from path,[%{public}d, %{public}d, %{public}u, %{public}u]", left, top, width, height); 141e0dac50fSopenharmony_ci DMRect cutoutMinOuterRect = {.posX_ = left, .posY_ = top, .width_ = width, .height_ = height}; 142e0dac50fSopenharmony_ci return cutoutMinOuterRect; 143e0dac50fSopenharmony_ci} 144e0dac50fSopenharmony_ci 145e0dac50fSopenharmony_civoid DisplayCutoutController::CalcBuiltInDisplayWaterfallRects() 146e0dac50fSopenharmony_ci{ 147e0dac50fSopenharmony_ci WaterfallDisplayAreaRects emptyRects = {}; 148e0dac50fSopenharmony_ci if (!isWaterfallDisplay_) { 149e0dac50fSopenharmony_ci WLOGFI("not waterfall display"); 150e0dac50fSopenharmony_ci waterfallDisplayAreaRects_ = emptyRects; 151e0dac50fSopenharmony_ci return; 152e0dac50fSopenharmony_ci } 153e0dac50fSopenharmony_ci if (curvedScreenBoundary_.empty()) { 154e0dac50fSopenharmony_ci WLOGFI("curved screen boundary is empty"); 155e0dac50fSopenharmony_ci waterfallDisplayAreaRects_ = emptyRects; 156e0dac50fSopenharmony_ci return; 157e0dac50fSopenharmony_ci } 158e0dac50fSopenharmony_ci uint32_t left = static_cast<uint32_t>(curvedScreenBoundary_[0]); 159e0dac50fSopenharmony_ci uint32_t top = static_cast<uint32_t>(curvedScreenBoundary_[1]); 160e0dac50fSopenharmony_ci uint32_t right = static_cast<uint32_t>(curvedScreenBoundary_[2]); 161e0dac50fSopenharmony_ci uint32_t bottom = static_cast<uint32_t>(curvedScreenBoundary_[3]); 162e0dac50fSopenharmony_ci if (left == 0 && top == 0 && right == 0 && bottom == 0) { 163e0dac50fSopenharmony_ci waterfallDisplayAreaRects_ = emptyRects; 164e0dac50fSopenharmony_ci return; 165e0dac50fSopenharmony_ci } 166e0dac50fSopenharmony_ci sptr<SupportedScreenModes> modes = 167e0dac50fSopenharmony_ci DisplayManagerServiceInner::GetInstance().GetScreenModesByDisplayId( 168e0dac50fSopenharmony_ci DisplayManagerServiceInner::GetInstance().GetDefaultDisplayId()); 169e0dac50fSopenharmony_ci if (!modes) { 170e0dac50fSopenharmony_ci WLOGE("support screen modes get failed"); 171e0dac50fSopenharmony_ci waterfallDisplayAreaRects_ = emptyRects; 172e0dac50fSopenharmony_ci return; 173e0dac50fSopenharmony_ci } 174e0dac50fSopenharmony_ci uint32_t displayHeight = modes->height_; 175e0dac50fSopenharmony_ci uint32_t displayWidth = modes->width_; 176e0dac50fSopenharmony_ci 177e0dac50fSopenharmony_ci if ((left > displayWidth / 2) || (right > displayWidth / 2) || // invalid if more than 1/2 width 178e0dac50fSopenharmony_ci (top > displayHeight / 2) || (bottom > displayHeight / 2)) { // invalid if more than 1/2 height 179e0dac50fSopenharmony_ci WLOGFE("Curved screen boundary data is not valid."); 180e0dac50fSopenharmony_ci waterfallDisplayAreaRects_ = emptyRects; 181e0dac50fSopenharmony_ci return; 182e0dac50fSopenharmony_ci } 183e0dac50fSopenharmony_ci CalcBuiltInDisplayWaterfallRectsByRotation( 184e0dac50fSopenharmony_ci DisplayManagerServiceInner::GetInstance().GetDefaultDisplay()->GetRotation(), 185e0dac50fSopenharmony_ci displayHeight, displayWidth); 186e0dac50fSopenharmony_ci} 187e0dac50fSopenharmony_ci 188e0dac50fSopenharmony_civoid DisplayCutoutController::CalcBuiltInDisplayWaterfallRectsByRotation( 189e0dac50fSopenharmony_ci Rotation rotation, uint32_t displayHeight, uint32_t displayWidth) 190e0dac50fSopenharmony_ci{ 191e0dac50fSopenharmony_ci uint32_t left = static_cast<uint32_t>(curvedScreenBoundary_[0]); 192e0dac50fSopenharmony_ci uint32_t top = static_cast<uint32_t>(curvedScreenBoundary_[1]); 193e0dac50fSopenharmony_ci uint32_t right = static_cast<uint32_t>(curvedScreenBoundary_[2]); 194e0dac50fSopenharmony_ci uint32_t bottom = static_cast<uint32_t>(curvedScreenBoundary_[3]); 195e0dac50fSopenharmony_ci switch (rotation) { 196e0dac50fSopenharmony_ci case Rotation::ROTATION_0: { 197e0dac50fSopenharmony_ci DMRect leftRect = CreateWaterfallRect(0, 0, left, displayHeight); 198e0dac50fSopenharmony_ci DMRect topRect = CreateWaterfallRect(0, 0, displayWidth, top); 199e0dac50fSopenharmony_ci DMRect rightRect = CreateWaterfallRect(displayWidth - right, 0, right, displayHeight); 200e0dac50fSopenharmony_ci DMRect bottomRect = CreateWaterfallRect(0, displayHeight - bottom, displayWidth, bottom); 201e0dac50fSopenharmony_ci waterfallDisplayAreaRects_ = WaterfallDisplayAreaRects {leftRect, topRect, rightRect, bottomRect}; 202e0dac50fSopenharmony_ci return; 203e0dac50fSopenharmony_ci } 204e0dac50fSopenharmony_ci case Rotation::ROTATION_90: { 205e0dac50fSopenharmony_ci DMRect leftRect = CreateWaterfallRect(0, 0, bottom, displayWidth); 206e0dac50fSopenharmony_ci DMRect topRect = CreateWaterfallRect(0, 0, displayHeight, left); 207e0dac50fSopenharmony_ci DMRect rightRect = CreateWaterfallRect(displayHeight - top, 0, top, displayWidth); 208e0dac50fSopenharmony_ci DMRect bottomRect = CreateWaterfallRect(0, displayWidth - right, displayHeight, right); 209e0dac50fSopenharmony_ci waterfallDisplayAreaRects_ = WaterfallDisplayAreaRects {leftRect, topRect, rightRect, bottomRect}; 210e0dac50fSopenharmony_ci return; 211e0dac50fSopenharmony_ci } 212e0dac50fSopenharmony_ci case Rotation::ROTATION_180: { 213e0dac50fSopenharmony_ci DMRect leftRect = CreateWaterfallRect(0, 0, right, displayHeight); 214e0dac50fSopenharmony_ci DMRect topRect = CreateWaterfallRect(0, 0, bottom, displayWidth); 215e0dac50fSopenharmony_ci DMRect rightRect = CreateWaterfallRect(displayWidth - left, 0, left, displayHeight); 216e0dac50fSopenharmony_ci DMRect bottomRect = CreateWaterfallRect(0, displayHeight - top, displayWidth, top); 217e0dac50fSopenharmony_ci waterfallDisplayAreaRects_ = WaterfallDisplayAreaRects {leftRect, topRect, rightRect, bottomRect}; 218e0dac50fSopenharmony_ci return; 219e0dac50fSopenharmony_ci } 220e0dac50fSopenharmony_ci case Rotation::ROTATION_270: { 221e0dac50fSopenharmony_ci DMRect leftRect = CreateWaterfallRect(0, 0, top, displayWidth); 222e0dac50fSopenharmony_ci DMRect topRect = CreateWaterfallRect(0, 0, displayHeight, right); 223e0dac50fSopenharmony_ci DMRect rightRect = CreateWaterfallRect(displayHeight - bottom, 0, bottom, displayWidth); 224e0dac50fSopenharmony_ci DMRect bottomRect = CreateWaterfallRect(0, displayWidth - left, displayHeight, left); 225e0dac50fSopenharmony_ci waterfallDisplayAreaRects_ = WaterfallDisplayAreaRects {leftRect, topRect, rightRect, bottomRect}; 226e0dac50fSopenharmony_ci return; 227e0dac50fSopenharmony_ci } 228e0dac50fSopenharmony_ci default: { 229e0dac50fSopenharmony_ci } 230e0dac50fSopenharmony_ci } 231e0dac50fSopenharmony_ci} 232e0dac50fSopenharmony_ci 233e0dac50fSopenharmony_civoid DisplayCutoutController::TransferBoundingRectsByRotation(DisplayId displayId, std::vector<DMRect>& boundingRects) 234e0dac50fSopenharmony_ci{ 235e0dac50fSopenharmony_ci std::vector<DMRect> resultVec; 236e0dac50fSopenharmony_ci if (boundingRects_.count(displayId) == 0) { 237e0dac50fSopenharmony_ci boundingRects = resultVec; 238e0dac50fSopenharmony_ci return; 239e0dac50fSopenharmony_ci } 240e0dac50fSopenharmony_ci std::vector<DMRect> displayBoundingRects = boundingRects_[displayId]; 241e0dac50fSopenharmony_ci if (displayBoundingRects.empty()) { 242e0dac50fSopenharmony_ci boundingRects = resultVec; 243e0dac50fSopenharmony_ci return; 244e0dac50fSopenharmony_ci } 245e0dac50fSopenharmony_ci sptr<DisplayInfo> displayInfo = DisplayManagerServiceInner::GetInstance().GetDisplayById(displayId); 246e0dac50fSopenharmony_ci if (!displayInfo) { 247e0dac50fSopenharmony_ci WLOGFE("display invaild"); 248e0dac50fSopenharmony_ci return; 249e0dac50fSopenharmony_ci } 250e0dac50fSopenharmony_ci Rotation currentRotation = displayInfo->GetRotation(); 251e0dac50fSopenharmony_ci CheckBoundingRectsBoundary(displayId, displayBoundingRects); 252e0dac50fSopenharmony_ci if (currentRotation == Rotation::ROTATION_0) { 253e0dac50fSopenharmony_ci boundingRects = displayBoundingRects; 254e0dac50fSopenharmony_ci return; 255e0dac50fSopenharmony_ci } 256e0dac50fSopenharmony_ci sptr<SupportedScreenModes> modes = 257e0dac50fSopenharmony_ci DisplayManagerServiceInner::GetInstance().GetScreenModesByDisplayId(displayId); 258e0dac50fSopenharmony_ci if (!modes) { 259e0dac50fSopenharmony_ci WLOGE("support screen modes get failed"); 260e0dac50fSopenharmony_ci return; 261e0dac50fSopenharmony_ci } 262e0dac50fSopenharmony_ci uint32_t displayHeight = modes->height_; 263e0dac50fSopenharmony_ci uint32_t displayWidth = modes->width_; 264e0dac50fSopenharmony_ci 265e0dac50fSopenharmony_ci switch (currentRotation) { 266e0dac50fSopenharmony_ci case Rotation::ROTATION_90: { 267e0dac50fSopenharmony_ci CurrentRotation90(resultVec, displayBoundingRects, displayHeight); 268e0dac50fSopenharmony_ci break; 269e0dac50fSopenharmony_ci } 270e0dac50fSopenharmony_ci case Rotation::ROTATION_180: { 271e0dac50fSopenharmony_ci CurrentRotation180(resultVec, displayBoundingRects, displayHeight, displayWidth); 272e0dac50fSopenharmony_ci break; 273e0dac50fSopenharmony_ci } 274e0dac50fSopenharmony_ci case Rotation::ROTATION_270: { 275e0dac50fSopenharmony_ci for (DMRect rect : displayBoundingRects) { 276e0dac50fSopenharmony_ci resultVec.emplace_back(DMRect {rect.posY_, displayWidth - rect.posX_ - rect.width_, 277e0dac50fSopenharmony_ci rect.height_, rect.width_}); 278e0dac50fSopenharmony_ci } 279e0dac50fSopenharmony_ci break; 280e0dac50fSopenharmony_ci } 281e0dac50fSopenharmony_ci default: { 282e0dac50fSopenharmony_ci } 283e0dac50fSopenharmony_ci } 284e0dac50fSopenharmony_ci boundingRects = resultVec; 285e0dac50fSopenharmony_ci} 286e0dac50fSopenharmony_ci 287e0dac50fSopenharmony_civoid DisplayCutoutController::CurrentRotation90(std::vector<DMRect> resultVec, 288e0dac50fSopenharmony_ci std::vector<DMRect> displayBoundingRects, uint32_t displayHeight) 289e0dac50fSopenharmony_ci{ 290e0dac50fSopenharmony_ci for (DMRect rect : displayBoundingRects) { 291e0dac50fSopenharmony_ci resultVec.emplace_back(DMRect {.posX_ = displayHeight - rect.posY_ - rect.height_, 292e0dac50fSopenharmony_ci .posY_ = rect.posX_, .width_ = rect.height_, .height_ = rect.width_}); 293e0dac50fSopenharmony_ci } 294e0dac50fSopenharmony_ci} 295e0dac50fSopenharmony_ci 296e0dac50fSopenharmony_civoid DisplayCutoutController::CurrentRotation180(std::vector<DMRect> resultVec, 297e0dac50fSopenharmony_ci std::vector<DMRect> displayBoundingRects, uint32_t displayHeight, uint32_t displayWidth) 298e0dac50fSopenharmony_ci{ 299e0dac50fSopenharmony_ci for (DMRect rect : displayBoundingRects) { 300e0dac50fSopenharmony_ci resultVec.emplace_back(DMRect {displayWidth - rect.posX_ - rect.width_, 301e0dac50fSopenharmony_ci displayHeight - rect.posY_ - rect.height_, rect.width_, rect.height_}); 302e0dac50fSopenharmony_ci } 303e0dac50fSopenharmony_ci} 304e0dac50fSopenharmony_ci 305e0dac50fSopenharmony_ciDMRect DisplayCutoutController::CreateWaterfallRect(uint32_t left, uint32_t top, uint32_t width, uint32_t height) 306e0dac50fSopenharmony_ci{ 307e0dac50fSopenharmony_ci if (width == 0 || height == 0) { 308e0dac50fSopenharmony_ci return DMRect {0, 0, 0, 0}; 309e0dac50fSopenharmony_ci } 310e0dac50fSopenharmony_ci return DMRect {left, top, width, height}; 311e0dac50fSopenharmony_ci} 312e0dac50fSopenharmony_ci 313e0dac50fSopenharmony_civoid DisplayCutoutController::SetWaterfallAreaCompressionEnableWhenHorzontal(bool isEnable) 314e0dac50fSopenharmony_ci{ 315e0dac50fSopenharmony_ci isWaterfallAreaCompressionEnableWhenHorizontal_ = isEnable; 316e0dac50fSopenharmony_ci} 317e0dac50fSopenharmony_ci 318e0dac50fSopenharmony_civoid DisplayCutoutController::SetWaterfallAreaCompressionSizeWhenHorizontal(uint32_t size) 319e0dac50fSopenharmony_ci{ 320e0dac50fSopenharmony_ci waterfallAreaCompressionSizeWhenHorizontal_ = size; 321e0dac50fSopenharmony_ci} 322e0dac50fSopenharmony_ci 323e0dac50fSopenharmony_cibool DisplayCutoutController::IsWaterfallAreaCompressionEnableWhenHorizontal() 324e0dac50fSopenharmony_ci{ 325e0dac50fSopenharmony_ci return isWaterfallDisplay_ && isWaterfallAreaCompressionEnableWhenHorizontal_; 326e0dac50fSopenharmony_ci} 327e0dac50fSopenharmony_ci 328e0dac50fSopenharmony_ciuint32_t DisplayCutoutController::GetWaterfallAreaCompressionSizeWhenHorizontal() 329e0dac50fSopenharmony_ci{ 330e0dac50fSopenharmony_ci if (!isWaterfallDisplay_ || !isWaterfallAreaCompressionEnableWhenHorizontal_) { 331e0dac50fSopenharmony_ci WLOGFW("Not waterfall display or not enable waterfall compression"); 332e0dac50fSopenharmony_ci return NO_WATERFALL_DISPLAY_COMPRESSION_SIZE; 333e0dac50fSopenharmony_ci } 334e0dac50fSopenharmony_ci return waterfallAreaCompressionSizeWhenHorizontal_; 335e0dac50fSopenharmony_ci} 336e0dac50fSopenharmony_ci} // Rosen 337e0dac50fSopenharmony_ci} // OHOS 338