diff --git a/build/libace.map b/build/libace.map index 251f0e8ecac..2beb902c2e5 100644 --- a/build/libace.map +++ b/build/libace.map @@ -47,7 +47,6 @@ "OHOS::Ace::BaseId::BaseId()"; OHOS::Ace::ConnectServerManager::*; OHOS::Ace::Container::*; - OHOS::Ace::CubicCurve::*; OHOS::Ace::Curves::*; OHOS::Ace::EngineHelper::*; OHOS::Ace::EventReport::*; @@ -65,7 +64,6 @@ OHOS::Ace::PluginComponentManager::*; OHOS::Ace::Scheduler::*; OHOS::Ace::ScopedDelegate::*; - OHOS::Ace::SpringCurve::*; OHOS::Ace::SpringMotion::*; OHOS::Ace::SubwindowManager::*; "OHOS::Ace::SystemGridInfo::ToString() const"; diff --git a/frameworks/bridge/cj_frontend/BUILD.gn b/frameworks/bridge/cj_frontend/BUILD.gn index c4329f3700f..8a6a38187e2 100644 --- a/frameworks/bridge/cj_frontend/BUILD.gn +++ b/frameworks/bridge/cj_frontend/BUILD.gn @@ -176,7 +176,6 @@ template("cj_frontend") { "interfaces/cj_ffi/cj_view_context_ffi.cpp", "interfaces/cj_ffi/cj_view_stack_processor_ffi.cpp", "interfaces/cj_ffi/concurrency/cj_concurrency_ffi.cpp", - "interfaces/cj_ffi/curves/cj_curves_ffi.cpp", "interfaces/cj_ffi/font/cj_font_ffi.cpp", "interfaces/cj_ffi/measure/cj_measure_ffi.cpp", "interfaces/cj_ffi/prompt/cj_prompt_ffi.cpp", diff --git a/frameworks/bridge/cj_frontend/interfaces/cj_ffi/curves/cj_curves_ffi.cpp b/frameworks/bridge/cj_frontend/interfaces/cj_ffi/curves/cj_curves_ffi.cpp deleted file mode 100644 index f3734327b33..00000000000 --- a/frameworks/bridge/cj_frontend/interfaces/cj_ffi/curves/cj_curves_ffi.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "bridge/cj_frontend/interfaces/cj_ffi/curves/cj_curves_ffi.h" - -#include - -#include "cj_lambda.h" - -#include "bridge/common/utils/utils.h" -#include "core/animation/cubic_curve.h" -#include "core/animation/spring_curve.h" - -using namespace OHOS::Ace; -using namespace OHOS::Ace::Framework; -using namespace OHOS::FFI; - -namespace { -constexpr int32_t INT_ERROR = 100001; -} - -extern "C" { -int64_t FfiOHOSAceFrameworkCurvesCreateStepsCurve(int32_t count, bool end) -{ - auto position = end ? StepsCurvePosition::END : StepsCurvePosition::START; - if (count < 1) { - count = 1; - } - auto stepsCurve = AceType::MakeRefPtr(count, position); - auto iCurve = FFIData::Create(std::move(stepsCurve)); - if (iCurve == nullptr) { - return INT_ERROR; - } - int64_t id = iCurve->GetID(); - return id; -} -int64_t FfiOHOSAceFrameworkCurvesCreateCubicBezierCurve(float x1, float y1, float x2, float y2) -{ - x1 = std::clamp(x1, 0.0f, 1.0f); - x2 = std::clamp(x2, 0.0f, 1.0f); - auto cubicBezierCurve = AceType::MakeRefPtr(x1, y1, x2, y2); - auto iCurve = FFIData::Create(std::move(cubicBezierCurve)); - if (iCurve == nullptr) { - return INT_ERROR; - } - int64_t id = iCurve->GetID(); - return id; -} -int64_t FfiOHOSAceFrameworkCurvesCreateSpringCurve(float velocity, float mass, float stiffness, float damping) -{ - if (LessOrEqual(mass, 0.0)) { - mass = 1.0; - } - if (LessOrEqual(stiffness, 0.0)) { - stiffness = 1.0; - } - if (LessOrEqual(damping, 0.0)) { - damping = 1.0; - } - auto springCurve = AceType::MakeRefPtr(velocity, mass, stiffness, damping); - auto iCurve = FFIData::Create(std::move(springCurve)); - if (iCurve == nullptr) { - return INT_ERROR; - } - int64_t id = iCurve->GetID(); - return id; -} -int64_t FfiOHOSAceFrameworkCurvesCreateInterpolatingSpring(float velocity, float mass, float stiffness, float damping) -{ - if (LessOrEqual(mass, 0.0)) { - mass = 1.0; - } - if (LessOrEqual(stiffness, 0.0)) { - stiffness = 1.0; - } - if (LessOrEqual(damping, 0.0)) { - damping = 1.0; - } - auto interpolatingSpring = AceType::MakeRefPtr(velocity, mass, stiffness, damping); - auto iCurve = FFIData::Create(std::move(interpolatingSpring)); - if (iCurve == nullptr) { - return INT_ERROR; - } - int64_t id = iCurve->GetID(); - return id; -} -int64_t FfiOHOSAceFrameworkCurvesCreateSpringMotion(float response, float dampingFraction, float overlapDuration) -{ - if (LessOrEqual(response, 0.0)) { - response = ResponsiveSpringMotion::DEFAULT_SPRING_MOTION_RESPONSE; - } - if (LessOrEqual(dampingFraction, 0.0)) { - dampingFraction = ResponsiveSpringMotion::DEFAULT_SPRING_MOTION_DAMPING_RATIO; - } - if (LessOrEqual(overlapDuration, 0.0)) { - overlapDuration = ResponsiveSpringMotion::DEFAULT_SPRING_MOTION_BLEND_DURATION; - } - auto responsiveSpringMotion = - AceType::MakeRefPtr(response, dampingFraction, overlapDuration); - auto iCurve = FFIData::Create(std::move(responsiveSpringMotion)); - if (iCurve == nullptr) { - return INT_ERROR; - } - int64_t id = iCurve->GetID(); - return id; -} -int64_t FfiOHOSAceFrameworkCurvesCreateResponsiveSpringMotion( - float response, float dampingFraction, float overlapDuration) -{ - if (LessOrEqual(response, 0.0)) { - response = ResponsiveSpringMotion::DEFAULT_RESPONSIVE_SPRING_MOTION_RESPONSE; - } - if (LessOrEqual(dampingFraction, 0.0)) { - dampingFraction = ResponsiveSpringMotion::DEFAULT_RESPONSIVE_SPRING_MOTION_DAMPING_RATIO; - } - if (LessOrEqual(overlapDuration, 0.0)) { - overlapDuration = ResponsiveSpringMotion::DEFAULT_RESPONSIVE_SPRING_MOTION_BLEND_DURATION; - } - auto responsiveMotion = AceType::MakeRefPtr(response, dampingFraction, overlapDuration); - auto iCurve = FFIData::Create(std::move(responsiveMotion)); - if (iCurve == nullptr) { - return INT_ERROR; - } - int64_t id = iCurve->GetID(); - return id; -} -int64_t FfiOHOSAceFrameworkCurvesCreateCustomCurve(float (*callback)(float fraction)) -{ - auto customCurve = AceType::MakeRefPtr(CJLambda::Create(callback)); - auto iCurve = FFIData::Create(std::move(customCurve)); - if (iCurve == nullptr) { - return INT_ERROR; - } - int64_t id = iCurve->GetID(); - return id; -} -int64_t FfiOHOSAceFrameworkCurvesInitCurve(char* aniTimFunc) -{ - auto curve = CreateCurve(aniTimFunc); - auto iCurve = FFIData::Create(std::move(curve)); - if (iCurve == nullptr) { - return INT_ERROR; - } - int64_t id = iCurve->GetID(); - return id; -} -int64_t FfiOHOSAceFrameworkCurvesInterpolate(int64_t id, float fraction) -{ - auto iCurve = FFIData::GetData(id); - if (!iCurve) { - return INT_ERROR; - } - if (LessOrEqual(fraction, 0.0)) { - fraction = 0.0; - } - if (GreatOrEqual(fraction, 1.0)) { - fraction = 1.0; - } - return iCurve->GetCurve()->MoveInternal(fraction); -} -} diff --git a/frameworks/bridge/cj_frontend/interfaces/cj_ffi/curves/cj_curves_ffi.h b/frameworks/bridge/cj_frontend/interfaces/cj_ffi/curves/cj_curves_ffi.h deleted file mode 100644 index b21b1b5fc8f..00000000000 --- a/frameworks/bridge/cj_frontend/interfaces/cj_ffi/curves/cj_curves_ffi.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2024 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_ACE_FRAMEWORK_CJ_CURVES_FFI_H -#define OHOS_ACE_FRAMEWORK_CJ_CURVES_FFI_H - -#include "ffi_remote_data.h" - -#include "bridge/cj_frontend/interfaces/cj_ffi/cj_macro.h" -#include "core/animation/curve.h" - -namespace OHOS::Ace { - -class ICurveImpl : public OHOS::FFI::FFIData { - DECL_TYPE(ICurveImpl, OHOS::FFI::FFIData); - -public: - ICurveImpl() = default; - ICurveImpl(RefPtr curve) : curve_(std::move(curve)) {} - ~ICurveImpl() override = default; - - RefPtr GetCurve() const - { - return curve_; - } - -private: - RefPtr curve_; -}; - -} // namespace OHOS::Ace - -extern "C" { -CJ_EXPORT int64_t FfiOHOSAceFrameworkCurvesCreateStepsCurve(int32_t count, bool end); -CJ_EXPORT int64_t FfiOHOSAceFrameworkCurvesCreateCubicBezierCurve(float x1, float y1, float x2, float y2); -CJ_EXPORT int64_t FfiOHOSAceFrameworkCurvesCreateSpringCurve( - float velocity, float mass, float stiffness, float damping); -CJ_EXPORT int64_t FfiOHOSAceFrameworkCurvesCreateInterpolatingSpring( - float velocity, float mass, float stiffness, float damping); -CJ_EXPORT int64_t FfiOHOSAceFrameworkCurvesCreateSpringMotion( - float response, float dampingFraction, float overlapDuration); -CJ_EXPORT int64_t FfiOHOSAceFrameworkCurvesCreateResponsiveSpringMotion( - float response, float dampingFraction, float overlapDuration); -CJ_EXPORT int64_t FfiOHOSAceFrameworkCurvesCreateCustomCurve(float (*callback)(float fraction)); -CJ_EXPORT int64_t FfiOHOSAceFrameworkCurvesInitCurve(char* aniTimFunc); -CJ_EXPORT int64_t FfiOHOSAceFrameworkCurvesInterpolate(int64_t id, float fraction); -} - -#endif // OHOS_ACE_FRAMEWORK_CJ_CURVES_FFI_H diff --git a/frameworks/core/animation/cubic_curve.h b/frameworks/core/animation/cubic_curve.h index 3886047f685..810f3b692d3 100644 --- a/frameworks/core/animation/cubic_curve.h +++ b/frameworks/core/animation/cubic_curve.h @@ -27,7 +27,7 @@ class NativeCurveHelper; // so Bx(m) = 3m(1-m)^2*x0_ + 3m^2*x1_ + m^3 // By(m) = 3m(1-m)^2*y0_ + 3m^2*y1_ + m^3 // in function MoveInternal, assume time as Bx(m), we let Bx(m) approaching time, and we can get m and the output By(m) -class ACE_FORCE_EXPORT CubicCurve : public Curve { +class ACE_EXPORT CubicCurve : public Curve { DECLARE_ACE_TYPE(CubicCurve, Curve); public: diff --git a/frameworks/core/animation/spring_curve.h b/frameworks/core/animation/spring_curve.h index cc4902ca73f..2034cc4b539 100644 --- a/frameworks/core/animation/spring_curve.h +++ b/frameworks/core/animation/spring_curve.h @@ -21,7 +21,7 @@ namespace OHOS::Ace { -class ACE_FORCE_EXPORT SpringCurve : public Curve { +class ACE_EXPORT SpringCurve : public Curve { DECLARE_ACE_TYPE(SpringCurve, Curve); public: