From 7b869299696d7ed01e4bad1856e4f47aed30e723 Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 31 Jul 2025 11:41:11 +0800 Subject: [PATCH] add screen render info Signed-off-by: jason --- rosen/modules/render_service_base/BUILD.gn | 3 + .../include/pipeline/rs_screen_properties.h | 111 ++++++++ .../include/pipeline/rs_screen_render_info.h | 47 +++- .../include/screen_manager/rs_screen_info.h | 136 +++++++++- .../src/pipeline/rs_screen_properties.cpp | 252 ++++++++++++++++++ .../src/pipeline/rs_screen_render_info.cpp | 116 ++++++++ .../src/screen_manager/rs_screen_info.cpp | 158 +++++++++++ 7 files changed, 814 insertions(+), 9 deletions(-) create mode 100644 rosen/modules/render_service_base/include/pipeline/rs_screen_properties.h create mode 100644 rosen/modules/render_service_base/src/pipeline/rs_screen_properties.cpp create mode 100644 rosen/modules/render_service_base/src/pipeline/rs_screen_render_info.cpp create mode 100644 rosen/modules/render_service_base/src/screen_manager/rs_screen_info.cpp diff --git a/rosen/modules/render_service_base/BUILD.gn b/rosen/modules/render_service_base/BUILD.gn index 1fd41aea0d..81b9c32cfa 100644 --- a/rosen/modules/render_service_base/BUILD.gn +++ b/rosen/modules/render_service_base/BUILD.gn @@ -253,6 +253,8 @@ ohos_source_set("render_service_base_src") { "src/pipeline/rs_render_node_gc.cpp", "src/pipeline/rs_render_node_map.cpp", "src/pipeline/rs_root_render_node.cpp", + "src/pipeline/rs_screen_properties.cpp", + "src/pipeline/rs_screen_render_info.cpp", "src/pipeline/rs_screen_render_node.cpp", "src/pipeline/rs_surface_buffer_callback_manager.cpp", "src/pipeline/rs_surface_handler.cpp", @@ -378,6 +380,7 @@ ohos_source_set("render_service_base_src") { "src/screen_manager/rs_screen_capability.cpp", "src/screen_manager/rs_screen_data.cpp", "src/screen_manager/rs_screen_hdr_capability.cpp", + "src/screen_manager/rs_screen_info.cpp", "src/screen_manager/rs_screen_mode_info.cpp", "src/screen_manager/rs_screen_props.cpp", "src/screen_manager/rs_virtual_screen_resolution.cpp", diff --git a/rosen/modules/render_service_base/include/pipeline/rs_screen_properties.h b/rosen/modules/render_service_base/include/pipeline/rs_screen_properties.h new file mode 100644 index 0000000000..1d2362868a --- /dev/null +++ b/rosen/modules/render_service_base/include/pipeline/rs_screen_properties.h @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2025 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 RENDER_SERVICE_BASE_CORE_PIPELINE_RS_SCREEN_PROPERTIES_H +#define RENDER_SERVICE_BASE_CORE_PIPELINE_RS_SCREEN_PROPERTIES_H +#include + +#include "screen_manager/rs_screen_info.h" + +namespace OHOS { +namespace Rosen { + +class RSScreenProperties { +public: + RSScreenProperties() = default; + virtual ~RSScreenProperties() = default; + + void SetWidth(uint32_t width); + void SetHeight(uint32_t height); + void SetPhyWidth(uint32_t phyWidth); + void SetPhyHeight(uint32_t phyHeight); + void SetOffsetX(int32_t offsetX); + void SetOffsetY(int32_t offsetY); + void SetIsSamplingOn(bool isSamlingOn); + void SetSamplingTranslateX(float samplingTranslateX); + void SetSamplingTranslateY(float samplingTranslateY); + void SetSamplingScale(float samplingScale); + void SetScreenColorGamut(ScreenColorGamut colorGamut); + void SetState(ScreenState state); + void SetScreenSkipFrameInterval(uint32_t skipFrameInterval); + void SetScreenExpectedRefreshRate(uint32_t expectedRefreshRate); + void SetScreenSkipFrameStrategy(SkipFrameStrategy skipFrameStrategy); + void SetIsEqualVsyncPeriod(bool isEqualVsyncPeriod); + void SetPixelFormat(GraphicPixelFormat pixelFormat); + void SetScreenHDRFormat(ScreenHDRFormat hdrFormat); + void SetWhiteList(std::unordered_set whiteList); + void SetEnableVisibleRect(bool enableVisibleRect); + void SetActiveRect(RectI activeRect); + void SetMaskRect(RectI maskRect); + void SetReviseRect(RectI reviseRect); + + uint32_t GetWidth() const; + uint32_t GetHeight() const; + uint32_t GetPhyWidth() const; + uint32_t GetPhyHeight() const; + int32_t GetOffsetX() const; + int32_t GetOffsetY() const; + bool GetIsSamplingOn() const; + float GetSamplingTranslateX() const; + float GetSamplingTranslateY() const; + float GetSamplingScale() const; + ScreenColorGamut GetScreenColorGamut() const; + ScreenState GetState() const; + uint32_t GetScreenSkipFrameInterval() const; + uint32_t GetScreenExpectedRefreshRate() const; + SkipFrameStrategy GetScreenSkipFrameStrategy() const; + bool GetEqualVsyncPeriod() const; + GraphicPixelFormat GetPixelFormat() const; + ScreenHDRFormat GetScreenHDRFormat() const; + std::unordered_set GetWhiteList() const; + bool GetEnableVisibleRect() const; + RectI GetActiveRect() const; + RectI GetMaskRect() const; + RectI GetReviseRect() const; + +private: + uint32_t width_ = 0; // render resolution + uint32_t height_ = 0; + uint32_t phyWidth_ = 0; // physical screen resolution + uint32_t phyHeight_ = 0; + int32_t offsetX_ = 0; + int32_t offsetY_ = 0; + bool isSamplingOn_ = false; + int samplingDistance_ = 1; + float samplingTranslateX_ = 0.f; + float samplingTranslateY_ = 0.f; + float samplingScale_ = 1.f; + ScreenColorGamut colorGamut_ = ScreenColorGamut::COLOR_GAMUT_SRGB; + ScreenState state_ = ScreenState::UNKNOWN; + ScreenRotation rotation_ = ScreenRotation::ROTATION_0; + std::unordered_set whiteList_ = {}; + RectI activeRect_; + RectI maskRect_; + RectI reviseRect_; + + uint32_t skipFrameInterval_ = DEFAULT_SKIP_FRAME_INTERVAL; // skip frame interval for change screen refresh rate + uint32_t expectedRefreshRate_ = INVALID_EXPECTED_REFRESH_RATE; + SkipFrameStrategy skipFrameStrategy_ = SKIP_FRAME_BY_INTERVAL; + bool isEqualVsyncPeriod_ = true; + + GraphicPixelFormat pixelFormat_ = GraphicPixelFormat::GRAPHIC_PIXEL_FMT_RGBA_8888; + ScreenHDRFormat hdrFormat_ = ScreenHDRFormat::NOT_SUPPORT_HDR; + + bool enableVisibleRect_ = false; +}; + +} // namespace Rosen +} // namespace OHOS +#endif // RENDER_SERVICE_BASE_CORE_PIPELINE_RS_SCREEN_PROPERTIES_H \ No newline at end of file diff --git a/rosen/modules/render_service_base/include/pipeline/rs_screen_render_info.h b/rosen/modules/render_service_base/include/pipeline/rs_screen_render_info.h index ce8c99d708..f5c8d8dea0 100644 --- a/rosen/modules/render_service_base/include/pipeline/rs_screen_render_info.h +++ b/rosen/modules/render_service_base/include/pipeline/rs_screen_render_info.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025-2025 Huawei Device Co., Ltd. + * Copyright (c) 2025 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 @@ -14,11 +14,52 @@ */ #ifndef RENDER_SERVICE_BASE_CORE_PIPELINE_RS_SCREEN_RENDER_INFO_H #define RENDER_SERVICE_BASE_CORE_PIPELINE_RS_SCREEN_RENDER_INFO_H + +#include +#include +#include +#include +#include + +#include "rs_screen_properties.h" + +#include "screen_manager/rs_screen_info.h" +#include "screen_manager/screen_types.h" + namespace OHOS { namespace Rosen { +class RSScreen; + class RSScreenRenderInfo { +public: + RSScreenRenderInfo() = default; + virtual ~RSScreenRenderInfo() = default; + void AddScreenProperties(ScreenId id); + void RemoveScreenProperties(ScreenId id); + void SyncScreenInfo(ScreenId id, ScreenInfo info); + void SetDefaultScreenId(ScreenId defaultScreenId) + { + defaultScreenId_ = defaultScreenId; + } + bool GetPowerOffNeedProcessOneFrame() + { + return powerOffNeedProcessOneFrame_; + } + ScreenInfo QueryScreenInfo(ScreenId id) const; +private: + std::shared_ptr GetScreenProperties(ScreenId id) const; + std::map> screenPropertiesMap_; + ScreenId defaultScreenId_ = INVALID_SCREEN_ID; + bool powerOffNeedProcessOneFrame_ = false; + // need to do + // std::unordered_set castScreenBlackList_ = {}; + // std::unordered_map> blackListInVirtualScreen_ = {}; + // std::unordered_set disableRenderControlScreens_ = {}; + // std::atomic isScreenSwitching_ = false; + // std::unordered_map> screenWhiteList_; }; -} -} + +} // namespace Rosen +} // namespace OHOS #endif // RENDER_SERVICE_BASE_CORE_PIPELINE_RS_SCREEN_RENDER_INFO_H \ No newline at end of file diff --git a/rosen/modules/render_service_base/include/screen_manager/rs_screen_info.h b/rosen/modules/render_service_base/include/screen_manager/rs_screen_info.h index 7e17b058ce..781ac05184 100644 --- a/rosen/modules/render_service_base/include/screen_manager/rs_screen_info.h +++ b/rosen/modules/render_service_base/include/screen_manager/rs_screen_info.h @@ -20,9 +20,12 @@ #include #include -#include "common/rs_rect.h" +#include "message_parcel.h" #include "screen_types.h" + +#include "common/rs_rect.h" #include "platform/common/rs_log.h" +#include "transaction/rs_marshalling_helper.h" namespace OHOS::Rosen { enum class ScreenState : uint8_t { @@ -33,7 +36,8 @@ enum class ScreenState : uint8_t { UNKNOWN, }; -struct ScreenInfo { +class ScreenInfo { +public: ScreenId id = INVALID_SCREEN_ID; uint32_t width = 0; // render resolution uint32_t height = 0; @@ -75,14 +79,14 @@ struct ScreenInfo { } uint32_t GetRotatedPhyWidth() const { - return (rotation == ScreenRotation::ROTATION_0 || - rotation == ScreenRotation::ROTATION_180) ? phyWidth : phyHeight; + return (rotation == ScreenRotation::ROTATION_0 || rotation == ScreenRotation::ROTATION_180) ? phyWidth + : phyHeight; } uint32_t GetRotatedPhyHeight() const { - return (rotation == ScreenRotation::ROTATION_0 || - rotation == ScreenRotation::ROTATION_180) ? phyHeight : phyWidth; + return (rotation == ScreenRotation::ROTATION_0 || rotation == ScreenRotation::ROTATION_180) ? phyHeight + : phyWidth; } float GetRogWidthRatio() const @@ -105,6 +109,126 @@ struct ScreenInfo { ret += "\n}\n"; return ret; } + + void Marshalling(MessageParcel& data) + { + if (!data.WriteUint64(id)) { + ROSEN_LOGE("WriteScreenInfo: WriteUint64 id err."); + return; + } + if (!data.WriteUint32(width)) { + ROSEN_LOGE("WriteScreenInfo: WriteUint32 width err."); + return; + } + if (!data.WriteUint32(height)) { + ROSEN_LOGE("WriteScreenInfo: WriteUint32 height err."); + return; + } + if (!data.WriteUint32(phyWidth)) { + ROSEN_LOGE("WriteScreenInfo: WriteUint32 phyWidth err."); + return; + } + if (!data.WriteUint32(phyHeight)) { + ROSEN_LOGE("WriteScreenInfo: WriteUint32 phyHeight err."); + return; + } + if (!data.WriteInt32(offsetX)) { + ROSEN_LOGE("WriteScreenInfo: WriteInt32 offsetX err."); + return; + } + if (!data.WriteInt32(offsetY)) { + ROSEN_LOGE("WriteScreenInfo: WriteInt32 offsetY err."); + return; + } + if (!data.WriteBool(isSamplingOn)) { + ROSEN_LOGE("WriteScreenInfo: WriteBool isSamplingOn err."); + return; + } + if (!data.WriteInt32(static_cast(samplingDistance))) { + ROSEN_LOGE("WriteScreenInfo: Write samplingDistance err."); + return; + } + if (!data.WriteFloat(samplingTranslateX)) { + ROSEN_LOGE("WriteScreenInfo: WriteFloat samplingTranslateX err."); + return; + } + if (!data.WriteFloat(samplingTranslateY)) { + ROSEN_LOGE("WriteScreenInfo: WriteFloat samplingTranslateY err."); + return; + } + if (!data.WriteFloat(samplingScale)) { + ROSEN_LOGE("WriteScreenInfo: WriteFloat samplingScale err."); + return; + } + if (!data.WriteUint32(static_cast(colorGamut))) { + ROSEN_LOGE("WriteScreenInfo: WriteUint32 colorGamut err."); + return; + } + if (!data.WriteUint8(static_cast(state))) { + ROSEN_LOGE("WriteScreenInfo: WriteUint8 state err."); + return; + } + if (!data.WriteUint32(static_cast(rotation))) { + ROSEN_LOGE("WriteScreenInfo: WriteUint32 rotation err."); + return; + } + uint32_t whiteListSize = whiteList.size(); + if (!data.WriteUint32(whiteListSize)) { + ROSEN_LOGE("WriteScreenInfo: WriteInt32 whiteListSize err."); + return; + } + for (auto screenId : whiteList) { + if (!data.WriteUint64(screenId)) { + ROSEN_LOGE("WriteScreenInfo: WriteUint64 whiteList err."); + return; + } + } +#ifdef ROSEN_OHOS + if (!activeRect.Marshalling(data)) { + ROSEN_LOGE("WriteScreenInfo: Marshalling activeRect err."); + return; + } + if (!maskRect.Marshalling(data)) { + ROSEN_LOGE("WriteScreenInfo: Marshalling maskRect err."); + return; + } + if (!reviseRect.Marshalling(data)) { + ROSEN_LOGE("WriteScreenInfo: Marshalling reviseRect err."); + return; + } +#endif + if (!data.WriteUint32(skipFrameInterval)) { + ROSEN_LOGE("WriteScreenInfo: WriteUint32 skipFrameInterval err."); + return; + } + if (!data.WriteUint32(expectedRefreshRate)) { + ROSEN_LOGE("WriteScreenInfo: WriteUint32 expectedRefreshRate err."); + return; + } + if (!data.WriteInt32(static_cast(skipFrameStrategy))) { + ROSEN_LOGE("WriteScreenInfo: Write skipFrameStrategy err."); + return; + } + if (!data.WriteBool(isEqualVsyncPeriod)) { + ROSEN_LOGE("WriteScreenInfo: Write isEqualVsyncPeriod err."); + return; + } + if (!data.WriteInt32(static_cast(pixelFormat))) { + ROSEN_LOGE("WriteScreenInfo: Write pixelFormat err."); + return; + } + if (!data.WriteUint32(static_cast(hdrFormat))) { + ROSEN_LOGE("WriteScreenInfo: WriteUint32 hdrFormat err."); + return; + } + if (!data.WriteBool(enableVisibleRect)) { + ROSEN_LOGE("WriteScreenInfo: Write enableVisibleRect err."); + return; + } + } + + static bool Unmarshalling(Parcel& data, ScreenInfo& info); }; + } // namespace OHOS::Rosen #endif // RENDER_SERVICE_BASE_SCREEN_MANAGER_RS_SCREEN_INFO_H \ No newline at end of file diff --git a/rosen/modules/render_service_base/src/pipeline/rs_screen_properties.cpp b/rosen/modules/render_service_base/src/pipeline/rs_screen_properties.cpp new file mode 100644 index 0000000000..9f6afd3438 --- /dev/null +++ b/rosen/modules/render_service_base/src/pipeline/rs_screen_properties.cpp @@ -0,0 +1,252 @@ +/* + * Copyright (c) 2025 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. + */ + +#include "pipeline/rs_screen_properties.h" + +namespace OHOS { +namespace Rosen { + +void RSScreenProperties::SetWidth(uint32_t width) +{ + width_ = width; +} + +void RSScreenProperties::SetHeight(uint32_t height) +{ + height_ = height; +} + +void RSScreenProperties::SetPhyWidth(uint32_t phyWidth) +{ + phyWidth_ = phyWidth; +} + +void RSScreenProperties::SetPhyHeight(uint32_t phyHeight) +{ + phyHeight_ = phyHeight; +} + +void RSScreenProperties::SetOffsetX(int32_t offsetX) +{ + offsetX_ = offsetX; +} + +void RSScreenProperties::SetOffsetY(int32_t offsetY) +{ + offsetY_ = offsetY; +} + +void RSScreenProperties::SetIsSamplingOn(bool isSamplingOn) +{ + isSamplingOn_ = isSamplingOn; +} + +void RSScreenProperties::SetSamplingTranslateX(float samplingTranslateX) +{ + samplingTranslateX_ = samplingTranslateX; +} + +void RSScreenProperties::SetSamplingTranslateY(float samplingTranslateY) +{ + samplingTranslateY_ = samplingTranslateY; +} + +void RSScreenProperties::SetSamplingScale(float samplingScale) +{ + samplingScale_ = samplingScale; +} + +void RSScreenProperties::SetScreenColorGamut(ScreenColorGamut colorGamut) +{ + colorGamut_ = colorGamut; +} + +void RSScreenProperties::SetState(ScreenState state) +{ + state_ = state; +} + +void RSScreenProperties::SetScreenSkipFrameInterval(uint32_t skipFrameInterval) +{ + skipFrameInterval_ = skipFrameInterval; +} + +void RSScreenProperties::SetScreenExpectedRefreshRate(uint32_t expectedRefreshRate) +{ + expectedRefreshRate_ = expectedRefreshRate; +} + +void RSScreenProperties::SetScreenSkipFrameStrategy(SkipFrameStrategy skipFrameStrategy) +{ + skipFrameStrategy_ = skipFrameStrategy; +} + +void RSScreenProperties::SetIsEqualVsyncPeriod(bool isEqualVsyncPeriod) +{ + isEqualVsyncPeriod_ = isEqualVsyncPeriod; +} + +void RSScreenProperties::SetPixelFormat(GraphicPixelFormat pixelFormat) +{ + pixelFormat_ = pixelFormat; +} + +void RSScreenProperties::SetScreenHDRFormat(ScreenHDRFormat hdrFormat) +{ + hdrFormat_ = hdrFormat; +} + +void RSScreenProperties::SetWhiteList(std::unordered_set whiteList) +{ + whiteList_.swap(whiteList); +} + +void RSScreenProperties::SetEnableVisibleRect(bool enableVisibleRect) +{ + enableVisibleRect_ = enableVisibleRect; +} + +void RSScreenProperties::SetActiveRect(RectI activeRect) +{ + activeRect_ = activeRect; +} + +void RSScreenProperties::SetMaskRect(RectI maskRect) +{ + maskRect_ = maskRect; +} + +void RSScreenProperties::SetReviseRect(RectI reviseRect) +{ + reviseRect_ = reviseRect; +} + +uint32_t RSScreenProperties::GetWidth() const +{ + return width_; +} + +uint32_t RSScreenProperties::GetHeight() const +{ + return height_; +} + +uint32_t RSScreenProperties::GetPhyWidth() const +{ + return phyWidth_; +} + +uint32_t RSScreenProperties::GetPhyHeight() const +{ + return phyHeight_; +} + +int32_t RSScreenProperties::GetOffsetX() const +{ + return offsetX_; +} + +int32_t RSScreenProperties::GetOffsetY() const +{ + return offsetY_; +} + +bool RSScreenProperties::GetIsSamplingOn() const +{ + return isSamplingOn_; +} + +float RSScreenProperties::GetSamplingTranslateX() const +{ + return samplingTranslateX_; +} + +float RSScreenProperties::GetSamplingTranslateY() const +{ + return samplingTranslateY_; +} + +float RSScreenProperties::GetSamplingScale() const +{ + return samplingScale_; +} + +ScreenColorGamut RSScreenProperties::GetScreenColorGamut() const +{ + return colorGamut_; +} + +ScreenState RSScreenProperties::GetState() const +{ + return state_; +} + +uint32_t RSScreenProperties::GetScreenSkipFrameInterval() const +{ + return skipFrameInterval_; +} + +uint32_t RSScreenProperties::GetScreenExpectedRefreshRate() const +{ + return expectedRefreshRate_; +} + +SkipFrameStrategy RSScreenProperties::GetScreenSkipFrameStrategy() const +{ + return skipFrameStrategy_; +} + +bool RSScreenProperties::GetEqualVsyncPeriod() const +{ + return isEqualVsyncPeriod_; +} + +GraphicPixelFormat RSScreenProperties::GetPixelFormat() const +{ + return pixelFormat_; +} + +ScreenHDRFormat RSScreenProperties::GetScreenHDRFormat() const +{ + return hdrFormat_; +} + +std::unordered_set RSScreenProperties::GetWhiteList() const +{ + return whiteList_; +} + +bool RSScreenProperties::GetEnableVisibleRect() const +{ + return enableVisibleRect_; +} + +RectI RSScreenProperties::GetActiveRect() const +{ + return activeRect_; +} + +RectI RSScreenProperties::GetMaskRect() const +{ + return maskRect_; +} + +RectI RSScreenProperties::GetReviseRect() const +{ + return reviseRect_; +} + +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/rosen/modules/render_service_base/src/pipeline/rs_screen_render_info.cpp b/rosen/modules/render_service_base/src/pipeline/rs_screen_render_info.cpp new file mode 100644 index 0000000000..5526379d69 --- /dev/null +++ b/rosen/modules/render_service_base/src/pipeline/rs_screen_render_info.cpp @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2025 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. + */ + +#include "pipeline/rs_screen_render_info.h" + +namespace OHOS { +namespace Rosen { +std::shared_ptr RSScreenRenderInfo::GetScreenProperties(ScreenId id) const +{ + auto iter = screenPropertiesMap_.find(id); + if (iter == screenPropertiesMap_.end() || iter->second == nullptr) { + return nullptr; + } + return iter->second; +} + +void RSScreenRenderInfo::AddScreenProperties(ScreenId id) +{ + if (GetScreenProperties(id)) { + RS_LOGW("%{public}s The screenProperties for id %{public}" PRIu64 " already existed.", __func__, id); + return; + } + auto screenProperties = std::make_shared(); + screenPropertiesMap_[id] = screenProperties; +} + +void RSScreenRenderInfo::RemoveScreenProperties(ScreenId id) +{ + if (!GetScreenProperties(id)) { + RS_LOGW("%{public}s The screenProperties for id %{public}" PRIu64 " not existed.", __func__, id); + return; + } + screenPropertiesMap_.erase(id); +} + +void RSScreenRenderInfo::SyncScreenInfo(ScreenId id, ScreenInfo info) +{ + auto screenProperties = GetScreenProperties(id); + if (screenProperties == nullptr) { + RS_LOGE("%{public}s: There is no screenProperties for id %{public}" PRIu64, __func__, id); + return; + } + + screenProperties->SetWidth(info.width); + screenProperties->SetHeight(info.height); + screenProperties->SetPhyWidth(info.phyWidth); + screenProperties->SetPhyHeight(info.phyHeight); + screenProperties->SetOffsetX(info.offsetX); + screenProperties->SetOffsetY(info.offsetY); + screenProperties->SetIsSamplingOn(info.isSamplingOn); + screenProperties->SetSamplingTranslateX(info.samplingTranslateX); + screenProperties->SetSamplingTranslateY(info.samplingTranslateY); + screenProperties->SetSamplingScale(info.samplingScale); + screenProperties->SetScreenColorGamut(info.colorGamut); + screenProperties->SetState(info.state); + screenProperties->SetScreenSkipFrameInterval(info.skipFrameInterval); + screenProperties->SetScreenExpectedRefreshRate(info.expectedRefreshRate); + screenProperties->SetScreenSkipFrameStrategy(info.skipFrameStrategy); + screenProperties->SetIsEqualVsyncPeriod(info.isEqualVsyncPeriod); + screenProperties->SetPixelFormat(info.pixelFormat); + screenProperties->SetScreenHDRFormat(info.hdrFormat); + screenProperties->SetWhiteList(info.whiteList); + screenProperties->SetEnableVisibleRect(info.enableVisibleRect); + screenProperties->SetActiveRect(info.activeRect); + screenProperties->SetMaskRect(info.maskRect); + screenProperties->SetReviseRect(info.reviseRect); +} + +ScreenInfo RSScreenRenderInfo::QueryScreenInfo(ScreenId id) const +{ + ScreenInfo info; + auto screenProperties = GetScreenProperties(id); + if (screenProperties == nullptr) { + RS_LOGE("%{public}s: There is no screenProperties for id %{public}" PRIu64, __func__, id); + return info; + } + info.width = screenProperties->GetWidth(); + info.height = screenProperties->GetHeight(); + info.phyWidth = screenProperties->GetPhyWidth(); + info.phyHeight = screenProperties->GetPhyHeight(); + info.offsetX = screenProperties->GetOffsetX(); + info.offsetY = screenProperties->GetOffsetY(); + info.isSamplingOn = screenProperties->GetIsSamplingOn(); + info.samplingTranslateX = screenProperties->GetSamplingTranslateX(); + info.samplingTranslateY = screenProperties->GetSamplingTranslateY(); + info.samplingScale = screenProperties->GetSamplingScale(); + info.colorGamut = screenProperties->GetScreenColorGamut(); + info.state = screenProperties->GetState(); + info.skipFrameInterval = screenProperties->GetScreenSkipFrameInterval(); + info.expectedRefreshRate = screenProperties->GetScreenExpectedRefreshRate(); + info.skipFrameStrategy = screenProperties->GetScreenSkipFrameStrategy(); + info.isEqualVsyncPeriod = screenProperties->GetEqualVsyncPeriod(); + info.pixelFormat = screenProperties->GetPixelFormat(); + info.hdrFormat = screenProperties->GetScreenHDRFormat(); + info.whiteList = screenProperties->GetWhiteList(); + info.enableVisibleRect = screenProperties->GetEnableVisibleRect(); + info.activeRect = screenProperties->GetActiveRect(); + info.maskRect = screenProperties->GetMaskRect(); + info.reviseRect = screenProperties->GetReviseRect(); + return info; +} + +} // namespace Rosen +} // namespace OHOS diff --git a/rosen/modules/render_service_base/src/screen_manager/rs_screen_info.cpp b/rosen/modules/render_service_base/src/screen_manager/rs_screen_info.cpp new file mode 100644 index 0000000000..25411eaf0d --- /dev/null +++ b/rosen/modules/render_service_base/src/screen_manager/rs_screen_info.cpp @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2025 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. + */ + +#include "screen_manager/rs_screen_info.h" + +namespace OHOS { +namespace Rosen { +bool ScreenInfo::Unmarshalling(Parcel& data, ScreenInfo& info) +{ + if (!data.ReadUint64(info.id)) { + ROSEN_LOGE("ScreenInfo::Unmarshalling: ReadUint64 info.id err."); + return false; + } + if (!data.ReadUint32(info.width)) { + ROSEN_LOGE("ScreenInfo::Unmarshalling: ReadUint32 info.width err."); + return false; + } + if (!data.ReadUint32(info.height)) { + ROSEN_LOGE("ScreenInfo::Unmarshalling: ReadUint32 info.height err."); + return false; + } + if (!data.ReadUint32(info.phyWidth)) { + ROSEN_LOGE("ScreenInfo::Unmarshalling: ReadUint32 info.phyWidth err."); + return false; + } + if (!data.ReadUint32(info.phyHeight)) { + ROSEN_LOGE("ScreenInfo::Unmarshalling: ReadUint32 info.phyHeight err."); + return false; + } + if (!data.ReadInt32(info.offsetX)) { + ROSEN_LOGE("ScreenInfo::Unmarshalling:ReadInt32 info.offsetX err."); + return false; + } + if (!data.ReadInt32(info.offsetY)) { + ROSEN_LOGE("ScreenInfo::Unmarshalling: ReadInt32 info.offsetY err."); + return false; + } + if (!data.ReadBool(info.isSamplingOn)) { + ROSEN_LOGE("ScreenInfo::Unmarshalling: ReadBool info.isSamplingOn err."); + return false; + } + int32_t samplingDistance = 0; + if (!data.ReadInt32(samplingDistance)) { + ROSEN_LOGE("ScreenInfo::Unmarshalling: ReadInt32 info.samplingDistance err."); + return false; + } + info.samplingDistance = static_cast(samplingDistance); + if (!data.ReadFloat(info.samplingTranslateX)) { + ROSEN_LOGE("ScreenInfo::Unmarshalling: ReadFloat info.samplingTranslateX err."); + return false; + } + if (!data.ReadFloat(info.samplingTranslateY)) { + ROSEN_LOGE("ScreenInfo::Unmarshalling: ReadFloat info.samplingTranslateY err."); + return false; + } + if (!data.ReadFloat(info.samplingScale)) { + ROSEN_LOGE("ScreenInfo::Unmarshalling: ReadFloat info.samplingScale err."); + return false; + } + uint32_t colorGamut = 0; + if (!data.ReadUint32(colorGamut)) { + ROSEN_LOGE("ScreenInfo::Unmarshalling: ReadUint32 info.colorGamut err."); + return false; + } + info.colorGamut = static_cast(colorGamut); + uint8_t state = 0; + if (!data.ReadUint8(state)) { + ROSEN_LOGE("ScreenInfo::Unmarshalling: ReadUint8 info.state err."); + return false; + } + info.state = static_cast(state); + uint32_t rotation = 0; + if (!data.ReadUint32(rotation)) { + ROSEN_LOGE("ScreenInfo::Unmarshalling: ReadUint32 info.rotation err."); + return false; + } + info.rotation = static_cast(rotation); + // whiteList + uint32_t whiteListSize = 0; + ScreenId screenId = 0; + if (!data.ReadUint32(whiteListSize)) { + ROSEN_LOGE("ScreenInfo::Unmarshalling: ReadUint32 whiteListSize err."); + return false; + } + for (auto i = 0; i < whiteListSize; i++) { + if (!data.ReadUint64(screenId)) { + ROSEN_LOGE("ScreenInfo::Unmarshalling: ReadUint64 info.whiteList err."); + return false; + } + info.whiteList.emplace(screenId); + } + +// Rects +#ifdef ROSEN_OHOS + if (!RSMarshallingHelper::Unmarshalling(data, info.activeRect)) { + ROSEN_LOGE("ScreenInfo::Unmarshalling: Marshalling info.activeRect err."); + return false; + } + if (!RSMarshallingHelper::Unmarshalling(data, info.maskRect)) { + ROSEN_LOGE("ScreenInfo::Unmarshalling: Marshalling info.maskRect err."); + return false; + } + if (!RSMarshallingHelper::Unmarshalling(data, info.reviseRect)) { + ROSEN_LOGE("ScreenInfo::Unmarshalling: Marshalling info.reviseRect err."); + return false; + } +#endif + + if (!data.ReadUint32(info.skipFrameInterval)) { + ROSEN_LOGE("ScreenInfo::Unmarshalling: ReadUint32 info.skipFrameInterval err."); + return false; + } + if (!data.ReadUint32(info.expectedRefreshRate)) { + ROSEN_LOGE("ScreenInfo::Unmarshalling: ReadUint32 info.expectedRefreshRate err."); + return false; + } + int32_t skipFrameStrategy = 0; + if (!data.ReadInt32(skipFrameStrategy)) { + ROSEN_LOGE("ScreenInfo::Unmarshalling: ReadInt32 info.skipFrameStrategy err."); + return false; + } + info.skipFrameStrategy = static_cast(skipFrameStrategy); + if (!data.ReadBool(info.isEqualVsyncPeriod)) { + ROSEN_LOGE("ScreenInfo::Unmarshalling: ReadBool info.isEqualVsyncPeriod err."); + return false; + } + int32_t pixelFormat = 0; + if (!data.ReadInt32(pixelFormat)) { + ROSEN_LOGE("ScreenInfo::Unmarshalling: ReadInt32 info.pixelFormat err."); + return false; + } + info.pixelFormat = static_cast(pixelFormat); + uint32_t hdrFormat = 0; + if (!data.ReadUint32(hdrFormat)) { + ROSEN_LOGE("ScreenInfo::Unmarshalling: ReadUint32 info.hdrFormat err."); + return false; + } + info.hdrFormat = static_cast(hdrFormat); + if (!data.ReadBool(info.enableVisibleRect)) { + ROSEN_LOGE("ScreenInfo::Unmarshalling: ReadBool info.enableVisibleRect err."); + return false; + } + return true; +} +} // namespace Rosen +} // namespace OHOS -- Gitee