diff --git a/interfaces/inner_api/common/graphic_common.h b/interfaces/inner_api/common/graphic_common.h index 7966e63c0c37f8041c734485961e1b9db6c48b66..cb23dcada77e3d022d647c0bfb18990328515ecd 100644 --- a/interfaces/inner_api/common/graphic_common.h +++ b/interfaces/inner_api/common/graphic_common.h @@ -117,6 +117,7 @@ inline bool operator !=(GSError a, GSError b) using WMError = GSError; using SurfaceError = GSError; using VsyncError = GSError; +using RSComposerError = GSError; } // namespace OHOS #endif // __cplusplus diff --git a/interfaces/inner_api/common/graphic_common_c.h b/interfaces/inner_api/common/graphic_common_c.h index 8ecda1e1c15f914ad8f215a43932eb712dbe23cd..8c4641f80105867d72fa3bcb3aa072a36a6a345f 100644 --- a/interfaces/inner_api/common/graphic_common_c.h +++ b/interfaces/inner_api/common/graphic_common_c.h @@ -124,5 +124,19 @@ typedef enum { VSYNC_ERROR_NOT_SUPPORT = GSERROR_NOT_SUPPORT, VSYNC_ERROR_NOT_INIT = GSERROR_NOT_INIT, VSYNC_ERROR_UNKOWN = GSERROR_INTERNAL, + + COMPOSITOR_ERROR_OK = GSERROR_OK, + COMPOSITOR_ERROR_API_FAILED = GSERROR_API_FAILED, + COMPOSITOR_ERROR_INVALID_OPERATING = GSERROR_INVALID_OPERATING, + COMPOSITOR_ERROR_NULLPTR = GSERROR_INVALID_ARGUMENTS, + COMPOSITOR_ERROR_BINDER_ERROR = GSERROR_BINDER, + COMPOSITOR_ERROR_SAMGR = GSERROR_CONNOT_CONNECT_SAMGR, + COMPOSITOR_ERROR_SERVICE_NOT_FOUND = GSERROR_SERVER_ERROR, + COMPOSITOR_ERROR_PROXY_NOT_INCLUDE = GSERROR_PROXY_NOT_INCLUDE, + COMPOSITOR_ERROR_INNER = GSERROR_INTERNAL, + COMPOSITOR_ERROR_INVALID_ARGUMENTS = GSERROR_INVALID_ARGUMENTS, + COMPOSITOR_ERROR_NOT_SUPPORT = GSERROR_NOT_SUPPORT, + COMPOSITOR_ERROR_NOT_INIT = GSERROR_NOT_INIT, + COMPOSITOR_ERROR_UNKOWN = GSERROR_INTERNAL, } GSError; #endif // INTERFACES_INNERKITS_COMMON_GRAPHIC_COMMON_H diff --git a/patchset1.diff b/patchset1.diff new file mode 100644 index 0000000000000000000000000000000000000000..df8787ff7db11cf233dc375e5988c6daaf46381f --- /dev/null +++ b/patchset1.diff @@ -0,0 +1,247 @@ +diff --git a/rosen/modules/render_service/BUILD.gn b/rosen/modules/render_service/BUILD.gn +index 65c98d9fb2..6da85120b3 100644 +--- a/rosen/modules/render_service/BUILD.gn ++++ b/rosen/modules/render_service/BUILD.gn +@@ -163,11 +163,28 @@ ohos_shared_library("librender_service") { + "core/screen_manager/rs_screen_manager.cpp", + "core/system/rs_system_parameters.cpp", + "core/transaction/rs_irender_service_connection_ipc_interface_code_access_verifier.cpp", +- "core/transaction/rs_irender_service_ipc_interface_code_access_verifier.cpp", ++ "core/transaction/rs_irender_service_connection_ipc_interface_code_access_verifier.cpp", + "core/transaction/rs_render_service_connection_stub.cpp", + "core/transaction/rs_render_service_security_utils.cpp", + "core/transaction/rs_render_service_stub.cpp", + "core/transaction/rs_unmarshal_thread.cpp", ++ # composer 模块源文件 ++ "composer/composer_base/rs_layer_marshalling_helper.cpp", ++ "composer/composer_base/rs_layer_parcel_factory.cpp", ++ "composer/composer_base/rs_layer_parcel.cpp", ++ "composer/composer_base/rs_render_layer_cmd.cpp", ++ "composer/composer_base/rs_render_layer_cmd_property.cpp", ++ "composer/composer_client/rs_layer_cmd.cpp", ++ "composer/composer_client/rs_layer_context.cpp", ++ "composer/composer_client/rs_surface_layer.cpp", ++ "composer/composer_client/rs_layer_factory.cpp", ++ "composer/pipeline/connection/buffer_release_listener_stub.cpp", ++ "composer/pipeline/connection/buffer_release_listener_proxy.cpp", ++ "composer/pipeline/connection/rs_composer_connection_proxy.cpp", ++ "composer/pipeline/connection/rs_composer_connection_stub.cpp", ++ "composer/pipeline/connection/rs_composer_connection.cpp", ++ "composer/pipeline/transaction/rs_layer_transaction_data.cpp", ++ "composer/pipeline/transaction/rs_layer_transaction_handler.cpp", + ] + + #feature_cfg +@@ -368,6 +385,10 @@ ohos_shared_library("librender_service") { + "$graphic_2d_root/rosen/modules/ressched/include", + "$graphic_2d_root/utils/log", + "$graphic_2d_root/utils/socketpair/export", ++ # composer 模块包含目录 ++ "composer/composer_base", ++ "composer/composer_client", ++ "composer/pipeline", + ] + + public_deps += [ +diff --git a/rosen/modules/render_service/composer/composer_base/BUILD.gn b/rosen/modules/render_service/composer/composer_base/BUILD.gn +deleted file mode 100644 +index 0519ecba6e..0000000000 +--- a/rosen/modules/render_service/composer/composer_base/BUILD.gn ++++ /dev/null +@@ -1 +0,0 @@ +- +\ No newline at end of file +diff --git a/rosen/modules/render_service/composer/composer_base/rs_layer_marshalling_helper.h b/rosen/modules/render_service/composer/composer_base/rs_layer_marshalling_helper.h +index 4327ba5be8..97e68c039b 100644 +--- a/rosen/modules/render_service/composer/composer_base/rs_layer_marshalling_helper.h ++++ b/rosen/modules/render_service/composer/composer_base/rs_layer_marshalling_helper.h +@@ -13,8 +13,8 @@ + * limitations under the License. + */ + +-#ifndef COMPOSER_BASE_RS_LAYER_MARSHLING_H +-#define COMPOSER_BASE_RS_LAYER_MARSHLING_H ++#ifndef COMPOSER_BASE_RS_LAYER_MARSHALLING_H ++#define COMPOSER_BASE_RS_LAYER_MARSHALLING_H + + #include + #include +@@ -69,4 +69,4 @@ public: + } // namespace Rosen + } // namespace OHOS + +-#endif // COMPOSER_BASE_RS_LAYER_MARSHLING_H ++#endif // COMPOSER_BASE_RS_LAYER_MARSHALLING_H +diff --git a/rosen/modules/render_service/composer/composer_base/rs_render_layer_cmd.cpp b/rosen/modules/render_service/composer/composer_base/rs_render_layer_cmd.cpp +index 24e7ce1541..47e0c58329 100644 +--- a/rosen/modules/render_service/composer/composer_base/rs_render_layer_cmd.cpp ++++ b/rosen/modules/render_service/composer/composer_base/rs_render_layer_cmd.cpp +@@ -14,6 +14,12 @@ + */ + + #include "rs_render_layer_cmd.h" ++#include "rs_layer_marshalling_helper.h" ++#include "common/rs_log.h" ++#include ++ ++// 前向声明 ++class RSLayerContext; + + namespace OHOS { + namespace Rosen { +diff --git a/rosen/modules/render_service/composer/composer_base/rs_render_layer_cmd.h b/rosen/modules/render_service/composer/composer_base/rs_render_layer_cmd.h +index a6472d26f2..d09bee2e5d 100644 +--- a/rosen/modules/render_service/composer/composer_base/rs_render_layer_cmd.h ++++ b/rosen/modules/render_service/composer/composer_base/rs_render_layer_cmd.h +@@ -13,8 +13,8 @@ + * limitations under the License. + */ + +-#ifndef COMPOSER_CLIENT_RS_RENDER_LAYER_CMD_H +-#define COMPOSER_CLIENT_RS_RENDER_LAYER_CMD_H ++#ifndef COMPOSER_BASE_RS_RENDER_LAYER_CMD_H ++#define COMPOSER_BASE_RS_RENDER_LAYER_CMD_H + + #include + +@@ -70,4 +70,4 @@ protected: + } // namespace Rosen + } // namespace OHOS + +-#endif // COMPOSER_CLIENT_RS_RENDER_LAYER_CMD_H +\ No newline at end of file ++#endif // COMPOSER_BASE_RS_RENDER_LAYER_CMD_H +\ No newline at end of file +diff --git a/rosen/modules/render_service/composer/composer_base/rs_render_layer_cmd_property.h b/rosen/modules/render_service/composer/composer_base/rs_render_layer_cmd_property.h +index bd3c1ef5a7..f87f6e2d12 100644 +--- a/rosen/modules/render_service/composer/composer_base/rs_render_layer_cmd_property.h ++++ b/rosen/modules/render_service/composer/composer_base/rs_render_layer_cmd_property.h +@@ -13,8 +13,8 @@ + * limitations under the License. + */ + +-#ifndef COMPOSER_CLIENT_RS_RENDER_LAYER_CMD_PROPERTY_H +-#define COMPOSER_CLIENT_RS_RENDER_LAYER_CMD_PROPERTY_H ++#ifndef COMPOSER_BASE_RS_RENDER_LAYER_CMD_PROPERTY_H ++#define COMPOSER_BASE_RS_RENDER_LAYER_CMD_PROPERTY_H + + #include + #include +@@ -36,7 +36,7 @@ + #endif + + #include "ibuffer_release_listener.h" +- ++#define PropertyId uint64_t + // 前向声明 + namespace OHOS { + GSError ReadSurfaceBufferImpl(MessageParcel &parcel, uint32_t &sequence, sptr &buffer, +@@ -418,4 +418,4 @@ UnmarshallingValue(MessageParcel& parcel, T& value) + } // namespace Rosen + } // namespace OHOS + +-#endif // COMPOSER_CLIENT_RS_RENDER_LAYER_CMD_PROPERTY_H +\ No newline at end of file ++#endif // COMPOSER_BASE_RS_RENDER_LAYER_CMD_PROPERTY_H +\ No newline at end of file +diff --git a/rosen/modules/render_service/composer/composer_client/rs_layer.h b/rosen/modules/render_service/composer/composer_client/rs_layer.h +index ee851601d5..68e97acc37 100644 +--- a/rosen/modules/render_service/composer/composer_client/rs_layer.h ++++ b/rosen/modules/render_service/composer/composer_client/rs_layer.h +@@ -1,6 +1,6 @@ + /* + * Copyright (c) 2025 Huawei Device Co., Ltd. +- * Licensed under the Apache License, Version 2.0 (the "License") = 0; ++ * 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 + * +@@ -39,7 +39,7 @@ public: + virtual void SetZorder(int32_t zOrder) = 0; + virtual void SetType(const GraphicLayerType& layerType) = 0; + virtual GraphicLayerType GetType() const = 0; +- virtual virtual void SetAlpha(const GraphicLayerAlpha &alpha) = 0; ++ virtual void SetAlpha(const GraphicLayerAlpha &alpha) = 0; + virtual void SetTransform(GraphicTransformType type) = 0; + virtual void SetCompositionType(GraphicCompositionType type) = 0; + virtual void SetVisibleRegions(const std::vector &visibleRegions) = 0; +@@ -78,8 +78,8 @@ public: + virtual const GraphicLayerAlpha &GetAlpha() = 0; + virtual GraphicTransformType GetTransformType() const = 0; + virtual GraphicCompositionType GetCompositionType() const = 0; +- virtual const std::vector &GetVisibleRegions() = 0; +- virtual const std::vector &GetDirtyRegions() = 0; ++ virtual const std::vector &GetVisibleRegions() = 0; ++ virtual const std::vector &GetDirtyRegions() = 0; + virtual GraphicBlendType GetBlendType() const = 0; + virtual const GraphicIRect &GetCropRect() = 0; + virtual const GraphicIRect &GetLayerSize() = 0; +@@ -88,14 +88,14 @@ public: + virtual int32_t GetGravity() const = 0; + virtual bool GetUniRenderFlag() const = 0; + virtual bool IsPreMulti() const = 0; +- virtual void SetWindowsName(std::vectorstd::string& windowsName) = 0; +- virtual const std::vectorstd::string& GetWindowsName() = 0; +- virtual const std::vector &GetColorTransform() = 0; ++ virtual void SetWindowsName(std::vector& windowsName) = 0; ++ virtual const std::vector& GetWindowsName() = 0; ++ virtual const std::vector &GetColorTransform() = 0; + virtual GraphicColorDataSpace GetColorDataSpace() const = 0; + virtual GraphicLayerColor GetLayerColor() const = 0; + virtual GraphicLayerColor GetBackgroundColor() const = 0; +- virtual const std::vector& GetCornerRadiusInfoForDRM() const = 0; +- virtual std::vector &GetMetaData() = 0; ++ virtual const std::vector& GetCornerRadiusInfoForDRM() const = 0; ++ virtual std::vector &GetMetaData() = 0; + virtual GraphicHDRMetaDataSet &GetMetaDataSet() = 0; + virtual bool GetTunnelHandleChange() const = 0; + virtual sptr GetTunnelHandle() const = 0; +@@ -107,8 +107,8 @@ public: + virtual void SetSdrNit(float sdrNit) = 0; + virtual void SetDisplayNit(float displayNit) = 0; + virtual void SetBrightnessRatio(float brightnessRatio) = 0; +- virtual const std::vector& GetLayerLinearMatrix() const = 0; +- virtual void SetLayerLinearMatrix(const std::vector& layerLinearMatrix) = 0; ++ virtual const std::vector& GetLayerLinearMatrix() const = 0; ++ virtual void SetLayerLinearMatrix(const std::vector& layerLinearMatrix) = 0; + // source crop tuning + virtual int32_t GetLayerSourceTuning() const = 0; + virtual void SetLayerSourceTuning(int32_t layerSouce) = 0; +diff --git a/rosen/modules/render_service/composer/composer_client/rs_surface_layer.h b/rosen/modules/render_service/composer/composer_client/rs_surface_layer.h +index 6b021de615..f9ab59cd53 100644 +--- a/rosen/modules/render_service/composer/composer_client/rs_surface_layer.h ++++ b/rosen/modules/render_service/composer/composer_client/rs_surface_layer.h +@@ -25,7 +25,7 @@ + #include "common/rs_anco_type.h" + + #include "rslayer.h" +-#include "rs_layer_property_cmd.h" ++#include "composer_base/rs_render_layer_cmd_property.h" + #include "ibuffer_release_listener.h" + + namespace OHOS { +diff --git a/rosen/modules/render_service/composer/pipeline/transaction/rs_layer_transaction_data.h b/rosen/modules/render_service/composer/pipeline/transaction/rs_layer_transaction_data.h +index c72d5d6097..486f43b946 100644 +--- a/rosen/modules/render_service/composer/pipeline/transaction/rs_layer_transaction_data.h ++++ b/rosen/modules/render_service/composer/pipeline/transaction/rs_layer_transaction_data.h +@@ -21,7 +21,7 @@ + #include + #include + +-#include "command/rs_layer_parcel.h" ++#include "composer_base/rs_layer_parcel.h" + + + namespace OHOS { +@@ -98,11 +98,7 @@ public: + return marshallingIndex_; + } + +-<<<<<<< HEAD +- std::vector>>& GetPayload() +-======= + std::vector>>& GetPayload() +->>>>>>> 17beb93761e5974c77c5e5a0fa5b7bc93c0383cf + { + return payload_; + } diff --git a/patchset2.diff b/patchset2.diff new file mode 100644 index 0000000000000000000000000000000000000000..3fed99595f653a51605f7cc739bdfc6ae460278d --- /dev/null +++ b/patchset2.diff @@ -0,0 +1,129 @@ +diff --git a/rosen/modules/render_service/composer/composer_base/rs_layer_cmd_def.in b/rosen/modules/render_service/composer/composer_base/rs_layer_cmd_def.in +index f301a3cb66..c645377c50 100644 +--- a/rosen/modules/render_service/composer/composer_base/rs_layer_cmd_def.in ++++ b/rosen/modules/render_service/composer/composer_base/rs_layer_cmd_def.in +@@ -13,7 +13,6 @@ + * limitations under the License. + */ + +-// 基础属性命令 + DECLARE_RSLAYER_CMD(ZOrder, uint32_t, ZORDER, Overwrite, ZERO) + DECLARE_RSLAYER_CMD(Type, GraphicLayerType, TYPE, Overwrite, ZERO) + DECLARE_RSLAYER_CMD(Transform, GraphicTransformType, TRANSFORM, Overwrite, ZERO) +@@ -21,7 +20,6 @@ DECLARE_RSLAYER_CMD(CompositionType, GraphicCompositionType, COMPOSITION_TYPE, O + DECLARE_RSLAYER_CMD(BlendType, GraphicBlendType, BLEND_TYPE, Overwrite, ZERO) + DECLARE_RSLAYER_CMD(Gravity, int32_t, GRAVITY, Overwrite, ZERO) + +-// 布尔属性命令 + DECLARE_RSLAYER_CMD(PreMulti, bool, PRE_MULTI, Overwrite, ZERO) + DECLARE_RSLAYER_CMD(UniRenderFlag, bool, UNI_RENDER_FLAG, Overwrite, ZERO) + DECLARE_RSLAYER_CMD(TunnelHandleChange, bool, TUNNEL_HANDLE_CHANGE, Overwrite, ZERO) +@@ -31,52 +29,42 @@ DECLARE_RSLAYER_CMD(LayerArsr, bool, LAYER_ARSR, Overwrite, ZERO) + DECLARE_RSLAYER_CMD(LayerCopybit, bool, LAYER_COPYBIT, Overwrite, ZERO) + DECLARE_RSLAYER_CMD(BilinearInterpolation, bool, BILINEAR_INTERPOLATION, Overwrite, ZERO) + +-// 浮点属性命令 + DECLARE_RSLAYER_CMD(SdrNit, float, SDR_NIT, Overwrite, ZERO) + DECLARE_RSLAYER_CMD(DisplayNit, float, DISPLAY_NIT, Overwrite, ZERO) + DECLARE_RSLAYER_CMD(BrightnessRatio, float, BRIGHTNESS_RATIO, Overwrite, ZERO) + +-// 整数属性命令 + DECLARE_RSLAYER_CMD(NodeId, uint64_t, NODE_ID, Overwrite, ZERO) + DECLARE_RSLAYER_CMD(TunnelLayerId, uint64_t, TUNNEL_LAYER_ID, Overwrite, ZERO) + DECLARE_RSLAYER_CMD(TunnelLayerProperty, uint32_t, TUNNEL_LAYER_PROPERTY, Overwrite, ZERO) + DECLARE_RSLAYER_CMD(AncoFlags, uint32_t, ANCO_FLAGS, Overwrite, ZERO) + DECLARE_RSLAYER_CMD(LayerSourceTuning, int32_t, LAYER_SOURCE_TUNING, Overwrite, ZERO) + +-// 矩形和区域命令 + DECLARE_RSLAYER_CMD(LayerSize, GraphicIRect, LAYER_SIZE, Overwrite, ZERO) + DECLARE_RSLAYER_CMD(BoundSize, GraphicIRect, BOUND_SIZE, Overwrite, ZERO) + DECLARE_RSLAYER_CMD(CropRect, GraphicIRect, CROP_RECT, Overwrite, ZERO) + DECLARE_RSLAYER_CMD(VisibleRegions, std::vector, VISIBLE_REGIONS, Overwrite, ZERO) + DECLARE_RSLAYER_CMD(DirtyRegions, std::vector, DIRTY_REGIONS, Overwrite, ZERO) + +-// 矩阵和变换命令 + DECLARE_RSLAYER_CMD(Matrix, GraphicMatrix, MATRIX, Overwrite, ZERO) + DECLARE_RSLAYER_CMD(ColorTransform, std::vector, COLOR_TRANSFORM, Overwrite, ZERO) + DECLARE_RSLAYER_CMD(LayerLinearMatrix, std::vector, LAYER_LINEAR_MATRIX, Overwrite, ZERO) + DECLARE_RSLAYER_CMD(DrmCornerRadiusInfo, std::vector, LAYER_MASK_INFO, Overwrite, ZERO) + +-// 颜色命令 + DECLARE_RSLAYER_CMD(LayerColor, GraphicLayerColor, LAYER_COLOR, Overwrite, ZERO) + DECLARE_RSLAYER_CMD(BackgroundColor, GraphicLayerColor, BACKGROUND_COLOR, Overwrite, ZERO) + DECLARE_RSLAYER_CMD(LayerAlpha, GraphicLayerAlpha, ALPHA, Overwrite, ZERO) + DECLARE_RSLAYER_CMD(ColorDataSpace, GraphicColorDataSpace, COLOR_DATA_SPACE, Overwrite, ZERO) + +-// 元数据命令 + DECLARE_RSLAYER_CMD(MetaData, std::vector, META_DATA, Overwrite, ZERO) + DECLARE_RSLAYER_CMD(MetaDataSet, GraphicHDRMetaDataSet, META_DATA_SET, Overwrite, ZERO) + +-// 时间戳命令 + DECLARE_RSLAYER_CMD(PresentTimestamp, GraphicPresentTimestamp, PRESENT_TIMESTAMP, Overwrite, ZERO) + +-// 字符串命令 + DECLARE_RSLAYER_CMD(WindowsName, std::vector, WINDOWS_NAME, Overwrite, ZERO) + +-// 特殊对象命令 (需要特殊处理) + DECLARE_RSLAYER_CMD(AcquireFence, sptr, ACQUIRE_FENCE, Overwrite, ZERO) + DECLARE_RSLAYER_CMD(Buffer, sptr, BUFFER, Overwrite, ZERO) + DECLARE_RSLAYER_CMD(PreBuffer, sptr, PRE_BUFFER, Overwrite, ZERO) + // DECLARE_RSLAYER_CMD(TunnelHandle, sptr, TUNNEL_HANDLE, Overwrite, ZERO) + +-// 缓冲区释放监听器命令 + DECLARE_RSLAYER_CMD(SetBufferReleaseListener, sptr, SET_BUFFER_RELEASE_LISTENER, Overwrite, ZERO) +diff --git a/rosen/modules/render_service/composer/composer_base/rs_render_layer_cmd.h b/rosen/modules/render_service/composer/composer_base/rs_render_layer_cmd.h +index d09bee2e5d..5ba35fdb56 100644 +--- a/rosen/modules/render_service/composer/composer_base/rs_render_layer_cmd.h ++++ b/rosen/modules/render_service/composer/composer_base/rs_render_layer_cmd.h +@@ -57,11 +57,14 @@ protected: + property->SetType(RSLayerCmdType::CMD_TYPE); \ + } \ + virtual ~RSRender##CMD_NAME##Cmd() = default; \ +- bool Marshalling(Parcel& parcel) override; \ +- RSLayerCmdType GetRsRenderLayerCmdType() override \ ++ bool Unmarshalling(Parcel& parcel) override; \ ++ RSLayerCmdType GetRsRenderLayerCmdType() override \ + { \ +- return (RSLayerCmdType::CMD_TYPE); \ +- } \ \ ++ return (RSLayerCmdType::CMD_TYPE); \ ++ } \ ++ std::shared_ptr CreateRenderLayerCmd() override { \ ++ return std::make_shared(GetProperty()); \ ++ } \ + }; + + #include "rs_layer_cmd_def.in" +diff --git a/rosen/modules/render_service/composer/composer_client/rs_layer_cmd.h b/rosen/modules/render_service/composer/composer_client/rs_layer_cmd.h +index f681f2e332..8bb7b962d8 100644 +--- a/rosen/modules/render_service/composer/composer_client/rs_layer_cmd.h ++++ b/rosen/modules/render_service/composer/composer_client/rs_layer_cmd.h +@@ -63,7 +63,28 @@ protected: + RSLayerId rsLayerId_; + std::shared_ptr rsLayerProperty_; + }; ++#define DECLARE_RSLAYER_CMD(CMD_NAME, TYPE, CMD_TYPE, DELTA_OP, THRESHOLD_TYPE) \ ++ class RSB_EXPORT RS##CMD_NAME##Cmd : public RSLayerCmd { \ ++ public: \ ++ RS##CMD_NAME##Cmd(const std::shared_ptr& property) \ ++ : RSLayerCmd(property) \ ++ { \ ++ property->SetType(RSLayerCmdType::CMD_TYPE); \ ++ } \ ++ virtual ~RS##CMD_NAME##Cmd() = default; \ ++ bool Marshalling(Parcel& parcel) override; \ ++ RSLayerCmdType GetRsLayerCmdType() override \ ++ { \ ++ return (RSLayerCmdType::CMD_TYPE); \ ++ } \ ++ std::shared_ptr CreateLayerCmd() override { \ ++ return std::make_shared(GetProperty()); \ ++ } \ ++ }; + ++#include "rs_layer_cmd_def.in" ++ ++#undef DECLARE_RSLAYER_CMD + } // namespace Rosen + } // namespace OHOS + diff --git a/rosen/modules/composer/hdi_backend/include/hdi_layer.h b/rosen/modules/composer/hdi_backend/include/hdi_layer.h index 7c1449dc1b80d7f11ec536cee176eb90c0ac9b20..c9ec9bcdc21327cdc86f9f0d0c9f2f948a7ff3f9 100644 --- a/rosen/modules/composer/hdi_backend/include/hdi_layer.h +++ b/rosen/modules/composer/hdi_backend/include/hdi_layer.h @@ -21,12 +21,13 @@ #include #include "hdi_device.h" #include "hdi_layer_info.h" +#include "rs_surface_layer.h" namespace OHOS { namespace Rosen { -using LayerInfoPtr = std::shared_ptr; +using LayerInfoPtr = std::shared_ptr; struct FPSInfo { int64_t presentTime; std::vector windowsName; diff --git a/rosen/modules/composer/hdi_backend/src/hdi_output.cpp b/rosen/modules/composer/hdi_backend/src/hdi_output.cpp index 5fa96c4a64af8bde1f1ad1d449cbbf4b337a23e0..7e1eb48da7623a029a5c8cddda80ff8547bda75d 100644 --- a/rosen/modules/composer/hdi_backend/src/hdi_output.cpp +++ b/rosen/modules/composer/hdi_backend/src/hdi_output.cpp @@ -714,18 +714,15 @@ void HdiOutput::ReleaseSurfaceBuffer(sptr& releaseFence) HLOGD("HdiOutput::ReleaseLayers: layer or layerInfo or layer's cSurface is nullptr"); continue; } - auto preBuffer = layer->GetLayerInfo()->GetPreBuffer(); - auto consumer = layer->GetLayerInfo()->GetSurface(); - releaseBuffer(preBuffer, SyncFence::InvalidFence(), consumer); + RS_TRACE_NAME_FMT("HdiOutput::ReleaseLayers, layerId %u", layer->GetLayerId()); + layer->GetLayerInfo()->ReleasePreBuffer(SyncFence::InvalidFence()); } HLOGD("HdiOutput::ReleaseLayers: no layer needs to release"); } for (const auto& [layer, fence] : layersReleaseFence) { if (layer != nullptr) { - auto preBuffer = layer->GetPreBuffer(); - auto consumer = layer->GetSurface(); ANCOTransactionOnComplete(layer, fence); - releaseBuffer(preBuffer, fence, consumer); + layer->GetLayerInfo()->ReleasePreBuffer(fence); if (layer->GetUniRenderFlag()) { releaseFence = fence; } diff --git a/rosen/modules/render_service/BUILD.gn b/rosen/modules/render_service/BUILD.gn index 65c98d9fb2e8650543f897fb278e02518bb01925..6da85120b3ec3fa137a6d400c3add8c9451d17db 100644 --- a/rosen/modules/render_service/BUILD.gn +++ b/rosen/modules/render_service/BUILD.gn @@ -163,11 +163,28 @@ ohos_shared_library("librender_service") { "core/screen_manager/rs_screen_manager.cpp", "core/system/rs_system_parameters.cpp", "core/transaction/rs_irender_service_connection_ipc_interface_code_access_verifier.cpp", - "core/transaction/rs_irender_service_ipc_interface_code_access_verifier.cpp", + "core/transaction/rs_irender_service_connection_ipc_interface_code_access_verifier.cpp", "core/transaction/rs_render_service_connection_stub.cpp", "core/transaction/rs_render_service_security_utils.cpp", "core/transaction/rs_render_service_stub.cpp", "core/transaction/rs_unmarshal_thread.cpp", + # composer 模块源文件 + "composer/composer_base/rs_layer_marshalling_helper.cpp", + "composer/composer_base/rs_layer_parcel_factory.cpp", + "composer/composer_base/rs_layer_parcel.cpp", + "composer/composer_base/rs_render_layer_cmd.cpp", + "composer/composer_base/rs_render_layer_cmd_property.cpp", + "composer/composer_client/rs_layer_cmd.cpp", + "composer/composer_client/rs_layer_context.cpp", + "composer/composer_client/rs_surface_layer.cpp", + "composer/composer_client/rs_layer_factory.cpp", + "composer/pipeline/connection/buffer_release_listener_stub.cpp", + "composer/pipeline/connection/buffer_release_listener_proxy.cpp", + "composer/pipeline/connection/rs_composer_connection_proxy.cpp", + "composer/pipeline/connection/rs_composer_connection_stub.cpp", + "composer/pipeline/connection/rs_composer_connection.cpp", + "composer/pipeline/transaction/rs_layer_transaction_data.cpp", + "composer/pipeline/transaction/rs_layer_transaction_handler.cpp", ] #feature_cfg @@ -368,6 +385,10 @@ ohos_shared_library("librender_service") { "$graphic_2d_root/rosen/modules/ressched/include", "$graphic_2d_root/utils/log", "$graphic_2d_root/utils/socketpair/export", + # composer 模块包含目录 + "composer/composer_base", + "composer/composer_client", + "composer/pipeline", ] public_deps += [ diff --git a/rosen/modules/render_service/composer/composer_base/rs_layer_cmd_def.in b/rosen/modules/render_service/composer/composer_base/rs_layer_cmd_def.in new file mode 100644 index 0000000000000000000000000000000000000000..c645377c50bdc2ad5ca41fa6902c9fa59161eca1 --- /dev/null +++ b/rosen/modules/render_service/composer/composer_base/rs_layer_cmd_def.in @@ -0,0 +1,70 @@ +/* + * 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. + */ + +DECLARE_RSLAYER_CMD(ZOrder, uint32_t, ZORDER, Overwrite, ZERO) +DECLARE_RSLAYER_CMD(Type, GraphicLayerType, TYPE, Overwrite, ZERO) +DECLARE_RSLAYER_CMD(Transform, GraphicTransformType, TRANSFORM, Overwrite, ZERO) +DECLARE_RSLAYER_CMD(CompositionType, GraphicCompositionType, COMPOSITION_TYPE, Overwrite, ZERO) +DECLARE_RSLAYER_CMD(BlendType, GraphicBlendType, BLEND_TYPE, Overwrite, ZERO) +DECLARE_RSLAYER_CMD(Gravity, int32_t, GRAVITY, Overwrite, ZERO) + +DECLARE_RSLAYER_CMD(PreMulti, bool, PRE_MULTI, Overwrite, ZERO) +DECLARE_RSLAYER_CMD(UniRenderFlag, bool, UNI_RENDER_FLAG, Overwrite, ZERO) +DECLARE_RSLAYER_CMD(TunnelHandleChange, bool, TUNNEL_HANDLE_CHANGE, Overwrite, ZERO) +DECLARE_RSLAYER_CMD(SupportedPresentTimestamp, bool, SUPPORTED_PRESENT_TIMESTAMP, Overwrite, ZERO) +DECLARE_RSLAYER_CMD(RotationFixed, bool, ROTATION_FIXED, Overwrite, ZERO) +DECLARE_RSLAYER_CMD(LayerArsr, bool, LAYER_ARSR, Overwrite, ZERO) +DECLARE_RSLAYER_CMD(LayerCopybit, bool, LAYER_COPYBIT, Overwrite, ZERO) +DECLARE_RSLAYER_CMD(BilinearInterpolation, bool, BILINEAR_INTERPOLATION, Overwrite, ZERO) + +DECLARE_RSLAYER_CMD(SdrNit, float, SDR_NIT, Overwrite, ZERO) +DECLARE_RSLAYER_CMD(DisplayNit, float, DISPLAY_NIT, Overwrite, ZERO) +DECLARE_RSLAYER_CMD(BrightnessRatio, float, BRIGHTNESS_RATIO, Overwrite, ZERO) + +DECLARE_RSLAYER_CMD(NodeId, uint64_t, NODE_ID, Overwrite, ZERO) +DECLARE_RSLAYER_CMD(TunnelLayerId, uint64_t, TUNNEL_LAYER_ID, Overwrite, ZERO) +DECLARE_RSLAYER_CMD(TunnelLayerProperty, uint32_t, TUNNEL_LAYER_PROPERTY, Overwrite, ZERO) +DECLARE_RSLAYER_CMD(AncoFlags, uint32_t, ANCO_FLAGS, Overwrite, ZERO) +DECLARE_RSLAYER_CMD(LayerSourceTuning, int32_t, LAYER_SOURCE_TUNING, Overwrite, ZERO) + +DECLARE_RSLAYER_CMD(LayerSize, GraphicIRect, LAYER_SIZE, Overwrite, ZERO) +DECLARE_RSLAYER_CMD(BoundSize, GraphicIRect, BOUND_SIZE, Overwrite, ZERO) +DECLARE_RSLAYER_CMD(CropRect, GraphicIRect, CROP_RECT, Overwrite, ZERO) +DECLARE_RSLAYER_CMD(VisibleRegions, std::vector, VISIBLE_REGIONS, Overwrite, ZERO) +DECLARE_RSLAYER_CMD(DirtyRegions, std::vector, DIRTY_REGIONS, Overwrite, ZERO) + +DECLARE_RSLAYER_CMD(Matrix, GraphicMatrix, MATRIX, Overwrite, ZERO) +DECLARE_RSLAYER_CMD(ColorTransform, std::vector, COLOR_TRANSFORM, Overwrite, ZERO) +DECLARE_RSLAYER_CMD(LayerLinearMatrix, std::vector, LAYER_LINEAR_MATRIX, Overwrite, ZERO) +DECLARE_RSLAYER_CMD(DrmCornerRadiusInfo, std::vector, LAYER_MASK_INFO, Overwrite, ZERO) + +DECLARE_RSLAYER_CMD(LayerColor, GraphicLayerColor, LAYER_COLOR, Overwrite, ZERO) +DECLARE_RSLAYER_CMD(BackgroundColor, GraphicLayerColor, BACKGROUND_COLOR, Overwrite, ZERO) +DECLARE_RSLAYER_CMD(LayerAlpha, GraphicLayerAlpha, ALPHA, Overwrite, ZERO) +DECLARE_RSLAYER_CMD(ColorDataSpace, GraphicColorDataSpace, COLOR_DATA_SPACE, Overwrite, ZERO) + +DECLARE_RSLAYER_CMD(MetaData, std::vector, META_DATA, Overwrite, ZERO) +DECLARE_RSLAYER_CMD(MetaDataSet, GraphicHDRMetaDataSet, META_DATA_SET, Overwrite, ZERO) + +DECLARE_RSLAYER_CMD(PresentTimestamp, GraphicPresentTimestamp, PRESENT_TIMESTAMP, Overwrite, ZERO) + +DECLARE_RSLAYER_CMD(WindowsName, std::vector, WINDOWS_NAME, Overwrite, ZERO) + +DECLARE_RSLAYER_CMD(AcquireFence, sptr, ACQUIRE_FENCE, Overwrite, ZERO) +DECLARE_RSLAYER_CMD(Buffer, sptr, BUFFER, Overwrite, ZERO) +DECLARE_RSLAYER_CMD(PreBuffer, sptr, PRE_BUFFER, Overwrite, ZERO) +// DECLARE_RSLAYER_CMD(TunnelHandle, sptr, TUNNEL_HANDLE, Overwrite, ZERO) + +DECLARE_RSLAYER_CMD(SetBufferReleaseListener, sptr, SET_BUFFER_RELEASE_LISTENER, Overwrite, ZERO) diff --git a/rosen/modules/render_service/composer/composer_base/rs_layer_marshalling_helper.cpp b/rosen/modules/render_service/composer/composer_base/rs_layer_marshalling_helper.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5a1dc7ee41009f6537a123be0185b99af0124ed2 --- /dev/null +++ b/rosen/modules/render_service/composer/composer_base/rs_layer_marshalling_helper.cpp @@ -0,0 +1,69 @@ +/* + * 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 "rs_layer_marshalling_helper.h" + +namespace OHOS { +namespace Rosen { + +#define MARSHALLING_AND_UNMARSHALLING(TYPE, TYPENAME) \ + bool RSLayerMarshallingHelper::Marshalling(Parcel& parcel, const TYPE& val) \ + { \ + return parcel.Write##TYPENAME(val); \ + } \ + bool RSLayerMarshallingHelper::Unmarshalling(Parcel& parcel, TYPE& val) \ + { \ + return parcel.Read##TYPENAME(val); \ + } + +// basic types +MARSHALLING_AND_UNMARSHALLING(bool, Bool) +MARSHALLING_AND_UNMARSHALLING(int8_t, Int8) +MARSHALLING_AND_UNMARSHALLING(uint8_t, Uint8) +MARSHALLING_AND_UNMARSHALLING(int16_t, Int16) +MARSHALLING_AND_UNMARSHALLING(uint16_t, Uint16) +MARSHALLING_AND_UNMARSHALLING(int32_t, Int32) +MARSHALLING_AND_UNMARSHALLING(uint32_t, Uint32) +MARSHALLING_AND_UNMARSHALLING(int64_t, Int64) +MARSHALLING_AND_UNMARSHALLING(uint64_t, Uint64) +MARSHALLING_AND_UNMARSHALLING(float, Float) +MARSHALLING_AND_UNMARSHALLING(double, Double) + +#undef MARSHALLING_AND_UNMARSHALLING + +bool RSLayerMarshallingHelper::Marshalling(Parcel& parcel, const std::shared_ptr& val) +{ + return val != nullptr && val->Marshalling(parcel); +} + +bool RSLayerMarshallingHelper::Unmarshalling(Parcel& parcel, std::shared_ptr& val) +{ + val.reset(RSRenderLayerCmd::Unmarshalling(parcel)); + return val != nullptr; +} + +bool RSLayerMarshallingHelper::Marshalling(Parcel& parcel, const std::shared_ptr& val) +{ + return val != nullptr && val->Marshalling(parcel); +} + +bool RSLayerMarshallingHelper::Unmarshalling(Parcel& parcel, std::shared_ptr& val) +{ + val.reset(RSRenderLayerCmd::Unmarshalling(parcel)); + return val != nullptr; +} + +} // namespace Rosen +} // namespace OHOS diff --git a/rosen/modules/render_service/composer/composer_base/rs_layer_marshalling_helper.h b/rosen/modules/render_service/composer/composer_base/rs_layer_marshalling_helper.h new file mode 100644 index 0000000000000000000000000000000000000000..97e68c039b6d65344487e69fccdc64c6f5aaad22 --- /dev/null +++ b/rosen/modules/render_service/composer/composer_base/rs_layer_marshalling_helper.h @@ -0,0 +1,72 @@ +/* + * 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 COMPOSER_BASE_RS_LAYER_MARSHALLING_H +#define COMPOSER_BASE_RS_LAYER_MARSHALLING_H + +#include +#include +#include +#include +#include + +#include "rs_render_layer_cmd.h" +#include "rs_render_layer_cmd_property.h" + + +namespace OHOS { +namespace Rosen { + +class RSRenderLayerCmd; +class RSRenderLayerCmdProperty; + +class RSB_EXPORT RSLayerMarshallingHelper { +public: + static bool Marshalling(Parcel& parcel) + { + return true; + } + static bool Unmarshalling(Parcel& parcel) + { + return true; + } + +// reloaded marshalling & unmarshalling function for types +#define DECLARE_FUNCTION_OVERLOAD(TYPE) \ + static RSB_EXPORT bool Marshalling(Parcel& parcel, const TYPE& val); \ + static RSB_EXPORT bool Unmarshalling(Parcel& parcel, TYPE& val); + + // basic types + DECLARE_FUNCTION_OVERLOAD(bool) + DECLARE_FUNCTION_OVERLOAD(int8_t) + DECLARE_FUNCTION_OVERLOAD(uint8_t) + DECLARE_FUNCTION_OVERLOAD(int16_t) + DECLARE_FUNCTION_OVERLOAD(uint16_t) + DECLARE_FUNCTION_OVERLOAD(int32_t) + DECLARE_FUNCTION_OVERLOAD(uint32_t) + DECLARE_FUNCTION_OVERLOAD(int64_t) + DECLARE_FUNCTION_OVERLOAD(uint64_t) + DECLARE_FUNCTION_OVERLOAD(float) + DECLARE_FUNCTION_OVERLOAD(double) + + // rs layer command + DECLARE_FUNCTION_OVERLOAD(std::shared_ptr) + DECLARE_FUNCTION_OVERLOAD(std::shared_ptr) +#undef DECLARE_FUNCTION_OVERLOAD +}; +} // namespace Rosen +} // namespace OHOS + +#endif // COMPOSER_BASE_RS_LAYER_MARSHALLING_H diff --git a/rosen/modules/render_service/composer/composer_base/rs_layer_parcel.cpp b/rosen/modules/render_service/composer/composer_base/rs_layer_parcel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3080ef6e19ee755d4a5d8f936e9f0992248bcf94 --- /dev/null +++ b/rosen/modules/render_service/composer/composer_base/rs_layer_parcel.cpp @@ -0,0 +1,35 @@ +/* + * 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 +#include + +#include "rs_layer_parcel.h" + +namespace OHOS { +namespace Rosen { + +void RSLayerParcelHelper::AddRSLayerCmd(RSLayerContext& context, LayerId layerId, + const std::shared_ptr& command) +{ + auto rsLsyer = context.GetRsRenderLayer(layerId); + if (rsLsyer) { + rsLsyer->UpdateRSLayerCmd(command); // + } +} + +} // namespace Rosen +} // namespace OHOS diff --git a/rosen/modules/render_service/composer/composer_base/rs_layer_parcel.h b/rosen/modules/render_service/composer/composer_base/rs_layer_parcel.h new file mode 100644 index 0000000000000000000000000000000000000000..4ef0a2af0923efe4be9b73da987e54e228a9c666 --- /dev/null +++ b/rosen/modules/render_service/composer/composer_base/rs_layer_parcel.h @@ -0,0 +1,58 @@ +/* + * 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 COMPOSER_BASE_RS_LAYER_PARCEL_H +#define COMPOSER_BASE_RS_LAYER_PARCEL_H + +#include +#include + +#include "rs_layer_parcel_templates.h" + +namespace OHOS { +namespace Rosen { + +class RSLayerParcel : public Parcelable { +public: + RSLayerParcel() = default; + RSLayerParcel(const RSLayerParcel&) = delete; + RSLayerParcel(const RSLayerParcel&&) = delete; + RSLayerParcel& operator=(const RSLayerParcel&) = delete; + RSLayerParcel& operator=(const RSLayerParcel&&) = delete; + ~RSLayerParcel() noexcept override = default; + + virtual void Process(RSLayerContext& context) = 0; + +private: + size_t indexVerifier_ = 0; + friend class RSLayerTransactionData; +}; + +enum RSLayerParcelType : uint16_t { + ADD_RS_LAYER_CMD = 0x0000, +} + +class RSB_EXPORT RSLayerParcelHelper { +public: + static void AddRSLayerCmd(RSLayerContext& context, LayerId layerId, const std::shared_ptr& command); +}; + +ADD_COMMAND(RSAddRSLayerCmd, + ARG(ADD_RS_LAYER_CMD, + RSLayerParcelHelper::AddRSLayerCmd, LayerId, std::shared_ptr)) + +} // namespace Rosen +} // namespace OHOS +#endif // COMPOSER_BASE_RS_LAYER_PARCEL_H diff --git a/rosen/modules/render_service/composer/composer_base/rs_layer_parcel_factory.cpp b/rosen/modules/render_service/composer/composer_base/rs_layer_parcel_factory.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a94ee1b325fecaf4e027dd0fa365bd780707cc34 --- /dev/null +++ b/rosen/modules/render_service/composer/composer_base/rs_layer_parcel_factory.cpp @@ -0,0 +1,55 @@ +/* + * 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 "rs_layer_parcel_factory.h" +#include "platform/common/rs_log.h" + +namespace OHOS { +namespace Rosen { + +namespace { +inline uint32_t MakeKey(uint16_t commandType) +{ + return ((uint32_t)commandType); +} +} // namespace + +RSLayerParcelFactory& RSLayerParcelFactory::Instance() +{ + static RSLayerParcelFactory instance; + return instance; +} + +void RSLayerParcelFactory::Register(uint16_t type, UnmarshallingFunc func) +{ + auto result = unmarshallingFuncLUT_.try_emplace(MakeKey(type), func); + if (!result.second) { + ROSEN_LOGD("RSLayerParcelFactory::Register, Duplicate command & sub_command detected!" + " type: %{public}d", type); + } +} + +UnmarshallingFunc RSLayerParcelFactory::GetUnmarshallingFunc(uint16_t type, uint16_t subtype) +{ + auto it = unmarshallingFuncLUT_.find(MakeKey(type)); + if (it == unmarshallingFuncLUT_.end()) { + ROSEN_LOGE("RSLayerParcelFactory::GetUnmarshallingFunc, Func is not found," + " type=%{public}d", type); + return nullptr; + } + return it->second; +} +} // namespace Rosen +} // namespace OHOS diff --git a/rosen/modules/render_service/composer/composer_base/rs_layer_parcel_factory.h b/rosen/modules/render_service/composer/composer_base/rs_layer_parcel_factory.h new file mode 100644 index 0000000000000000000000000000000000000000..a6e7c77ac1bd94adf1ba50ce1f042e76760cf252 --- /dev/null +++ b/rosen/modules/render_service/composer/composer_base/rs_layer_parcel_factory.h @@ -0,0 +1,55 @@ +/* + * 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 COMPOSER_BASE_RS_LAYER_PARCEL_FACTORY_H +#define COMPOSER_BASE_RS_LAYER_PARCEL_FACTORY_H + +#include +#include + + +namespace OHOS { +namespace Rosen { +class RSLayerParcel; +using UnmarshallingFunc = RSLayerParcel* (*)(Parcel& parcel); + +class RSB_EXPORT RSLayerParcelFactory { +public: + static RSLayerParcelFactory& Instance(); + + void Register(uint16_t type, uint16_t subtype, UnmarshallingFunc func); + UnmarshallingFunc GetUnmarshallingFunc(uint16_t type, uint16_t subtype); + +private: + RSLayerParcelFactory() = default; + ~RSLayerParcelFactory() = default; + + std::unordered_map unmarshallingFuncLUT_; +}; + +// Helper class for automatically registry +template +class RSLayerParcelRegister { +public: + RSCommandRegister() + { + RSLayerParcelFactory::Instance().Register(rsLayerParcelType, func); + } +}; + +} // namespace Rosen +} // namespace OHOS + +#endif // COMPOSER_BASE_RS_LAYER_PARCEL_FACTORY_H diff --git a/rosen/modules/render_service/composer/composer_base/rs_layer_parcel_templates.h b/rosen/modules/render_service/composer/composer_base/rs_layer_parcel_templates.h new file mode 100644 index 0000000000000000000000000000000000000000..590b7ee476ac5c550868137b3f59f0ce14af8e91 --- /dev/null +++ b/rosen/modules/render_service/composer/composer_base/rs_layer_parcel_templates.h @@ -0,0 +1,86 @@ +/* + * 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 COMPOSER_BASE_RS_LAYER_PARCEL_TEMPLATES_H +#define COMPOSER_BASE_RS_LAYER_PARCEL_TEMPLATES_H + +#include +#include + +#include "rs_layer_parcel_factory.h" + +namespace OHOS { +namespace Rosen { + +// avoiding C++ macros spliting parameters +#ifndef ARG +#define ARG(...) __VA_ARGS__ +#endif + +#define ADD_COMMAND(ALIAS, TYPE) \ + using ALIAS = RSLayerParcelTemplate; \ + template class RSLayerParcelTemplate; + +template +class RSLayerParcelTemplate : public RSLayerParcel { +public: + RSLayerParcelTemplate(const Params&... params) : params_(params...) {} + RSLayerParcelTemplate(std::tuple&& params) : params_(std::move(params)) {} + ~RSLayerParcelTemplate() override = default; + + uint16_t GetType() const override + { + return rsLayerParcelType; + } + + LayerId GetLayerId() const override + { + using idType = typename std::tuple_element<0, decltype(params_)>::type; + if (std::is_same::value) { + return std::get<0>(params_); + } + return 0; // invalidId + } + + void Process(RSContext& context) override + { + // expand the tuple to function parameters + std::apply([&context](auto&... args) { return (*processFunc)(context, args...); }, params_); + } + + bool Marshalling(Parcel& parcel) const override + { + return RSLayerMarshallingHelper::Marshalling(parcel, rsLayerParcelType) && + std::apply([&parcel](const auto&... args) { return RSLayerMarshallingHelper::Marshalling(parcel, args...); }, params_); + }; + + [[nodiscard]] static Parcelable* Unmarshalling(Parcel& parcel) + { + std::tuple params; + if (!std::apply( + [&parcel](auto&... args) { return RSLayerMarshallingHelper::Unmarshalling(parcel, args...); }, params)) { + return nullptr; + } + return new RSLayerParcelTemplate(std::move(params)); + } + + static inline RSLayerParcelRegister registry; + +private: + std::tuple params_; +}; +} // namespace Rosen +} // namespace OHOS +#endif // COMPOSER_BASE_RS_LAYER_PARCEL_TEMPLATES_H diff --git a/rosen/modules/render_service/composer/composer_base/rs_layer_property_def.in b/rosen/modules/render_service/composer/composer_base/rs_layer_property_def.in new file mode 100644 index 0000000000000000000000000000000000000000..247a1a21371d76ef2c7fc3c1a9fb407a8deb6d09 --- /dev/null +++ b/rosen/modules/render_service/composer/composer_base/rs_layer_property_def.in @@ -0,0 +1,54 @@ +/* + * 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. + */ + +// 基础类型属性 +DECLARE_RSLAYER_PROPERTY(uint32_t, UINT32) // ZORDER +DECLARE_RSLAYER_PROPERTY(GraphicLayerType, INT) // TYPE +DECLARE_RSLAYER_PROPERTY(GraphicTransformType, INT) // TRANSFORM +DECLARE_RSLAYER_PROPERTY(GraphicCompositionType, INT) // COMPOSITION_TYPE +DECLARE_RSLAYER_PROPERTY(GraphicBlendType, INT) // BLEND_TYPE +DECLARE_RSLAYER_PROPERTY(int32_t, INT) // GRAVITY +DECLARE_RSLAYER_PROPERTY(bool, BOOL) // PRE_MULTI, UNI_RENDER_FLAG, etc. +DECLARE_RSLAYER_PROPERTY(float, FLOAT) // ALPHA, SDR_NIT, DISPLAY_NIT, BRIGHTNESS_RATIO +DECLARE_RSLAYER_PROPERTY(uint64_t, UINT64) // NODE_ID, TUNNEL_LAYER_ID +DECLARE_RSLAYER_PROPERTY(uint32_t, UINT32) // TUNNEL_LAYER_PROPERTY, ANCO_FLAGS + +// 矩形和区域属性 +DECLARE_RSLAYER_PROPERTY(GraphicIRect, IRECT) // LAYER_SIZE, BOUND_SIZE, CROP_RECT +DECLARE_RSLAYER_PROPERTY(std::vector, VECTOR_IRECT) // VISIBLE_REGIONS, DIRTY_REGIONS + +// 矩阵和变换属性 +DECLARE_RSLAYER_PROPERTY(GraphicMatrix, MATRIX) // MATRIX +DECLARE_RSLAYER_PROPERTY(std::vector, VECTOR_FLOAT) // COLOR_TRANSFORM, LAYER_LINEAR_MATRIX, DRM_CORNER_RADIUS + +// 颜色属性 +DECLARE_RSLAYER_PROPERTY(GraphicLayerColor, COLOR) // LAYER_COLOR, BACKGROUND_COLOR +DECLARE_RSLAYER_PROPERTY(GraphicLayerAlpha, ALPHA) // LAYER_ALPHA +DECLARE_RSLAYER_PROPERTY(GraphicColorDataSpace, INT) // COLOR_DATA_SPACE + +// 元数据属性 +DECLARE_RSLAYER_PROPERTY(std::vector, META_DATA) // META_DATA +DECLARE_RSLAYER_PROPERTY(GraphicHDRMetaDataSet, META_DATA_SET) // META_DATA_SET + +// 时间戳属性 +DECLARE_RSLAYER_PROPERTY(GraphicPresentTimestamp, TIMESTAMP) // PRESENT_TIMESTAMP + +// 字符串属性 +DECLARE_RSLAYER_PROPERTY(std::vector, VECTOR_STRING) // WINDOWS_NAME + +// 特殊对象属性 (需要特殊处理) +DECLARE_RSLAYER_PROPERTY(sptr, FENCE) // ACQUIRE_FENCE +DECLARE_RSLAYER_PROPERTY(sptr, BUFFER) // BUFFER, PRE_BUFFER +// DECLARE_RSLAYER_PROPERTY(sptr, TUNNEL_HANDLE) // TUNNEL_HANDLE diff --git a/rosen/modules/render_service/composer/composer_base/rs_render_layer_cmd.cpp b/rosen/modules/render_service/composer/composer_base/rs_render_layer_cmd.cpp new file mode 100644 index 0000000000000000000000000000000000000000..47e0c583296db161bb58e87341cec3535cc0e471 --- /dev/null +++ b/rosen/modules/render_service/composer/composer_base/rs_render_layer_cmd.cpp @@ -0,0 +1,82 @@ +/* + * 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 "rs_render_layer_cmd.h" +#include "rs_layer_marshalling_helper.h" +#include "common/rs_log.h" +#include + +// 前向声明 +class RSLayerContext; + +namespace OHOS { +namespace Rosen { + +using ModifierUnmarshallingFunc = RSRenderLayerCmd* (*)(Parcel& parcel); + +#define DECLARE_RSLAYER_CMD(CMD_NAME, TYPE, CMD_TYPE, DELTA_OP, THRESHOLD_TYPE) \ + { \ + RSLayerCmdType::CMD_TYPE, \ + [](Parcel& parcel) -> RSRenderLayerCmd* { \ + std::shared_ptr> prop; \ + if (!RSMarshallingHelper::Unmarshalling(parcel, prop)) { \ + return nullptr; \ + } \ + auto command = new RSRender##CMD_NAME##Cmd(prop); \ + return command; \ + }, \ + }, + +static std::unordered_map funcLUT = { +#include "rs_layer_cmd_def.in" +}; +#undef DECLARE_RSLAYER_CMD + +RSRenderLayerCmd* RSRenderLayerCmd::Unmarshalling(Parcel& parcel) +{ + int16_t type = 0; + if (!parcel.ReadInt16(type)) { + ROSEN_LOGE("RSRenderLayerCmd::Unmarshalling ReadInt16 failed"); + return nullptr; + } + auto it = funcLUT.find(static_cast(type)); + if (it == funcLUT.end()) { + ROSEN_LOGE("RSRenderLayerCmd Unmarshalling cannot find func in lut %{public}d", type); + return nullptr; + } + return it->second(parcel); +} + +#define DECLARE_RSLAYER_CMD(CMD_NAME, TYPE, CMD_TYPE, DELTA_OP, THRESHOLD_TYPE) \ + bool RSRender##CMD_NAME##Cmd::Marshalling(Parcel& parcel) \ + { \ + auto renderProperty = std::static_pointer_cast>(property_); \ + bool flag = parcel.WriteInt16(static_cast(RSLayerCmdType::CMD_TYPE)) && \ + RSMarshallingHelper::Marshalling(parcel, renderProperty); \ + if (!flag) { \ + ROSEN_LOGE("RSRenderLayerCmd::Marshalling WriteInt16 or Marshalling failed"); \ + } \ + return flag; \ + } \ + std::shared_ptr RSRender##CMD_NAME##Cmd::GetProperty() const \ + { \ + return property_; \ + } + +#include "rs_layer_cmd_def.in" + +#undef DECLARE_RSLAYER_CMD +} // namespace Rosen +} // namespace OHOS diff --git a/rosen/modules/render_service/composer/composer_base/rs_render_layer_cmd.h b/rosen/modules/render_service/composer/composer_base/rs_render_layer_cmd.h new file mode 100644 index 0000000000000000000000000000000000000000..5ba35fdb560e227d30095fb3aa50a48fdbefe9dc --- /dev/null +++ b/rosen/modules/render_service/composer/composer_base/rs_render_layer_cmd.h @@ -0,0 +1,76 @@ +/* + * 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 COMPOSER_BASE_RS_RENDER_LAYER_CMD_H +#define COMPOSER_BASE_RS_RENDER_LAYER_CMD_H + +#include + +#include "parcel.h" +#include "rs_layer_cmd_type.h" + +namespace OHOS { +namespace Rosen { + +class RSC_EXPORT RSRenderLayerCmd { +public: + RSRenderLayerCmd(const RSRenderLayerCmd&) = delete; + RSRenderLayerCmd(const RSRenderLayerCmd&&) = delete; + RSRenderLayerCmd& operator=(const RSRenderLayerCmd&) = delete; + RSRenderLayerCmd& operator=(const RSRenderLayerCmd&&) = delete; + virtual ~RSRenderLayerCmd() = default; + + virtual PropertyId GetPropertyId() = 0; + virtual std::shared_ptr GetProperty() const = 0; + + virtual RSLayerCmdType GetRsRenderLayerCmdType() const + { + return RSLayerCmdType::INVALID; + } + + virtual void Update(RSLayerContext& context) = 0; + virtual bool Marshalling(Parcel& parcel) = 0; + [[nodiscard]] static RSRenderLayerCmd* Unmarshalling(Parcel& parcel); + +protected: + std::shared_ptr property_; +}; + +#define DECLARE_RSLAYER_CMD(CMD_NAME, TYPE, CMD_TYPE, DELTA_OP, THRESHOLD_TYPE) \ + class RSB_EXPORT RSRender##CMD_NAME##Cmd : public RSRenderLayerCmd { \ + public: \ + RSRender##CMD_NAME##Cmd(const std::shared_ptr& property) \ + : RSRenderLayerCmd(property) \ + { \ + property->SetType(RSLayerCmdType::CMD_TYPE); \ + } \ + virtual ~RSRender##CMD_NAME##Cmd() = default; \ + bool Unmarshalling(Parcel& parcel) override; \ + RSLayerCmdType GetRsRenderLayerCmdType() override \ + { \ + return (RSLayerCmdType::CMD_TYPE); \ + } \ + std::shared_ptr CreateRenderLayerCmd() override { \ + return std::make_shared(GetProperty()); \ + } \ + }; + +#include "rs_layer_cmd_def.in" + +#undef DECLARE_RSLAYER_CMD +} // namespace Rosen +} // namespace OHOS + +#endif // COMPOSER_BASE_RS_RENDER_LAYER_CMD_H \ No newline at end of file diff --git a/rosen/modules/render_service/composer/composer_base/rs_render_layer_cmd_property.cpp b/rosen/modules/render_service/composer/composer_base/rs_render_layer_cmd_property.cpp new file mode 100644 index 0000000000000000000000000000000000000000..292970a41bf5618da7271e65e2ae42e1769abcd0 --- /dev/null +++ b/rosen/modules/render_service/composer/composer_base/rs_render_layer_cmd_property.cpp @@ -0,0 +1,40 @@ +/* + * 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 "rs_render_layer_cmd_property.h" + +namespace OHOS { +namespace Rosen { + +template +bool RSRenderLayerCmdProperty::OnUnmarshalling(Parcel& parcel, std::shared_ptr& val) +{ + auto ret = new RSRenderLayerCmdProperty(); + if (ret == nullptr) { + ROSEN_LOGE("%s Creating property failed", __PRETTY_FUNCTION__); + return false; + } + if (!RSMarshallingHelper::UnmarshallingPidPlusId(parcel, ret->id_) || + !RSMarshallingHelper::Unmarshalling(parcel, ret->stagingValue_)) { + ROSEN_LOGE("%s Unmarshalling failed", __PRETTY_FUNCTION__); + delete ret; + return false; + } + val.reset(ret); + return true; +} + +} // namespace Rosen +} // namespace OHOS diff --git a/rosen/modules/render_service/composer/composer_base/rs_render_layer_cmd_property.h b/rosen/modules/render_service/composer/composer_base/rs_render_layer_cmd_property.h new file mode 100644 index 0000000000000000000000000000000000000000..ed5a81170f5b561f54e0b8fc21eac6af91e94e00 --- /dev/null +++ b/rosen/modules/render_service/composer/composer_base/rs_render_layer_cmd_property.h @@ -0,0 +1,372 @@ +/* + * 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 COMPOSER_BASE_RS_RENDER_LAYER_CMD_PROPERTY_H +#define COMPOSER_BASE_RS_RENDER_LAYER_CMD_PROPERTY_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../composer_client/rs_layer_cmd_type.h" +#include "common/rs_common_def.h" + +#ifndef ROSEN_CROSS_PLATFORM +#include "surface_buffer.h" +#include "sync_fence.h" +#endif + +#include "ibuffer_release_listener.h" +#define PropertyId uint64_t +// 前向声明 +namespace OHOS { + GSError ReadSurfaceBufferImpl(MessageParcel &parcel, uint32_t &sequence, sptr &buffer, + std::function readFdDefaultFunc)> readSafeFdFunc); +} + +namespace OHOS { +namespace Rosen { + +enum class RSLayerCmdPropertyType : uint8_t { + INVALID = 0, + BOOL, + INT, + SHORT, + FLOAT, + UINT32, + UINT64, + STRING, + VECTOR_FLOAT, + VECTOR_STRING, + VECTOR_IRECT, + IRECT, + MATRIX, + COLOR, + ALPHA, + META_DATA, + META_DATA_SET, + TIMESTAMP, + FENCE, + BUFFER, + TUNNEL_HANDLE, + + MAX_RS_LAYER_PROPERTY_TYPE = 255, +}; + +template +class RSRenderLayerCmdProperty : public std::enable_shared_from_this> { +public: + RSRenderLayerCmdProperty() = default; + + explicit RSRenderLayerCmdProperty(const T& value) + { + stagingValue_ = value; + } + + ~RSRenderLayerCmdProperty() = default; + + using ValueType = T; + + virtual void Set(const T& value) + { + if (value == stagingValue_ || !IsValid(value)) { + return; + } + stagingValue_ = value; + } + + virtual T Get() const + { + return stagingValue_; + } + + std::shared_ptr> GetRsRenderLayerProperty() + { + return std::make_shared>(stagingValue_); + } + + PropertyId GetId() const { return id_; } + void SetId(PropertyId id) { id_ = id; } + + RSLayerCmdType GetType() const { return type_; } + void SetType(RSLayerCmdType type) { type_ = type; } + + bool Marshalling(MessageParcel& parcel) const + { + if (type_ == RSLayerCmdType::INVALID) { + return false; + } + + // 写入命令类型 + if (!parcel.WriteUint16(static_cast(type_))) { + return false; + } + + // 写入属性ID + if (!parcel.WriteUint64(id_)) { + return false; + } + + // 写入属性值 + return MarshallingValue(parcel, stagingValue_); + } + + bool OnUnmarshalling(MessageParcel& parcel, std::shared_ptr>& val) + { + // 读取命令类型 + uint16_t typeValue; + if (!parcel.ReadUint16(typeValue)) { + return false; + } + + // 读取属性ID + PropertyId id; + if (!parcel.ReadUint64(id)) { + return false; + } + + // 读取属性值 + T value; + if (!UnmarshallingValue(parcel, value)) { + return false; + } + + val = std::make_shared>(value); + val->SetId(id); + val->SetType(static_cast(typeValue)); + + return true; + } + +protected: + bool IsValid(const T& value) + { + return true; + } + + // 模板特化函数实现 + template + typename std::enable_if::value, bool>::type + MarshallingValue(MessageParcel& parcel, const U& value) const + { + return parcel.WriteUnpadBuffer(&value, sizeof(U)); + } + + template + typename std::enable_if::value, bool>::type + MarshallingValue(MessageParcel& parcel, const U& value) const + { + return parcel.WriteString(value); + } + + template + typename std::enable_if>::value, bool>::type + MarshallingValue(MessageParcel& parcel, const U& value) const + { + constexpr uint32_t MAX_VECTOR_SIZE = 10000; + if (value.size() > MAX_VECTOR_SIZE) { + return false; + } + if (!parcel.WriteUint32(value.size())) { + return false; + } + for (const auto& item : value) { + if (!MarshallingValue(parcel, item)) { + return false; + } + } + return true; + } + + template + typename std::enable_if>::value, bool>::type + MarshallingValue(MessageParcel& parcel, const U& value) const + { + if (value == nullptr) { + return parcel.WriteBool(false); + } + if (!parcel.WriteBool(true)) { + return false; + } + return value->WriteToMessageParcel(parcel); + } + + template + typename std::enable_if>::value, bool>::type + MarshallingValue(MessageParcel& parcel, const U& value) const + { + if (value == nullptr) { + return parcel.WriteBool(false); + } + if (!parcel.WriteBool(true)) { + return false; + } + return value->WriteToMessageParcel(parcel); + } + + template + typename std::enable_if>::value, bool>::type + MarshallingValue(MessageParcel& parcel, const U& value) const + { + if (value == nullptr) { + return parcel.WriteBool(false); + } + if (!parcel.WriteBool(true)) { + return false; + } + return parcel.WriteRemoteObject(value); + } + + // UnmarshallingValue 模板特化实现 + template + typename std::enable_if::value, bool>::type + UnmarshallingValue(MessageParcel& parcel, U& value) const + { + return parcel.ReadUnpadBuffer(&value, sizeof(U)); + } + + template + typename std::enable_if::value, bool>::type + UnmarshallingValue(MessageParcel& parcel, U& value) const + { + return parcel.ReadString(value); + } + + template + typename std::enable_if>::value, bool>::type + UnmarshallingValue(MessageParcel& parcel, U& value) const + { + constexpr uint32_t MAX_VECTOR_SIZE = 10000; + uint32_t size; + if (!parcel.ReadUint32(size)) { + return false; + } + if (size > MAX_VECTOR_SIZE) { + return false; + } + value.clear(); + value.reserve(size); + for (uint32_t i = 0; i < size; i++) { + typename U::value_type item; + if (!UnmarshallingValue(parcel, item)) { + return false; + } + value.emplace_back(item); + } + return true; + } + + template + typename std::enable_if>::value, bool>::type + UnmarshallingValue(MessageParcel& parcel, U& value) const + { + bool hasValue; + if (!parcel.ReadBool(hasValue)) { + return false; + } + if (!hasValue) { + value = nullptr; + return true; + } + + uint32_t sequence; + sptr buffer; + auto readSafeFdFunc = [](MessageParcel& parcel, std::function readFdDefaultFunc) -> int { + return parcel.ReadFileDescriptor(); + }; + + GSError ret = ReadSurfaceBufferImpl(parcel, sequence, buffer, readSafeFdFunc); + if (ret != GSERROR_OK) { + return false; + } + + value = buffer; + return true; + } + + template + typename std::enable_if>::value, bool>::type + UnmarshallingValue(MessageParcel& parcel, U& value) const + { + bool hasValue; + if (!parcel.ReadBool(hasValue)) { + return false; + } + if (!hasValue) { + value = nullptr; + return true; + } + + MessageParcel* msgParcel = static_cast(&parcel); + if (msgParcel == nullptr) { + return false; + } + + auto readSafeFdFunc = [](MessageParcel& parcel, std::function readFdDefaultFunc) -> int { + return parcel.ReadFileDescriptor(); + }; + + value = SyncFence::ReadFromMessageParcel(*msgParcel, readSafeFdFunc); + return value != nullptr; + } + + template + typename std::enable_if>::value, bool>::type + UnmarshallingValue(MessageParcel& parcel, U& value) const + { + bool hasObject = false; + if (!parcel.ReadBool(hasObject)) { + return false; + } + if (!hasObject) { + value = nullptr; + return true; + } + sptr remoteObj = parcel.ReadRemoteObject(); + if (remoteObj == nullptr) { + value = nullptr; + return false; + } + value = iface_cast(remoteObj); + return value != nullptr; + } + + RSLayerCmdType type_ { RSLayerCmdType::INVALID }; + PropertyId id_ { 0 }; + T stagingValue_ {}; + + friend class RSMarshallingHelper; +}; + +#define DECLARE_RSLAYER_PROPERTY(T, TYPE_ENUM) \ + template<> \ + inline const RSLayerCmdPropertyType RSRenderLayerCmdProperty::type_ = RSLayerCmdPropertyType::TYPE_ENUM; \ + template class RSRenderLayerCmdProperty + +#include "rs_layer_property_def.in" + +#undef DECLARE_RSLAYER_PROPERTY + +} // namespace Rosen +} // namespace OHOS + +#endif // COMPOSER_BASE_RS_RENDER_LAYER_CMD_PROPERTY_H \ No newline at end of file diff --git a/rosen/modules/render_service/composer/composer_client/rs_layer.h b/rosen/modules/render_service/composer/composer_client/rs_layer.h new file mode 100644 index 0000000000000000000000000000000000000000..68e97acc378af20f85bf96d7510077bae83e140e --- /dev/null +++ b/rosen/modules/render_service/composer/composer_client/rs_layer.h @@ -0,0 +1,141 @@ +/* + * 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 COMPOSER_CLIENT_RS_LAYER_H +#define COMPOSER_CLIENT_RS_LAYER_H + +#include "iconsumer_surface.h" +#include +#include +#include "graphic_error.h" +#include "hdi_display_type.h" +#include "common/rs_anco_type.h" + +namespace OHOS { +namespace Rosen { +class RSC_EXPORT RSLayer { +public: + virtual RSLayerId GetRsLayerId() const = 0; + virtual std::shared_ptr GetRSLayerContext() = 0; + + /* create or update rslayer info */ + virtual bool CreateRsLayer() = 0; + virtual bool DestroyRsLayer() = 0; + virtual void SetSurface(const sptr &surface) = 0; + virtual void SetBuffer(const sptr &sbuffer, const sptr &acquireFence) = 0; + virtual void SetPreBuffer(const sptr &buffer) = 0; + virtual void SetZorder(int32_t zOrder) = 0; + virtual void SetType(const GraphicLayerType& layerType) = 0; + virtual GraphicLayerType GetType() const = 0; + virtual void SetAlpha(const GraphicLayerAlpha &alpha) = 0; + virtual void SetTransform(GraphicTransformType type) = 0; + virtual void SetCompositionType(GraphicCompositionType type) = 0; + virtual void SetVisibleRegions(const std::vector &visibleRegions) = 0; + virtual void SetDirtyRegions(const std::vector &dirtyRegions) = 0; + virtual void SetBlendType(GraphicBlendType type) = 0; + virtual void SetCropRect(const GraphicIRect &crop) = 0; + virtual void SetPreMulti(bool preMulti) = 0; + virtual void SetLayerSize(const GraphicIRect &layerRect) = 0; + virtual void SetBoundSize(const GraphicIRect &boundRect) = 0; + virtual void SetLayerColor(GraphicLayerColor layerColor) = 0; + virtual void SetBackgroundColor(GraphicLayerColor backgroundColor) = 0; + virtual void SetCornerRadiusInfoForDRM(const std::vector& drmCornerRadiusInfo) = 0; + virtual void SetColorTransform(const std::vector &matrix) = 0; + virtual void SetColorDataSpace(GraphicColorDataSpace colorSpace) = 0; + virtual void SetMetaData(const std::vector &metaData) = 0; + virtual void SetMetaDataSet(const GraphicHDRMetaDataSet &metaDataSet) = 0; + virtual void SetMatrix(GraphicMatrix matrix) = 0; + virtual void SetGravity(int32_t gravity) = 0; + virtual void SetUniRenderFlag(bool isUniRender) = 0; + virtual void SetTunnelHandleChange(bool change) = 0; + virtual void SetTunnelHandle(const sptr &handle) = 0; + virtual void SetTunnelLayerId(const uint64_t &tunnelLayerId) = 0; + virtual uint64_t GetTunnelLayerId() const = 0; + virtual void SetTunnelLayerProperty(uint32_t tunnelLayerProperty) = 0; + virtual uint32_t GetTunnelLayerProperty() const = 0; + virtual bool IsSupportedPresentTimestamp() const = 0; + virtual const GraphicPresentTimestamp &GetPresentTimestamp() = 0; + /* create or update rslayer info */ + + /* get rslayer info */ + virtual sptr GetSurface() const = 0; + virtual sptr GetBuffer() const = 0; + virtual sptr GetPreBuffer() const = 0; + virtual uint32_t GetZorder() const = 0; + virtual sptr GetAcquireFence() const = 0; + virtual const GraphicLayerAlpha &GetAlpha() = 0; + virtual GraphicTransformType GetTransformType() const = 0; + virtual GraphicCompositionType GetCompositionType() const = 0; + virtual const std::vector &GetVisibleRegions() = 0; + virtual const std::vector &GetDirtyRegions() = 0; + virtual GraphicBlendType GetBlendType() const = 0; + virtual const GraphicIRect &GetCropRect() = 0; + virtual const GraphicIRect &GetLayerSize() = 0; + virtual GraphicIRect GetBoundSize() const = 0; + virtual GraphicMatrix GetMatrix() const = 0; + virtual int32_t GetGravity() const = 0; + virtual bool GetUniRenderFlag() const = 0; + virtual bool IsPreMulti() const = 0; + virtual void SetWindowsName(std::vector& windowsName) = 0; + virtual const std::vector& GetWindowsName() = 0; + virtual const std::vector &GetColorTransform() = 0; + virtual GraphicColorDataSpace GetColorDataSpace() const = 0; + virtual GraphicLayerColor GetLayerColor() const = 0; + virtual GraphicLayerColor GetBackgroundColor() const = 0; + virtual const std::vector& GetCornerRadiusInfoForDRM() const = 0; + virtual std::vector &GetMetaData() = 0; + virtual GraphicHDRMetaDataSet &GetMetaDataSet() = 0; + virtual bool GetTunnelHandleChange() const = 0; + virtual sptr GetTunnelHandle() const = 0; + virtual void SetIsSupportedPresentTimestamp(bool isSupported) = 0; + virtual void SetPresentTimestamp(const GraphicPresentTimestamp ×tamp) = 0; + virtual float GetSdrNit() const = 0; + virtual float GetDisplayNit() const = 0; + virtual float GetBrightnessRatio() const = 0; + virtual void SetSdrNit(float sdrNit) = 0; + virtual void SetDisplayNit(float displayNit) = 0; + virtual void SetBrightnessRatio(float brightnessRatio) = 0; + virtual const std::vector& GetLayerLinearMatrix() const = 0; + virtual void SetLayerLinearMatrix(const std::vector& layerLinearMatrix) = 0; + // source crop tuning + virtual int32_t GetLayerSourceTuning() const = 0; + virtual void SetLayerSourceTuning(int32_t layerSouce) = 0; + virtual void SetRotationFixed(bool rotationFixed) = 0; + virtual bool GetRotationFixed() const = 0; + virtual void SetLayerArsr(bool arsrTag) = 0; + virtual bool GetLayerArsr() const = 0; + virtual void SetLayerCopybit(bool copybitTag) = 0; + virtual bool GetLayerCopybit() const = 0; + virtual void SetNeedBilinearInterpolation(bool need) = 0; + virtual bool GetNeedBilinearInterpolation() const = 0; + virtual void SetIsMaskLayer(bool isMaskLayer) = 0; + virtual bool IsMaskLayer() const = 0; + + virtual void CopyLayerInfo(const std::shared_ptr &layerInfo) = 0; + virtual void Dump(std::string &result) const = 0; + virtual void DumpCurrentFrameLayer() const = 0; + virtual RosenError SetLayerMaskInfo(LayerMask mask) = 0; + virtual LayerMask GetLayerMaskInfo() = 0; + virtual inline uint64_t GetNodeId() = 0; + virtual void SetNodeId(uint64_t nodeId) = 0; + virtual void SetAncoFlags(const uint32_t ancoFlags) = 0; + virtual uint32_t GetAncoFlags() const = 0; + virtual bool IsAncoNative() const = 0; + /* get rslayer info */ +}; +} // namespace Rosen +} // namespace OHOS + +#endif // COMPOSER_CLIENT_RS_LAYER_H \ No newline at end of file diff --git a/rosen/modules/render_service/composer/composer_client/rs_layer_cmd.cpp b/rosen/modules/render_service/composer/composer_client/rs_layer_cmd.cpp new file mode 100644 index 0000000000000000000000000000000000000000..75698673a075299625b5819d57a33f1ac73d6b64 --- /dev/null +++ b/rosen/modules/render_service/composer/composer_client/rs_layer_cmd.cpp @@ -0,0 +1,44 @@ +/* + * 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 "rs_layer_cmd.h" +#include "rs_render_layer_cmd.h" + +namespace OHOS { +namespace Rosen { + +#define DECLARE_RSLAYER_CMD_CREATE(CMD_NAME) \ + std::shared_ptr RSLayer##CMD_NAME##Cmd::CreateRenderLayerCmd() const \ + { \ + auto renderProperty = GetRsRenderLayerProperty(); \ + auto renderLayerCmd = std::make_shared(renderProperty); \ + return renderLayerCmd; \ + } + +#define DECLARE_RSLAYER_CMD(CMD_NAME, TYPE, CMD_TYPE, DELTA_OP, THRESHOLD_TYPE) \ + RSLayer##CMD_NAME##Cmd::RSLayer##CMD_NAME##Cmd(const std::shared_ptr& property) \ + : RSLayerCmd(property, RSLayerCmdType::CMD_TYPE) \ + {} \ + RSLayerCmdType RSLayer##CMD_NAME##Cmd::GetRSLayerCmdType() const \ + { \ + return RSLayerCmdType::CMD_TYPE; \ + } \ + DECLARE_RSLAYER_CMD_CREATE(CMD_NAME) + +#include "rs_layer_cmd_def.in" + +#undef DECLARE_RSLAYER_CMD +} // namespace Rosen +} // namespace OHOS diff --git a/rosen/modules/render_service/composer/composer_client/rs_layer_cmd.h b/rosen/modules/render_service/composer/composer_client/rs_layer_cmd.h new file mode 100644 index 0000000000000000000000000000000000000000..8bb7b962d8890917bf15b3aa3bb18ff79bea0274 --- /dev/null +++ b/rosen/modules/render_service/composer/composer_client/rs_layer_cmd.h @@ -0,0 +1,91 @@ +/* + * 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 COMPOSER_CLIENT_RS_LAYER_CMD_H +#define COMPOSER_CLIENT_RS_LAYER_CMD_H + +#include "rs_layer_cmd_property.h" +#include "rs_layer_cmd_type.h" +#include "rs_render_layer_cmd.h" + +namespace OHOS { +namespace Rosen { + +class RSC_EXPORT RSLayerCmd : public std::enable_shared_from_this { +public: + explicit RSLayerCmd(const std::shared_ptr& property) + : rsLayerProperty_(property ? property : std::make_shared()) + {} + + RSLayerCmd(const std::shared_ptr& property, const RSLayerCmdType type) + : rsLayerProperty_(property ? property : std::make_shared()) + { + rsLayerProperty_->SetType(type); + } + + virtual ~RSLayerCmd() = default; + + RSLayerId GetLayerId() const + { + return rsLayerId_; + } + + std::shared_ptr GetRSLayerProperty() + { + return rsLayerProperty_; + } + + virtual RSLayerCmdType GetRSLayerCmdType() const + { + return RSLayerCmdType::INVALID; + } + + std::shared_ptr GetRsRenderLayerProperty() const + { + return rsLayerProperty_->GetRsRenderLayerProperty(); + } + + virtual std::shared_ptr CreateRenderLayerCmd(); + +protected: + RSLayerId rsLayerId_; + std::shared_ptr rsLayerProperty_; +}; +#define DECLARE_RSLAYER_CMD(CMD_NAME, TYPE, CMD_TYPE, DELTA_OP, THRESHOLD_TYPE) \ + class RSB_EXPORT RS##CMD_NAME##Cmd : public RSLayerCmd { \ + public: \ + RS##CMD_NAME##Cmd(const std::shared_ptr& property) \ + : RSLayerCmd(property) \ + { \ + property->SetType(RSLayerCmdType::CMD_TYPE); \ + } \ + virtual ~RS##CMD_NAME##Cmd() = default; \ + bool Marshalling(Parcel& parcel) override; \ + RSLayerCmdType GetRsLayerCmdType() override \ + { \ + return (RSLayerCmdType::CMD_TYPE); \ + } \ + std::shared_ptr CreateLayerCmd() override { \ + return std::make_shared(GetProperty()); \ + } \ + }; + +#include "rs_layer_cmd_def.in" + +#undef DECLARE_RSLAYER_CMD +} // namespace Rosen +} // namespace OHOS + +#endif // COMPOSER_CLIENT_RS_LAYER_CMD_H \ No newline at end of file diff --git a/rosen/modules/render_service/composer/composer_client/rs_layer_cmd_property.h b/rosen/modules/render_service/composer/composer_client/rs_layer_cmd_property.h new file mode 100644 index 0000000000000000000000000000000000000000..4abc124610007fb73ab0e1db43e97dab38cc3189 --- /dev/null +++ b/rosen/modules/render_service/composer/composer_client/rs_layer_cmd_property.h @@ -0,0 +1,87 @@ +/* + * 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 COMPOSER_CLIENT_RS_LAYER_CMD_PROPERTY_H +#define COMPOSER_CLIENT_RS_LAYER_CMD_PROPERTY_H + +#include +#include + +#include "rs_layer_cmd_type.h" + +namespace OHOS { +namespace Rosen { + +template +class RSC_EXPORT RSLayerCmdProperty : public std::enable_shared_from_this { +public: + RSLayerCmdProperty() = default; + + explicit RSLayerCmdProperty(const T& value) + { + stagingValue_ = value; + } + + ~RSLayerCmdProperty() = default; + + using ValueType = T; + + virtual void Set(const T& value) + { + if (ROSEN_EQ(value, stagingValue_) || !IsValid(value)) { + return; + } + stagingValue_ = value; + } + + virtual T Get() const + { + return stagingValue_; + } + + T& GetRef() + { + return stagingValue_; + } + + std::shared_ptr GetRsRenderLayerProperty() + { + return std::make_shared>(stagingValue_); + } + +protected: + bool IsValid(const T& value) + { + return true; + } + + RSLayerCmdType type_ { RSLayerCmdType::INVALID }; + + T stagingValue_ {}; + uint32_t layerId_ = INT_MAX; +}; + +#define DECLARE_RSLAYER_PROPERTY(T, TYPE_ENUM) \ + template<> \ + inline const RSLayerCmdPropertyType RSLayerCmdProperty::type_ = RSLayerCmdPropertyType::TYPE_ENUM; \ + template class RSLayerCmdProperty + +#include "composer_base/rs_layer_cmd_property_def.in" + +#undef DECLARE_RSLAYER_PROPERTY +} // namespace Rosen +} // namespace OHOS + +#endif // COMPOSER_CLIENT_RS_LAYER_CMD_PROPERTY_H \ No newline at end of file diff --git a/rosen/modules/render_service/composer/composer_client/rs_layer_cmd_type.h b/rosen/modules/render_service/composer/composer_client/rs_layer_cmd_type.h new file mode 100644 index 0000000000000000000000000000000000000000..a1bc2392d0590d9d9d688fe4f46f7722a6c30d43 --- /dev/null +++ b/rosen/modules/render_service/composer/composer_client/rs_layer_cmd_type.h @@ -0,0 +1,100 @@ +/* + * 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 COMPOSER_CLIENT_RS_LAYER_CMD_TYPE_H +#define COMPOSER_CLIENT_RS_LAYER_CMD_TYPE_H + +#include +#include + +namespace OHOS { +namespace Rosen { +enum class RSLayerCmdType : uint16_t { + INVALID = 0, + BOUNDS = 1, + FRAME = 2, + POSITION_Z = 3, + POSITION_Z_APPLICABLE_CAMERA3D = 4, + PIVOT = 5, + PIVOT_Z = 6, + QUATERNION = 7, + ROTATION = 8, + ROTATION_X = 9, + ROTATION_Y = 10, + CAMERA_DISTANCE = 11, + SCALE = 12, + SCALE_Z = 13, + SKEW = 14, + PERSP = 15, + TRANSLATE = 16, + TRANSLATE_Z = 17, + SUBLAYER_TRANSFORM = 18, + CORNER_RADIUS = 19, + ALPHA = 20, + ALPHA_OFFSCREEN = 21, + ZORDER = 22, + TYPE = 23, + TRANSFORM = 24, + COMPOSITION_TYPE = 25, + VISIBLE_REGIONS = 26, + DIRTY_REGIONS = 27, + BLEND_TYPE = 28, + CROP_RECT = 29, + PRE_MULTI = 30, + LAYER_SIZE = 31, + BOUND_SIZE = 32, + LAYER_COLOR = 33, + BACKGROUND_COLOR = 34, + COLOR_TRANSFORM = 35, + COLOR_DATA_SPACE = 36, + META_DATA = 37, + META_DATA_SET = 38, + MATRIX = 39, + GRAVITY = 40, + UNI_RENDER_FLAG = 41, + TUNNEL_HANDLE_CHANGE = 42, + TUNNEL_HANDLE = 43, + TUNNEL_LAYER_ID = 44, + TUNNEL_LAYER_PROPERTY = 45, + SUPPORTED_PRESENT_TIMESTAMP = 46, + PRESENT_TIMESTAMP = 47, + SDR_NIT = 48, + DISPLAY_NIT = 49, + BRIGHTNESS_RATIO = 50, + LAYER_LINEAR_MATRIX = 51, + LAYER_SOURCE_TUNING = 52, + ROTATION_FIXED = 53, + LAYER_ARSR = 54, + LAYER_COPYBIT = 55, + BILINEAR_INTERPOLATION = 56, + MASK_LAYER = 57, + NODE_ID = 58, + ANCO_FLAGS = 59, + SURFACE = 60, + BUFFER = 61, + PRE_BUFFER = 62, + ACQUIRE_FENCE = 63, + WINDOWS_NAME = 64, + LAYER_MASK_INFO = 65, + LAYER_CMD = 66, + SET_BUFFER_RELEASE_LISTENER = 67, + + MAX_RS_LAYER_CMD_TYPE = 255, +}; + +} // namespace Rosen +} // namespace OHOS + +#endif // COMPOSER_CLIENT_RS_LAYER_CMD_TYPE_H \ No newline at end of file diff --git a/rosen/modules/render_service/composer/composer_client/rs_layer_context.cpp b/rosen/modules/render_service/composer/composer_client/rs_layer_context.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0ad62b0a2104aa0006b33fd9eebef87f3ca70b7c --- /dev/null +++ b/rosen/modules/render_service/composer/composer_client/rs_layer_context.cpp @@ -0,0 +1,62 @@ +/* + * 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 "rs_layer_context.h" + +namespace OHOS { +namespace Rosen { +RSLayerContext::RSLayerContext(uint64_t token) : token_(token) +{ + rsLayerTransactionHandler_ = std::make_shared(token); +} + +RSLayerContext::RSLayerContext() : RSLayerContext(0) {} +RSLayerContext::~RSLayerContext() {} + +void RSLayerContext::AddRsLayer(const std::shared_ptr& rsLayer) +{ + std::unique_lock lock(rsLayerMutex_); + if (rsLayer == nullptr) { + return; + } + if (rsLayers_.count(rsLayer->GetRsLayerId())) { + return; + } + rsLayers_.emplace(rsLayer->GetRsLayerId(), rsLayer); +} + +void RSLayerContext::RemoveRsLayer(const std::shared_ptr rsLayer) +{ + std::unique_lock lock(rsLayerMutex_); + if (rsLayer == nullptr || !rsLayers_.count(rsLayer->GetRsLayerId())) { + return; + } + rsLayers_.erase(rsLayer->GetRsLayerId()); +} + +void RSLayerContext::ClearAllRsLayer() +{ + std::unique_lock lock(rsLayerMutex_); + rsLayers_.clear(); +} + +void RSLayerContext::UpdateRsLayerCmdProperty(RSLayerId rsLayerId) +{ + std::unique_lock lock(rsLayerMutex_); + +} +} // namespace Rosen +} // namespace OHOS \ No newline at end of file diff --git a/rosen/modules/render_service/composer/composer_client/rs_layer_context.h b/rosen/modules/render_service/composer/composer_client/rs_layer_context.h new file mode 100644 index 0000000000000000000000000000000000000000..e2d8e1de5fc95b8a810f0d7ceeba201daf69df8b --- /dev/null +++ b/rosen/modules/render_service/composer/composer_client/rs_layer_context.h @@ -0,0 +1,65 @@ +/* + * 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_COMPOSER_CLIENT_RS_LAYER_CONTEXT_H +#define RENDER_SERVICE_COMPOSER_CLIENT_RS_LAYER_CONTEXT_H + +#include +#include +#include + +#include "pipeline/transaction/rs_layer_transaction_handler.h" +#include "rs_layer_manager.h" + +namespace OHOS { +namespace Rosen { + +class RSC_EXPORT RSLayerContext : public std::enable_shared_from_this { +public: + virtual ~RSLayerContext(); + + inline std::shared_ptr GetRSLayerTransaction() const + { + return rsLayerTransactionHandler_; + } + + inline uint64_t GetToken() const + { + return token_; + } + + void AddRsLayer(const std::shared_ptr& rsLayer); + void RemoveRsLayer(const std::shared_ptr rsLayer); + void ClearAllRsLayer(); + void UpdateRsLayerCmdProperty(RSLayerId rsLayerId); + +private: + RSLayerContext(); + RSLayerContext(uint64_t token); + RSLayerContext(const RSLayerContext&) = delete; + RSLayerContext(const RSLayerContext&&) = delete; + RSLayerContext& operator=(const RSLayerContext&) = delete; + RSLayerContext& operator=(const RSLayerContext&&) = delete; + + uint64_t token_; + mutable std::recursive_mutex rsLayerMutex_; + std::shared_ptr rsLayerTransactionHandler_; + std::map> rsLayers_; +}; + +} // namespace Rosen +} // namespace OHOS +#endif // RENDER_SERVICE_COMPOSER_CLIENT_RS_LAYER_CONTEXT_H \ No newline at end of file diff --git a/rosen/modules/render_service/composer/composer_client/rs_layer_factory.cpp b/rosen/modules/render_service/composer/composer_client/rs_layer_factory.cpp new file mode 100644 index 0000000000000000000000000000000000000000..adc3929b9225f6a6e34acc05c3eff8fff694af81 --- /dev/null +++ b/rosen/modules/render_service/composer/composer_client/rs_layer_factory.cpp @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License") = 0; + * 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 "rs_layer.h" +#include "rs_surface_layer.h" + +namespace OHOS { +namespace Rosen { + +std::shared_ptr RSLayerFactory::CreateRSLayer() +{ + return std::make_shared(); +} + +} // namespace Rosen +} // namespace OHOS diff --git a/rosen/modules/render_service/composer/composer_client/rs_layer_factory.h b/rosen/modules/render_service/composer/composer_client/rs_layer_factory.h new file mode 100644 index 0000000000000000000000000000000000000000..9d6d88fa8af5ea83e0d815a8e3e3efa833f5f8f9 --- /dev/null +++ b/rosen/modules/render_service/composer/composer_client/rs_layer_factory.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License") = 0; + * 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 COMPOSER_CLIENT_RS_LAYER_FACTORY_H +#define COMPOSER_CLIENT_RS_LAYER_FACTORY_H + +#include "rs_layer.h" + +namespace OHOS { +namespace Rosen { + +class RSC_EXPORT RSLayerFactory { +public: + static std::shared_ptr CreateRSLayer(); +}; +} // namespace Rosen +} // namespace OHOS + +#endif // COMPOSER_CLIENT_RS_LAYER_FACTORY_H \ No newline at end of file diff --git a/rosen/modules/render_service/composer/composer_client/rs_surface_layer.cpp b/rosen/modules/render_service/composer/composer_client/rs_surface_layer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..87120944bdc7e2c5a4b63c9cc6efe82598e00d77 --- /dev/null +++ b/rosen/modules/render_service/composer/composer_client/rs_surface_layer.cpp @@ -0,0 +1,550 @@ +/* + * 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 "rs_surface_layer.h" +#include +#include + +namespace OHOS { +namespace Rosen { + +RSSurfaceLayer::RSSurfaceLayer(RSLayerId rsLayerId, std::shared_ptr rsLayerContex) + : rsLayerId_(rsLayerId), rsLayerContext_(rsLayerContex) +{} + +RSLayerId RSSurfaceLayer::GetRsLayerId() const +{ + retnru rsLayerId_; +} + +std::shared_ptr RSSurfaceLayer::GetRSLayerContext() +{ + return rsLayerContext_.lock(); +} + +std::shared_ptr RSSurfaceLayer::GetRSLayerTransaction() const +{ + auto rsLayerContext = rsLayerContext_.lock(); + if (!rsLayerContext) { + return nullptr; + } + return rsLayerContext->GetRSLayerTransaction(); +} + +bool RSSurfaceLayer::AddRsLayerParcel(std::unique_ptr& layerParcel, RSLayerId rsLayerId) const +{ + auto transaction = GetRSLayerTransaction(); + if (transaction != nullptr) { + transaction->AddRsLayerParcel(layerParcel, rsLayerId); + } + return true; +} + +void RSSurfaceLayer::AddRSLayerCmd(const std::shared_ptr layerCmd) +{ + { + std::unique_lock lock(propertyMutex_); + if (!layerCmd || commands_.count(layerCmd->GetPropertyId())) { + return; + } + layerCmd->AttachToLayer(shared_from_this()); + commands_.emplace(layerCmd->GetPropertyId(), layerCmd); + } + if (layerCmd->GetRSLayerCmdType() == RSLayerCmdType::LAYER_CMD) { + return; + } + CheckLayerCmdType(layerCmd->GetRSLayerCmdType()); + std::unique_ptr layerParcel = std::make_unique(GetRsLayerId(), layerCmd->CreateRenderModifier()); + AddRsLayerParcel(layerParcel, GetRsLayerId()); +} + +template +void RSSurfaceLayer::SetRSLayerCmd(RSLayerCmdType RSLayerCmdType, T value) +{ + std::unique_lock lock(propertyMutex_); + auto iter = rsLayerCmds_.find(RSLayerCmdType); + if (iter != rsLayerCmds_.end()) { + auto rsLayerProperty = std::static_pointer_cast(iter->second->GetRSLayerProperty()); + if (rsLayerProperty == nullptr) { + ROSEN_LOGE("RSLayer::SetRSLayerCmd: failed to set rsLayerProperty, rsLayerProperty is null!"); + return; + } + rsLayerProperty->Set(value); + return; + } + auto rsLayerProperty = std::make_shared(value); + auto rsLayerCmd = std::make_shared(rsLayerProperty); + rsLayerCmds_.emplace(RSLayerCmdType, rsLayerCmd); + AddRSLayerCmd(rsLayerCmd); +} + +void RSSurfaceLayer::UpdateProperty(const LayerInfoPtr& layerInfo) +{ + std::lock_guard lock(mutex_); + SetBuffer(layerInfo->GetBuffer()); + SetPreBuffer(layerInfo->GetPreBuffer()); + SetZorder(layerInfo->GetZorder()); + SetLayerSize(layerInfo->GetLayerSize()); + SetBoundSize(layerInfo->GetBoundSize()); + SetVisibleRegions(layerInfo->GetVisibleRegions()); + SetDirtyRegions(layerInfo->GetDirtyRegions()); + SetCropRect(layerInfo->GetCropRect()); + SetMatrix(layerInfo->GetMatrix()); + SetGravity(layerInfo->GetGravity()); + SetAlpha(layerInfo->GetAlpha()); + SetTransformType(layerInfo->GetTransformType()); + SetCompositionType(layerInfo->GetCompositionType()); + SetBlendType(layerInfo->GetBlendType()); + SetColorTransform(layerInfo->GetColorTransform()); + SetColorDataSpace(layerInfo->GetColorDataSpace()); + SetLayerColor(layerInfo->GetLayerColor()); + SetMetaData(layerInfo->GetMetaData()); + SetMetaDataSet(layerInfo->GetMetaDataSet()); + SetTunnelHandle(layerInfo->GetTunnelHandle()); + SetTunnelHandleChange(layerInfo->GetTunnelHandleChange()); + SetAcquireFence(layerInfo->GetAcquireFence()); + IsPreMulti(layerInfo->GetIsPreMulti()); + SetSdrNit(layerInfo->GetSdrNit()); + SetDisplayNit(layerInfo->GetDisplayNit()); + SetBrightnessRatio(layerInfo->GetBrightnessRatio()); + SetLayerLinearMatrix(layerInfo->GetLayerLinearMatrix()); + SetLayerSourceTuning(layerInfo->GetLayerSourceTuning()); + SetRotationFixed(layerInfo->GetRotationFixed()); + SetLayerArsr(layerInfo->GetLayerArsr()); + SetLayerCopybit(layerInfo->GetLayerCopybit()); + SetNeedBilinearInterpolation(layerInfo->GetNeedBilinearInterpolation()); + SetTunnelLayerId(layerInfo->GetTunnelLayerId()); + SetTunnelLayerProperty(layerInfo->GetTunnelLayerProperty()); + SetAncoFlags(layerInfo->GetAncoFlags()); +} + +void RSSurfaceLayer::SetAlpha(const GraphicLayerAlpha &alpha) +{ + if (alpha == layerAlpha_) { + return; + } + layerAlpha_ = alpha; + SetRSLayerCmd(RSLayerCmdType::ALPHA, alpha); +} + +void RSSurfaceLayer::SetZorder(int32_t zOrder) +{ + if (zOrder == zOrder_) { + return; + } + zOrder_ = zOrder; + SetRSLayerCmd(RSLayerCmdType::ZORDER, zOrder); +} + +void RSSurfaceLayer::SetType(const GraphicLayerType& layerType) +{ + if (layerType == layerType_) { + return; + } + layerType_ = layerType; + SetRSLayerCmd(RSLayerCmdType::TYPE, layerType); +} + +void RSSurfaceLayer::SetTransform(GraphicTransformType type) +{ + if (type == transformType_) { + return; + } + transformType_ = type; + SetRSLayerCmd(RSLayerCmdType::TRANSFORM, type); +} + +void RSSurfaceLayer::SetCompositionType(GraphicCompositionType type) +{ + if (type == compositionType_) { + return; + } + compositionType_ = type; + SetRSLayerCmd(RSLayerCmdType::COMPOSITION_TYPE, type); +} + +void RSSurfaceLayer::SetVisibleRegions(const std::vector &visibleRegions) +{ + if (visibleRegions == visibleRegions_) { + return; + } + visibleRegions_ = visibleRegions; + SetRSLayerCmd(RSLayerCmdType::VISIBLE_REGIONS, visibleRegions); +} + +void RSSurfaceLayer::SetDirtyRegions(const std::vector &dirtyRegions) +{ + if (dirtyRegions == dirtyRegions_) { + return; + } + dirtyRegions_ = dirtyRegions; + SetRSLayerCmd(RSLayerCmdType::DIRTY_REGIONS, dirtyRegions); +} + +void RSSurfaceLayer::SetBlendType(GraphicBlendType type) +{ + if (type == blendType_) { + return; + } + blendType_ = type; + SetRSLayerCmd(RSLayerCmdType::BLEND_TYPE, type); +} + +void RSSurfaceLayer::SetCropRect(const GraphicIRect &crop) +{ + if (crop == cropRect_) { + return; + } + cropRect_ = crop; + SetRSLayerCmd(RSLayerCmdType::CROP_RECT, crop); +} + +void RSSurfaceLayer::SetPreMulti(bool preMulti) +{ + if (preMulti == preMulti_) { + return; + } + preMulti_ = preMulti; + SetRSLayerCmd(RSLayerCmdType::PRE_MULTI, preMulti); +} + +void RSSurfaceLayer::SetLayerSize(const GraphicIRect &layerRect) +{ + if (layerRect == layerRect_) { + return; + } + layerRect_ = layerRect; + SetRSLayerCmd(RSLayerCmdType::LAYER_SIZE, layerRect); +} + +void RSSurfaceLayer::SetBoundSize(const GraphicIRect &boundRect) +{ + if (boundRect == boundRect_) { + return; + } + boundRect_ = boundRect; + SetRSLayerCmd(RSLayerCmdType::BOUND_SIZE, boundRect); +} + +void RSSurfaceLayer::SetLayerColor(GraphicLayerColor layerColor) +{ + if (layerColor == layerColor_) { + return; + } + layerColor_ = layerColor; + SetRSLayerCmd(RSLayerCmdType::LAYER_COLOR, layerColor); +} + +void RSSurfaceLayer::SetBackgroundColor(GraphicLayerColor backgroundColor) +{ + if (backgroundColor == backgroundColor_) { + return; + } + backgroundColor_ = backgroundColor; + SetRSLayerCmd(RSLayerCmdType::BACKGROUND_COLOR, backgroundColor); +} + +void RSSurfaceLayer::SetCornerRadiusInfoForDRM(const std::vector& drmCornerRadiusInfo) +{ + if (drmCornerRadiusInfo == drmCornerRadiusInfo_) { + return; + } + drmCornerRadiusInfo_ = drmCornerRadiusInfo; + SetRSLayerCmd(RSLayerCmdType::CORNER_RADIUS, drmCornerRadiusInfo); +} + +void RSSurfaceLayer::SetColorTransform(const std::vector &matrix) +{ + if (matrix == colorTransformMatrix_) { + return; + } + colorTransformMatrix_ = matrix; + SetRSLayerCmd(RSLayerCmdType::COLOR_TRANSFORM, matrix); +} + +void RSSurfaceLayer::SetColorDataSpace(GraphicColorDataSpace colorSpace) +{ + if (colorSpace == colorSpace_) { + return; + } + colorSpace_ = colorSpace; + SetRSLayerCmd(RSLayerCmdType::COLOR_DATA_SPACE, colorSpace); +} + +void RSSurfaceLayer::SetMetaData(const std::vector &metaData) +{ + if (metaData == metaData_) { + return; + } + metaData_ = metaData; + SetRSLayerCmd(RSLayerCmdType::META_DATA, metaData); +} + +void RSSurfaceLayer::SetMetaDataSet(const GraphicHDRMetaDataSet &metaDataSet) +{ + if (metaDataSet == metaDataSet_) { + return; + } + metaDataSet_ = metaDataSet; + SetRSLayerCmd(RSLayerCmdType::META_DATA_SET, metaDataSet); +} + +void RSSurfaceLayer::SetMatrix(GraphicMatrix matrix) +{ + if (matrix == matrix_) { + return; + } + matrix_ = matrix; + SetRSLayerCmd(RSLayerCmdType::MATRIX, matrix); +} + +void RSSurfaceLayer::SetGravity(int32_t gravity) +{ + if (gravity == gravity_) { + return; + } + gravity_ = gravity; + SetRSLayerCmd(RSLayerCmdType::GRAVITY, gravity); +} + +void RSSurfaceLayer::SetUniRenderFlag(bool isUniRender) +{ + if (isUniRender == isUniRender_) { + return; + } + isUniRender_ = isUniRender; + SetRSLayerCmd(RSLayerCmdType::UNI_RENDER_FLAG, isUniRender); +} + +void RSSurfaceLayer::SetTunnelHandleChange(bool change) +{ + if (change == tunnelHandleChange_) { + return; + } + tunnelHandleChange_ = change; + SetRSLayerCmd(RSLayerCmdType::TUNNEL_HANDLE_CHANGE, change); +} + +void RSSurfaceLayer::SetTunnelHandle(const sptr &handle) +{ + if (handle == tunnelHandle_) { + return; + } + tunnelHandle_ = handle; + SetRSLayerCmd(RSLayerCmdType::TUNNEL_HANDLE, handle); +} + +void RSSurfaceLayer::SetTunnelLayerId(const uint64_t &tunnelLayerId) +{ + if (tunnelLayerId == tunnelLayerId_) { + return; + } + tunnelLayerId_ = tunnelLayerId; + SetRSLayerCmd(RSLayerCmdType::TUNNEL_LAYER_ID, tunnelLayerId); +} + +void RSSurfaceLayer::SetTunnelLayerProperty(uint32_t tunnelLayerProperty) +{ + if (tunnelLayerProperty == tunnelLayerProperty_) { + return; + } + tunnelLayerProperty_ = tunnelLayerProperty; + SetRSLayerCmd(RSLayerCmdType::TUNNEL_LAYER_PROPERTY, tunnelLayerProperty); +} + +void RSSurfaceLayer::SetIsSupportedPresentTimestamp(bool isSupported) +{ + if (isSupported == IsSupportedPresentTimestamp_) { + return; + } + IsSupportedPresentTimestamp_ = isSupported; + SetRSLayerCmd(RSLayerCmdType::SUPPORTED_PRESENT_TIMESTAMP, isSupported); +} + +void RSSurfaceLayer::SetPresentTimestamp(const GraphicPresentTimestamp ×tamp) +{ + if (timestamp == presentTimestamp_) { + return; + } + presentTimestamp_ = timestamp; + SetRSLayerCmd(RSLayerCmdType::PRESENT_TIMESTAMP, timestamp); +} + +void RSSurfaceLayer::SetSdrNit(float sdrNit) +{ + if (sdrNit == sdrNit_) { + return; + } + sdrNit_ = sdrNit; + SetRSLayerCmd(RSLayerCmdType::SDR_NIT, sdrNit); +} + +void RSSurfaceLayer::SetDisplayNit(float displayNit) +{ + if (displayNit == displayNit_) { + return; + } + displayNit_ = displayNit; + SetRSLayerCmd(RSLayerCmdType::DISPLAY_NIT, displayNit); +} + +void RSSurfaceLayer::SetBrightnessRatio(float brightnessRatio) +{ + if (brightnessRatio == brightnessRatio_) { + return; + } + brightnessRatio_ = brightnessRatio; + SetRSLayerCmd(RSLayerCmdType::BRIGHTNESS_RATIO, brightnessRatio); +} + +void RSSurfaceLayer::SetLayerLinearMatrix(const std::vector& layerLinearMatrix) +{ + if (layerLinearMatrix == layerLinearMatrix_) { + return; + } + layerLinearMatrix_ = layerLinearMatrix; + SetRSLayerCmd(RSLayerCmdType::LAYER_LINEAR_MATRIX, layerLinearMatrix); +} + +void RSSurfaceLayer::SetLayerSourceTuning(int32_t layerSource) +{ + if (layerSource == layerSource_) { + return; + } + layerSource_ = layerSource; + SetRSLayerCmd(RSLayerCmdType::LAYER_SOURCE_TUNING, layerSource); +} + +void RSSurfaceLayer::SetRotationFixed(bool rotationFixed) +{ + if (rotationFixed == rotationFixed_) { + return; + } + rotationFixed_ = rotationFixed; + SetRSLayerCmd(RSLayerCmdType::ROTATION_FIXED, rotationFixed); +} + +void RSSurfaceLayer::SetLayerArsr(bool arsrTag) +{ + if (arsrTag == arsrTag_) { + return; + } + arsrTag_ = arsrTag; + SetRSLayerCmd(RSLayerCmdType::LAYER_ARSR, arsrTag); +} + +void RSSurfaceLayer::SetLayerCopybit(bool copybitTag) +{ + if (copybitTag == copybitTag_) { + return; + } + copybitTag_ = copybitTag; + SetRSLayerCmd(RSLayerCmdType::LAYER_COPYBIT, copybitTag); +} + +void RSSurfaceLayer::SetNeedBilinearInterpolation(bool need) +{ + if (need == needBilinearInterpolation_) { + return; + } + needBilinearInterpolation_ = need; + SetRSLayerCmd(RSLayerCmdType::BILINEAR_INTERPOLATION, need); +} + +void RSSurfaceLayer::SetIsMaskLayer(bool isMaskLayer) +{ + if (isMaskLayer == isMaskLayer_) { + return; + } + isMaskLayer_ = isMaskLayer; + SetRSLayerCmd(RSLayerCmdType::MASK_LAYER, isMaskLayer); +} + +void RSSurfaceLayer::SetNodeId(uint64_t nodeId) +{ + if (nodeId == nodeId_) { + return; + } + nodeId_ = nodeId; + SetRSLayerCmd(RSLayerCmdType::NODE_ID, nodeId); +} + +void RSSurfaceLayer::SetAncoFlags(const uint32_t ancoFlags) +{ + if (ancoFlags == ancoFlags_) { + return; + } + ancoFlags_ = ancoFlags; + SetRSLayerCmd(RSLayerCmdType::ANCO_FLAGS, ancoFlags); +} + +void RSSurfaceLayer::SetSurface(const sptr &surface) +{ + if (surface == cSurface_) { + return; + } + cSurface_ = surface; + SetRSLayerCmd(RSLayerCmdType::SURFACE, surface); +} + +void RSSurfaceLayer::SetBuffer(const sptr &sbuffer, const sptr &acquireFence) +{ + if (sbuffer == sbuffer_ && acquireFence == acquireFence_) { + return; + } + sbuffer_ = sbuffer; + acquireFence_ = acquireFence; + SetRSLayerCmd(RSLayerCmdType::BUFFER, sbuffer); + SetRSLayerCmd(RSLayerCmdType::ACQUIRE_FENCE, acquireFence); +} + +void RSSurfaceLayer::SetPreBuffer(const sptr &buffer) +{ + if (buffer == pbuffer_) { + return; + } + pbuffer_ = buffer; + SetRSLayerCmd(RSLayerCmdType::PRE_BUFFER, buffer); +} + +void RSSurfaceLayer::SetAcquireFence(const sptr &acquireFence) +{ + if (acquireFence == acquireFence_) { + return; + } + acquireFence_ = acquireFence; + SetRSLayerCmd(RSLayerCmdType::ACQUIRE_FENCE, acquireFence); +} + +void RSSurfaceLayer::SetWindowsName(std::vector& windowsName) +{ + if (windowsName == windowsName_) { + return; + } + windowsName_ = windowsName; + SetRSLayerCmd(RSLayerCmdType::WINDOWS_NAME, windowsName); +} + +void RSSurfaceLayer::SetLayerMaskInfo(LayerMask mask) +{ + if (mask == layerMask_) { + return; + } + layerMask_ = mask; + SetRSLayerCmd(RSLayerCmdType::LAYER_MASK_INFO, mask); +} + +} // namespace Rosen +} // namespace OHOS diff --git a/rosen/modules/render_service/composer/composer_client/rs_surface_layer.h b/rosen/modules/render_service/composer/composer_client/rs_surface_layer.h new file mode 100644 index 0000000000000000000000000000000000000000..f9ab59cd53de74263d81a0cf8a826bb94272a247 --- /dev/null +++ b/rosen/modules/render_service/composer/composer_client/rs_surface_layer.h @@ -0,0 +1,281 @@ +/* + * 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 COMPOSER_CLIENT_RS_LAYER_IMPL_H +#define COMPOSER_CLIENT_RS_LAYER_IMPL_H + +#include +#include "iconsumer_surface.h" +#include +#include +#include "graphic_error.h" +#include "hdi_display_type.h" +#include "common/rs_anco_type.h" + +#include "rslayer.h" +#include "composer_base/rs_render_layer_cmd_property.h" +#include "ibuffer_release_listener.h" + +namespace OHOS { +namespace Rosen { +static const std::map TransformTypeStrs = { + {GRAPHIC_ROTATE_NONE, "0 "}, + {GRAPHIC_ROTATE_90, "1 "}, + {GRAPHIC_ROTATE_180, "2 "}, + {GRAPHIC_ROTATE_270, "3 "}, + {GRAPHIC_FLIP_H, "4 "}, + {GRAPHIC_FLIP_V, "5 "}, + {GRAPHIC_FLIP_H_ROT90, "6 "}, + {GRAPHIC_FLIP_V_ROT90, "7 "}, + {GRAPHIC_FLIP_H_ROT180, "8 "}, + {GRAPHIC_FLIP_V_ROT180, "9 "}, + {GRAPHIC_FLIP_H_ROT270, "10 "}, + {GRAPHIC_FLIP_V_ROT270, "11 "}, + {GRAPHIC_ROTATE_BUTT, "12 "}, +}; + +static const std::map CompositionTypeStrs = { + {GRAPHIC_COMPOSITION_CLIENT, "0 "}, + {GRAPHIC_COMPOSITION_DEVICE, "1 "}, + {GRAPHIC_COMPOSITION_CURSOR, "2 "}, + {GRAPHIC_COMPOSITION_VIDEO, "3