1 /* 2 * Copyright (c) 2021-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_CUBIC_BEZIER_INTERPOLATOR_H 17 #define RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_CUBIC_BEZIER_INTERPOLATOR_H 18 19 #include <cinttypes> 20 21 #include "animation/rs_interpolator.h" 22 #include "common/rs_common_def.h" 23 24 namespace OHOS { 25 namespace Rosen { 26 class RSB_EXPORT RSCubicBezierInterpolator : public RSInterpolator { 27 public: 28 RSCubicBezierInterpolator(float ctlX1, float ctlY1, float ctlX2, float ctlY2); 29 ~RSCubicBezierInterpolator() override = default; 30 31 float InterpolateImpl(float input) const override; 32 33 bool Marshalling(Parcel& parcel) const override; 34 [[nodiscard]] static RSCubicBezierInterpolator* Unmarshalling(Parcel& parcel); 35 GetType()36 InterpolatorType GetType() override { return InterpolatorType::CUBIC_BEZIER; } 37 private: 38 RSCubicBezierInterpolator(uint64_t id, float ctlX1, float ctlY1, float ctlX2, float ctlY2); 39 40 int BinarySearch(float key) const; 41 42 constexpr static int MAX_RESOLUTION = 4000; 43 constexpr static float SEARCH_STEP = 1.0f / MAX_RESOLUTION; 44 45 float controlX1_ { 0.0 }; 46 float controlY1_ { 0.0 }; 47 float controlX2_ { 0.0 }; 48 float controlY2_ { 0.0 }; 49 }; 50 } // namespace Rosen 51 } // namespace OHOS 52 53 #endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_CUBIC_BEZIER_INTERPOLATOR_H 54