From bf52b4c8317de937c108dc2ee3ec35d2327dfda6 Mon Sep 17 00:00:00 2001 From: xpeng Date: Tue, 2 Aug 2022 21:06:12 +0800 Subject: [PATCH] fix some problems Signed-off-by: xpeng Change-Id: Ib12e476f8a7ad8ec86df0f1b591ab5edd93dc253 --- dmserver/include/display_cutout_controller.h | 3 +- dmserver/src/display_cutout_controller.cpp | 28 ++++++++- dmserver/src/display_manager_config.cpp | 2 +- .../js/declaration/api/@ohos.display.d.ts | 60 +++++++++++-------- .../config/rk3568/display_manager_config.xml | 14 ++--- 5 files changed, 72 insertions(+), 35 deletions(-) diff --git a/dmserver/include/display_cutout_controller.h b/dmserver/include/display_cutout_controller.h index ee6b1313..673664ef 100644 --- a/dmserver/include/display_cutout_controller.h +++ b/dmserver/include/display_cutout_controller.h @@ -48,13 +48,14 @@ public: void SetCurvedScreenBoundary(std::vector curvedScreenBoundary); private: Rect CalcCutoutBoundingRect(std::string svgPath); + void CheckBoudingRectBoundary(DisplayId displayId, Rect& boundingRect); void CalcBuiltInDisplayWaterfallRects(); void CalcBuiltInDisplayWaterfallRectsByRotation(Rotation rotation, uint32_t displayHeight, uint32_t displayWidth); void TransferBoundingRectsByRotation(DisplayId displayId, std::vector& boudingRects); // Raw data std::map> svgPaths_; - bool isWaterfallDisplay_ = true; + bool isWaterfallDisplay_ = false; std::vector curvedScreenBoundary_; // Order: left top right bottom bool isWaterfallAreaLayoutEnable_ = true; diff --git a/dmserver/src/display_cutout_controller.cpp b/dmserver/src/display_cutout_controller.cpp index 6e8a783b..e005472d 100644 --- a/dmserver/src/display_cutout_controller.cpp +++ b/dmserver/src/display_cutout_controller.cpp @@ -36,6 +36,9 @@ void DisplayCutoutController::SetIsWaterfallDisplay(bool isWaterfallDisplay) void DisplayCutoutController::SetCurvedScreenBoundary(std::vector curvedScreenBoundary) { + while (curvedScreenBoundary.size() < 4) { // 4 directions. + curvedScreenBoundary.emplace_back(0); + } WLOGFI("Set curvedScreenBoundary"); curvedScreenBoundary_ = curvedScreenBoundary; } @@ -57,6 +60,7 @@ void DisplayCutoutController::SetCutoutSvgPath(DisplayId displayId, const std::s svgPaths_[displayId] = pathVec; } Rect boundingRect = CalcCutoutBoundingRect(svgPath); + CheckBoudingRectBoundary(displayId, boundingRect); if (boundingRects_.count(displayId) == 1) { boundingRects_[displayId].emplace_back(boundingRect); } else { @@ -82,6 +86,25 @@ sptr DisplayCutoutController::GetCutoutInfo(DisplayId displayId) return cutoutInfo; } +void DisplayCutoutController::CheckBoudingRectBoundary(DisplayId displayId, Rect& boundingRect) +{ + sptr modes = + DisplayManagerServiceInner::GetInstance().GetScreenModesByDisplayId(displayId); + if (modes == nullptr) { + WLOGFE("DisplayId is invalid"); + return; + } + uint32_t displayHeight = modes->height_; + uint32_t displayWidth = modes->width_; + if (boundingRect.posX_ < 0 || boundingRect.posY_ < 0 || + boundingRect.width_ + boundingRect.posX_ > displayWidth || + boundingRect.height_ + boundingRect.posY_ > displayHeight) { + WLOGFE("boundingRect boundary is invalid"); + boundingRect = {.posX_ = 0, .posY_ = 0, .width_ = 0, .height_ = 0}; + return; + } +} + Rect DisplayCutoutController::CalcCutoutBoundingRect(std::string svgPath) { Rect emptyRect = {0, 0, 0, 0}; @@ -125,7 +148,10 @@ void DisplayCutoutController::CalcBuiltInDisplayWaterfallRects() uint32_t top = curvedScreenBoundary_[1]; uint32_t right = curvedScreenBoundary_[2]; uint32_t bottom = curvedScreenBoundary_[3]; - + if (left == 0 && top == 0 && right == 0 && bottom == 0) { + waterfallDisplayAreaRects_ = emptyRects; + return; + } sptr modes = DisplayManagerServiceInner::GetInstance().GetScreenModesByDisplayId( DisplayManagerServiceInner::GetInstance().GetDefaultDisplayId()); diff --git a/dmserver/src/display_manager_config.cpp b/dmserver/src/display_manager_config.cpp index 2aa31d74..dc5b85dd 100644 --- a/dmserver/src/display_manager_config.cpp +++ b/dmserver/src/display_manager_config.cpp @@ -165,7 +165,7 @@ void DisplayManagerConfig::ReadEnableConfigInfo(const xmlNodePtr& currNode) std::string nodeName = reinterpret_cast(currNode->name); if (!xmlStrcmp(enable, reinterpret_cast("true"))) { enableConfig_[nodeName] = true; - } else if (!xmlStrcmp(enable, reinterpret_cast("false"))) { + } else { enableConfig_[nodeName] = false; } xmlFree(enable); diff --git a/interfaces/kits/js/declaration/api/@ohos.display.d.ts b/interfaces/kits/js/declaration/api/@ohos.display.d.ts index 445c526f..3174e96a 100644 --- a/interfaces/kits/js/declaration/api/@ohos.display.d.ts +++ b/interfaces/kits/js/declaration/api/@ohos.display.d.ts @@ -103,6 +103,40 @@ declare namespace display { STATE_ON_SUSPEND, } + /** + * Rectangle + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ + interface Rect { + left: number; + top: number; + width: number; + height: number; + } + + /** + * Curved area rects of the waterfall display. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 9 + */ + interface WaterfallDisplayAreaRects { + readonly left: Rect; + readonly right: Rect; + readonly top: Rect; + readonly bottom: Rect; + } + + /** + * cutout information of the display. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 9 + */ + interface CutoutInfo { + readonly boundingRects: Array; + readonly waterfallDisplayAreaRects: WaterfallDisplayAreaRects; + } + /** * Defines properties of the display. They cannot be updated automatically. * @syscap SystemCapability.WindowManager.WindowManager.Core @@ -178,7 +212,7 @@ declare namespace display { * Obtain the cutout info of the display. * @devices tv, phone, tablet, wearable */ - getCutoutInfo(callback: AsyncCallback): void; + getCutoutInfo(callback: AsyncCallback): void; /** * Obtain the cutout info of the display. @@ -186,30 +220,6 @@ declare namespace display { */ getCutoutInfo(): Promise; } - - /** - * cutout information of the display. - * @syscap SystemCapability.WindowManager.WindowManager.Core - * @since 9 - */ - interface CutoutInfo { - BoundingRects: Array; - waterfallDisplayAreaRects: WaterfallDisplayAreaRects; - } - - interface WaterfallDisplayAreaRects { - left: Rect; - right: Rect; - top: Rect; - bottom: Rect; - } - - interface Rect { - left: number; - top: number; - width: number; - height: number; - } } export default display; \ No newline at end of file diff --git a/resources/config/rk3568/display_manager_config.xml b/resources/config/rk3568/display_manager_config.xml index 7a37db34..5d84a697 100644 --- a/resources/config/rk3568/display_manager_config.xml +++ b/resources/config/rk3568/display_manager_config.xml @@ -21,19 +21,19 @@ 0 10 10 100 20 + - - - - M 100,100 m -75,0 a 75,75 0 1,0 150,0 a 75,75 0 1,0 -150,0 z + + + + - 0 0 0 0 + - - false +