diff --git a/export/dm/dm_common.h b/export/dm/dm_common.h deleted file mode 100644 index a3e8a6b9c8dec1ffccd8fd3906431e8af6cf79cc..0000000000000000000000000000000000000000 --- a/export/dm/dm_common.h +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (c) 2021-2022 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 OHOS_ROSEN_DM_COMMON_H -#define OHOS_ROSEN_DM_COMMON_H - -#include -#include -#include - -namespace OHOS { -namespace Rosen { -using DisplayId = uint64_t; -using ScreenId = uint64_t; -namespace { - constexpr DisplayId DISPLAY_ID_INVALID = -1ULL; - constexpr ScreenId SCREEN_ID_INVALID = -1ULL; - constexpr int DOT_PER_INCH = 160; - const static std::string DEFAULT_SCREEN_NAME = "buildIn"; - constexpr int DOT_PER_INCH_MAXIMUM_VALUE = 640; - constexpr int DOT_PER_INCH_MINIMUM_VALUE = 80; - constexpr uint32_t BASELINE_DENSITY = 160; -} - -enum class PowerStateChangeReason : uint32_t { - POWER_BUTTON, -}; - -enum class ScreenPowerState : uint32_t { - POWER_ON, - POWER_STAND_BY, - POWER_SUSPEND, - POWER_OFF, - POWER_BUTT, - INVALID_STATE, -}; - -enum class DisplayState : uint32_t { - ON, - OFF, - UNKNOWN, -}; - -enum class DisplayEvent : uint32_t { - UNLOCK, - KEYGUARD_DRAWN, -}; - -enum class DMError : int32_t { - DM_OK = 0, - DM_ERROR_INIT_DMS_PROXY_LOCKED = 100, - DM_ERROR_IPC_FAILED = 101, - DM_ERROR_REMOTE_CREATE_FAILED = 110, - DM_ERROR_NULLPTR = 120, - DM_ERROR_INVALID_PARAM = 130, - DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED = 140, - DM_ERROR_DEATH_RECIPIENT = 150, - DM_ERROR_INVALID_MODE_ID = 160, - DM_ERROR_WRITE_DATA_FAILED = 170, - DM_ERROR_RENDER_SERVICE_FAILED = 180, - DM_ERROR_UNREGISTER_AGENT_FAILED = 190, - DM_ERROR_INVALID_CALLING = 200, - DM_ERROR_INVALID_PERMISSION = 201, - DM_ERROR_UNKNOWN = -1, -}; - -enum class DmErrorCode : int32_t { - DM_OK = 0, - DM_ERROR_NO_PERMISSION = 201, - DM_ERROR_INVALID_PARAM = 401, - DM_ERROR_DEVICE_NOT_SUPPORT = 801, - DM_ERROR_INVALID_SCREEN = 1400001, - DM_ERROR_INVALID_CALLING = 1400002, - DM_ERROR_SYSTEM_INNORMAL = 1400003, -}; - -const std::map DM_JS_TO_ERROR_CODE_MAP { - {DMError::DM_OK, DmErrorCode::DM_OK }, - {DMError::DM_ERROR_INVALID_PERMISSION, DmErrorCode::DM_ERROR_NO_PERMISSION }, - {DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, - {DMError::DM_ERROR_IPC_FAILED, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, - {DMError::DM_ERROR_REMOTE_CREATE_FAILED, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, - {DMError::DM_ERROR_NULLPTR, DmErrorCode::DM_ERROR_INVALID_SCREEN }, - {DMError::DM_ERROR_INVALID_PARAM, DmErrorCode::DM_ERROR_INVALID_PARAM }, - {DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, - {DMError::DM_ERROR_DEATH_RECIPIENT, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, - {DMError::DM_ERROR_INVALID_MODE_ID, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, - {DMError::DM_ERROR_WRITE_DATA_FAILED, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, - {DMError::DM_ERROR_RENDER_SERVICE_FAILED, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, - {DMError::DM_ERROR_UNREGISTER_AGENT_FAILED, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, - {DMError::DM_ERROR_INVALID_CALLING, DmErrorCode::DM_ERROR_INVALID_CALLING }, - {DMError::DM_ERROR_UNKNOWN, DmErrorCode::DM_ERROR_SYSTEM_INNORMAL }, -}; - -using DisplayStateCallback = std::function; - -enum class DisplayPowerEvent : uint32_t { - WAKE_UP, - SLEEP, - DISPLAY_ON, - DISPLAY_OFF, - DESKTOP_READY, -}; - -enum class EventStatus : uint32_t { - BEGIN, - END, -}; - -class IDisplayPowerEventListener : public RefBase { -public: - virtual void OnDisplayPowerEvent(DisplayPowerEvent event, EventStatus status) = 0; -}; - -enum class ScreenChangeEvent : uint32_t { - UPDATE_ORIENTATION, - UPDATE_ROTATION, - CHANGE_MODE, - VIRTUAL_PIXEL_RATIO_CHANGED, -}; - -enum class ScreenGroupChangeEvent : uint32_t { - ADD_TO_GROUP, - REMOVE_FROM_GROUP, - CHANGE_GROUP, -}; - -enum class Rotation : uint32_t { - ROTATION_0, - ROTATION_90, - ROTATION_180, - ROTATION_270, -}; - -enum class Orientation : uint32_t { - BEGIN = 0, - UNSPECIFIED = BEGIN, - VERTICAL = 1, - HORIZONTAL = 2, - REVERSE_VERTICAL = 3, - REVERSE_HORIZONTAL = 4, - SENSOR = 5, - SENSOR_VERTICAL = 6, - SENSOR_HORIZONTAL = 7, - AUTO_ROTATION_RESTRICTED = 8, - AUTO_ROTATION_PORTRAIT_RESTRICTED = 9, - AUTO_ROTATION_LANDSCAPE_RESTRICTED = 10, - LOCKED = 11, - END = LOCKED, -}; - -enum class DisplayChangeEvent : uint32_t { - UPDATE_ORIENTATION, - UPDATE_ROTATION, - DISPLAY_SIZE_CHANGED, - DISPLAY_FREEZED, - DISPLAY_UNFREEZED, - DISPLAY_VIRTUAL_PIXEL_RATIO_CHANGED, - UNKNOWN, -}; -} -} -#endif // OHOS_ROSEN_DM_COMMON_H \ No newline at end of file diff --git a/export/render_service_client/core/animation/rs_animation.h b/export/render_service_client/core/animation/rs_animation.h deleted file mode 100644 index b8d90b428160ea000fa039d207d9fc481225136d..0000000000000000000000000000000000000000 --- a/export/render_service_client/core/animation/rs_animation.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_ANIMATION_H -#define RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_ANIMATION_H - -#include -#include - -#include "animation/rs_animation_common.h" -#include "animation/rs_animation_timing_protocol.h" -#include "common/rs_common_def.h" -#include "modifier/rs_modifier_type.h" - -#ifdef _WIN32 -#include -#define gettid GetCurrentThreadId -#endif - -#ifdef __APPLE__ -#define gettid getpid -#endif - -#ifdef __gnu_linux__ -#include -#include -#define gettid []() -> int32_t { return static_cast(syscall(SYS_gettid)); } -#endif - -namespace OHOS { -namespace Rosen { -class RSNode; -class AnimationFinishCallback; -class RSRenderAnimation; - -class RSC_EXPORT RSAnimation : public RSAnimationTimingProtocol, public std::enable_shared_from_this { -public: - virtual ~RSAnimation() = default; - - AnimationId GetId() const; - - void SetFinishCallback(const std::function& finishCallback); - - void Start(const std::shared_ptr& target); - - const std::weak_ptr GetTarget() const; - - void Pause(); - - void Resume(); - - void Finish(); - - void Reverse(); - - void SetFraction(float fraction); - - bool IsStarted() const; - - bool IsRunning() const; - - bool IsPaused() const; - - bool IsFinished() const; - -protected: - enum class AnimationState { - INITIALIZED, - RUNNING, - PAUSED, - FINISHED, - }; - - RSAnimation(); - - virtual void OnStart() {} - virtual void OnReverse(); - virtual void OnPause(); - virtual void OnResume(); - virtual void OnFinish(); - virtual void OnSetFraction(float fraction); - virtual void OnUpdateStagingValue(bool isFirstStart) {}; - virtual PropertyId GetPropertyId() const; - - void StartInner(const std::shared_ptr& target); - bool IsReversed() const; - void CallFinishCallback(); - void UpdateParamToRenderAnimation(const std::shared_ptr& animation); - virtual void OnCallFinishCallback() {} - virtual void SetPropertyOnAllAnimationFinish() {} - -private: - static AnimationId GenerateId(); - const AnimationId id_; - - void SetFinishCallback(const std::shared_ptr& finishCallback); - void UpdateStagingValue(bool isFirstStart); - void UIAnimationFinish(); - - bool isReversed_ { false }; - AnimationState state_ { AnimationState::INITIALIZED }; - std::weak_ptr target_; - std::shared_ptr finishCallback_; - - friend class RSCurveImplicitAnimParam; - friend class RSAnimationGroup; - friend class RSNode; - friend class RSImplicitAnimator; - friend class RSUIAnimationManager; -}; -} // namespace Rosen -} // namespace OHOS - -#endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_ANIMATION_H diff --git a/export/render_service_client/core/animation/rs_animation_manager_map.h b/export/render_service_client/core/animation/rs_animation_manager_map.h deleted file mode 100644 index 9098068dac2ff92b52da8c128778513cc7be4ad7..0000000000000000000000000000000000000000 --- a/export/render_service_client/core/animation/rs_animation_manager_map.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_ANIMATION_MANAGER_MAP_H -#define RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_ANIMATION_MANAGER_MAP_H - -#include -#include -#include - -#include "common/rs_macros.h" - -namespace OHOS { -namespace Rosen { -class RSUIAnimationManager; - -class RS_EXPORT RSAnimationManagerMap final { -public: - ~RSAnimationManagerMap() = default; - static std::shared_ptr& Instance(); - - const std::shared_ptr& GetAnimationManager(const int32_t id); - -private: - RSAnimationManagerMap() = default; - RSAnimationManagerMap(const RSAnimationManagerMap&) = delete; - RSAnimationManagerMap(const RSAnimationManagerMap&&) = delete; - RSAnimationManagerMap& operator=(const RSAnimationManagerMap&) = delete; - RSAnimationManagerMap& operator=(const RSAnimationManagerMap&&) = delete; - - std::mutex mutex_; - std::unordered_map> managerMap_; - static std::shared_ptr instance_; -}; -} // namespace Rosen -} // namespace OHOS - -#endif // RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_ANIMATION_MANAGER_MAP_H diff --git a/export/render_service_client/core/animation/rs_animation_timing_curve.h b/export/render_service_client/core/animation/rs_animation_timing_curve.h deleted file mode 100644 index 62679124b32f446bdca201829985b7ceefb160b0..0000000000000000000000000000000000000000 --- a/export/render_service_client/core/animation/rs_animation_timing_curve.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_ANIMATION_TIMING_CURVE_H -#define RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_ANIMATION_TIMING_CURVE_H - -#include -#include -#include - -#include "common/rs_macros.h" - -namespace OHOS { -namespace Rosen { -class RSInterpolator; -enum class StepsCurvePosition; -class RSC_EXPORT RSAnimationTimingCurve final { -public: - static const RSAnimationTimingCurve DEFAULT; - static const RSAnimationTimingCurve LINEAR; - static const RSAnimationTimingCurve EASE; - static const RSAnimationTimingCurve EASE_IN; - static const RSAnimationTimingCurve EASE_OUT; - static const RSAnimationTimingCurve EASE_IN_OUT; - static const RSAnimationTimingCurve SPRING; - static const RSAnimationTimingCurve INTERACTIVE_SPRING; - - static RSAnimationTimingCurve CreateCustomCurve(const std::function& customCurveFunc); - static RSAnimationTimingCurve CreateCubicCurve(float ctrlX1, float ctrlY1, float ctrlX2, float ctrlY2); - static RSAnimationTimingCurve CreateStepsCurve(int32_t steps, StepsCurvePosition position); - // Create interpolating spring, which duration is determined by TimingProtocol. Multiple animations on the same - // property will run simultaneously and act additively. - static RSAnimationTimingCurve CreateSpringCurve(float velocity, float mass, float stiffness, float damping); - // Create physical spring, which duration is determined by the spring model. When mixed with other physical spring - // animations on the same property, each animation will be replaced by their successor, preserving velocity from one - // animation to the next. - static RSAnimationTimingCurve CreateSpring(float response, float dampingRatio, float blendDuration = 0.0f); - - RSAnimationTimingCurve(); - RSAnimationTimingCurve(const RSAnimationTimingCurve& timingCurve) = default; - RSAnimationTimingCurve& operator=(const RSAnimationTimingCurve& timingCurve) = default; - virtual ~RSAnimationTimingCurve() = default; - - enum class CurveType { INTERPOLATING, SPRING }; - CurveType type_ { CurveType::INTERPOLATING }; -private: - RSAnimationTimingCurve(const std::shared_ptr& interpolator); - RSAnimationTimingCurve(const std::function& customCurveFunc); - RSAnimationTimingCurve(float response, float dampingRatio, float blendDuration); - - float response_ { 0.0f }; - float dampingRatio_ { 0.0f }; - float blendDuration_ { 0.0f }; - - std::shared_ptr GetInterpolator(int duration) const; - - std::shared_ptr interpolator_; - std::function customCurveFunc_; - - friend class RSCurveAnimation; - friend class RSKeyframeAnimation; - friend class RSSpringAnimation; - friend class RSPathAnimation; - friend class RSTransition; -}; -} // namespace Rosen -} // namespace OHOS - -#endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_ANIMATION_TIMING_CURVE_H diff --git a/export/render_service_client/core/animation/rs_animation_timing_protocol.h b/export/render_service_client/core/animation/rs_animation_timing_protocol.h deleted file mode 100644 index c3732cb74be2e8c932c83e2797ff3d0b7e682519..0000000000000000000000000000000000000000 --- a/export/render_service_client/core/animation/rs_animation_timing_protocol.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_ANIMATION_TIMING_PROTOCOL_H -#define RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_ANIMATION_TIMING_PROTOCOL_H - -#include "common/rs_common_def.h" - -namespace OHOS { -namespace Rosen { -enum class FillMode { - NONE, - FORWARDS, - BACKWARDS, - BOTH, -}; - -class RSB_EXPORT RSAnimationTimingProtocol { -public: - RSAnimationTimingProtocol() = default; - RSAnimationTimingProtocol(int duration) : duration_(duration) {} - virtual ~RSAnimationTimingProtocol() = default; - - void SetDuration(int duration) - { - duration_ = duration; - } - - void SetStartDelay(int startDelay) - { - startDelay_ = startDelay; - } - - void SetSpeed(float speed) - { - speed_ = speed; - } - - void SetRepeatCount(int repeatCount) - { - repeatCount_ = repeatCount; - } - - void SetAutoReverse(bool autoReverse) - { - autoReverse_ = autoReverse; - } - - void SetFillMode(const FillMode& fillMode) - { - fillMode_ = fillMode; - } - - void SetDirection(bool isForward) - { - isForward_ = isForward; - } - - int GetDuration() const - { - return duration_; - } - - int GetStartDelay() const - { - return startDelay_; - } - - float GetSpeed() const - { - return speed_; - } - - int GetRepeatCount() const - { - return repeatCount_; - } - - bool GetAutoReverse() const - { - return autoReverse_; - } - - const FillMode& GetFillMode() const - { - return fillMode_; - } - - bool GetDirection() const - { - return isForward_; - } - -protected: - int duration_ { 300 }; - int startDelay_ { 0 }; - float speed_ { 1.0f }; - int repeatCount_ { 1 }; - bool autoReverse_ { false }; - FillMode fillMode_ { FillMode::FORWARDS }; - bool isForward_ { true }; -}; -} // namespace Rosen -} // namespace OHOS - -#endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_ANIMATION_TIMING_PROTOCOL_H diff --git a/export/render_service_client/core/animation/rs_implicit_animator.h b/export/render_service_client/core/animation/rs_implicit_animator.h deleted file mode 100644 index 3e8fb9001df005ccf2ce779a4acce6d3dff3a401..0000000000000000000000000000000000000000 --- a/export/render_service_client/core/animation/rs_implicit_animator.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_IMPLICIT_ANIMATOR_H -#define RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_IMPLICIT_ANIMATOR_H - -#include - -#include "animation/rs_animation_timing_curve.h" -#include "animation/rs_animation_timing_protocol.h" - -#include "common/rs_macros.h" - -namespace OHOS { -namespace Rosen { -class RSAnimation; -class RSPropertyBase; -class RSImplicitAnimationParam; -class RSTransitionEffect; -class RSMotionPathOption; -class RSNode; - -class RSC_EXPORT RSImplicitAnimator { -public: - RSImplicitAnimator() = default; - virtual ~RSImplicitAnimator() = default; - - void OpenImplicitAnimation(const RSAnimationTimingProtocol& timingProtocol, - const RSAnimationTimingCurve& timingCurve, const std::function& finishCallback); - std::vector> CloseImplicitAnimation(); - - void BeginImplicitKeyFrameAnimation(float fraction, const RSAnimationTimingCurve& timingCurve); - void BeginImplicitKeyFrameAnimation(float fraction); - void EndImplicitKeyFrameAnimation(); - - void BeginImplicitTransition(const std::shared_ptr& effect); - void EndImplicitTransition(); - - void BeginImplicitPathAnimation(const std::shared_ptr& motionPathOption); - void EndImplicitPathAnimation(); - - bool NeedImplicitAnimation(); - - std::shared_ptr CreateImplicitAnimation(const std::shared_ptr& target, - std::shared_ptr property, const std::shared_ptr& startValue, - const std::shared_ptr& endValue); - - std::shared_ptr CreateImplicitTransition(RSNode& target, bool isTransitionIn); - -private: - void EndImplicitAnimation(); - void BeginImplicitCurveAnimation(); - void BeginImplicitSpringAnimation(); - - void PushImplicitParam(const std::shared_ptr& implicitParam); - void PopImplicitParam(); - void CreateEmptyAnimation(); - - void SetPropertyValue(std::shared_ptr property, const std::shared_ptr& value); - - std::stack>> - globalImplicitParams_; - std::stack> implicitAnimationParams_; - std::stack, NodeId>>> implicitAnimations_; - std::stack, std::shared_ptr>> keyframeAnimations_; -}; -} // namespace Rosen -} // namespace OHOS - -#endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_IMPLICIT_ANIMATOR_H diff --git a/export/render_service_client/core/animation/rs_implicit_animator_map.h b/export/render_service_client/core/animation/rs_implicit_animator_map.h deleted file mode 100644 index ef71512b409371e90f5bec0574c2a1b48bcf2dda..0000000000000000000000000000000000000000 --- a/export/render_service_client/core/animation/rs_implicit_animator_map.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_IMPLICIT_ANIMATOR_MAP_H -#define RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_IMPLICIT_ANIMATOR_MAP_H - -#include -#include -#include - -#include "common/rs_macros.h" - -namespace OHOS { -namespace Rosen { -class RSImplicitAnimator; - -class RSC_EXPORT RSImplicitAnimatorMap final { -public: - static RSImplicitAnimatorMap& Instance(); - - const std::shared_ptr& GetAnimator(const int32_t id); - -private: - RSImplicitAnimatorMap() = default; - ~RSImplicitAnimatorMap() = default; - RSImplicitAnimatorMap(const RSImplicitAnimatorMap&) = delete; - RSImplicitAnimatorMap(const RSImplicitAnimatorMap&&) = delete; - RSImplicitAnimatorMap& operator=(const RSImplicitAnimatorMap&) = delete; - RSImplicitAnimatorMap& operator=(const RSImplicitAnimatorMap&&) = delete; - - std::mutex mutex_; - std::unordered_map> animatorMap_; -}; -} // namespace Rosen -} // namespace OHOS - -#endif // RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_IMPLICIT_ANIMATOR_MAP_H diff --git a/export/render_service_client/core/animation/rs_motion_path_option.h b/export/render_service_client/core/animation/rs_motion_path_option.h deleted file mode 100644 index 0570f7a155dcee12a29190caa50745d39bfbe2f8..0000000000000000000000000000000000000000 --- a/export/render_service_client/core/animation/rs_motion_path_option.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_MOTION_PATH_OPTION_H -#define RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_MOTION_PATH_OPTION_H - -#include - -#include "animation/rs_animation_common.h" -#include "common/rs_macros.h" - -namespace OHOS { -namespace Rosen { - -class RSC_EXPORT RSMotionPathOption { -public: - RSMotionPathOption(const std::string& path) : path_(path) {} - - virtual ~RSMotionPathOption() = default; - - std::string GetPath() const - { - return path_; - } - - void SetBeginFraction(float beginFraction) - { - beginFraction_ = beginFraction; - } - - float GetBeginFraction() const - { - return beginFraction_; - } - - void SetEndFraction(float endFraction) - { - endFraction_ = endFraction; - } - - float GetEndFraction() const - { - return endFraction_; - } - - void SetRotationMode(const RotationMode& rotationMode) - { - rotationMode_ = rotationMode; - } - - RotationMode GetRotationMode() const - { - return rotationMode_; - } - - void SetPathNeedAddOrigin(bool pathNeedOrigin) - { - pathNeedOrigin_ = pathNeedOrigin; - } - - bool GetPathNeedAddOrigin() - { - return pathNeedOrigin_; - } - -private: - std::string path_; - float beginFraction_ { FRACTION_MIN }; - float endFraction_ { FRACTION_MAX }; - bool pathNeedOrigin_ { true }; - RotationMode rotationMode_ { RotationMode::ROTATE_NONE }; -}; -} // namespace Rosen -} // namespace OHOS - -#endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_MOTION_PATH_OPTION_H diff --git a/export/render_service_client/core/animation/rs_transition.h b/export/render_service_client/core/animation/rs_transition.h deleted file mode 100644 index 471220b69bf42ebe6de6bc1b595ad51ebbfa0fe2..0000000000000000000000000000000000000000 --- a/export/render_service_client/core/animation/rs_transition.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef RENDER_SERVICE_CLIENT_CORE_TRANSITION_RS_TRANSITION_H -#define RENDER_SERVICE_CLIENT_CORE_TRANSITION_RS_TRANSITION_H - -#include "animation/rs_animation.h" -#include "animation/rs_animation_timing_curve.h" -#include "animation/rs_interpolator.h" -#include "animation/rs_transition_effect.h" -#include "platform/common/rs_log.h" - -namespace OHOS { -namespace Rosen { - -class RSC_EXPORT RSTransition : public RSAnimation { -public: - RSTransition(const std::shared_ptr& effect, bool isTransitionIn); - virtual ~RSTransition() = default; - - void SetTransitionEffect(const std::shared_ptr& effect) - { - effect_ = effect; - } - - void SetTimingCurve(const RSAnimationTimingCurve& timingCurve) - { - if (timingCurve.type_ != RSAnimationTimingCurve::CurveType::INTERPOLATING) { - ROSEN_LOGE("RSTransition::SetTimingCurve: invalid timing curve type"); - return; - } - timingCurve_ = timingCurve; - } - -protected: - void OnStart() override; - -private: - bool isTransitionIn_; - std::shared_ptr effect_; - RSAnimationTimingCurve timingCurve_ { RSAnimationTimingCurve::DEFAULT }; -}; -} // namespace Rosen -} // namespace OHOS - -#endif diff --git a/export/render_service_client/core/animation/rs_ui_animation_manager.h b/export/render_service_client/core/animation/rs_ui_animation_manager.h deleted file mode 100644 index c18f3255aaf95c996832a3563b4c04490f87fd09..0000000000000000000000000000000000000000 --- a/export/render_service_client/core/animation/rs_ui_animation_manager.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_UI_ANIMATION_MANAGER_H -#define RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_UI_ANIMATION_MANAGER_H - -#include -#include -#include - -#include "common/rs_common_def.h" - -namespace OHOS { -namespace Rosen { -class RSModifierManager; -class RSAnimation; -class RSRenderAnimation; -class RSPropertyBase; -class RSRenderPropertyBase; - -class RS_EXPORT RSUIAnimationManager { -public: - RSUIAnimationManager(); - virtual ~RSUIAnimationManager() = default; - - void AddAnimation(const std::shared_ptr& animation, - const std::shared_ptr& uiAnimation); - void RemoveAnimation(const AnimationId keyId); - const std::shared_ptr GetAnimation(AnimationId id) const; - void AddAnimatableProp(const PropertyId id, - const std::shared_ptr& uiProperty, - const std::shared_ptr& renderProperty); - const std::shared_ptr GetRenderProperty( - const PropertyId id); - void RemoveProperty(const PropertyId id); - - bool Animate(int64_t time); - void Draw(); - -private: - void OnAnimationRemove(const std::shared_ptr& animation); - void OnAnimationAdd(const std::shared_ptr& animation); - void OnAnimationFinished(const std::shared_ptr& animation); - bool UpdateAnimateValue(const std::shared_ptr& animation, int64_t time); - void RemoveUIAnimation(const AnimationId id); - - std::shared_ptr modifierManager_; - std::unordered_map> animations_; - std::unordered_map> uiAnimations_; - std::unordered_map animationNum_; - std::unordered_map, - std::shared_ptr>> properties_; - -}; -} // namespace Rosen -} // namespace OHOS - -#endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_UI_ANIMATION_MANAGER_H diff --git a/export/render_service_client/core/modifier/rs_extended_modifier.h b/export/render_service_client/core/modifier/rs_extended_modifier.h deleted file mode 100644 index 91e75d06ce65a7054667ec99ff37d3266f986a4c..0000000000000000000000000000000000000000 --- a/export/render_service_client/core/modifier/rs_extended_modifier.h +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_EXTENDED_MODIFIER_H -#define RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_EXTENDED_MODIFIER_H - -#include "command/rs_node_command.h" -#include "common/rs_common_def.h" -#include "common/rs_macros.h" -#include "modifier/rs_modifier.h" -#include "pipeline/rs_draw_cmd_list.h" -#include "transaction/rs_transaction_proxy.h" - -class SkCanvas; - -namespace OHOS { -namespace Rosen { -class RSC_EXPORT RSExtendedModifierHelper { -public: - static RSDrawingContext CreateDrawingContext(NodeId nodeId); - static std::shared_ptr CreateRenderModifier( - RSDrawingContext& ctx, PropertyId id, RSModifierType type); - static std::shared_ptr FinishDrawing(RSDrawingContext& ctx); -}; - -class RSC_EXPORT RSExtendedModifier : public RSModifier { -public: - RSExtendedModifier(const std::shared_ptr& property = {}) - : RSModifier(property, RSModifierType::EXTENDED) - { - property_->SetIsCustom(true); - } - RSModifierType GetModifierType() const override - { - return RSModifierType::EXTENDED; - } - virtual ~RSExtendedModifier() = default; - virtual void Draw(RSDrawingContext& context) const = 0; - -protected: - explicit RSExtendedModifier(const RSModifierType type, const std::shared_ptr& property = {}) - : RSModifier(property, type) - { - property_->SetIsCustom(true); - } - - std::shared_ptr CreateRenderModifier() const override - { - auto node = property_->target_.lock(); - if (node == nullptr) { - return nullptr; - } - RSDrawingContext ctx = RSExtendedModifierHelper::CreateDrawingContext(node->GetId()); - Draw(ctx); - return RSExtendedModifierHelper::CreateRenderModifier(ctx, property_->GetId(), GetModifierType()); - } - - void UpdateToRender() override - { - auto node = property_->target_.lock(); - if (node == nullptr) { - return; - } - RSDrawingContext ctx = RSExtendedModifierHelper::CreateDrawingContext(node->GetId()); - Draw(ctx); - auto drawCmdList = RSExtendedModifierHelper::FinishDrawing(ctx); - std::unique_ptr command = std::make_unique( - node->GetId(), drawCmdList, property_->id_, false); - auto transactionProxy = RSTransactionProxy::GetInstance(); - if (transactionProxy != nullptr) { - transactionProxy->AddCommand(command, node->IsRenderServiceNode()); - if (node->NeedForcedSendToRemote()) { - std::unique_ptr commandForRemote = std::make_unique( - node->GetId(), drawCmdList, property_->id_, false); - transactionProxy->AddCommand(commandForRemote, true, node->GetFollowType(), node->GetId()); - } - if (node->NeedSendExtraCommand()) { - std::unique_ptr extraCommand = std::make_unique( - node->GetId(), drawCmdList, property_->id_, false); - transactionProxy->AddCommand(extraCommand, !node->IsRenderServiceNode(), node->GetFollowType(), - node->GetId()); - } - } - } -}; - -class RSC_EXPORT RSBackgroundStyleModifier : public RSExtendedModifier { -public: - RSBackgroundStyleModifier() : RSExtendedModifier(RSModifierType::BACKGROUND_STYLE) - {} - - RSModifierType GetModifierType() const override - { - return RSModifierType::BACKGROUND_STYLE; - } -}; - -class RSC_EXPORT RSContentStyleModifier : public RSExtendedModifier { -public: - RSContentStyleModifier() : RSExtendedModifier(RSModifierType::CONTENT_STYLE) - {} - - RSModifierType GetModifierType() const override - { - return RSModifierType::CONTENT_STYLE; - } -}; - -class RSC_EXPORT RSForegroundStyleModifier : public RSExtendedModifier { -public: - RSForegroundStyleModifier() : RSExtendedModifier(RSModifierType::FOREGROUND_STYLE) - {} - - RSModifierType GetModifierType() const override - { - return RSModifierType::FOREGROUND_STYLE; - } -}; - -class RSC_EXPORT RSOverlayStyleModifier : public RSExtendedModifier { -public: - RSOverlayStyleModifier() : RSExtendedModifier(RSModifierType::OVERLAY_STYLE) - {} - - RSModifierType GetModifierType() const override - { - return RSModifierType::OVERLAY_STYLE; - } - - void SetOverlayBounds(std::shared_ptr rect) - { - overlayRect_ = rect; - } - - std::shared_ptr GetOverlayBounds() const - { - return overlayRect_; - } - - std::shared_ptr CreateRenderModifier() const override - { - auto renderModifier = RSExtendedModifier::CreateRenderModifier(); - auto drawCmdModifier = std::static_pointer_cast(renderModifier); - if (drawCmdModifier != nullptr && drawCmdModifier->GetType() == RSModifierType::OVERLAY_STYLE) { - drawCmdModifier->SetOverlayBounds(overlayRect_); - } - return renderModifier; - } - -private: - std::shared_ptr overlayRect_ = nullptr; -}; -} // namespace Rosen -} // namespace OHOS - -#endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_EXTENDED_MODIFIER_H diff --git a/export/render_service_client/core/modifier/rs_modifier.h b/export/render_service_client/core/modifier/rs_modifier.h deleted file mode 100644 index ec10185f945123bcfb258a2781466437bbb59ac2..0000000000000000000000000000000000000000 --- a/export/render_service_client/core/modifier/rs_modifier.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef RENDER_SERVICE_CLIENT_CORE_MODIFIER_RS_MODIFIER_H -#define RENDER_SERVICE_CLIENT_CORE_MODIFIER_RS_MODIFIER_H - -#include "common/rs_macros.h" -#include "modifier/rs_property.h" - -class SkCanvas; - -namespace OHOS { -namespace Rosen { -struct RSDrawingContext { - SkCanvas* canvas; - float width; - float height; -}; -class RSRenderModifier; - -class RSC_EXPORT RSModifier : public std::enable_shared_from_this { -public: - explicit RSModifier(const std::shared_ptr& property) - : property_(property ? property : std::make_shared()) - {} - - virtual ~RSModifier() = default; - - virtual std::shared_ptr GetProperty() - { - return property_; - } - - virtual PropertyId GetPropertyId() - { - return property_->id_; - } - -protected: - RSModifier(const std::shared_ptr& property, const RSModifierType type) - : property_(property ? property : std::make_shared()) - { - property_->type_ = type; - } - - virtual RSModifierType GetModifierType() const - { - return RSModifierType::INVALID; - } - - void AttachProperty(const std::shared_ptr& property) - { - if (property != nullptr) { - property->target_ = property_->target_; - property->SetIsCustom(true); - property->AttachModifier(shared_from_this()); - property->UpdateExtendedProperty(); - } - } - - void AttachToNode(const std::shared_ptr target) - { - property_->target_ = std::weak_ptr(target); - } - - virtual void DetachFromNode() - { - property_->target_.reset(); - } - - virtual void SetMotionPathOption(const std::shared_ptr& motionPathOption) - { - property_->SetMotionPathOption(motionPathOption); - } - - virtual void UpdateToRender() {} - - virtual std::shared_ptr CreateRenderModifier() const = 0; - - std::shared_ptr property_; - - friend class RSModifierExtractor; - friend class RSModifierManager; - friend class RSNode; - friend class RSPathAnimation; -}; -} // namespace Rosen -} // namespace OHOS - -#endif // RENDER_SERVICE_CLIENT_CORE_MODIFIER_RS_MODIFIER_H diff --git a/export/render_service_client/core/modifier/rs_modifier_extractor.h b/export/render_service_client/core/modifier/rs_modifier_extractor.h deleted file mode 100644 index d1076d20db1895416877f7233c86deb058cf1f0b..0000000000000000000000000000000000000000 --- a/export/render_service_client/core/modifier/rs_modifier_extractor.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_MODIFIER_EXTRACTOR_H -#define RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_MODIFIER_EXTRACTOR_H - -#include "common/rs_common_def.h" -#include "property/rs_properties.h" - -namespace OHOS { -namespace Rosen { -class RSNode; - -class RSC_EXPORT RSModifierExtractor { -public: - RSModifierExtractor(NodeId id); - virtual ~RSModifierExtractor() = default; - - Vector4f GetBounds() const; - Vector4f GetFrame() const; - float GetPositionZ() const; - - Vector2f GetPivot() const; - Quaternion GetQuaternion() const; - float GetRotation() const; - float GetRotationX() const; - float GetRotationY() const; - Vector2f GetTranslate() const; - float GetTranslateZ() const; - Vector2f GetScale() const; - - float GetAlpha() const; - bool GetAlphaOffscreen() const; - - Vector4f GetCornerRadius() const; - - Color GetForegroundColor() const; - Color GetBackgroundColor() const; - Color GetSurfaceBgColor() const; - std::shared_ptr GetBackgroundShader() const; - std::shared_ptr GetBgImage() const; - float GetBgImageWidth() const; - float GetBgImageHeight() const; - float GetBgImagePositionX() const; - float GetBgImagePositionY() const; - - Vector4 GetBorderColor() const; - Vector4f GetBorderWidth() const; - Vector4 GetBorderStyle() const; - - std::shared_ptr GetBackgroundFilter() const; - std::shared_ptr GetFilter() const; - - Color GetShadowColor() const; - float GetShadowOffsetX() const; - float GetShadowOffsetY() const; - float GetShadowAlpha() const; - float GetShadowElevation() const; - float GetShadowRadius() const; - std::shared_ptr GetShadowPath() const; - - Gravity GetFrameGravity() const; - - std::shared_ptr GetClipBounds() const; - bool GetClipToBounds() const; - bool GetClipToFrame() const; - bool GetVisible() const; - - std::shared_ptr GetMask() const; - - std::string Dump() const; -private: - NodeId id_; -}; -} // namespace Rosen -} // namespace OHOS - -#endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_MODIFIER_EXTRACTOR_H diff --git a/export/render_service_client/core/modifier/rs_modifier_manager.h b/export/render_service_client/core/modifier/rs_modifier_manager.h deleted file mode 100644 index d93f69a7beaf4b2badb29774d8ca5136397bcf80..0000000000000000000000000000000000000000 --- a/export/render_service_client/core/modifier/rs_modifier_manager.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_MODIFIER_MANAGER_H -#define RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_MODIFIER_MANAGER_H - -#include -#include - -#include "common/rs_macros.h" - -namespace OHOS { -namespace Rosen { -class RSModifier; - -class RSC_EXPORT RSModifierManager { -public: - RSModifierManager() = default; - virtual ~RSModifierManager() = default; - - void AddModifier(const std::shared_ptr& modifier); - void Draw(); - -private: - std::set> modifiers_; -}; -} // namespace Rosen -} // namespace OHOS - -#endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_MODIFIER_MANAGER_H diff --git a/export/render_service_client/core/modifier/rs_property.h b/export/render_service_client/core/modifier/rs_property.h deleted file mode 100644 index b24f0d5af70e18d7b28743e9bf19eb3a81b11514..0000000000000000000000000000000000000000 --- a/export/render_service_client/core/modifier/rs_property.h +++ /dev/null @@ -1,561 +0,0 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_PROP_H -#define RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_PROP_H - -#include -#include - -#include "animation/rs_animation_manager_map.h" -#include "animation/rs_implicit_animator.h" -#include "animation/rs_implicit_animator_map.h" -#include "animation/rs_motion_path_option.h" -#include "animation/rs_ui_animation_manager.h" -#include "common/rs_color.h" -#include "common/rs_common_def.h" -#include "common/rs_macros.h" -#include "common/rs_vector2.h" -#include "common/rs_vector4.h" -#include "modifier/rs_animatable_arithmetic.h" -#include "modifier/rs_modifier_manager.h" -#include "modifier/rs_modifier_type.h" -#include "modifier/rs_render_property.h" -#include "pipeline/rs_node_map.h" -#include "property/rs_properties_def.h" -#include "render/rs_border.h" -#include "render/rs_filter.h" -#include "render/rs_image.h" -#include "render/rs_mask.h" -#include "render/rs_path.h" -#include "render/rs_shader.h" -#include "transaction/rs_transaction_proxy.h" -#include "ui/rs_node.h" - -#ifdef _WIN32 -#include -#define gettid GetCurrentThreadId -#endif - -#ifdef __APPLE__ -#define gettid getpid -#endif - -#ifdef __gnu_linux__ -#include -#include -#define gettid []() -> int32_t { return static_cast(syscall(SYS_gettid)); } -#endif - -namespace OHOS { -namespace Rosen { -class RSModifier; -class RSNode; - -template -struct make_void { using type = void; }; -template -using void_t = typename make_void::type; - -template -struct supports_arithmetic : std::false_type {}; -template -struct supports_arithmetic() == std::declval())>> - : std::true_type {}; - -template -struct supports_animatable_arithmetic : std::false_type {}; -template -struct supports_animatable_arithmetic() + std::declval()), - decltype(std::declval() - std::declval()), - decltype(std::declval() * std::declval()), - decltype(std::declval() == std::declval())>> - : std::true_type {}; - -class RSC_EXPORT RSPropertyBase : public std::enable_shared_from_this { -public: - RSPropertyBase(); - virtual ~RSPropertyBase() = default; - - PropertyId GetId() const - { - return id_; - } - - virtual std::shared_ptr CreateRenderProperty() - { - return std::make_shared(id_); - } - -protected: - virtual void SetIsCustom(bool isCustom) {} - - virtual bool GetIsCustom() const - { - return false; - } - - virtual void SetValue(const std::shared_ptr& value) {} - - virtual std::shared_ptr Clone() const - { - return std::make_shared(); - } - - virtual void SetMotionPathOption(const std::shared_ptr& motionPathOption) {} - - virtual RSRenderPropertyType GetPropertyType() const - { - return RSRenderPropertyType::INVALID; - } - - virtual void UpdateExtendedProperty() const {} - - virtual void UpdateOnAllAnimationFinish() {} - - virtual void AddPathAnimation() {} - - virtual void RemovePathAnimation() {} - - virtual void UpdateShowingValue(const std::shared_ptr& property) {} - - virtual void AttachModifier(const std::shared_ptr& modifier) {} - - virtual void MarkModifierDirty(const std::shared_ptr& modifierManager) {} - - PropertyId id_; - RSModifierType type_ { RSModifierType::INVALID }; - std::weak_ptr target_; - -private: - virtual std::shared_ptr Add(const std::shared_ptr& value) - { - return shared_from_this(); - } - - virtual std::shared_ptr Minus(const std::shared_ptr& value) - { - return shared_from_this(); - } - - virtual std::shared_ptr Multiply(const float scale) - { - return shared_from_this(); - } - - virtual bool IsEqual(const std::shared_ptr& value) const - { - return true; - } - - friend std::shared_ptr operator+=( - const std::shared_ptr& a, const std::shared_ptr& b); - friend std::shared_ptr operator-=( - const std::shared_ptr& a, const std::shared_ptr& b); - friend std::shared_ptr operator*=(const std::shared_ptr& value, const float scale); - friend std::shared_ptr operator+( - const std::shared_ptr& a, const std::shared_ptr& b); - friend std::shared_ptr operator-( - const std::shared_ptr& a, const std::shared_ptr& b); - friend std::shared_ptr operator*( - const std::shared_ptr& value, const float scale); - friend bool operator==( - const std::shared_ptr& a, const std::shared_ptr& b); - friend bool operator!=( - const std::shared_ptr& a, const std::shared_ptr& b); - friend class RSCurveAnimation; - friend class RSExtendedModifier; - friend class RSImplicitAnimator; - friend class RSImplicitCurveAnimationParam; - friend class RSImplicitKeyframeAnimationParam; - friend class RSImplicitSpringAnimationParam; - friend class RSModifier; - friend class RSPropertyAnimation; - friend class RSPathAnimation; - friend class RSKeyframeAnimation; - friend class RSSpringAnimation; - friend class RSUIAnimationManager; -}; - -template -class RSProperty : public RSPropertyBase { - static_assert(std::is_base_of_v, T> || supports_arithmetic::value); - -public: - RSProperty() : RSPropertyBase() {} - explicit RSProperty(const T& value) : RSPropertyBase() - { - stagingValue_ = value; - } - virtual ~RSProperty() = default; - - virtual void Set(const T& value) - { - if (ROSEN_EQ(value, stagingValue_) || !IsValid(value)) { - return; - } - - stagingValue_ = value; - if (target_.lock() == nullptr) { - return; - } - - if (isCustom_) { - UpdateExtendedProperty(); - } else { - UpdateToRender(stagingValue_, false); - } - } - - virtual T Get() const - { - return stagingValue_; - } - - std::shared_ptr CreateRenderProperty() override - { - return std::make_shared>(stagingValue_, id_); - } - -protected: - void UpdateToRender(const T& value, bool isDelta, bool forceUpdate = false) const - {} - - void UpdateExtendedProperty() const override - { - auto node = target_.lock(); - if (node == nullptr) { - return; - } - node->UpdateExtendedModifier(modifier_); - } - - void SetValue(const std::shared_ptr& value) override - { - auto property = std::static_pointer_cast>(value); - if (property != nullptr) { - stagingValue_ = property->stagingValue_; - } - } - - std::shared_ptr Clone() const override - { - return std::make_shared>(stagingValue_); - } - - bool IsValid(const T& value) - { - return true; - } - - void AttachModifier(const std::shared_ptr& modifier) override - { - modifier_ = modifier; - } - - void SetIsCustom(bool isCustom) override - { - isCustom_ = isCustom; - } - - bool GetIsCustom() const override - { - return isCustom_; - } - - T stagingValue_ {}; - bool isCustom_ { false }; - std::weak_ptr modifier_; - - friend class RSPathAnimation; - friend class RSImplicitAnimator; - friend class RSExtendedModifier; - friend class RSModifier; -}; - -template -class RSAnimatableProperty : public RSProperty { - static_assert(std::is_integral_v || std::is_floating_point_v || std::is_same_v || - std::is_same_v || std::is_same_v || std::is_same_v || - std::is_same_v || std::is_same_v, T> || - std::is_same_v, T> || std::is_base_of_v, T> || - supports_animatable_arithmetic::value); - -public: - RSAnimatableProperty() {} - RSAnimatableProperty(const T& value) : RSProperty(value) - { - showingValue_ = value; - } - - virtual ~RSAnimatableProperty() = default; - - void Set(const T& value) override - { - if (ROSEN_EQ(value, RSProperty::stagingValue_) || !RSProperty::IsValid(value)) { - return; - } - - auto node = RSProperty::target_.lock(); - if (node == nullptr) { - RSProperty::stagingValue_ = value; - return; - } - - auto implicitAnimator = RSImplicitAnimatorMap::Instance().GetAnimator(gettid()); - if (implicitAnimator && implicitAnimator->NeedImplicitAnimation()) { - auto startValue = std::make_shared>(RSProperty::stagingValue_); - auto endValue = std::make_shared>(value); - if (motionPathOption_ != nullptr) { - implicitAnimator->BeginImplicitPathAnimation(motionPathOption_); - implicitAnimator->CreateImplicitAnimation( - node, RSProperty::shared_from_this(), startValue, endValue); - implicitAnimator->EndImplicitPathAnimation(); - } else { - implicitAnimator->CreateImplicitAnimation( - node, RSProperty::shared_from_this(), startValue, endValue); - } - return; - } - - if (runningPathNum_ > 0) { - return; - } - - bool hasPropertyAnimation = node->HasPropertyAnimation(RSProperty::id_); - T sendValue = value; - if (hasPropertyAnimation) { - sendValue = value - RSProperty::stagingValue_; - } - RSProperty::stagingValue_ = value; - if (RSProperty::isCustom_) { - UpdateExtendedAnimatableProperty(sendValue, hasPropertyAnimation); - } else { - RSProperty::UpdateToRender(sendValue, hasPropertyAnimation); - } - } - - T Get() const override - { - if (RSProperty::isCustom_) { - return showingValue_; - } - return RSProperty::stagingValue_; - } - - std::shared_ptr CreateRenderProperty() override - { - return std::make_shared>( - RSProperty::stagingValue_, RSProperty::id_, GetPropertyType()); - } - -protected: - void MarkModifierDirty(const std::shared_ptr& modifierManager) override - { - auto modifier = RSProperty::modifier_.lock(); - if (modifier != nullptr && modifierManager != nullptr) { - modifierManager->AddModifier(modifier); - } - } - - void UpdateOnAllAnimationFinish() override - { - if (RSProperty::isCustom_) { - return; - } - RSProperty::UpdateToRender(RSProperty::stagingValue_, false, true); - } - - void UpdateExtendedAnimatableProperty(const T& value, bool isDelta) - { - auto renderProperty = std::static_pointer_cast>(GetExtendedRenderProperty()); - if (isDelta) { - if (renderProperty != nullptr) { - renderProperty->Set(renderProperty->Get() + value); - } - } else { - showingValue_ = value; - RSProperty::UpdateExtendedProperty(); - if (renderProperty != nullptr) { - renderProperty->Set(value); - } - } - } - - std::shared_ptr GetExtendedRenderProperty() - { - auto animationManager = RSAnimationManagerMap::Instance()->GetAnimationManager(gettid()); - if (animationManager == nullptr) { - return nullptr; - } - - return animationManager->GetRenderProperty(RSProperty::GetId()); - } - - void AddPathAnimation() override - { - runningPathNum_ += 1; - } - - void RemovePathAnimation() override - { - runningPathNum_ -= 1; - } - - void UpdateShowingValue(const std::shared_ptr& property) override - { - auto renderProperty = std::static_pointer_cast>(property); - if (renderProperty != nullptr) { - showingValue_ = renderProperty->Get(); - } - } - - void SetValue(const std::shared_ptr& value) override - { - auto property = std::static_pointer_cast>(value); - if (property != nullptr && property->GetPropertyType() == GetPropertyType()) { - RSProperty::stagingValue_ = property->stagingValue_; - } - } - - std::shared_ptr Clone() const override - { - return std::make_shared>(RSProperty::stagingValue_); - } - - void SetMotionPathOption(const std::shared_ptr& motionPathOption) override - { - motionPathOption_ = motionPathOption; - } - - T showingValue_ {}; - int runningPathNum_ { 0 }; - std::shared_ptr motionPathOption_ {}; - -private: - RSRenderPropertyType GetPropertyType() const override - { - return RSRenderPropertyType::INVALID; - } - - std::shared_ptr Add(const std::shared_ptr& value) override - { - auto animatableProperty = std::static_pointer_cast>(value); - if (animatableProperty != nullptr) { - RSProperty::stagingValue_ = RSProperty::stagingValue_ + animatableProperty->stagingValue_; - } - return RSProperty::shared_from_this(); - } - - std::shared_ptr Minus(const std::shared_ptr& value) override - { - auto animatableProperty = std::static_pointer_cast>(value); - if (animatableProperty != nullptr) { - RSProperty::stagingValue_ = RSProperty::stagingValue_ - animatableProperty->stagingValue_; - } - return RSProperty::shared_from_this(); - } - - std::shared_ptr Multiply(const float scale) override - { - RSProperty::stagingValue_ = RSProperty::stagingValue_ * scale; - return RSProperty::shared_from_this(); - } - - bool IsEqual(const std::shared_ptr& value) const override - { - auto animatableProperty = std::static_pointer_cast>(value); - if (animatableProperty != nullptr) { - return RSProperty::stagingValue_ == animatableProperty->stagingValue_; - } - return true; - } - - friend class RSPropertyAnimation; - friend class RSPathAnimation; - friend class RSUIAnimationManager; - friend class RSExtendedModifier; - friend class RSModifier; -}; - -template<> -RSC_EXPORT void RSProperty::UpdateToRender(const bool& value, bool isDelta, bool forceUpdate) const; -template<> -RSC_EXPORT void RSProperty::UpdateToRender(const float& value, bool isDelta, bool forceUpdate) const; -template<> -RSC_EXPORT void RSProperty::UpdateToRender(const int& value, bool isDelta, bool forceUpdate) const; -template<> -RSC_EXPORT void RSProperty::UpdateToRender(const Color& value, bool isDelta, bool forceUpdate) const; -template<> -RSC_EXPORT void RSProperty::UpdateToRender(const Gravity& value, bool isDelta, bool forceUpdate) const; -template<> -RSC_EXPORT void RSProperty::UpdateToRender(const Matrix3f& value, bool isDelta, bool forceUpdate) const; -template<> -RSC_EXPORT void RSProperty::UpdateToRender(const Quaternion& value, bool isDelta, bool forceUpdate) const; -template<> -RSC_EXPORT void RSProperty>::UpdateToRender( - const std::shared_ptr& value, bool isDelta, bool forceUpdate) const; -template<> -RSC_EXPORT void RSProperty>::UpdateToRender( - const std::shared_ptr& value, bool isDelta, bool forceUpdate) const; -template<> -RSC_EXPORT void RSProperty>::UpdateToRender( - const std::shared_ptr& value, bool isDelta, bool forceUpdate) const; -template<> -RSC_EXPORT void RSProperty>::UpdateToRender( - const std::shared_ptr& value, bool isDelta, bool forceUpdate) const; -template<> -RSC_EXPORT void RSProperty>::UpdateToRender( - const std::shared_ptr& value, bool isDelta, bool forceUpdate) const; -template<> -RSC_EXPORT void RSProperty::UpdateToRender(const Vector2f& value, bool isDelta, bool forceUpdate) const; -template<> -RSC_EXPORT void RSProperty>::UpdateToRender( - const Vector4& value, bool isDelta, bool forceUpdate) const; -template<> -RSC_EXPORT void RSProperty>::UpdateToRender( - const Vector4& value, bool isDelta, bool forceUpdate) const; -template<> -RSC_EXPORT void RSProperty::UpdateToRender(const Vector4f& value, bool isDelta, bool forceUpdate) const; - -template<> -RSC_EXPORT bool RSProperty::IsValid(const float& value); -template<> -RSC_EXPORT bool RSProperty::IsValid(const Vector2f& value); -template<> -RSC_EXPORT bool RSProperty::IsValid(const Vector4f& value); - -template<> -RSC_EXPORT RSRenderPropertyType RSAnimatableProperty::GetPropertyType() const; -template<> -RSC_EXPORT RSRenderPropertyType RSAnimatableProperty::GetPropertyType() const; -template<> -RSC_EXPORT RSRenderPropertyType RSAnimatableProperty::GetPropertyType() const; -template<> -RSC_EXPORT RSRenderPropertyType RSAnimatableProperty::GetPropertyType() const; -template<> -RSC_EXPORT RSRenderPropertyType RSAnimatableProperty::GetPropertyType() const; -template<> -RSC_EXPORT RSRenderPropertyType RSAnimatableProperty::GetPropertyType() const; -template<> -RSC_EXPORT RSRenderPropertyType RSAnimatableProperty>::GetPropertyType() const; -template<> -RSC_EXPORT RSRenderPropertyType RSAnimatableProperty>::GetPropertyType() const; -} // namespace Rosen -} // namespace OHOS - -#endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_PROP_H diff --git a/export/render_service_client/core/modifier/rs_property_modifier.h b/export/render_service_client/core/modifier/rs_property_modifier.h deleted file mode 100644 index 2eaf19708f8c858bfe0a686ae76e4ce5d572d817..0000000000000000000000000000000000000000 --- a/export/render_service_client/core/modifier/rs_property_modifier.h +++ /dev/null @@ -1,412 +0,0 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_MODIFIER_H -#define RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_MODIFIER_H - -#include "modifier/rs_modifier.h" - -namespace OHOS { -namespace Rosen { -class RSC_EXPORT RSBoundsModifier : public RSModifier { -public: - explicit RSBoundsModifier(const std::shared_ptr& property); - virtual ~RSBoundsModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSBoundsSizeModifier : public RSModifier { -public: - explicit RSBoundsSizeModifier(const std::shared_ptr& property); - virtual ~RSBoundsSizeModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSBoundsPositionModifier : public RSModifier { -public: - explicit RSBoundsPositionModifier(const std::shared_ptr& property); - virtual ~RSBoundsPositionModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSFrameModifier : public RSModifier { -public: - explicit RSFrameModifier(const std::shared_ptr& property); - virtual ~RSFrameModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSPositionZModifier : public RSModifier { -public: - explicit RSPositionZModifier(const std::shared_ptr& property); - virtual ~RSPositionZModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSPivotModifier : public RSModifier { -public: - explicit RSPivotModifier(const std::shared_ptr& property); - virtual ~RSPivotModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSQuaternionModifier : public RSModifier { -public: - explicit RSQuaternionModifier(const std::shared_ptr& property); - virtual ~RSQuaternionModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSRotationModifier : public RSModifier { -public: - explicit RSRotationModifier(const std::shared_ptr& property); - virtual ~RSRotationModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSRotationXModifier : public RSModifier { -public: - explicit RSRotationXModifier(const std::shared_ptr& property); - virtual ~RSRotationXModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSRotationYModifier : public RSModifier { -public: - explicit RSRotationYModifier(const std::shared_ptr& property); - virtual ~RSRotationYModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSScaleModifier : public RSModifier { -public: - explicit RSScaleModifier(const std::shared_ptr& property); - virtual ~RSScaleModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSTranslateModifier : public RSModifier { -public: - explicit RSTranslateModifier(const std::shared_ptr& property); - virtual ~RSTranslateModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSTranslateZModifier : public RSModifier { -public: - explicit RSTranslateZModifier(const std::shared_ptr& property); - virtual ~RSTranslateZModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSCornerRadiusModifier : public RSModifier { -public: - explicit RSCornerRadiusModifier(const std::shared_ptr& property); - virtual ~RSCornerRadiusModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSAlphaModifier : public RSModifier { -public: - explicit RSAlphaModifier(const std::shared_ptr& property); - virtual ~RSAlphaModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSAlphaOffscreenModifier : public RSModifier { -public: - explicit RSAlphaOffscreenModifier(const std::shared_ptr& property); - virtual ~RSAlphaOffscreenModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSForegroundColorModifier : public RSModifier { -public: - explicit RSForegroundColorModifier(const std::shared_ptr& property); - virtual ~RSForegroundColorModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSBackgroundColorModifier : public RSModifier { -public: - explicit RSBackgroundColorModifier(const std::shared_ptr& property); - virtual ~RSBackgroundColorModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSSurfaceBgColorModifier : public RSModifier { -public: - explicit RSSurfaceBgColorModifier(const std::shared_ptr& property); - virtual ~RSSurfaceBgColorModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSBackgroundShaderModifier : public RSModifier { -public: - explicit RSBackgroundShaderModifier(const std::shared_ptr& property); - virtual ~RSBackgroundShaderModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSBgImageModifier : public RSModifier { -public: - explicit RSBgImageModifier(const std::shared_ptr& property); - virtual ~RSBgImageModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSBgImageWidthModifier : public RSModifier { -public: - explicit RSBgImageWidthModifier(const std::shared_ptr& property); - virtual ~RSBgImageWidthModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSBgImageHeightModifier : public RSModifier { -public: - explicit RSBgImageHeightModifier(const std::shared_ptr& property); - virtual ~RSBgImageHeightModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSBgImagePositionXModifier : public RSModifier { -public: - explicit RSBgImagePositionXModifier(const std::shared_ptr& property); - virtual ~RSBgImagePositionXModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSBgImagePositionYModifier : public RSModifier { -public: - explicit RSBgImagePositionYModifier(const std::shared_ptr& property); - virtual ~RSBgImagePositionYModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSBorderColorModifier : public RSModifier { -public: - explicit RSBorderColorModifier(const std::shared_ptr& property); - virtual ~RSBorderColorModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSBorderWidthModifier : public RSModifier { -public: - explicit RSBorderWidthModifier(const std::shared_ptr& property); - virtual ~RSBorderWidthModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSBorderStyleModifier : public RSModifier { -public: - explicit RSBorderStyleModifier(const std::shared_ptr& property); - virtual ~RSBorderStyleModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSFilterModifier : public RSModifier { -public: - explicit RSFilterModifier(const std::shared_ptr& property); - virtual ~RSFilterModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSBackgroundFilterModifier : public RSModifier { -public: - explicit RSBackgroundFilterModifier(const std::shared_ptr& property); - virtual ~RSBackgroundFilterModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSFrameGravityModifier : public RSModifier { -public: - explicit RSFrameGravityModifier(const std::shared_ptr& property); - virtual ~RSFrameGravityModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSClipBoundsModifier : public RSModifier { -public: - explicit RSClipBoundsModifier(const std::shared_ptr& property); - virtual ~RSClipBoundsModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSClipToBoundsModifier : public RSModifier { -public: - explicit RSClipToBoundsModifier(const std::shared_ptr& property); - virtual ~RSClipToBoundsModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSClipToFrameModifier : public RSModifier { -public: - explicit RSClipToFrameModifier(const std::shared_ptr& property); - virtual ~RSClipToFrameModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSVisibleModifier : public RSModifier { -public: - explicit RSVisibleModifier(const std::shared_ptr& property); - virtual ~RSVisibleModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSShadowColorModifier : public RSModifier { -public: - explicit RSShadowColorModifier(const std::shared_ptr& property); - virtual ~RSShadowColorModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSShadowOffsetXModifier : public RSModifier { -public: - explicit RSShadowOffsetXModifier(const std::shared_ptr& property); - virtual ~RSShadowOffsetXModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSShadowOffsetYModifier : public RSModifier { -public: - explicit RSShadowOffsetYModifier(const std::shared_ptr& property); - virtual ~RSShadowOffsetYModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSShadowAlphaModifier : public RSModifier { -public: - explicit RSShadowAlphaModifier(const std::shared_ptr& property); - virtual ~RSShadowAlphaModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSShadowElevationModifier : public RSModifier { -public: - explicit RSShadowElevationModifier(const std::shared_ptr& property); - virtual ~RSShadowElevationModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSShadowRadiusModifier : public RSModifier { -public: - explicit RSShadowRadiusModifier(const std::shared_ptr& property); - virtual ~RSShadowRadiusModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSShadowPathModifier : public RSModifier { -public: - explicit RSShadowPathModifier(const std::shared_ptr& property); - virtual ~RSShadowPathModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; - -class RSC_EXPORT RSMaskModifier : public RSModifier { -public: - explicit RSMaskModifier(const std::shared_ptr& property); - virtual ~RSMaskModifier() = default; -protected: - RSModifierType GetModifierType() const override; - std::shared_ptr CreateRenderModifier() const override; -}; -} // namespace Rosen -} // namespace OHOS - -#endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_MODIFIER_H diff --git a/export/render_service_client/core/pipeline/rs_node_map.h b/export/render_service_client/core/pipeline/rs_node_map.h deleted file mode 100644 index 0dbd064308316c70c6b6a9a45b9f19e95a875c54..0000000000000000000000000000000000000000 --- a/export/render_service_client/core/pipeline/rs_node_map.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_NODE_MAP_H -#define RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_NODE_MAP_H - -#include -#include - -#include "common/rs_common_def.h" -#include "common/rs_macros.h" -#include "ui/rs_base_node.h" - -namespace OHOS { -namespace Rosen { -class RSNode; - -class RSC_EXPORT RSNodeMap final { -public: - static const RSNodeMap& Instance(); - static RSNodeMap& MutableInstance(); - - bool RegisterNode(const std::shared_ptr& nodePtr); - void UnregisterNode(NodeId id); - - // Get RSNode with type T, return nullptr if not found or type mismatch - template - const std::shared_ptr GetNode(NodeId id) const - { - return RSBaseNode::ReinterpretCast(GetNode(id)); - } - template<> - const std::shared_ptr GetNode(NodeId id) const; - - const std::shared_ptr GetAnimationFallbackNode() const; - -private: - explicit RSNodeMap(); - ~RSNodeMap() noexcept; - RSNodeMap(const RSNodeMap&) = delete; - RSNodeMap(const RSNodeMap&&) = delete; - RSNodeMap& operator=(const RSNodeMap&) = delete; - RSNodeMap& operator=(const RSNodeMap&&) = delete; - -private: - mutable std::mutex mutex_; - std::unordered_map> nodeMap_; - std::shared_ptr animationFallbackNode_; -}; -} // namespace Rosen -} // namespace OHOS - -#endif // RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_NODE_MAP_H diff --git a/export/render_service_client/core/transaction/rs_interfaces.h b/export/render_service_client/core/transaction/rs_interfaces.h deleted file mode 100644 index 30f513f445d7f9e55ac30d649b6650ddde5a1ea6..0000000000000000000000000000000000000000 --- a/export/render_service_client/core/transaction/rs_interfaces.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef RENDER_SERVICE_CLIENT_CORE_TRANSACTION_RS_INTERFACES_H -#define RENDER_SERVICE_CLIENT_CORE_TRANSACTION_RS_INTERFACES_H - -#include - -#include "transaction/rs_render_service_client.h" -#include "ui/rs_display_node.h" -#include "ui/rs_surface_node.h" -#include "ipc_callbacks/rs_iocclusion_change_callback.h" - -namespace OHOS { -namespace Rosen { - -struct FocusAppInfo { - int32_t pid = -1; - int32_t uid = -1; - std::string bundleName; - std::string abilityName; -}; - -class RSC_EXPORT RSInterfaces { -public: - static RSInterfaces &GetInstance(); - RSInterfaces(const RSInterfaces &) = delete; - void operator=(const RSInterfaces &) = delete; - - int32_t SetFocusAppInfo(FocusAppInfo& info); - - ScreenId GetDefaultScreenId(); - - std::vector GetAllScreenIds(); - - // mirrorId: decide which screen id to mirror, INVALID_SCREEN_ID means do not mirror any screen. -#ifndef ROSEN_CROSS_PLATFORM - ScreenId CreateVirtualScreen( - const std::string &name, - uint32_t width, - uint32_t height, - sptr surface, - ScreenId mirrorId = 0, - int flags = 0); - - int32_t SetVirtualScreenSurface(ScreenId id, sptr surface); -#endif - - void RemoveVirtualScreen(ScreenId id); - - int32_t SetScreenChangeCallback(const ScreenChangeCallback &callback); - - bool TakeSurfaceCapture(std::shared_ptr node, - std::shared_ptr callback, float scaleX = 1.0f, float scaleY = 1.0f); - - bool TakeSurfaceCapture(std::shared_ptr node, - std::shared_ptr callback, float scaleX = 1.0f, float scaleY = 1.0f); - - void SetScreenActiveMode(ScreenId id, uint32_t modeId); - - int32_t SetVirtualScreenResolution(ScreenId id, uint32_t width, uint32_t height); - - RSVirtualScreenResolution GetVirtualScreenResolution(ScreenId id); - - void SetScreenPowerStatus(ScreenId id, ScreenPowerStatus status); - - RSScreenModeInfo GetScreenActiveMode(ScreenId id); - - std::vector GetScreenSupportedModes(ScreenId id); - - RSScreenCapability GetScreenCapability(ScreenId id); - - ScreenPowerStatus GetScreenPowerStatus(ScreenId id); - - RSScreenData GetScreenData(ScreenId id); - - int32_t GetScreenBacklight(ScreenId id); - - void SetScreenBacklight(ScreenId id, uint32_t level); - - int32_t GetScreenSupportedColorGamuts(ScreenId id, std::vector& mode); - - int32_t GetScreenSupportedMetaDataKeys(ScreenId id, std::vector& keys); - - int32_t GetScreenColorGamut(ScreenId id, ScreenColorGamut& mode); - - int32_t SetScreenColorGamut(ScreenId id, int32_t modeIdx); - - int32_t SetScreenGamutMap(ScreenId id, ScreenGamutMap mode); - - int32_t GetScreenGamutMap(ScreenId id, ScreenGamutMap& mode); - - int32_t GetScreenHDRCapability(ScreenId id, RSScreenHDRCapability& screenHdrCapability); - - int32_t GetScreenType(ScreenId id, RSScreenType& screenType); - - /* skipFrameInterval : decide how many frames apart to refresh a frame, - DEFAULT_SKIP_FRAME_INTERVAL means refresh each frame, - change screen refresh rate finally */ - int32_t SetScreenSkipFrameInterval(ScreenId id, uint32_t skipFrameInterval); - - std::shared_ptr CreateVSyncReceiver( - const std::string& name, - const std::shared_ptr &looper = nullptr); - - int32_t RegisterOcclusionChangeCallback(const OcclusionChangeCallback& callback); - - int32_t UnRegisterOcclusionChangeCallback(const OcclusionChangeCallback& callback); - - int32_t SetRenderModeChangeCallback(const RenderModeChangeCallback& callback); - - void UpdateRenderMode(bool isUniRender); - - void SetAppWindowNum(uint32_t num); -private: - RSInterfaces(); - ~RSInterfaces() noexcept; - - std::unique_ptr renderServiceClient_; -}; -} // namespace Rosen -} // namespace OHOS - -#endif // RENDER_SERVICE_CLIENT_CORE_TRANSACTION_RS_INTERFACES_H diff --git a/export/render_service_client/core/ui/rs_base_node.h b/export/render_service_client/core/ui/rs_base_node.h deleted file mode 100644 index 9e5bb0b07273b04dc5277f243f36053c16fc05f9..0000000000000000000000000000000000000000 --- a/export/render_service_client/core/ui/rs_base_node.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef RENDER_SERVICE_CLIENT_CORE_UI_RS_BASE_NODE_H -#define RENDER_SERVICE_CLIENT_CORE_UI_RS_BASE_NODE_H - -#include -#include -#include - -#include "common/rs_common_def.h" -#include "platform/common/rs_system_properties.h" - -namespace OHOS { -namespace Rosen { -class RSTransitionEffect; - -class RSC_EXPORT RSBaseNode : public std::enable_shared_from_this { -public: - using WeakPtr = std::weak_ptr; - using SharedPtr = std::shared_ptr; - static inline constexpr RSUINodeType Type = RSUINodeType::BASE_NODE; - virtual RSUINodeType GetType() const - { - return Type; - } - - virtual ~RSBaseNode(); - - virtual void AddChild(SharedPtr child, int index = -1); - void MoveChild(SharedPtr child, int index); - virtual void RemoveChild(SharedPtr child); - void RemoveFromTree(); - virtual void ClearChildren(); - const std::vector& GetChildren() const - { - return children_; - } - - // Add/RemoveCrossParentChild only used as: the child is under multiple parents(e.g. a window cross multi-screens) - void AddCrossParentChild(SharedPtr child, int index); - void RemoveCrossParentChild(SharedPtr child, NodeId newParentId); - - NodeId GetId() const - { - return id_; - } - - virtual FollowType GetFollowType() const - { - return FollowType::NONE; - } - - bool IsInstanceOf(RSUINodeType type) const; - template - RSC_EXPORT bool IsInstanceOf() const; - - // type-safe reinterpret_cast - template - static std::shared_ptr ReinterpretCast(const std::shared_ptr& node) - { - return node ? node->ReinterpretCastTo() : nullptr; - } - template - std::shared_ptr ReinterpretCastTo() - { - return (IsInstanceOf()) ? std::static_pointer_cast(shared_from_this()) : nullptr; - } - virtual std::string DumpNode(int depth) const; - -protected: - bool isRenderServiceNode_; - bool skipDestroyCommandInDestructor_ = false; - - explicit RSBaseNode(bool isRenderServiceNode); - explicit RSBaseNode(bool isRenderServiceNode, NodeId id); - RSBaseNode(const RSBaseNode&) = delete; - RSBaseNode(const RSBaseNode&&) = delete; - RSBaseNode& operator=(const RSBaseNode&) = delete; - RSBaseNode& operator=(const RSBaseNode&&) = delete; - - // this id is ONLY used in hierarchy operation commands, this may differ from id_ when the node is a proxy node. - virtual NodeId GetHierarchyCommandNodeId() const - { - return id_; - } - - virtual void OnAddChildren() {} - virtual void OnRemoveChildren() {} - SharedPtr GetParent(); - - void SetId(const NodeId& id) - { - id_ = id; - } - - bool IsUniRenderEnabled() const; - bool IsRenderServiceNode() const; - bool NeedSendExtraCommand() const; - -private: - static NodeId GenerateId(); - static void InitUniRenderEnabled(); - NodeId id_; - NodeId parent_ = 0; - std::vector children_; - void SetParent(NodeId parent); - void RemoveChildById(NodeId childId); - - friend class RSUIDirector; -}; -} // namespace Rosen -} // namespace OHOS - -#endif // RENDER_SERVICE_CLIENT_CORE_UI_RS_BASE_NODE_H diff --git a/export/render_service_client/core/ui/rs_canvas_node.h b/export/render_service_client/core/ui/rs_canvas_node.h deleted file mode 100644 index a028007ef943d2163e0238f4843bccbf7df4a38f..0000000000000000000000000000000000000000 --- a/export/render_service_client/core/ui/rs_canvas_node.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef RENDER_SERVICE_CLIENT_CORE_UI_RS_CANVAS_NODE_H -#define RENDER_SERVICE_CLIENT_CORE_UI_RS_CANVAS_NODE_H - -#include "ui/rs_node.h" - -class SkCanvas; - -namespace OHOS { -namespace Rosen { -class RSNodeMap; - -class RSC_EXPORT RSCanvasNode : public RSNode { -public: - using WeakPtr = std::weak_ptr; - using SharedPtr = std::shared_ptr; - static inline constexpr RSUINodeType Type = RSUINodeType::CANVAS_NODE; - RSUINodeType GetType() const override - { - return Type; - } - - ~RSCanvasNode() override; - - static SharedPtr Create(bool isRenderServiceNode = false); - - SkCanvas* BeginRecording(int width, int height); - bool IsRecording() const; - void FinishRecording(); - float GetPaintWidth() const; - float GetPaintHeight() const; - void DrawOnNode(RSModifierType type, DrawFunc func) override; - -protected: - RSCanvasNode(bool isRenderServiceNode); - RSCanvasNode(const RSCanvasNode&) = delete; - RSCanvasNode(const RSCanvasNode&&) = delete; - RSCanvasNode& operator=(const RSCanvasNode&) = delete; - RSCanvasNode& operator=(const RSCanvasNode&&) = delete; - -private: - SkCanvas* recordingCanvas_ = nullptr; - - friend class RSUIDirector; - friend class RSAnimation; - friend class RSPathAnimation; - friend class RSPropertyAnimation; - friend class RSNodeMap; -}; -} // namespace Rosen -} // namespace OHOS - -#endif // RENDER_SERVICE_CLIENT_CORE_UI_RS_CANVAS_NODE_H diff --git a/export/render_service_client/core/ui/rs_display_node.h b/export/render_service_client/core/ui/rs_display_node.h deleted file mode 100644 index afb0e45ed4c3e459b53aa55fab4e100298e66b95..0000000000000000000000000000000000000000 --- a/export/render_service_client/core/ui/rs_display_node.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef RENDER_SERVICE_CLIENT_CORE_UI_RS_DISPLAY_NODE_H -#define RENDER_SERVICE_CLIENT_CORE_UI_RS_DISPLAY_NODE_H - -#include "ui/rs_node.h" - -class SkCanvas; -namespace OHOS { -namespace Rosen { - -class RSC_EXPORT RSDisplayNode : public RSNode { -public: - using WeakPtr = std::weak_ptr; - using SharedPtr = std::shared_ptr; - static inline constexpr RSUINodeType Type = RSUINodeType::DISPLAY_NODE; - RSUINodeType GetType() const override - { - return Type; - } - - ~RSDisplayNode() override; - - static SharedPtr Create(const RSDisplayNodeConfig& displayNodeConfig); - - void SetScreenId(uint64_t screenId); - - void SetDisplayOffset(int32_t offsetX, int32_t offsetY); - - void SetSecurityDisplay(bool isSecurityDisplay); - - void SetDisplayNodeMirrorConfig(const RSDisplayNodeConfig& displayNodeConfig); - - bool GetSecurityDisplay() const; - - bool IsMirrorDisplay() const; - -protected: - explicit RSDisplayNode(const RSDisplayNodeConfig& config); - RSDisplayNode(const RSDisplayNode&) = delete; - RSDisplayNode(const RSDisplayNode&&) = delete; - RSDisplayNode& operator=(const RSDisplayNode&) = delete; - RSDisplayNode& operator=(const RSDisplayNode&&) = delete; - -private: - uint64_t screenId_; - int32_t offsetX_; - int32_t offsetY_; - bool isSecurityDisplay_ = false; - bool isMirroredDisplay_ = false; -}; -} // namespace Rosen -} // namespace OHOS - -#endif // RENDER_SERVICE_CLIENT_CORE_UI_RS_DISPLAY_NODE_H diff --git a/export/render_service_client/core/ui/rs_node.h b/export/render_service_client/core/ui/rs_node.h deleted file mode 100644 index ddf42b90795eb8eb10f7d6c17e3bc6ad50396c44..0000000000000000000000000000000000000000 --- a/export/render_service_client/core/ui/rs_node.h +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef RENDER_SERVICE_CLIENT_CORE_UI_RS_NODE_H -#define RENDER_SERVICE_CLIENT_CORE_UI_RS_NODE_H - -#include - -#include "animation/rs_animation_timing_curve.h" -#include "animation/rs_animation_timing_protocol.h" -#include "animation/rs_motion_path_option.h" -#include "animation/rs_transition_effect.h" -#include "common/rs_vector2.h" -#include "common/rs_vector4.h" -#include "modifier/rs_modifier_extractor.h" -#include "modifier/rs_modifier_type.h" -#include "pipeline/rs_recording_canvas.h" -#include "property/rs_properties.h" -#include "render/rs_mask.h" -#include "render/rs_path.h" -#include "ui/rs_base_node.h" - -class SkCanvas; - -namespace OHOS { -namespace Rosen { -using DrawFunc = std::function)>; -using PropertyCallback = std::function; -class RSAnimation; -class RSCommand; -class RSImplicitAnimParam; -class RSImplicitAnimator; -class RSUIAnimationManager; -class RSModifier; - -class RSC_EXPORT RSNode : public RSBaseNode { -public: - using WeakPtr = std::weak_ptr; - using SharedPtr = std::shared_ptr; - static inline constexpr RSUINodeType Type = RSUINodeType::RS_NODE; - RSUINodeType GetType() const override - { - return Type; - } - - ~RSNode() override; - std::string DumpNode(int depth) const override; - - static std::vector> Animate(const RSAnimationTimingProtocol& timingProtocol, - const RSAnimationTimingCurve& timingCurve, const PropertyCallback& callback, - const std::function& finishCallback = nullptr); - static void OpenImplicitAnimation(const RSAnimationTimingProtocol& timingProtocol, - const RSAnimationTimingCurve& timingCurve, const std::function& finishCallback = nullptr); - static std::vector> CloseImplicitAnimation(); - static void AddKeyFrame( - float fraction, const RSAnimationTimingCurve& timingCurve, const PropertyCallback& callback); - static void AddKeyFrame(float fraction, const PropertyCallback& callback); - - void NotifyTransition(const std::shared_ptr& effect, bool isTransitionIn); - - void AddAnimation(const std::shared_ptr& animation); - void RemoveAllAnimations(); - void RemoveAnimation(const std::shared_ptr& animation); - void SetMotionPathOption(const std::shared_ptr& motionPathOption); - const std::shared_ptr GetMotionPathOption() const; - - virtual void DrawOnNode(RSModifierType type, DrawFunc func) {} // [PLANNING]: support SurfaceNode - - const RSModifierExtractor& GetStagingProperties() const; - - template - void SetProperty(RSModifierType modifierType, T value); - - virtual void SetBounds(const Vector4f& bounds); - virtual void SetBounds(float positionX, float positionY, float width, float height); - virtual void SetBoundsWidth(float width); - virtual void SetBoundsHeight(float height); - - virtual void SetFrame(const Vector4f& frame); - virtual void SetFrame(float positionX, float positionY, float width, float height); - virtual void SetFramePositionX(float positionX); - virtual void SetFramePositionY(float positionY); - - void SetPositionZ(float positionZ); - - void SetPivot(const Vector2f& pivot); - void SetPivot(float pivotX, float pivotY); - void SetPivotX(float pivotX); - void SetPivotY(float pivotY); - - void SetCornerRadius(float cornerRadius); - void SetCornerRadius(const Vector4f& cornerRadius); - - void SetRotation(const Quaternion& quaternion); - void SetRotation(float degreeX, float degreeY, float degreeZ); - void SetRotation(float degree); - void SetRotationX(float degree); - void SetRotationY(float degree); - - void SetTranslate(const Vector2f& translate); - void SetTranslate(float translateX, float translateY, float translateZ); - void SetTranslateX(float translate); - void SetTranslateY(float translate); - void SetTranslateZ(float translate); - - void SetScale(float scale); - void SetScale(float scaleX, float scaleY); - void SetScale(const Vector2f& scale); - void SetScaleX(float scaleX); - void SetScaleY(float scaleY); - - void SetAlpha(float alpha); - void SetAlphaOffscreen(bool alphaOffscreen); - - void SetForegroundColor(uint32_t colorValue); - void SetBackgroundColor(uint32_t colorValue); - void SetBackgroundShader(const std::shared_ptr& shader); - - void SetBgImage(const std::shared_ptr& image); - void SetBgImageSize(float width, float height); - void SetBgImageWidth(float width); - void SetBgImageHeight(float height); - void SetBgImagePosition(float positionX, float positionY); - void SetBgImagePositionX(float positionX); - void SetBgImagePositionY(float positionY); - - void SetBorderColor(uint32_t colorValue); - void SetBorderColor(uint32_t left, uint32_t top, uint32_t right, uint32_t bottom); - void SetBorderColor(const Vector4& color); - void SetBorderWidth(float width); - void SetBorderWidth(float left, float top, float right, float bottom); - void SetBorderWidth(const Vector4f& width); - void SetBorderStyle(uint32_t styleValue); - void SetBorderStyle(uint32_t left, uint32_t top, uint32_t right, uint32_t bottom); - void SetBorderStyle(const Vector4& style); - - void SetBackgroundFilter(const std::shared_ptr& backgroundFilter); - void SetFilter(const std::shared_ptr& filter); - void SetCompositingFilter(const std::shared_ptr& compositingFilter); - - void SetShadowColor(uint32_t colorValue); - void SetShadowOffset(float offsetX, float offsetY); - void SetShadowOffsetX(float offsetX); - void SetShadowOffsetY(float offsetY); - void SetShadowAlpha(float alpha); - void SetShadowElevation(float elevation); - void SetShadowRadius(float radius); - void SetShadowPath(const std::shared_ptr& shadowPath); - - void SetFrameGravity(Gravity gravity); - - void SetClipBounds(const std::shared_ptr& clipToBounds); - void SetClipToBounds(bool clipToBounds); - void SetClipToFrame(bool clipToFrame); - - void SetVisible(bool visible); - void SetMask(const std::shared_ptr& mask); - - void SetPaintOrder(bool drawContentLast); - - void SetTransitionEffect(const std::shared_ptr& effect) - { - transitionEffect_ = effect; - } - - void AddModifier(const std::shared_ptr modifier); - void RemoveModifier(const std::shared_ptr modifier); - -protected: - explicit RSNode(bool isRenderServiceNode); - explicit RSNode(bool isRenderServiceNode, NodeId id); - RSNode(const RSNode&) = delete; - RSNode(const RSNode&&) = delete; - RSNode& operator=(const RSNode&) = delete; - RSNode& operator=(const RSNode&&) = delete; - - bool drawContentLast_ = false; - - void OnAddChildren() override; - void OnRemoveChildren() override; - - virtual bool NeedForcedSendToRemote() const - { - return false; - } - - std::vector GetModifierIds() const; - -private: - bool AnimationFinish(AnimationId animationId); - bool HasPropertyAnimation(const PropertyId& id); - void FallbackAnimationsToRoot(); - void AddAnimationInner(const std::shared_ptr& animation); - void RemoveAnimationInner(const std::shared_ptr& animation); - void FinishAnimationByProperty(const PropertyId& id); - const std::shared_ptr GetModifier(const PropertyId& propertyId); - virtual void OnBoundsSizeChanged() const {}; - void UpdateModifierMotionPathOption(); - void UpdateExtendedModifier(const std::weak_ptr& modifier); - - // Planning: refactor RSUIAnimationManager and remove this method - void ClearAllModifiers(); - - std::unordered_map> animations_; - std::unordered_map animatingPropertyNum_; - std::unordered_map> modifiers_; - std::unordered_map> propertyModifiers_; - std::shared_ptr motionPathOption_; - - void UpdateImplicitAnimator(); - pid_t implicitAnimatorTid_ = 0; - std::shared_ptr implicitAnimator_; - std::shared_ptr transitionEffect_; - - RSModifierExtractor stagingPropertiesExtractor_; - - friend class RSAnimation; - friend class RSCurveAnimation; - friend class RSKeyframeAnimation; - friend class RSPropertyAnimation; - friend class RSSpringAnimation; - template - friend class RSProperty; - template - friend class RSAnimatableProperty; - friend class RSPathAnimation; - friend class RSExtendedModifier; - friend class RSTransition; - friend class RSUIDirector; - friend class RSImplicitAnimator; - friend class RSModifierExtractor; -}; -} // namespace Rosen -} // namespace OHOS - -#endif // RENDER_SERVICE_CLIENT_CORE_UI_RS_NODE_H diff --git a/export/render_service_client/core/ui/rs_root_node.h b/export/render_service_client/core/ui/rs_root_node.h deleted file mode 100644 index 165088282d503c500da5dd6e686240fc24594365..0000000000000000000000000000000000000000 --- a/export/render_service_client/core/ui/rs_root_node.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef RENDER_SERVICE_CLIENT_CORE_UI_RS_ROOT_NODE_H -#define RENDER_SERVICE_CLIENT_CORE_UI_RS_ROOT_NODE_H - -#include "ui/rs_canvas_node.h" - -namespace OHOS { -namespace Rosen { -class RSSurfaceNode; -class RSC_EXPORT RSRootNode : public RSCanvasNode { -public: - using WeakPtr = std::weak_ptr; - using SharedPtr = std::shared_ptr; - static inline constexpr RSUINodeType Type = RSUINodeType::ROOT_NODE; - RSUINodeType GetType() const override - { - return Type; - } - - ~RSRootNode() override = default; - - static std::shared_ptr Create(bool isRenderServiceNode = false); - -protected: - void AttachRSSurfaceNode(std::shared_ptr surfaceNode) const; - void SetEnableRender(bool flag) const; - void OnBoundsSizeChanged() const override; - - explicit RSRootNode(bool isRenderServiceNode); - RSRootNode(const RSRootNode&) = delete; - RSRootNode(const RSRootNode&&) = delete; - RSRootNode& operator=(const RSRootNode&) = delete; - RSRootNode& operator=(const RSRootNode&&) = delete; - - friend class RSUIDirector; -}; -} // namespace Rosen -} // namespace OHOS - -#endif // RENDER_SERVICE_CLIENT_CORE_UI_RS_ROOT_NODE_H \ No newline at end of file diff --git a/export/render_service_client/core/ui/rs_surface_node.h b/export/render_service_client/core/ui/rs_surface_node.h deleted file mode 100644 index 171bacb612bd12c10b30e80fa929a213c193f280..0000000000000000000000000000000000000000 --- a/export/render_service_client/core/ui/rs_surface_node.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef RENDER_SERVICE_CLIENT_CORE_UI_RS_SURFACE_NODE_H -#define RENDER_SERVICE_CLIENT_CORE_UI_RS_SURFACE_NODE_H - -#include -#include -#include - -#include "surface.h" -#include "surface_delegate.h" -#include "surface_type.h" - -#include "platform/drawing/rs_surface.h" -#include "transaction/rs_transaction_proxy.h" -#include "ui/rs_node.h" - -class SkCanvas; - -namespace OHOS { -namespace Rosen { - -using BufferAvailableCallback = std::function; -struct RSSurfaceNodeConfig { - std::string SurfaceNodeName = "SurfaceNode"; - UseSurfaceToRenderFunc onRender = nullptr; -}; - -class RSC_EXPORT RSSurfaceNode : public RSNode { -public: - using WeakPtr = std::weak_ptr; - using SharedPtr = std::shared_ptr; - static inline constexpr RSUINodeType Type = RSUINodeType::SURFACE_NODE; - RSUINodeType GetType() const override - { - return Type; - } - - ~RSSurfaceNode() override; - - static SharedPtr Create(const RSSurfaceNodeConfig& surfaceNodeConfig, bool isWindow = true); - - // This interface is only available for WMS - static SharedPtr Create(const RSSurfaceNodeConfig& surfaceNodeConfig, RSSurfaceNodeType type, bool isWindow = true); - - // This API is only for abilityView create RSRenderSurfaceNode in RenderThread. - // Do not call this API unless you are sure what you do. - // After calling it, this surfaceNode is disallowed to add/remove child. - void CreateNodeInRenderThread(); - - void AddChild(std::shared_ptr child, int index) override; - void RemoveChild(std::shared_ptr child) override; - void ClearChildren() override; - - void SetSecurityLayer(bool isSecurityLayer); - bool GetSecurityLayer() const; - void SetAbilityBGAlpha(uint8_t alpha); - void SetIsNotifyUIBufferAvailable(bool available); - - bool SetBufferAvailableCallback(BufferAvailableCallback callback); - void SetAnimationFinished(); - - bool Marshalling(Parcel& parcel) const; - static SharedPtr Unmarshalling(Parcel& parcel); - // Create RSProxyNode by unmarshalling RSSurfaceNode, return existing node if it exists in RSNodeMap. - static RSNode::SharedPtr UnmarshallingAsProxyNode(Parcel& parcel); - - FollowType GetFollowType() const override; - -#ifndef ROSEN_CROSS_PLATFORM - sptr GetSurface() const; - - void SetColorSpace(ColorGamut colorSpace); - ColorGamut GetColorSpace() - { - return colorSpace_; - } -#endif - std::string GetName() const - { - return name_; - } - - void ResetContextAlpha() const; - - void SetAppFreeze(bool isAppFreeze); - void SetContainerWindow(bool hasContainerWindow, float density); - void SetWindowId(uint32_t windowId); - -protected: - bool NeedForcedSendToRemote() const override; - RSSurfaceNode(const RSSurfaceNodeConfig& config, bool isRenderServiceNode); - RSSurfaceNode(const RSSurfaceNodeConfig& config, bool isRenderServiceNode, NodeId id); - RSSurfaceNode(const RSSurfaceNode&) = delete; - RSSurfaceNode(const RSSurfaceNode&&) = delete; - RSSurfaceNode& operator=(const RSSurfaceNode&) = delete; - RSSurfaceNode& operator=(const RSSurfaceNode&&) = delete; - -private: - bool CreateNode(const RSSurfaceRenderNodeConfig& config); - bool CreateNodeAndSurface(const RSSurfaceRenderNodeConfig& config); - void OnBoundsSizeChanged() const override; - std::shared_ptr surface_; - std::string name_; - std::mutex mutex_; - BufferAvailableCallback callback_; -#ifndef ROSEN_CROSS_PLATFORM - ColorGamut colorSpace_ = ColorGamut::COLOR_GAMUT_SRGB; -#endif - bool isSecurityLayer_ = false; - bool isChildOperationDisallowed_ { false }; - - uint32_t windowId_; -#ifndef ROSEN_CROSS_PLATFORM - sptr surfaceDelegate_; - sptr surfaceCallback_; -#endif - - friend class RSUIDirector; - friend class RSAnimation; - friend class RSPathAnimation; - friend class RSPropertyAnimation; - friend class RSSurfaceExtractor; - friend class RSSurfaceCallback; -}; -} // namespace Rosen -} // namespace OHOS - -#endif // RENDER_SERVICE_CLIENT_CORE_UI_RS_SURFACE_NODE_H diff --git a/export/render_service_client/core/ui/rs_ui_director.h b/export/render_service_client/core/ui/rs_ui_director.h deleted file mode 100644 index c62f718cfa156f4c6f9ecd9e8a52c1e7963e9f61..0000000000000000000000000000000000000000 --- a/export/render_service_client/core/ui/rs_ui_director.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef RENDER_SERVICE_CLIENT_CORE_UI_RS_UI_DIRECTOR_H -#define RENDER_SERVICE_CLIENT_CORE_UI_RS_UI_DIRECTOR_H - -#include -#include -#include - -#include "common/rs_common_def.h" - -namespace OHOS { -class Surface; -namespace Rosen { -class RSSurfaceNode; -class RSTransactionData; -using TaskRunner = std::function&)>; - -class RSC_EXPORT RSUIDirector final { -public: - static std::shared_ptr Create(); - - ~RSUIDirector(); - void GoBackground(); - void GoForeground(); - void Init(bool shouldCreateRenderThread = true); - void Destroy(); - void SetRSSurfaceNode(std::shared_ptr surfaceNode); - void SetAbilityBGAlpha(uint8_t alpha); - /** - * @brief Set rt render status and keep it till set again - * - * @param isRenderForced if true, rt will reject partial render and be forced to render all frames - */ - void SetRTRenderForced(bool isRenderForced); - void SetContainerWindow(bool hasContainerWindow, float density); - - void SetRoot(NodeId root); - void SetUITaskRunner(const TaskRunner& uiTaskRunner); - void SendMessages(); // post messages to render thread - - void SetTimeStamp(uint64_t timeStamp, const std::string& abilityName); - void SetCacheDir(const std::string& cacheFilePath); - - bool RunningCustomAnimation(uint64_t timeStamp); - - void SetAppFreeze(bool isAppFreeze); - -private: - void AttachSurface(); - static void RecvMessages(bool needProcess = true); - static void RecvMessages(std::shared_ptr cmds); - static void ProcessMessages(std::shared_ptr cmds); // receive message - static void AnimationCallbackProcessor(NodeId nodeId, AnimationId animId); - - RSUIDirector() = default; - RSUIDirector(const RSUIDirector&) = delete; - RSUIDirector(const RSUIDirector&&) = delete; - RSUIDirector& operator=(const RSUIDirector&) = delete; - RSUIDirector& operator=(const RSUIDirector&&) = delete; - - std::mutex mutex_; - NodeId root_ = 0; - - bool isActive_ = false; - uint64_t refreshPeriod_ = 16666667; - uint64_t timeStamp_ = 0; - std::string abilityName_; - std::weak_ptr surfaceNode_; - int surfaceWidth_ = 0; - int surfaceHeight_ = 0; - std::string cacheDir_; - - friend class RSRenderThread; - friend class RSApplicationAgentImpl; -}; -} // namespace Rosen -} // namespace OHOS - -#endif // RENDER_SERVICE_CLIENT_CORE_UI_RS_UI_DIRECTOR_H diff --git a/export/surface/buffer_extra_data.h b/export/surface/buffer_extra_data.h deleted file mode 100644 index 19001df1a56f05d6851fdc3ee399705fdfcaeb29..0000000000000000000000000000000000000000 --- a/export/surface/buffer_extra_data.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2021 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 INTERFACES_INNERKITS_SURFACE_BUFFER_EXTRA_DATA_H -#define INTERFACES_INNERKITS_SURFACE_BUFFER_EXTRA_DATA_H - -#include - -#include -#include "surface_type.h" - -namespace OHOS { -class MessageParcel; -class BufferExtraData : public RefBase { -public: - virtual GSError ReadFromParcel(MessageParcel &parcel) = 0; - virtual GSError WriteToParcel(MessageParcel &parcel) = 0; - virtual GSError ExtraGet(const std::string &key, int32_t &value) const = 0; - virtual GSError ExtraGet(const std::string &key, int64_t &value) const = 0; - virtual GSError ExtraGet(const std::string &key, double &value) const = 0; - virtual GSError ExtraGet(const std::string &key, std::string &value) const = 0; - virtual GSError ExtraSet(const std::string &key, int32_t value) = 0; - virtual GSError ExtraSet(const std::string &key, int64_t value) = 0; - virtual GSError ExtraSet(const std::string &key, double value) = 0; - virtual GSError ExtraSet(const std::string &key, const std::string& value) = 0; -}; -} // namespace OHOS - -#endif // INTERFACES_INNERKITS_SURFACE_BUFFER_EXTRA_DATA_H diff --git a/export/surface/egl_data.h b/export/surface/egl_data.h deleted file mode 100644 index a5290e79f0528b94cbd0bd36f55caf6c93a737f9..0000000000000000000000000000000000000000 --- a/export/surface/egl_data.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2021 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 INTERFACES_INNERKITS_SURFACE_EGL_DATA_H -#define INTERFACES_INNERKITS_SURFACE_EGL_DATA_H - -#include - -namespace OHOS { -class EglData : public RefBase { -public: - virtual ~EglData() = default; - - virtual uint32_t GetFrameBufferObj() const = 0; - virtual uint32_t GetTexture() const = 0; -}; -} // namespace OHOS - -#endif // INTERFACES_INNERKITS_SURFACE_EGL_DATA_H diff --git a/export/surface/ibuffer_consumer_listener.h b/export/surface/ibuffer_consumer_listener.h deleted file mode 100644 index fd1e7dec608f03050cc493f978550794f6abc2bb..0000000000000000000000000000000000000000 --- a/export/surface/ibuffer_consumer_listener.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2021 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 INTERFACES_INNERKITS_SURFACE_IBUFFER_CONSUMER_LISTENER_H -#define INTERFACES_INNERKITS_SURFACE_IBUFFER_CONSUMER_LISTENER_H - -#include -#include "surface_type.h" - -namespace OHOS { -class IBufferConsumerListener : public RefBase { -public: - virtual ~IBufferConsumerListener() = default; - virtual void OnBufferAvailable() = 0; - virtual void OnTunnelHandleChange() {}; - virtual void OnGoBackground() {}; - virtual void OnCleanCache() {}; -}; - -class IBufferConsumerListenerClazz { -public: - virtual ~IBufferConsumerListenerClazz() = default; - virtual void OnBufferAvailable() = 0; - virtual void OnTunnelHandleChange() {}; - virtual void OnGoBackground() {}; - virtual void OnCleanCache() {}; -}; -} // namespace OHOS - -#endif // INTERFACES_INNERKITS_SURFACE_IBUFFER_CONSUMER_LISTENER_H diff --git a/export/surface/ibuffer_producer.h b/export/surface/ibuffer_producer.h deleted file mode 100644 index 8da64a08d5922f7c3796289cfe6ad8a8da162b3f..0000000000000000000000000000000000000000 --- a/export/surface/ibuffer_producer.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2021 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 INTERFACES_INNERKITS_SURFACE_IBUFFER_PRODUCER_H -#define INTERFACES_INNERKITS_SURFACE_IBUFFER_PRODUCER_H - -#include -#include - -#include "iremote_broker.h" - -#include "buffer_extra_data.h" -#include "native_surface.h" -#include "surface_buffer.h" -#include "surface_type.h" - -namespace OHOS { -class SyncFence; -class IBufferProducer : public IRemoteBroker { -public: - struct RequestBufferReturnValue { - uint32_t sequence; - sptr buffer; - sptr fence; - std::vector deletingBuffers; - }; - virtual GSError RequestBuffer(const BufferRequestConfig &config, sptr &bedata, - RequestBufferReturnValue &retval) = 0; - - virtual GSError CancelBuffer(uint32_t sequence, const sptr &bedata) = 0; - - virtual GSError FlushBuffer(uint32_t sequence, const sptr &bedata, - const sptr& fence, BufferFlushConfig &config) = 0; - - virtual GSError AttachBuffer(sptr& buffer) = 0; - virtual GSError DetachBuffer(sptr& buffer) = 0; - - virtual uint32_t GetQueueSize() = 0; - virtual GSError SetQueueSize(uint32_t queueSize) = 0; - - virtual GSError GetName(std::string &name) = 0; - virtual uint64_t GetUniqueId() = 0; - virtual GSError GetNameAndUniqueId(std::string& name, uint64_t& uniqueId) = 0; - - virtual int32_t GetDefaultWidth() = 0; - virtual int32_t GetDefaultHeight() = 0; - virtual uint32_t GetDefaultUsage() = 0; - - virtual GSError CleanCache() = 0; - virtual GSError GoBackground() = 0; - - virtual GSError RegisterReleaseListener(OnReleaseFunc func) = 0; - - virtual GSError SetTransform(GraphicTransformType transform) = 0; - - virtual GSError IsSupportedAlloc(const std::vector &infos, - std::vector &supporteds) = 0; - - virtual GSError Disconnect() = 0; - - virtual GSError SetScalingMode(uint32_t sequence, ScalingMode scalingMode) = 0; - virtual GSError SetMetaData(uint32_t sequence, const std::vector &metaData) = 0; - virtual GSError SetMetaDataSet(uint32_t sequence, GraphicHDRMetadataKey key, - const std::vector &metaData) = 0; - virtual GSError SetTunnelHandle(const GraphicExtDataHandle *handle) = 0; - virtual GSError GetPresentTimestamp(uint32_t sequence, GraphicPresentTimestampType type, int64_t &time) = 0; - - virtual sptr GetNativeSurface() = 0; - - DECLARE_INTERFACE_DESCRIPTOR(u"surf.IBufferProducer"); - -protected: - enum { - BUFFER_PRODUCER_REQUEST_BUFFER = 0, - BUFFER_PRODUCER_CANCEL_BUFFER = 1, - BUFFER_PRODUCER_FLUSH_BUFFER = 2, - BUFFER_PRODUCER_GET_QUEUE_SIZE = 3, - BUFFER_PRODUCER_SET_QUEUE_SIZE = 4, - BUFFER_PRODUCER_GET_NAME = 5, - BUFFER_PRODUCER_GET_DEFAULT_WIDTH = 6, - BUFFER_PRODUCER_GET_DEFAULT_HEIGHT = 7, - BUFFER_PRODUCER_GET_DEFAULT_USAGE = 8, - BUFFER_PRODUCER_CLEAN_CACHE = 9, - BUFFER_PRODUCER_ATTACH_BUFFER = 10, - BUFFER_PRODUCER_DETACH_BUFFER = 11, - BUFFER_PRODUCER_REGISTER_RELEASE_LISTENER = 12, - BUFFER_PRODUCER_GET_UNIQUE_ID = 13, - BUFFER_PRODUCER_SET_TRANSFORM = 14, - BUFFER_PRODUCER_IS_SUPPORTED_ALLOC = 15, - BUFFER_PRODUCER_GET_NAMEANDUNIQUEDID = 16, - BUFFER_PRODUCER_DISCONNECT = 17, - BUFFER_PRODUCER_SET_SCALING_MODE = 18, - BUFFER_PRODUCER_SET_METADATA = 19, - BUFFER_PRODUCER_SET_METADATASET = 20, - BUFFER_PRODUCER_SET_TUNNEL_HANDLE = 21, - BUFFER_PRODUCER_GO_BACKGROUND = 22, - BUFFER_PRODUCER_GET_PRESENT_TIMESTAMP = 23, - }; -}; -} // namespace OHOS - -#endif // INTERFACES_INNERKITS_SURFACE_IBUFFER_PRODUCER_H diff --git a/export/surface/native_buffer.h b/export/surface/native_buffer.h deleted file mode 100644 index 9d746579ee108fb7b271f1eddebb464721b50871..0000000000000000000000000000000000000000 --- a/export/surface/native_buffer.h +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) 2022 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 NDK_INCLUDE_NATIVE_BUFFER_H_ -#define NDK_INCLUDE_NATIVE_BUFFER_H_ - -/** - * @addtogroup OH_NativeBuffer - * @{ - * - * @brief Provides the native buffer capability. - * - * @syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer - * @since 9 - * @version 1.0 - */ - -/** - * @file native_buffer.h - * - * @brief Defines the functions for obtaining and using a native buffer. - * - * @since 9 - * @version 1.0 - */ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -struct OH_NativeBuffer; -typedef struct OH_NativeBuffer OH_NativeBuffer; - -/** - * @brief OH_NativeBuffer config. \n - * Used to allocating new OH_NativeBuffer andquery parameters if existing ones. - * - * @syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer - * @since 9 - * @version 1.0 - */ -typedef struct { - int32_t width; ///< Width in pixels - int32_t height; ///< Height in pixels - int32_t format; ///< One of PixelFormat - int32_t usage; ///< Combination of buffer usage -} OH_NativeBuffer_Config; - -/** - * @brief Alloc a OH_NativeBuffer that matches the passed BufferRequestConfig. \n - * A new OH_NativeBuffer instance is created each time this function is called. - * - * @syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer - * @param config Indicates the pointer to a BufferRequestConfig instance. - * @return Returns the pointer to the OH_NativeBuffer instance created if the operation is successful, \n - * returns NULL otherwise. - * @since 9 - * @version 1.0 - */ -OH_NativeBuffer* OH_NativeBuffer_Alloc(const OH_NativeBuffer_Config* config); - -/** - * @brief Adds the reference count of a OH_NativeBuffer. - * - * @syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer - * @param buffer Indicates the pointer to a OH_NativeBuffer instance. - * @return Returns an error code defined in GSError. - * @since 9 - * @version 1.0 - */ -int32_t OH_NativeBuffer_Reference(OH_NativeBuffer *buffer); - -/** - * @brief Decreases the reference count of a OH_NativeBuffer and, when the reference count reaches 0, \n - * destroys this OH_NativeBuffer. - * - * @syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer - * @param buffer Indicates the pointer to a OH_NativeBuffer instance. - * @return Returns an error code defined in GSError. - * @since 9 - * @version 1.0 - */ -int32_t OH_NativeBuffer_Unreference(OH_NativeBuffer *buffer); - -/** - * @brief Return a config of the OH_NativeBuffer in the passed OHNativeBufferConfig struct. - * - * @syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer - * @param buffer Indicates the pointer to a OH_NativeBuffer instance. - * @param config Indicates the pointer to the NativeBufferConfig of the buffer. - * @return Returns the pointer to the BufferRequestConfig instance if the operation is successful, \n - * returns NULL otherwise. - * @since 9 - * @version 1.0 - */ -void OH_NativeBuffer_GetConfig(OH_NativeBuffer *buffer, OH_NativeBuffer_Config* config); - -/** - * @brief Provide direct cpu access to the OH_NativeBuffer in the process's address space. - * - * @syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer - * @param buffer Indicates the pointer to a OH_NativeBuffer instance. - * @param virAddr Indicates the address of the OH_NativeBuffer in virtual memory. - * @return Returns an error code defined in GSError. - * @since 9 - * @version 1.0 - */ - -int32_t OH_NativeBuffer_Map(OH_NativeBuffer *buffer, void **virAddr); - -/** - * @brief Remove direct cpu access ability of the OH_NativeBuffer in the process's address space. - * - * @syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer - * @param buffer Indicates the pointer to a OH_NativeBuffer instance. - * @return Returns an error code defined in GSError. - * @since 9 - * @version 1.0 - */ -int32_t OH_NativeBuffer_Unmap(OH_NativeBuffer *buffer); - -/** - * @brief Get the systen wide unique sequence number of the OH_NativeBuffer. - * - * @syscap SystemCapability.Graphic.Graphic2D.OH_NativeBuffer - * @param buffer Indicates the pointer to a OH_NativeBuffer instance. - * @return Returns the sequence number, which is unique for each OH_NativeBuffer. - * @since 9 - * @version 1.0 - */ -uint32_t OH_NativeBuffer_GetSeqNum(OH_NativeBuffer *buffer); - -#ifdef __cplusplus -} -#endif - -/** @} */ -#endif \ No newline at end of file diff --git a/export/surface/native_surface.h b/export/surface/native_surface.h deleted file mode 100644 index 4ee1d23c4b1711f48de4798dd250fd87cc7ace1a..0000000000000000000000000000000000000000 --- a/export/surface/native_surface.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2022 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 INTERFACES_INNERKITS_SURFACE_NATIVE_SURFACE_H -#define INTERFACES_INNERKITS_SURFACE_NATIVE_SURFACE_H - -#include -#include - -namespace OHOS { -class NativeSurface : public RefBase { - friend class SurfaceDelegate; - -public: - /* - * Constructor of native surface. - */ - NativeSurface(); - - /* - * Destructor of native surface. - */ - ~NativeSurface(); - - /* - * Get compat native window. - * - * @return native window. - */ - void* GetNativeWindow(); - - /* - * Get compat native window(for compatbility). - * - * @return native window. - */ - void* Get(); - -private: - /* - * Callback when the compat native window is created. - * - * @param nativeWindow the native window. - */ - void OnNativeWindowCreated(void* nativeWindow); - - /* - * Callback when the compat native window is destroyed. - */ - void OnNativeWindowDestroyed(); - - /* - * Release native window. - */ - void ReleaseNativeWindow(); - - void* nativeWindow_ = nullptr; - - std::condition_variable condVar_; - - std::mutex mutex_; -}; -} // namespace OHOS -#endif // INTERFACES_INNERKITS_SURFACE_NATIVE_SURFACE_H \ No newline at end of file diff --git a/export/surface/surface.h b/export/surface/surface.h deleted file mode 100644 index 48408608c8461955e1168c3948f8e9385a167dbe..0000000000000000000000000000000000000000 --- a/export/surface/surface.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2021 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 INTERFACES_INNERKITS_SURFACE_SURFACE_H -#define INTERFACES_INNERKITS_SURFACE_SURFACE_H - -#include - -#include "ibuffer_consumer_listener.h" -#include "ibuffer_producer.h" -#include "surface_buffer.h" -#include "surface_type.h" -#include "surface_tunnel_handle.h" - -namespace OHOS { -class Surface : public RefBase { -public: - static sptr CreateSurfaceAsConsumer(std::string name = "noname", bool isShared = false); - static sptr CreateSurfaceAsProducer(sptr& producer); - - virtual ~Surface() = default; - - virtual bool IsConsumer() const = 0; - virtual sptr GetProducer() const = 0; - - virtual GSError RequestBuffer(sptr& buffer, - int32_t &fence, BufferRequestConfig &config) = 0; - - virtual GSError CancelBuffer(sptr& buffer) = 0; - - virtual GSError FlushBuffer(sptr& buffer, - int32_t fence, BufferFlushConfig &config) = 0; - - virtual GSError AcquireBuffer(sptr& buffer, int32_t &fence, - int64_t ×tamp, Rect &damage) = 0; - virtual GSError ReleaseBuffer(sptr& buffer, int32_t fence) = 0; - - virtual GSError RequestBuffer(sptr& buffer, - sptr& fence, BufferRequestConfig &config) = 0; - virtual GSError FlushBuffer(sptr& buffer, - const sptr& fence, BufferFlushConfig &config) = 0; - virtual GSError AcquireBuffer(sptr& buffer, sptr& fence, - int64_t ×tamp, Rect &damage) = 0; - virtual GSError ReleaseBuffer(sptr& buffer, const sptr& fence) = 0; - - virtual GSError AttachBuffer(sptr& buffer) = 0; - - virtual GSError DetachBuffer(sptr& buffer) = 0; - - virtual uint32_t GetQueueSize() = 0; - virtual GSError SetQueueSize(uint32_t queueSize) = 0; - - virtual GSError SetDefaultWidthAndHeight(int32_t width, int32_t height) = 0; - virtual int32_t GetDefaultWidth() = 0; - virtual int32_t GetDefaultHeight() = 0; - - virtual GSError SetDefaultUsage(uint32_t usage) = 0; - virtual uint32_t GetDefaultUsage() = 0; - - virtual GSError SetUserData(const std::string &key, const std::string &val) = 0; - virtual std::string GetUserData(const std::string &key) = 0; - - virtual const std::string& GetName() = 0; - virtual uint64_t GetUniqueId() const = 0; - - virtual GSError RegisterConsumerListener(sptr& listener) = 0; - virtual GSError RegisterConsumerListener(IBufferConsumerListenerClazz *listener) = 0; - virtual GSError RegisterReleaseListener(OnReleaseFunc func) = 0; - virtual GSError RegisterDeleteBufferListener(OnDeleteBufferFunc func) = 0; - virtual GSError UnregisterConsumerListener() = 0; - - // Call carefully. This interface will empty all caches of the current process - virtual GSError CleanCache() = 0; - virtual GSError GoBackground() = 0; - - virtual GSError SetTransform(GraphicTransformType transform) = 0; - virtual GraphicTransformType GetTransform() const = 0; - - virtual GSError IsSupportedAlloc(const std::vector &infos, - std::vector &supporteds) = 0; - virtual GSError Disconnect() = 0; - virtual GSError SetScalingMode(uint32_t sequence, ScalingMode scalingMode) = 0; - virtual GSError GetScalingMode(uint32_t sequence, ScalingMode &scalingMode) = 0; - virtual GSError SetMetaData(uint32_t sequence, const std::vector &metaData) = 0; - virtual GSError SetMetaDataSet(uint32_t sequence, GraphicHDRMetadataKey key, - const std::vector &metaData) = 0; - virtual GSError QueryMetaDataType(uint32_t sequence, HDRMetaDataType &type) const = 0; - virtual GSError GetMetaData(uint32_t sequence, std::vector &metaData) const = 0; - virtual GSError GetMetaDataSet(uint32_t sequence, GraphicHDRMetadataKey &key, - std::vector &metaData) const = 0; - virtual GSError SetTunnelHandle(const GraphicExtDataHandle *handle) = 0; - virtual sptr GetTunnelHandle() const = 0; - virtual GSError SetPresentTimestamp(uint32_t sequence, const GraphicPresentTimestamp ×tamp) = 0; - virtual GSError GetPresentTimestamp(uint32_t sequence, GraphicPresentTimestampType type, - int64_t &time) const = 0; - - virtual void Dump(std::string &result) const = 0; - - virtual int32_t GetDefaultFormat() = 0; - virtual GSError SetDefaultFormat(int32_t format) = 0; - virtual int32_t GetDefaultColorGamut() = 0; - virtual GSError SetDefaultColorGamut(int32_t colorGamut) = 0; - - virtual sptr GetNativeSurface() = 0; - -protected: - Surface() = default; -}; -} // namespace OHOS - -#endif // INTERFACES_INNERKITS_SURFACE_SURFACE_H diff --git a/export/surface/surface_buffer.h b/export/surface/surface_buffer.h deleted file mode 100644 index b876eadba584f14ec80893dc03c5a76fd7b38eac..0000000000000000000000000000000000000000 --- a/export/surface/surface_buffer.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2021 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 INTERFACES_INNERKITS_SURFACE_SURFACE_BUFFER_H -#define INTERFACES_INNERKITS_SURFACE_SURFACE_BUFFER_H - -#include - -#include -#include - -#include "buffer_handle_utils.h" -#include "surface_type.h" -#include "egl_data.h" -#include "buffer_extra_data.h" -#include "native_buffer.h" - -struct BufferWrapper; - -namespace OHOS { -class MessageParcel; -class SurfaceBuffer : public RefBase { -public: - virtual BufferHandle *GetBufferHandle() const = 0; - virtual int32_t GetWidth() const = 0; - virtual int32_t GetHeight() const = 0; - virtual int32_t GetStride() const = 0; - virtual int32_t GetFormat() const = 0; - virtual uint64_t GetUsage() const = 0; - virtual uint64_t GetPhyAddr() const = 0; - virtual int32_t GetKey() const = 0; - virtual void *GetVirAddr() = 0; - virtual int32_t GetFileDescriptor() const = 0; - virtual uint32_t GetSize() const = 0; - - virtual const GraphicColorGamut& GetSurfaceBufferColorGamut() const = 0; - virtual const GraphicTransformType& GetSurfaceBufferTransform() const = 0; - virtual void SetSurfaceBufferColorGamut(const GraphicColorGamut& colorGamut) = 0; - virtual void SetSurfaceBufferTransform(const GraphicTransformType& transform) = 0; - - virtual int32_t GetSurfaceBufferWidth() const = 0; - virtual int32_t GetSurfaceBufferHeight() const = 0; - virtual void SetSurfaceBufferWidth(int32_t width) = 0; - virtual void SetSurfaceBufferHeight(int32_t width) = 0; - - virtual uint32_t GetSeqNum() const = 0; - - // opt EglData - virtual sptr GetEglData() const = 0; - virtual void SetEglData(const sptr& data) = 0; - - virtual void SetExtraData(const sptr &bedata) = 0; - virtual const sptr& GetExtraData() const = 0; - virtual GSError WriteToMessageParcel(MessageParcel &parcel) = 0; - virtual GSError ReadFromMessageParcel(MessageParcel &parcel) = 0; - virtual void SetBufferHandle(BufferHandle *handle) = 0; - - virtual BufferWrapper GetBufferWrapper() = 0; - virtual void SetBufferWrapper(BufferWrapper wrapper) = 0; - - // gralloc - virtual GSError Alloc(const BufferRequestConfig &config) = 0; - virtual GSError Map() = 0; - virtual GSError Unmap() = 0; - virtual GSError FlushCache() = 0; - virtual GSError InvalidateCache() = 0; - - static SurfaceBuffer* NativeBufferToSurfaceBuffer(OH_NativeBuffer* buffer) - { - return reinterpret_cast(buffer); - }; - - static const SurfaceBuffer* NativeBufferToSurfaceBuffer(OH_NativeBuffer const* buffer) - { - return reinterpret_cast(buffer); - }; - - virtual OH_NativeBuffer* SurfaceBufferToNativeBuffer() = 0; - -protected: - SurfaceBuffer(){} - SurfaceBuffer(const SurfaceBuffer&) = delete; - SurfaceBuffer& operator=(const SurfaceBuffer&) = delete; - virtual ~SurfaceBuffer(){} -}; - -using OnReleaseFunc = std::function &)>; -using OnDeleteBufferFunc = std::function; -} // namespace OHOS - -#endif // INTERFACES_INNERKITS_SURFACE_SURFACE_BUFFER_H diff --git a/export/surface/surface_delegate.h b/export/surface/surface_delegate.h deleted file mode 100644 index 320ab233427ebb31114f6c8524b2c3b205408ca4..0000000000000000000000000000000000000000 --- a/export/surface/surface_delegate.h +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright (c) 2022 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 INTERFACES_INNERKITS_SURFACE_SURFACE_DELEGATE_H -#define INTERFACES_INNERKITS_SURFACE_SURFACE_DELEGATE_H - -#include - -#include "surface.h" - -struct NativeSurfaceCallback; - -namespace OHOS { - -enum class SurfaceDelegateError : int32_t { - SURFACE_DELEGATE_ERROR_DEFAULT = -1, - SURFACE_DELEGATE_OK = 0, - SURFACE_DELEGATE_DO_NOTHING = 1, - SURFACE_DELEGATE_ERROR_SAMGR = 100, - SURFACE_DELEGATE_ERROR_IPC_FAILED = 101, - SURFACE_DELEGATE_ERROR_NO_MEM = 110, - SURFACE_DELEGATE_ERROR_NULLPTR = 120, - SURFACE_DELEGATE_ERROR_INVALID_PARAM = 130, - SURFACE_DELEGATE_ERROR_DESTROYED_OBJECT = 140, - SURFACE_DELEGATE_ERROR_DEATH_RECIPIENT = 150, - SURFACE_DELEGATE_ERROR_INVALID_WINDOW = 160, - SURFACE_DELEGATE_ERROR_INVALID_OPERATION = 170, - SURFACE_DELEGATE_ERROR_INVALID_TYPE = 180, - SURFACE_DELEGATE_ERROR_INVALID_PERMISSION = 190, - SURFACE_DELEGATE_ERROR_UNKNOWN, -}; - -class SurfaceDelegate : public RefBase { -public: - /* - * Define callback for the surface lifecycle. - */ - class ISurfaceCallback : virtual public RefBase { - public: - /* - * Callback when the surface was created. - * - * @param surface the surface. - */ - virtual void OnSurfaceCreated(const sptr& surface) = 0; - - /* - * Callback when the surface was changed. - * - * @param surface the surface. - * @param width the surface width. - * @param height the surface height. - */ - virtual void OnSurfaceChanged(const sptr& surface, int32_t width, int32_t height) = 0; - - /* - * Callback when the surface was destroyed. - */ - virtual void OnSurfaceDestroyed() = 0; - }; - - /* - * Add the surface callback. - * - * @param callback the ISurfaceCallback. - */ - void AddSurfaceCallback(const sptr& callback); - - /* - * Remove the surface callback. - * - * @param callback the ISurfaceCallback. - */ - void RemoveSurfaceCallback(const sptr& callback); - - /* - * Constructor of SurfaceDelegate. - * - * @param windowId the window id the surface will be on. - */ - SurfaceDelegate(int windowId); - - /* - * Destructor of SurfaceDelegate. - */ - ~SurfaceDelegate() = default; - - /* - * Create the surface. - * - * @param isWindowSurface if the surface is a window type surface. - * @return the SurfaceDelegateError code. - */ - SurfaceDelegateError CreateSurface(bool isWindowSurface = false); - - /* - * Set the boundaries of the area where the surface is located. - * - * @param left the left of the boundaries. - * @param right the right of the boundaries. - * @param width the width of the boundaries. - * @param height the height of the boundaries. - * @return the SurfaceDelegateError code. - */ - SurfaceDelegateError SetBounds(int32_t left, int32_t right, int32_t width, int32_t height); - - /* - * Release the surface. - * - * @return the SurfaceDelegateError code. - */ - SurfaceDelegateError ReleaseSurface(); - - /* - * Set the surface size. - * - * @param width the surface width. - * @param height the surface height. - * @return the SurfaceDelegateError code. - */ - SurfaceDelegateError SetSurfaceSize(uint32_t width, uint32_t height); - - /* - * Get the surface. - * - * @return the surface. - */ - sptr GetSurface(); - - /* - * Get the native window. - * - * @return the void pointer of the native window. - */ - void* GetNativeWindow(); - -private: - NativeSurfaceCallback CreateNativeSurfaceCallback(); - - sptr GetNativeSurface(); - - void OnSurfaceCreated(uint32_t windowId, uint64_t surfaceId); - void OnSurfaceChanged(uint32_t windowId, uint64_t surfaceId, int32_t width, int32_t height); - void OnSurfaceDestroyed(uint32_t windowId, uint64_t surfaceId); - - void OnNativeSurfaceCreated(void* nativeWindow); - void OnNativeSurfaceDestroyed(); - - sptr surface_ = nullptr; - - std::vector> surfaceCallbacks_; - std::recursive_mutex mutex_; - - int windowId_ = 0; -}; -} // namespace OHOS -#endif // INTERFACES_INNERKITS_SURFACE_SURFACE_DELEGATE_H \ No newline at end of file diff --git a/export/surface/surface_tunnel_handle.h b/export/surface/surface_tunnel_handle.h deleted file mode 100644 index e136d08aaa0f8898aceb4f9f678dccecedf14a75..0000000000000000000000000000000000000000 --- a/export/surface/surface_tunnel_handle.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2022 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 FRAMEWORKS_SURFACE_INCLUDE_SURFACE_TUNNEL_HANDLE_H -#define FRAMEWORKS_SURFACE_INCLUDE_SURFACE_TUNNEL_HANDLE_H -#include -#include -#include -#include "surface_type.h" - -namespace OHOS { -GraphicExtDataHandle *AllocExtDataHandle(uint32_t reserveInts); -void FreeExtDataHandle(GraphicExtDataHandle *handle); -class SurfaceTunnelHandle : public RefBase { -public: - SurfaceTunnelHandle(); - virtual ~SurfaceTunnelHandle(); - GSError SetHandle(const GraphicExtDataHandle *handle); - GraphicExtDataHandle *GetHandle(); - bool Different(const sptr &handle); - -protected: - SurfaceTunnelHandle(const SurfaceTunnelHandle&) = delete; - SurfaceTunnelHandle& operator=(const SurfaceTunnelHandle&) = delete; - -private: - GraphicExtDataHandle *tunnelHandle_ = nullptr; - mutable std::mutex mutex_; -}; -} // namespace OHOS - -#endif // FRAMEWORKS_SURFACE_INCLUDE_SURFACE_TUNNEL_HANDLE_H diff --git a/export/surface/surface_type.h b/export/surface/surface_type.h deleted file mode 100644 index fb2df398a159d739149ca8c88d9734c8d3832b2b..0000000000000000000000000000000000000000 --- a/export/surface/surface_type.h +++ /dev/null @@ -1,377 +0,0 @@ -/* - * Copyright (c) 2021 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 INTERFACES_INNERKITS_SURFACE_SURFACE_TYPE_H -#define INTERFACES_INNERKITS_SURFACE_SURFACE_TYPE_H - -#include -#include -#include -#include -#include - -namespace OHOS { -#define SURFACE_MAX_USER_DATA_COUNT 1000 -#define SURFACE_MAX_QUEUE_SIZE 32 -#define SURFACE_DEFAULT_QUEUE_SIZE 3 -#define SURFACE_MAX_STRIDE_ALIGNMENT 32 -#define SURFACE_MIN_STRIDE_ALIGNMENT 4 -#define SURFACE_DEFAULT_STRIDE_ALIGNMENT 4 -#define SURFACE_MAX_SIZE 58982400 // 8K * 8K - -using GraphicDispErrCode = enum { - GRAPHIC_DISPLAY_SUCCESS = 0, /**< Success */ - GRAPHIC_DISPLAY_FAILURE = -1, /**< Failure */ - GRAPHIC_DISPLAY_FD_ERR = -2, /**< File handle (FD) error */ - GRAPHIC_DISPLAY_PARAM_ERR = -3, /**< Parameter error */ - GRAPHIC_DISPLAY_NULL_PTR = -4, /**< Null pointer */ - GRAPHIC_DISPLAY_NOT_SUPPORT = -5, /**< Unsupported feature */ - GRAPHIC_DISPLAY_NOMEM = -6, /**< Insufficient memory */ - GRAPHIC_DISPLAY_SYS_BUSY = -7, /**< System busy */ - GRAPHIC_DISPLAY_NOT_PERM = -8 /**< Forbidden operation */ -}; - -using GraphicCompositionType = enum { - GRAPHIC_COMPOSITION_CLIENT, /**< Client composition type. The composer should be the CPU or GPU. */ - GRAPHIC_COMPOSITION_DEVICE, /**< Device composition type. The composer should be the hardware. */ - GRAPHIC_COMPOSITION_CURSOR, /**< Cursor composition type, used for cursor. */ - GRAPHIC_COMPOSITION_VIDEO, /**< Video composition type, used for video. */ - GRAPHIC_COMPOSITION_DEVICE_CLEAR, /**< Device clear composition type, the device will clear the target region. */ - GRAPHIC_COMPOSITION_CLIENT_CLEAR, /**< Client clear composition type, the service will clear the target region. */ - GRAPHIC_COMPOSITION_TUNNEL, /**< Tunnel composition type, used for tunnel. */ - GRAPHIC_COMPOSITION_BUTT -}; - -using GraphicBlendType = enum { - GRAPHIC_BLEND_NONE = 0, /**< No blending */ - GRAPHIC_BLEND_CLEAR, /**< CLEAR blending */ - GRAPHIC_BLEND_SRC, /**< SRC blending */ - GRAPHIC_BLEND_SRCOVER, /**< SRC_OVER blending */ - GRAPHIC_BLEND_DSTOVER, /**< DST_OVER blending */ - GRAPHIC_BLEND_SRCIN, /**< SRC_IN blending */ - GRAPHIC_BLEND_DSTIN, /**< DST_IN blending */ - GRAPHIC_BLEND_SRCOUT, /**< SRC_OUT blending */ - GRAPHIC_BLEND_DSTOUT, /**< DST_OUT blending */ - GRAPHIC_BLEND_SRCATOP, /**< SRC_ATOP blending */ - GRAPHIC_BLEND_DSTATOP, /**< DST_ATOP blending */ - GRAPHIC_BLEND_ADD, /**< ADD blending */ - GRAPHIC_BLEND_XOR, /**< XOR blending */ - GRAPHIC_BLEND_DST, /**< DST blending */ - GRAPHIC_BLEND_AKS, /**< AKS blending */ - GRAPHIC_BLEND_AKD, /**< AKD blending */ - GRAPHIC_BLEND_BUTT /**< Null operation */ -}; - -using GraphicPixelFormat = enum { - GRAPHIC_PIXEL_FMT_CLUT8 = 0, /**< CLUT8 format */ - GRAPHIC_PIXEL_FMT_CLUT1, /**< CLUT1 format */ - GRAPHIC_PIXEL_FMT_CLUT4, /**< CLUT4 format */ - GRAPHIC_PIXEL_FMT_RGB_565, /**< RGB565 format */ - GRAPHIC_PIXEL_FMT_RGBA_5658, /**< RGBA5658 format */ - GRAPHIC_PIXEL_FMT_RGBX_4444, /**< RGBX4444 format */ - GRAPHIC_PIXEL_FMT_RGBA_4444, /**< RGBA4444 format */ - GRAPHIC_PIXEL_FMT_RGB_444, /**< RGB444 format */ - GRAPHIC_PIXEL_FMT_RGBX_5551, /**< RGBX5551 format */ - GRAPHIC_PIXEL_FMT_RGBA_5551, /**< RGBA5551 format */ - GRAPHIC_PIXEL_FMT_RGB_555, /**< RGB555 format */ - GRAPHIC_PIXEL_FMT_RGBX_8888, /**< RGBX8888 format */ - GRAPHIC_PIXEL_FMT_RGBA_8888, /**< RGBA8888 format */ - GRAPHIC_PIXEL_FMT_RGB_888, /**< RGB888 format */ - GRAPHIC_PIXEL_FMT_BGR_565, /**< BGR565 format */ - GRAPHIC_PIXEL_FMT_BGRX_4444, /**< BGRX4444 format */ - GRAPHIC_PIXEL_FMT_BGRA_4444, /**< BGRA4444 format */ - GRAPHIC_PIXEL_FMT_BGRX_5551, /**< BGRX5551 format */ - GRAPHIC_PIXEL_FMT_BGRA_5551, /**< BGRA5551 format */ - GRAPHIC_PIXEL_FMT_BGRX_8888, /**< BGRX8888 format */ - GRAPHIC_PIXEL_FMT_BGRA_8888, /**< BGRA8888 format */ - GRAPHIC_PIXEL_FMT_YUV_422_I, /**< YUV422 interleaved format */ - GRAPHIC_PIXEL_FMT_YCBCR_422_SP, /**< YCBCR422 semi-planar format */ - GRAPHIC_PIXEL_FMT_YCRCB_422_SP, /**< YCRCB422 semi-planar format */ - GRAPHIC_PIXEL_FMT_YCBCR_420_SP, /**< YCBCR420 semi-planar format */ - GRAPHIC_PIXEL_FMT_YCRCB_420_SP, /**< YCRCB420 semi-planar format */ - GRAPHIC_PIXEL_FMT_YCBCR_422_P, /**< YCBCR422 planar format */ - GRAPHIC_PIXEL_FMT_YCRCB_422_P, /**< YCRCB422 planar format */ - GRAPHIC_PIXEL_FMT_YCBCR_420_P, /**< YCBCR420 planar format */ - GRAPHIC_PIXEL_FMT_YCRCB_420_P, /**< YCRCB420 planar format */ - GRAPHIC_PIXEL_FMT_YUYV_422_PKG, /**< YUYV422 packed format */ - GRAPHIC_PIXEL_FMT_UYVY_422_PKG, /**< UYVY422 packed format */ - GRAPHIC_PIXEL_FMT_YVYU_422_PKG, /**< YVYU422 packed format */ - GRAPHIC_PIXEL_FMT_VYUY_422_PKG, /**< VYUY422 packed format */ - GRAPHIC_PIXEL_FMT_VENDER_MASK = 0X7FFF0000, /**< vendor mask format */ - GRAPHIC_PIXEL_FMT_BUTT = 0X7FFFFFFF /**< Invalid pixel format */ -}; - -using GraphicLayerType = enum { - GRAPHIC_LAYER_TYPE_GRAPHIC, /**< Graphic layer */ - GRAPHIC_LAYER_TYPE_OVERLAY, /**< Overlay layer */ - GRAPHIC_LAYER_TYPE_SDIEBAND, /**< Sideband layer */ - GRAPHIC_LAYER_TYPE_CURSOR, /**< Cursor Layer */ - GRAPHIC_LAYER_TYPE_BUTT /**< Empty layer */ -}; - -using GraphicLayerAlpha = struct { - bool enGlobalAlpha; /**< Global alpha enable bit */ - bool enPixelAlpha; /**< Pixel alpha enable bit */ - uint8_t alpha0; /**< Alpha0 value, ranging from 0 to 255 */ - uint8_t alpha1; /**< Alpha1 value, ranging from 0 to 255 */ - uint8_t gAlpha; /**< Global alpha value, ranging from 0 to 255 */ -}; - -using GraphicLayerInfo = struct { - int32_t width; /**< Layer width */ - int32_t height; /**< Layer height */ - GraphicLayerType type; /**< Layer type, which can be a graphic layer, overlay layer, or sideband layer */ - int32_t bpp; /**< Number of bits occupied by each pixel */ - GraphicPixelFormat pixFormat; /**< Pixel format of the layer */ -}; - -using Rect = struct { - int32_t x; - int32_t y; - int32_t w; - int32_t h; -}; - -using BufferAllocInfo = struct { - uint32_t width; /**< Width of the requested memory */ - uint32_t height; /**< Height of the requested memory */ - uint64_t usage; /**< Usage of the requested memory */ - GraphicPixelFormat format; /**< Format of the requested memory */ - uint32_t expectedSize; /**< Size assigned by memory requester */ -}; - - -using BufferVerifyAllocInfo = struct { - uint32_t width; /**< Width of the memory to allocate */ - uint32_t height; /**< Height of the memory to allocate */ - uint64_t usage; /**< Usage of the memory */ - GraphicPixelFormat format; /**< Format of the memory to allocate */ -}; - -using GraphicPresentTimestampType = enum { - GRAPHIC_DISPLAY_PTS_UNSUPPORTED = 0, /**< Unsupported */ - GRAPHIC_DISPLAY_PTS_DELAY = 1 << 0, /**< Delay */ - GRAPHIC_DISPLAY_PTS_TIMESTAMP = 1 << 1, /**< Timestamp */ -}; - -using GraphicPresentTimestamp = struct { - GraphicPresentTimestampType type; /**< Present timestamp type */ - int64_t time; /**< Present timestamp value */ -}; - -using ScalingMode = enum { - SCALING_MODE_FREEZE = 0, - SCALING_MODE_SCALE_TO_WINDOW, - SCALING_MODE_SCALE_CROP, - SCALING_MODE_NO_SCALE_CROP, -}; - -using HDRMetaDataType = enum { - HDR_NOT_USED = 0, - HDR_META_DATA, - HDR_META_DATA_SET, -}; - -using GraphicHDRMetadataKey = enum { - GRAPHIC_MATAKEY_RED_PRIMARY_X = 0, - GRAPHIC_MATAKEY_RED_PRIMARY_Y = 1, - GRAPHIC_MATAKEY_GREEN_PRIMARY_X = 2, - GRAPHIC_MATAKEY_GREEN_PRIMARY_Y = 3, - GRAPHIC_MATAKEY_BLUE_PRIMARY_X = 4, - GRAPHIC_MATAKEY_BLUE_PRIMARY_Y = 5, - GRAPHIC_MATAKEY_WHITE_PRIMARY_X = 6, - GRAPHIC_MATAKEY_WHITE_PRIMARY_Y = 7, - GRAPHIC_MATAKEY_MAX_LUMINANCE = 8, - GRAPHIC_MATAKEY_MIN_LUMINANCE = 9, - GRAPHIC_MATAKEY_MAX_CONTENT_LIGHT_LEVEL = 10, - GRAPHIC_MATAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL = 11, - GRAPHIC_MATAKEY_HDR10_PLUS = 12, - GRAPHIC_MATAKEY_HDR_VIVID = 13, -}; - -using GraphicHDRMetaDataSet = struct GraphicHDRMetaDataSet { - GraphicHDRMetadataKey key = GraphicHDRMetadataKey::GRAPHIC_MATAKEY_RED_PRIMARY_X; - std::vector metaData; -}; - -typedef struct { - GraphicHDRMetadataKey key; - float value; -} GraphicHDRMetaData; - -using SurfaceBufferUsage = enum { - BUFFER_USAGE_CPU_READ = (1ULL << 0), /**< CPU read buffer */ - BUFFER_USAGE_CPU_WRITE = (1ULL << 1), /**< CPU write memory */ - BUFFER_USAGE_MEM_MMZ = (1ULL << 2), /**< Media memory zone (MMZ) */ - BUFFER_USAGE_MEM_DMA = (1ULL << 3), /**< Direct memory access (DMA) buffer */ - BUFFER_USAGE_MEM_SHARE = (1ULL << 4), /**< Shared memory buffer*/ - BUFFER_USAGE_MEM_MMZ_CACHE = (1ULL << 5), /**< MMZ with cache*/ - BUFFER_USAGE_MEM_FB = (1ULL << 6), /**< Framebuffer */ - BUFFER_USAGE_ASSIGN_SIZE = (1ULL << 7), /**< Memory assigned */ - BUFFER_USAGE_HW_RENDER = (1ULL << 8), /**< For GPU write case */ - BUFFER_USAGE_HW_TEXTURE = (1ULL << 9), /**< For GPU read case */ - BUFFER_USAGE_HW_COMPOSER = (1ULL << 10), /**< For hardware composer */ - BUFFER_USAGE_PROTECTED = (1ULL << 11), /**< For safe buffer case, such as DRM */ - BUFFER_USAGE_CAMERA_READ = (1ULL << 12), /**< For camera read case */ - BUFFER_USAGE_CAMERA_WRITE = (1ULL << 13), /**< For camera write case */ - BUFFER_USAGE_VIDEO_ENCODER = (1ULL << 14), /**< For encode case */ - BUFFER_USAGE_VIDEO_DECODER = (1ULL << 15), /**< For decode case */ - BUFFER_USAGE_VENDOR_PRI0 = (1ULL << 44), /**< Reserverd for vendor */ - BUFFER_USAGE_VENDOR_PRI1 = (1ULL << 45), /**< Reserverd for vendor */ - BUFFER_USAGE_VENDOR_PRI2 = (1ULL << 46), /**< Reserverd for vendor */ - BUFFER_USAGE_VENDOR_PRI3 = (1ULL << 47), /**< Reserverd for vendor */ - BUFFER_USAGE_VENDOR_PRI4 = (1ULL << 48), /**< Reserverd for vendor */ - BUFFER_USAGE_VENDOR_PRI5 = (1ULL << 49), /**< Reserverd for vendor */ - BUFFER_USAGE_VENDOR_PRI6 = (1ULL << 50), /**< Reserverd for vendor */ - BUFFER_USAGE_VENDOR_PRI7 = (1ULL << 51), /**< Reserverd for vendor */ - BUFFER_USAGE_VENDOR_PRI8 = (1ULL << 52), /**< Reserverd for vendor */ - BUFFER_USAGE_VENDOR_PRI9 = (1ULL << 53), /**< Reserverd for vendor */ - BUFFER_USAGE_VENDOR_PRI10 = (1ULL << 54), /**< Reserverd for vendor */ - BUFFER_USAGE_VENDOR_PRI11 = (1ULL << 55), /**< Reserverd for vendor */ - BUFFER_USAGE_VENDOR_PRI12 = (1ULL << 56), /**< Reserverd for vendor */ - BUFFER_USAGE_VENDOR_PRI13 = (1ULL << 57), /**< Reserverd for vendor */ - BUFFER_USAGE_VENDOR_PRI14 = (1ULL << 58), /**< Reserverd for vendor */ - BUFFER_USAGE_VENDOR_PRI15 = (1ULL << 59), /**< Reserverd for vendor */ - BUFFER_USAGE_VENDOR_PRI16 = (1ULL << 60), /**< Reserverd for vendor */ - BUFFER_USAGE_VENDOR_PRI17 = (1ULL << 61), /**< Reserverd for vendor */ - BUFFER_USAGE_VENDOR_PRI18 = (1ULL << 62), /**< Reserverd for vendor */ - BUFFER_USAGE_VENDOR_PRI19 = (1ULL << 63), /**< Reserverd for vendor */ -}; - -using GraphicColorGamut = enum { - GRAPHIC_COLOR_GAMUT_INVALID = -1, /**< Invalid */ - GRAPHIC_COLOR_GAMUT_NATIVE = 0, /**< Native or default */ - GRAPHIC_COLOR_GAMUT_STANDARD_BT601 = 1, /**< Standard BT601 */ - GRAPHIC_COLOR_GAMUT_STANDARD_BT709 = 2, /**< Standard BT709 */ - GRAPHIC_COLOR_GAMUT_DCI_P3 = 3, /**< DCI P3 */ - GRAPHIC_COLOR_GAMUT_SRGB = 4, /**< SRGB */ - GRAPHIC_COLOR_GAMUT_ADOBE_RGB = 5, /**< Adobe RGB */ - GRAPHIC_COLOR_GAMUT_DISPLAY_P3 = 6, /**< display P3 */ - GRAPHIC_COLOR_GAMUT_BT2020 = 7, /**< BT2020 */ - GRAPHIC_COLOR_GAMUT_BT2100_PQ = 8, /**< BT2100 PQ */ - GRAPHIC_COLOR_GAMUT_BT2100_HLG = 9, /**< BT2100 HLG */ - GRAPHIC_COLOR_GAMUT_DISPLAY_BT2020 = 10, /**< Display BT2020 */ -}; - -using GraphicColorDataSpace = enum { - GRAPHIC_COLOR_DATA_SPACE_UNKNOWN = 0, - GRAPHIC_GAMUT_BT601 = 0x00000001, - GRAPHIC_GAMUT_BT709 = 0x00000002, - GRAPHIC_GAMUT_DCI_P3 = 0x00000003, - GRAPHIC_GAMUT_SRGB = 0x00000004, - GRAPHIC_GAMUT_ADOBE_RGB = 0x00000005, - GRAPHIC_GAMUT_DISPLAY_P3 = 0x00000006, - GRAPHIC_GAMUT_BT2020 = 0x00000007, - GRAPHIC_GAMUT_BT2100_PQ = 0x00000008, - GRAPHIC_GAMUT_BT2100_HLG = 0x00000009, - GRAPHIC_GAMUT_DISPLAY_BT2020 = 0x0000000a, - GRAPHIC_TRANSFORM_FUNC_UNSPECIFIED = 0x00000100, - GRAPHIC_TRANSFORM_FUNC_LINEAR = 0x00000200, - GRAPHIC_TRANSFORM_FUNC_SRGB = 0x00000300, - GRAPHIC_TRANSFORM_FUNC_SMPTE_170M = 0x00000400, - GRAPHIC_TRANSFORM_FUNC_GM2_2 = 0x00000500, - GRAPHIC_TRANSFORM_FUNC_GM2_6 = 0x00000600, - GRAPHIC_TRANSFORM_FUNC_GM2_8 = 0x00000700, - GRAPHIC_TRANSFORM_FUNC_ST2084 = 0x00000800, - GRAPHIC_TRANSFORM_FUNC_HLG = 0x00000900, - GRAPHIC_PRECISION_UNSPECIFIED = 0x00010000, - GRAPHIC_PRECISION_FULL = 0x00020000, - GRAPHIC_PRESION_LIMITED = 0x00030000, - GRAPHIC_PRESION_EXTENDED = 0x00040000, - GRAPHIC_BT601_SMPTE170M_FULL = GRAPHIC_GAMUT_BT601 | GRAPHIC_TRANSFORM_FUNC_SMPTE_170M | GRAPHIC_PRECISION_FULL, - GRAPHIC_BT601_SMPTE170M_LIMITED = GRAPHIC_GAMUT_BT601 | GRAPHIC_TRANSFORM_FUNC_SMPTE_170M | GRAPHIC_PRESION_LIMITED, - GRAPHIC_BT709_LINEAR_FULL = GRAPHIC_GAMUT_BT709 | GRAPHIC_TRANSFORM_FUNC_LINEAR | GRAPHIC_PRECISION_FULL, - GRAPHIC_BT709_LINEAR_EXTENDED = GRAPHIC_GAMUT_BT709 | GRAPHIC_TRANSFORM_FUNC_LINEAR | GRAPHIC_PRESION_EXTENDED, - GRAPHIC_BT709_SRGB_FULL = GRAPHIC_GAMUT_BT709 | GRAPHIC_TRANSFORM_FUNC_SRGB | GRAPHIC_PRECISION_FULL, - GRAPHIC_BT709_SRGB_EXTENDED = GRAPHIC_GAMUT_BT709 | GRAPHIC_TRANSFORM_FUNC_SRGB | GRAPHIC_PRESION_EXTENDED, - GRAPHIC_BT709_SMPTE170M_LIMITED = GRAPHIC_GAMUT_BT709 | GRAPHIC_TRANSFORM_FUNC_SMPTE_170M | GRAPHIC_PRESION_LIMITED, - GRAPHIC_DCI_P3_LINEAR_FULL = GRAPHIC_GAMUT_DCI_P3 | GRAPHIC_TRANSFORM_FUNC_LINEAR | GRAPHIC_PRECISION_FULL, - GRAPHIC_DCI_P3_GAMMA26_FULL = GRAPHIC_GAMUT_DCI_P3 | GRAPHIC_TRANSFORM_FUNC_GM2_6 | GRAPHIC_PRECISION_FULL, - GRAPHIC_DISPLAY_P3_LINEAR_FULL = GRAPHIC_GAMUT_DISPLAY_P3 | GRAPHIC_TRANSFORM_FUNC_LINEAR | GRAPHIC_PRECISION_FULL, - GRAPHIC_DCI_P3_SRGB_FULL = GRAPHIC_GAMUT_DCI_P3 | GRAPHIC_TRANSFORM_FUNC_SRGB | GRAPHIC_PRECISION_FULL, - GRAPHIC_ADOBE_RGB_GAMMA22_FULL = GRAPHIC_GAMUT_ADOBE_RGB | GRAPHIC_TRANSFORM_FUNC_GM2_2 | GRAPHIC_PRECISION_FULL, - GRAPHIC_BT2020_LINEAR_FULL = GRAPHIC_GAMUT_BT2020 | GRAPHIC_TRANSFORM_FUNC_LINEAR | GRAPHIC_PRECISION_FULL, - GRAPHIC_BT2020_SRGB_FULL = GRAPHIC_GAMUT_BT2020 | GRAPHIC_TRANSFORM_FUNC_SRGB | GRAPHIC_PRECISION_FULL, - GRAPHIC_BT2020_SMPTE170M_FULL = GRAPHIC_GAMUT_BT2020 | GRAPHIC_TRANSFORM_FUNC_SMPTE_170M | GRAPHIC_PRECISION_FULL, - GRAPHIC_BT2020_ST2084_FULL = GRAPHIC_GAMUT_BT2020 | GRAPHIC_TRANSFORM_FUNC_ST2084 | GRAPHIC_PRECISION_FULL, - GRAPHIC_BT2020_HLG_FULL = GRAPHIC_GAMUT_BT2020 | GRAPHIC_TRANSFORM_FUNC_HLG | GRAPHIC_PRECISION_FULL, - GRAPHIC_BT2020_ST2084_LIMITED = GRAPHIC_GAMUT_BT2020 | GRAPHIC_TRANSFORM_FUNC_ST2084 | GRAPHIC_PRESION_LIMITED, -}; - -using GraphicTransformType = enum { - GRAPHIC_ROTATE_NONE = 0, /**< No rotation */ - GRAPHIC_ROTATE_90, /**< Rotation by 90 degrees */ - GRAPHIC_ROTATE_180, /**< Rotation by 180 degrees */ - GRAPHIC_ROTATE_270, /**< Rotation by 270 degrees */ - GRAPHIC_FLIP_H, /**< Flip horizontally */ - GRAPHIC_FLIP_V, /**< Flip vertically */ - GRAPHIC_FLIP_H_ROT90, /**< Flip horizontally and rotate 90 degrees */ - GRAPHIC_FLIP_V_ROT90, /**< Flip vertically and rotate 90 degrees */ - GRAPHIC_FLIP_H_ROT180, /**< Flip horizontally and rotate 180 degrees */ - GRAPHIC_FLIP_V_ROT180, /**< Flip vertically and rotate 180 degrees */ - GRAPHIC_FLIP_H_ROT270, /**< Flip horizontally and rotate 270 degrees */ - GRAPHIC_FLIP_V_ROT270, /**< Flip vertically and rotate 270 degrees */ - GRAPHIC_ROTATE_BUTT /**< Invalid operation */ -}; - -using BufferRequestConfig = struct BufferRequestConfig { - int32_t width; - int32_t height; - int32_t strideAlignment; - int32_t format; // PixelFormat - uint64_t usage; - int32_t timeout; - GraphicColorGamut colorGamut = GraphicColorGamut::GRAPHIC_COLOR_GAMUT_SRGB; - GraphicTransformType transform = GraphicTransformType::GRAPHIC_ROTATE_NONE; - bool operator ==(const struct BufferRequestConfig &config) const - { - return width == config.width && - height == config.height && - strideAlignment == config.strideAlignment && - format == config.format && - usage == config.usage && - timeout == config.timeout && - colorGamut == config.colorGamut && - transform == config.transform; - } - bool operator != (const struct BufferRequestConfig &config) const - { - return !(*this == config); - } -}; - -using BufferFlushConfig = struct { - Rect damage; - int64_t timestamp; -}; - -using SceneType = enum { - SURFACE_SCENE_TYPE_EGL = 0, - SURFACE_SCENE_TYPE_MEDIA, - SURFACE_SCENE_TYPE_CAMERA, - SURFACE_SCENE_TYPE_CPU, -}; - -using GraphicExtDataHandle = struct { - /**< Handle fd, -1 if not supported */ - int32_t fd; - /**< the number of reserved integer value */ - uint32_t reserveInts; - /**< the reserved data */ - int32_t reserve[0]; -}; - -} // namespace OHOS -#endif // INTERFACES_INNERKITS_SURFACE_SURFACE_TYPE_H diff --git a/export/surface/surface_utils.h b/export/surface/surface_utils.h deleted file mode 100644 index f33a4c3ee1071ff19bc1dfb4741dbf7e26769d25..0000000000000000000000000000000000000000 --- a/export/surface/surface_utils.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2021 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 INTERFACES_INNERKITS_SURFACE_SURFACE_UTILS_H -#define INTERFACES_INNERKITS_SURFACE_SURFACE_UTILS_H - -#include -#include -#include "surface.h" - -namespace OHOS { -class SurfaceUtils { -public: - static SurfaceUtils* GetInstance(); - - // get surface by uniqueId. - sptr GetSurface(uint64_t uniqueId); - // maintenance map with uniqueId and surface. - SurfaceError Add(uint64_t uniqueId, const sptr &surface); - // remove surface by uniqueId. - SurfaceError Remove(uint64_t uniqueId); - -private: - SurfaceUtils() = default; - virtual ~SurfaceUtils(); - - std::unordered_map> surfaceCache_; - std::mutex mutex_; -}; -} // namespace OHOS - -#endif // INTERFACES_INNERKITS_SURFACE_SURFACE_UTILS_H