From 3c81b8be2910ca418ce8ba440846a62dc8bcf61f Mon Sep 17 00:00:00 2001 From: jason Date: Sat, 26 Jul 2025 15:46:15 +0800 Subject: [PATCH] rs_screen_render_info Signed-off-by: jason --- .../rs_render_service_connection_stub.cpp | 135 ++++++++++++++++++ .../include/pipeline/rs_screen_render_info.h | 49 +++++++ .../rs_render_service_connection_proxy.cpp | 118 +++++++++++++++ 3 files changed, 302 insertions(+) create mode 100644 rosen/modules/render_service_base/include/pipeline/rs_screen_render_info.h diff --git a/rosen/modules/render_service/core/transaction/rs_render_service_connection_stub.cpp b/rosen/modules/render_service/core/transaction/rs_render_service_connection_stub.cpp index 1a8a08a4c8..60a54fac16 100644 --- a/rosen/modules/render_service/core/transaction/rs_render_service_connection_stub.cpp +++ b/rosen/modules/render_service/core/transaction/rs_render_service_connection_stub.cpp @@ -3875,6 +3875,141 @@ bool RSRenderServiceConnectionStub::ReadAppInfo(AppInfo& info, MessageParcel& da return true; } +void RSRenderServiceConnectionStub::ReadScreenInfo(RSScreenInfo info, MessageParcel& data) +{ + if (!data.ReadUint64(info.id)) { + ROSEN_LOGE("ReadScreenInfo: ReadUint64 info.id err."); + return; + } + if (!data.ReadUint32(info.width)) { + ROSEN_LOGE("ReadScreenInfo: ReadUint32 info.width err."); + return; + } + if (!data.ReadUint32(info.height)) { + ROSEN_LOGE("ReadScreenInfo: ReadUint32 info.height err."); + return; + } + if (!data.ReadUint32(info.phyWidth)) { + ROSEN_LOGE("ReadScreenInfo: ReadUint32 info.phyWidth err."); + return; + } + if (!data.ReadUint32(info.phyHeight)) { + ROSEN_LOGE("ReadScreenInfo: ReadUint32 info.phyHeight err."); + return; + } + if (!data.ReadInt32(info.offsetX)) { + ROSEN_LOGE("ReadScreenInfo:ReadInt32 info.offsetX err."); + return; + } + if (!data.ReadInt32(info.offsetY)) { + ROSEN_LOGE("ReadScreenInfo: ReadInt32 info.offsetY err."); + return; + } + if (!data.ReadBool(info.isSamplingOn)) { + ROSEN_LOGE("ReadScreenInfo: ReadBool info.isSamplingOn err."); + return; + } + if (!data.Read(info.samplingDistance)) { + ROSEN_LOGE("ReadScreenInfo: Read info.samplingDistance err."); + return; + } + if (!data.ReadFloat(info.samplingTranslateX)) { + ROSEN_LOGE("ReadScreenInfo: ReadFloat info.samplingTranslateX err."); + return; + } + if (!data.ReadFloat(info.samplingTranslateY)) { + ROSEN_LOGE("ReadScreenInfo: ReadFloat info.samplingTranslateY err."); + return; + } + if (!data.ReadFloat(info.samplingScale)) { + ROSEN_LOGE("ReadScreenInfo: ReadFloat info.samplingScale err."); + return; + } + uint32_t colorGamut = 0; + if (!data.ReadUint32(colorGamut)) { + ROSEN_LOGE("ReadScreenInfo: ReadUint32 info.colorGamut err."); + return; + } + info.colorGamut = static_cast(colorGamut); + uint8_t state = 0; + if (!data.ReadUint8(state)) { + ROSEN_LOGE("ReadScreenInfo: ReadUint8 info.state err."); + return; + } + info.state = static_cast(state); + uint32_t rotation = 0; + if (!data.ReadUint32(info.rotation)) { + ROSEN_LOGE("ReadScreenInfo: ReadUint32 info.rotation err."); + return; + } + info.rotation = static_cast(rotation); +// whiteList + uint32_t whiteListSize = 0; + ScreenId screenId = 0; + if (!data.ReadUint32(whiteListSize)) { + ROSEN_LOGE("ReadScreenInfo: ReadUint32 whiteListSize err."); + return; + } + for (auto i = 0; i < whiteListSize; i++) { + if (!data.ReadUint64(screenId)) { + ROSEN_LOGE("ReadScreenInfo: ReadUint64 info.whiteList err."); + return; + } + info.whiteList.emplace(screenId); + } + +// Rects +#ifdef ROSEN_OHOS + if (!info.activeRect = RectI::Unmarshalling(data)) { + ROSEN_LOGE("ReadScreenInfo: Marshalling info.activeRect err."); + return; + } + if (!info.maskRect = RectI::Unmarshalling(data)) { + ROSEN_LOGE("ReadScreenInfo: Marshalling info.maskRect err."); + return; + } + if (!info.revise = RectI::Unmarshalling(data)) { + ROSEN_LOGE("ReadScreenInfo: Marshalling info.reviseRect err."); + return; + } +#endif + + if (!data.ReadUint32(info.skipFrameInterval)) { + ROSEN_LOGE("ReadScreenInfo: ReadUint32 info.skipFrameInterval err."); + return; + } + if (!data.ReadUint32(info.expectedRefreshRate)) { + ROSEN_LOGE("ReadScreenInfo: ReadUint32 info.expectedRefreshRate err."); + return; + } + int skipFrameStrategy = 0; + if (!data.Read(static_cast(info.skipFrameStrategy))) { + ROSEN_LOGE("ReadScreenInfo: Read info.skipFrameStrategy err."); + return; + } + info.skipFrameStrategy = static_cast(skipFrameStrategy); + if (!data.ReadBool(info.isEqualVsyncPeriod)) { + ROSEN_LOGE("ReadScreenInfo: ReadBool info.isEqualVsyncPeriod err."); + return; + } + int pixelFormat = 0; + if (!data.Read(info.pixelFormat)) { + ROSEN_LOGE("ReadScreenInfo: Read info.pixelFormat err."); + return; + } + info.pixelFormat = static_cast(pixelFormat); + uint32_t hdrFormat = 0; + if (!data.ReadUint32(hdrFormat)) { + ROSEN_LOGE("ReadScreenInfo: ReadUint32 info.hdrFormat err."); + return; + } + info.hdrFormat = static_cast(hdrFormat); + if (!data.ReadBool(info.enableVisibleRect)) { + ROSEN_LOGE("ReadScreenInfo: ReadBool info.enableVisibleRect err."); + return; + } +} + bool RSRenderServiceConnectionStub::ReadGameStateDataRs(GameStateData& info, MessageParcel& data) { if (!data.ReadInt32(info.pid) || !data.ReadInt32(info.uid) || 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 new file mode 100644 index 0000000000..3bacac16b5 --- /dev/null +++ b/rosen/modules/render_service_base/include/pipeline/rs_screen_render_info.h @@ -0,0 +1,49 @@ +/* + * 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_CLIENT_CORE_PIPELINE_RS_SCREEN_RENDER_INFO_H +#define RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_SCREEN_RENDER_INFO_H +#include +#include "rs_screen.h" + + +namespace OHOS { +namespace Rosen { +class RSScreenRenderInfo{ +public: + RSScreenRenderInfo() = default; + virtual ~RSScreenRenderInfo() = default; + void OnSceenConnect(); + void OnScreenDisConnect(); + void SetDefaultScreenId(ScreenId defaultScreenId) { + defaultScreenId_ = defaultScreenId; + } + bool GetPowerOffNeedProcessOneFrame() { + return powerOffNeedProcessOneFrame_; + } + +private: + std::map> screenMap_; + std::atomic defaultScreenId_ = INVALID_SCREEN_ID; + // std::unordered_set castScreenBlackList_ = {}; + // std::unordered_map> blackListInVirtualScreen_ = {}; + std::atomic powerOffNeedProcessOneFrame_ = false; + // std::unordered_set disableRenderControlScreens_ = {}; + // std::atomic isScreenSwitching_ = false; + // std::unordered_map> screenWhiteList_; +}; + +} +} +#endif RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_SCREEN_RENDER_INFO_H \ No newline at end of file diff --git a/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_connection_proxy.cpp b/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_connection_proxy.cpp index 8a6074dc48..d00a7d98c1 100644 --- a/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_connection_proxy.cpp +++ b/rosen/modules/render_service_base/src/platform/ohos/rs_render_service_connection_proxy.cpp @@ -4203,6 +4203,124 @@ void RSRenderServiceConnectionProxy::ReportDataBaseRs( option.SetFlags(MessageOption::TF_ASYNC); } +void RSRenderServiceConnectionProxy::WriteScreenInfo( + MessageParcel& data, MessageParcel& reply, MessageOption& option, ScreenInfo info) +{ + if (!data.WriteUint64(info.id)) { + ROSEN_LOGE("WriteScreenInfo: WriteUint64 info.id err."); + return; + } + if (!data.WriteUint32(info.width)) { + ROSEN_LOGE("WriteScreenInfo: WriteUint32 info.width err."); + return; + } + if (!data.WriteUint32(info.height)) { + ROSEN_LOGE("WriteScreenInfo: WriteUint32 info.height err."); + return; + } + if (!data.WriteUint32(info.phyWidth)) { + ROSEN_LOGE("WriteScreenInfo: WriteUint32 info.phyWidth err."); + return; + } + if (!data.WriteUint32(info.phyHeight)) { + ROSEN_LOGE("WriteScreenInfo: WriteUint32 info.phyHeight err."); + return; + } + if (!data.WriteInt32(info.offsetX)) { + ROSEN_LOGE("WriteScreenInfo: WriteInt32 info.offsetX err."); + return; + } + if (!data.WriteInt32(info.offsetY)) { + ROSEN_LOGE("WriteScreenInfo: WriteInt32 info.offsetY err."); + return; + } + if (!data.WriteBool(info.isSamplingOn)) { + ROSEN_LOGE("WriteScreenInfo: WriteBool info.isSamplingOn err."); + return; + } + if (!data.Write(info.samplingDistance)) { + ROSEN_LOGE("WriteScreenInfo: Write info.samplingDistance err."); + return; + } + if (!data.WriteFloat(info.samplingTranslateX)) { + ROSEN_LOGE("WriteScreenInfo: WriteFloat info.samplingTranslateX err."); + return; + } + if (!data.WriteFloat(info.samplingTranslateY)) { + ROSEN_LOGE("WriteScreenInfo: WriteFloat info.samplingTranslateY err."); + return; + } + if (!data.WriteFloat(info.samplingScale)) { + ROSEN_LOGE("WriteScreenInfo: WriteFloat info.samplingScale err."); + return; + } + if (!data.WriteUint32(static_cast(info.colorGamut))) { + ROSEN_LOGE("WriteScreenInfo: WriteUint32 info.colorGamut err."); + return; + } + if (!data.WriteUint8(static_cast(info.state))) { + ROSEN_LOGE("WriteScreenInfo: WriteUint8 info.state err."); + return; + } + if (!data.WriteUint32(static_cast(info.rotation))) { + ROSEN_LOGE("WriteScreenInfo: WriteUint32 info.rotation err."); + return; + } + uint32_t whiteListSize = info.whiteList.size(); + if (!data.WriteUint32(whiteListSize)) { + ROSEN_LOGE("WriteScreenInfo: WriteInt32 whiteListSize err."); + return; + } + for (auto screenId : info.whiteList) { + if (!data.WriteUint64(screenId)) { + ROSEN_LOGE("WriteScreenInfo: WriteUint64 info.whiteList err."); + return; + } + } +#ifdef ROSEN_OHOS + if (!info.activeRect->Marshalling(data)) { + ROSEN_LOGE("WriteScreenInfo: Marshalling info.activeRect err."); + return; + } + if (!info.maskRect->Marshalling(data)) { + ROSEN_LOGE("WriteScreenInfo: Marshalling info.maskRect err."); + return; + } + if (!info.reviseRect->Marshalling(data)) { + ROSEN_LOGE("WriteScreenInfo: Marshalling info.reviseRect err."); + return; + } +#endif + if (!data.WriteUint32(info.skipFrameInterval)) { + ROSEN_LOGE("WriteScreenInfo: WriteUint32 info.skipFrameInterval err."); + return; + } + if (!data.WriteUint32(info.expectedRefreshRate)) { + ROSEN_LOGE("WriteScreenInfo: WriteUint32 info.expectedRefreshRate err."); + return; + } + if (!data.Write(static_cast(info.skipFrameStrategy))) { + ROSEN_LOGE("WriteScreenInfo: Write info.skipFrameStrategy err."); + return; + } + if (!data.WriteBool(info.isEqualVsyncPeriod)) { + ROSEN_LOGE("WriteScreenInfo: Write info.isEqualVsyncPeriod err."); + return; + } + if (!data.Write(static_cast(info.pixelFormat))) { + ROSEN_LOGE("WriteScreenInfo: Write info.pixelFormat err."); + return; + } + if (!data.WriteUint32(static_cast(info.hdrFormat))) { + ROSEN_LOGE("WriteScreenInfo: WriteUint32 info.hdrFormat err."); + return; + } + if (!data.WriteBool(info.enableVisibleRect)) { + ROSEN_LOGE("WriteScreenInfo: Write info.enableVisibleRect err."); + return; + } +} + void RSRenderServiceConnectionProxy::WriteAppInfo( MessageParcel& data, MessageParcel& reply, MessageOption& option, AppInfo info) { -- Gitee