1 /* 2 * Copyright (c) 2022-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_BASE_MODIFIER_RS_RENDER_PROPERTY_H 17 #define RENDER_SERVICE_BASE_MODIFIER_RS_RENDER_PROPERTY_H 18 19 #include "recording/draw_cmd_list.h" 20 21 #include "animation/rs_render_particle.h" 22 #include "animation/rs_value_estimator.h" 23 #include "common/rs_common_def.h" 24 #include "common/rs_macros.h" 25 #include "common/rs_rect.h" 26 #include "modifier/rs_animatable_arithmetic.h" 27 #include "modifier_ng/rs_modifier_ng_type.h" 28 #include "property/rs_properties_def.h" 29 #include "transaction/rs_marshalling_helper.h" 30 #ifdef USE_M133_SKIA 31 #include "include/core/SkMatrix.h" 32 #endif 33 34 namespace OHOS { 35 namespace Rosen { 36 class RSNGRenderFilterBase; 37 class RSNGRenderMaskBase; 38 class RSNGRenderShaderBase; 39 class RSRenderMaskPara; 40 class RSRenderNode; 41 enum class ForegroundColorStrategyType; 42 enum class Gravity; 43 namespace ModifierNG { 44 class RSRenderModifier; 45 } 46 47 template<class...> 48 struct make_void { using type = void; }; 49 template<class... T> 50 using void_t = typename make_void<T...>::type; 51 52 template<class T, class = void> 53 struct supports_arithmetic : std::false_type {}; 54 template<class T> 55 struct supports_arithmetic<T, 56 void_t<decltype(std::declval<T>() == std::declval<T>())>> 57 : std::true_type {}; 58 59 template<class T, class = void> 60 struct supports_animatable_arithmetic : std::false_type {}; 61 template<class T> 62 struct supports_animatable_arithmetic<T, 63 void_t<decltype(std::declval<T>() + std::declval<T>()), 64 decltype(std::declval<T>() - std::declval<T>()), 65 decltype(std::declval<T>() * std::declval<float>()), 66 decltype(std::declval<T>() == std::declval<T>())>> 67 : std::true_type {}; 68 69 enum PropertyUpdateType : uint8_t { 70 UPDATE_TYPE_OVERWRITE = 0, // overwrite by given value 71 UPDATE_TYPE_INCREMENTAL, // incremental update by given value 72 UPDATE_TYPE_FORCE_OVERWRITE, // overwrite and cancel all previous animations 73 }; 74 75 enum class RSPropertyType : uint8_t { 76 INVALID = 0, 77 BOOL, 78 INT, 79 FLOAT, 80 VECTOR4_UINT32, 81 RS_COLOR, 82 MATRIX3F, 83 QUATERNION, 84 VECTOR2F, 85 VECTOR3F, 86 VECTOR4F, 87 VECTOR4_COLOR, 88 SK_MATRIX, 89 RRECT, 90 DRAW_CMD_LIST, 91 FOREGROUND_COLOR_STRATEGY, 92 RS_SHADER, 93 RS_IMAGE, 94 RS_PATH, 95 GRAVITY, 96 DRAWING_MATRIX, 97 LINEAR_GRADIENT_BLUR_PARA, 98 MAGNIFIER_PARAMS, 99 MOTION_BLUR_PARAM, 100 VECTOR_EMITTER_UPDATER, 101 PARTICLE_NOISE_FIELD, 102 RS_MASK, 103 WATER_RIPPLE_PARAMS, 104 FLY_OUT_PARAMS, 105 RENDER_PARTICLE_VECTOR, 106 SHADER_PARAM, 107 UI_FILTER, 108 PIXEL_MAP, 109 DYNAMIC_BRIGHTNESS_PARA, 110 RS_RENDER_FILTER, 111 VECTOR_FLOAT, 112 VECTOR_VECTOR2F, 113 SHORT, // HRP: move it to the middle of FLOAT and INT 114 RS_NG_RENDER_FILTER_BASE, 115 RS_NG_RENDER_MASK_BASE, 116 RS_NG_RENDER_SHADER_BASE, 117 SHADOW_BLENDER_PARAMS, 118 }; 119 120 enum class RSPropertyUnit : uint8_t { 121 UNKNOWN = 0, 122 PIXEL_POSITION, 123 PIXEL_SIZE, 124 RATIO_SCALE, 125 ANGLE_ROTATION, 126 }; 127 128 class RSB_EXPORT RSRenderPropertyBase : public std::enable_shared_from_this<RSRenderPropertyBase> { 129 public: 130 RSRenderPropertyBase() = default; 131 RSRenderPropertyBase(const PropertyId& id) : id_(id) {} 132 RSRenderPropertyBase(const RSRenderPropertyBase&) = delete; 133 RSRenderPropertyBase(const RSRenderPropertyBase&&) = delete; 134 RSRenderPropertyBase& operator=(const RSRenderPropertyBase&) = delete; 135 RSRenderPropertyBase& operator=(const RSRenderPropertyBase&&) = delete; 136 virtual ~RSRenderPropertyBase() = default; 137 138 PropertyId GetId() const 139 { 140 return id_; 141 } 142 143 // Planning: move to protected 144 void Attach(RSRenderNode& node, std::weak_ptr<ModifierNG::RSRenderModifier> modifier = {}); 145 void Detach(); 146 147 std::weak_ptr<ModifierNG::RSRenderModifier> GetModifierNG() const 148 { 149 return modifier_; 150 } 151 152 virtual void Dump(std::string& out) const = 0; 153 virtual size_t GetSize() const = 0; 154 155 protected: 156 virtual bool Marshalling(Parcel& parcel) = 0; 157 [[nodiscard]] static bool Unmarshalling(Parcel& parcel, std::shared_ptr<RSRenderPropertyBase>& val); 158 159 void OnChange() const; 160 161 virtual void OnAttach(RSRenderNode& node, std::weak_ptr<ModifierNG::RSRenderModifier> modifier) {} 162 virtual void OnDetach() {} 163 164 void UpdatePropertyUnitNG(ModifierNG::RSPropertyType propertyType); 165 166 virtual const std::shared_ptr<RSRenderPropertyBase> Clone() const 167 { 168 return nullptr; 169 } 170 171 virtual void SetValue(const std::shared_ptr<RSRenderPropertyBase>& value) {} 172 173 virtual RSPropertyType GetPropertyType() const = 0; 174 175 virtual void SetPropertyUnit(RSPropertyUnit unit) {} 176 177 virtual RSPropertyUnit GetPropertyUnit() const 178 { 179 return RSPropertyUnit::UNKNOWN; 180 } 181 182 virtual float ToFloat() const 183 { 184 return 1.f; 185 } 186 187 virtual std::shared_ptr<RSValueEstimator> CreateRSValueEstimator(const RSValueEstimatorType type) 188 { 189 return nullptr; 190 } 191 192 virtual std::shared_ptr<RSSpringValueEstimatorBase> CreateRSSpringValueEstimator() 193 { 194 return nullptr; 195 } 196 197 virtual bool IsNearEqual(const std::shared_ptr<RSRenderPropertyBase>& value, float zeroThreshold) const 198 { 199 return true; 200 } 201 202 PropertyId id_; 203 // Only used in RSRenderProperty<std::shared_ptr<RSNGRenderFilterBase>>::Set 204 // refactor this to remove the node_ member 205 std::weak_ptr<RSRenderNode> node_; 206 207 std::weak_ptr<ModifierNG::RSRenderModifier> modifier_; 208 209 using UnmarshallingFunc = std::function<bool (Parcel&, std::shared_ptr<RSRenderPropertyBase>&)>; 210 inline static std::unordered_map<uint16_t, UnmarshallingFunc> UnmarshallingFuncs_; 211 212 class RSPropertyUnmarshallingFuncRegister { 213 public: 214 RSPropertyUnmarshallingFuncRegister(bool isAnimatable, RSPropertyType type, UnmarshallingFunc func) 215 { 216 if (type != RSPropertyType::INVALID) { 217 uint16_t key = static_cast<uint16_t>(isAnimatable) << 8 | static_cast<uint16_t>(type); 218 UnmarshallingFuncs_[key] = func; 219 } 220 } 221 }; 222 223 private: 224 virtual std::shared_ptr<RSRenderPropertyBase> Add(const std::shared_ptr<const RSRenderPropertyBase>& value) 225 { 226 return shared_from_this(); 227 } 228 229 virtual std::shared_ptr<RSRenderPropertyBase> Minus(const std::shared_ptr<const RSRenderPropertyBase>& value) 230 { 231 return shared_from_this(); 232 } 233 234 virtual std::shared_ptr<RSRenderPropertyBase> Multiply(const float scale) 235 { 236 return shared_from_this(); 237 } 238 239 virtual bool IsEqual(const std::shared_ptr<const RSRenderPropertyBase>& value) const 240 { 241 return true; 242 } 243 244 friend std::shared_ptr<RSRenderPropertyBase> operator+=( 245 const std::shared_ptr<RSRenderPropertyBase>& a, const std::shared_ptr<const RSRenderPropertyBase>& b); 246 friend std::shared_ptr<RSRenderPropertyBase> operator-=( 247 const std::shared_ptr<RSRenderPropertyBase>& a, const std::shared_ptr<const RSRenderPropertyBase>& b); 248 friend std::shared_ptr<RSRenderPropertyBase> operator*=( 249 const std::shared_ptr<RSRenderPropertyBase>& value, const float scale); 250 friend std::shared_ptr<RSRenderPropertyBase> operator+( 251 const std::shared_ptr<const RSRenderPropertyBase>& a, const std::shared_ptr<const RSRenderPropertyBase>& b); 252 friend std::shared_ptr<RSRenderPropertyBase> operator-( 253 const std::shared_ptr<const RSRenderPropertyBase>& a, const std::shared_ptr<const RSRenderPropertyBase>& b); 254 friend std::shared_ptr<RSRenderPropertyBase> operator*( 255 const std::shared_ptr<const RSRenderPropertyBase>& value, const float scale); 256 friend bool operator==( 257 const std::shared_ptr<const RSRenderPropertyBase>& a, const std::shared_ptr<const RSRenderPropertyBase>& b); 258 friend bool operator!=( 259 const std::shared_ptr<const RSRenderPropertyBase>& a, const std::shared_ptr<const RSRenderPropertyBase>& b); 260 friend class RSAnimationRateDecider; 261 friend class RSRenderPropertyAnimation; 262 friend class RSMarshallingHelper; 263 friend class RSValueEstimator; 264 friend class RSRenderPathAnimation; 265 friend class RSRenderSpringAnimation; 266 friend class RSRenderInterpolatingSpringAnimation; 267 friend class RSRenderCurveAnimation; 268 friend class RSRenderKeyframeAnimation; 269 template<typename T> 270 friend class RSSpringModel; 271 friend class RSTransitionCustom; 272 friend class RSAnimationTraceUtils; 273 friend class ModifierNG::RSRenderModifier; 274 }; 275 276 template<typename T> 277 class RSB_EXPORT_TMP RSRenderProperty : public RSRenderPropertyBase { 278 public: 279 RSRenderProperty() : RSRenderPropertyBase(0) {} 280 RSRenderProperty(const T& value, const PropertyId& id) : RSRenderPropertyBase(id), stagingValue_(value) {} 281 ~RSRenderProperty() override = default; 282 283 using ValueType = T; 284 285 virtual void Set(const T& value, PropertyUpdateType type = UPDATE_TYPE_OVERWRITE) 286 { 287 if (value == stagingValue_) { 288 return; 289 } 290 stagingValue_ = value; 291 OnChange(); 292 if (updateUIPropertyFunc_) { 293 updateUIPropertyFunc_(shared_from_this()); 294 } 295 } 296 297 T Get() const 298 { 299 return stagingValue_; 300 } 301 302 T& GetRef() 303 { 304 return stagingValue_; 305 } 306 307 size_t GetSize() const override 308 { 309 return sizeof(*this); 310 } 311 312 void Dump(std::string& out) const override {} 313 314 void SetUpdateUIPropertyFunc( 315 const std::function<void(const std::shared_ptr<RSRenderPropertyBase>&)>& updateUIPropertyFunc) 316 { 317 updateUIPropertyFunc_ = updateUIPropertyFunc; 318 } 319 320 protected: 321 T stagingValue_{}; 322 inline static const RSPropertyType type_ = RSPropertyType::INVALID; 323 std::function<void(const std::shared_ptr<RSRenderPropertyBase>&)> updateUIPropertyFunc_; 324 325 void OnAttach(RSRenderNode& node, std::weak_ptr<ModifierNG::RSRenderModifier> modifier) override {} 326 void OnDetach() override {} 327 328 RSPropertyType GetPropertyType() const override 329 { 330 return type_; 331 } 332 333 bool Marshalling(Parcel& parcel) override 334 { 335 // Planning: use static_assert to limit the types that can be used with RSRenderProperty. 336 if constexpr (RSRenderProperty<T>::type_ == RSPropertyType::INVALID) { 337 return false; 338 } 339 340 auto result = RSMarshallingHelper::Marshalling(parcel, type_) && 341 RSMarshallingHelper::Marshalling(parcel, false) && // for non-animatable properties 342 RSMarshallingHelper::Marshalling(parcel, GetId()) && 343 RSMarshallingHelper::Marshalling(parcel, stagingValue_); 344 return result; 345 } 346 static bool OnUnmarshalling(Parcel& parcel, std::shared_ptr<RSRenderPropertyBase>& val); 347 inline static RSPropertyUnmarshallingFuncRegister unmarshallingFuncRegister_ { false, type_, OnUnmarshalling }; 348 349 friend class RSMarshallingHelper; 350 }; 351 352 template<typename T> 353 class RSB_EXPORT_TMP RSRenderAnimatableProperty : public RSRenderProperty<T> { 354 static_assert(std::is_floating_point_v<T> || std::is_same_v<Color, T> || std::is_same_v<Matrix3f, T> || 355 std::is_same_v<Vector2f, T> || std::is_same_v<Vector3f, T> || std::is_same_v<Vector4f, T> || 356 std::is_same_v<Quaternion, T> || std::is_same_v<Vector4<Color>, T> || 357 supports_animatable_arithmetic<T>::value || std::is_base_of_v<RSAnimatableArithmetic<T>, T> || 358 std::is_same_v<RRect, T>); 359 360 public: 361 RSRenderAnimatableProperty() : RSRenderProperty<T>() {} 362 RSRenderAnimatableProperty(const T& value) : RSRenderProperty<T>(value, 0) {} 363 RSRenderAnimatableProperty(const T& value, const PropertyId& id) : RSRenderProperty<T>(value, id) {} 364 RSRenderAnimatableProperty(const T& value, const PropertyId& id, const RSPropertyUnit unit) 365 : RSRenderProperty<T>(value, id), unit_(unit) 366 {} 367 virtual ~RSRenderAnimatableProperty() = default; 368 369 using ValueType = T; 370 371 void Set(const T& value, PropertyUpdateType type = UPDATE_TYPE_OVERWRITE) override 372 { 373 if (type == UPDATE_TYPE_OVERWRITE && value == RSRenderProperty<T>::stagingValue_) { 374 return; 375 } 376 RSRenderProperty<T>::stagingValue_ = 377 type == UPDATE_TYPE_INCREMENTAL ? static_cast<T>(RSRenderProperty<T>::Get() + value) : value; 378 RSRenderProperty<T>::OnChange(); 379 if (RSRenderProperty<T>::updateUIPropertyFunc_) { 380 RSRenderProperty<T>::updateUIPropertyFunc_(RSRenderProperty<T>::shared_from_this()); 381 } 382 } 383 384 protected: 385 const std::shared_ptr<RSRenderPropertyBase> Clone() const override 386 { 387 return std::make_shared<RSRenderAnimatableProperty<T>>( 388 RSRenderProperty<T>::stagingValue_, RSRenderProperty<T>::id_, unit_); 389 } 390 391 void SetValue(const std::shared_ptr<RSRenderPropertyBase>& value) override 392 { 393 auto property = std::static_pointer_cast<RSRenderAnimatableProperty<T>>(value); 394 if (property != nullptr && property->GetPropertyType() == RSRenderProperty<T>::type_) { 395 RSRenderProperty<T>::Set(property->Get()); 396 } 397 } 398 399 void SetPropertyUnit(RSPropertyUnit unit) override 400 { 401 unit_ = unit; 402 } 403 404 RSPropertyUnit GetPropertyUnit() const override 405 { 406 return unit_; 407 } 408 409 float ToFloat() const override 410 { 411 return 1.f; 412 } 413 414 bool IsNearEqual(const std::shared_ptr<RSRenderPropertyBase>& value, float zeroThreshold) const override 415 { 416 return IsEqual(value); 417 } 418 419 std::shared_ptr<RSValueEstimator> CreateRSValueEstimator(const RSValueEstimatorType type) override 420 { 421 switch (type) { 422 case RSValueEstimatorType::CURVE_VALUE_ESTIMATOR: { 423 return std::make_shared<RSCurveValueEstimator<T>>(); 424 } 425 case RSValueEstimatorType::KEYFRAME_VALUE_ESTIMATOR: { 426 return std::make_shared<RSKeyframeValueEstimator<T>>(); 427 } 428 default: { 429 return nullptr; 430 } 431 } 432 } 433 434 std::shared_ptr<RSSpringValueEstimatorBase> CreateRSSpringValueEstimator() override 435 { 436 return std::make_shared<RSSpringValueEstimator<T>>(); 437 } 438 439 bool Marshalling(Parcel& parcel) override 440 { 441 // Planning: use static_assert to limit the types that can be used with RSRenderAnimatableProperty. 442 if constexpr (RSRenderProperty<T>::type_ == RSPropertyType::INVALID) { 443 return false; 444 } 445 446 auto result = RSMarshallingHelper::Marshalling(parcel, RSRenderProperty<T>::type_) && 447 RSMarshallingHelper::Marshalling(parcel, true) && // for animatable properties 448 RSMarshallingHelper::Marshalling(parcel, RSRenderProperty<T>::GetId()) && 449 RSMarshallingHelper::Marshalling(parcel, RSRenderProperty<T>::stagingValue_) && 450 RSMarshallingHelper::Marshalling(parcel, unit_); 451 return result; 452 } 453 static bool OnUnmarshalling(Parcel& parcel, std::shared_ptr<RSRenderPropertyBase>& val); 454 455 private: 456 RSPropertyUnit unit_ = RSPropertyUnit::UNKNOWN; 457 458 std::shared_ptr<RSRenderPropertyBase> Add(const std::shared_ptr<const RSRenderPropertyBase>& value) override 459 { 460 auto animatableProperty = std::static_pointer_cast<const RSRenderAnimatableProperty<T>>(value); 461 if (animatableProperty != nullptr) { 462 RSRenderProperty<T>::stagingValue_ = RSRenderProperty<T>::stagingValue_ + animatableProperty->stagingValue_; 463 } 464 return RSRenderProperty<T>::shared_from_this(); 465 } 466 467 std::shared_ptr<RSRenderPropertyBase> Minus(const std::shared_ptr<const RSRenderPropertyBase>& value) override 468 { 469 auto animatableProperty = std::static_pointer_cast<const RSRenderAnimatableProperty<T>>(value); 470 if (animatableProperty != nullptr) { 471 RSRenderProperty<T>::stagingValue_ = RSRenderProperty<T>::stagingValue_ - animatableProperty->stagingValue_; 472 } 473 return RSRenderProperty<T>::shared_from_this(); 474 } 475 476 std::shared_ptr<RSRenderPropertyBase> Multiply(const float scale) override 477 { 478 RSRenderProperty<T>::stagingValue_ = RSRenderProperty<T>::stagingValue_ * scale; 479 return RSRenderProperty<T>::shared_from_this(); 480 } 481 482 bool IsEqual(const std::shared_ptr<const RSRenderPropertyBase>& value) const override 483 { 484 auto animatableProperty = std::static_pointer_cast<const RSRenderAnimatableProperty<T>>(value); 485 if (animatableProperty != nullptr) { 486 return RSRenderProperty<T>::stagingValue_ == animatableProperty->stagingValue_; 487 } 488 return true; 489 } 490 491 inline static RSRenderPropertyBase::RSPropertyUnmarshallingFuncRegister unmarshallingFuncRegister_ { true, 492 RSRenderProperty<T>::type_, RSRenderAnimatableProperty<T>::OnUnmarshalling }; 493 friend class RSMarshallingHelper; 494 friend class RSRenderPathAnimation; 495 friend class RSRenderPropertyBase; 496 }; 497 498 template<> 499 RSB_EXPORT float RSRenderAnimatableProperty<float>::ToFloat() const; 500 template<> 501 RSB_EXPORT float RSRenderAnimatableProperty<Vector2f>::ToFloat() const; 502 template<> 503 RSB_EXPORT float RSRenderAnimatableProperty<Vector4f>::ToFloat() const; 504 template<> 505 RSB_EXPORT float RSRenderAnimatableProperty<Vector3f>::ToFloat() const; 506 template<> 507 RSB_EXPORT float RSRenderAnimatableProperty<Quaternion>::ToFloat() const; 508 509 template<> 510 RSB_EXPORT void RSRenderProperty<bool>::Dump(std::string& out) const; 511 template<> 512 RSB_EXPORT void RSRenderProperty<int>::Dump(std::string& out) const; 513 template<> 514 RSB_EXPORT void RSRenderProperty<float>::Dump(std::string& out) const; 515 template<> 516 RSB_EXPORT void RSRenderProperty<Quaternion>::Dump(std::string& out) const; 517 template<> 518 RSB_EXPORT void RSRenderProperty<Vector2f>::Dump(std::string& out) const; 519 template<> 520 RSB_EXPORT void RSRenderProperty<Vector3f>::Dump(std::string& out) const; 521 template<> 522 RSB_EXPORT void RSRenderProperty<Color>::Dump(std::string& out) const; 523 template<> 524 RSB_EXPORT void RSRenderProperty<Vector4<Color>>::Dump(std::string& out) const; 525 template<> 526 RSB_EXPORT void RSRenderProperty<RRect>::Dump(std::string& out) const; 527 template<> 528 RSB_EXPORT void RSRenderProperty<Drawing::DrawCmdListPtr>::Dump(std::string& out) const; 529 template<> 530 RSB_EXPORT void RSRenderProperty<ForegroundColorStrategyType>::Dump(std::string& out) const; 531 template<> 532 RSB_EXPORT void RSRenderProperty<SkMatrix>::Dump(std::string& out) const; 533 template<> 534 RSB_EXPORT void RSRenderProperty<std::shared_ptr<RSShader>>::Dump(std::string& out) const; 535 template<> 536 RSB_EXPORT void RSRenderProperty<std::shared_ptr<RSImage>>::Dump(std::string& out) const; 537 template<> 538 RSB_EXPORT void RSRenderProperty<std::shared_ptr<RSPath>>::Dump(std::string& out) const; 539 template<> 540 RSB_EXPORT void RSRenderProperty<Gravity>::Dump(std::string& out) const; 541 template<> 542 RSB_EXPORT void RSRenderProperty<Drawing::Matrix>::Dump(std::string& out) const; 543 template<> 544 RSB_EXPORT void RSRenderProperty<std::shared_ptr<RSLinearGradientBlurPara>>::Dump(std::string& out) const; 545 template<> 546 RSB_EXPORT void RSRenderProperty<std::shared_ptr<MotionBlurParam>>::Dump(std::string& out) const; 547 template<> 548 RSB_EXPORT void RSRenderProperty<std::shared_ptr<RSMagnifierParams>>::Dump(std::string& out) const; 549 template<> 550 RSB_EXPORT void RSRenderProperty<std::vector<std::shared_ptr<EmitterUpdater>>>::Dump(std::string& out) const; 551 template<> 552 RSB_EXPORT void RSRenderProperty<std::shared_ptr<ParticleNoiseFields>>::Dump(std::string& out) const; 553 template<> 554 RSB_EXPORT void RSRenderProperty<std::shared_ptr<RSMask>>::Dump(std::string& out) const; 555 template<> 556 RSB_EXPORT void RSRenderProperty<std::shared_ptr<RSNGRenderFilterBase>>::Dump(std::string& out) const; 557 template<> 558 RSB_EXPORT void RSRenderProperty<std::shared_ptr<RSNGRenderShaderBase>>::Dump(std::string& out) const; 559 template<> 560 RSB_EXPORT void RSRenderProperty<std::shared_ptr<RSNGRenderMaskBase>>::Dump(std::string& out) const; 561 562 template<> 563 RSB_EXPORT bool RSRenderAnimatableProperty<float>::IsNearEqual( 564 const std::shared_ptr<RSRenderPropertyBase>& value, float zeroThreshold) const; 565 template<> 566 RSB_EXPORT bool RSRenderAnimatableProperty<Vector4f>::IsNearEqual( 567 const std::shared_ptr<RSRenderPropertyBase>& value, float zeroThreshold) const; 568 template<> 569 RSB_EXPORT bool RSRenderAnimatableProperty<Quaternion>::IsNearEqual( 570 const std::shared_ptr<RSRenderPropertyBase>& value, float zeroThreshold) const; 571 template<> 572 RSB_EXPORT bool RSRenderAnimatableProperty<Vector2f>::IsNearEqual( 573 const std::shared_ptr<RSRenderPropertyBase>& value, float zeroThreshold) const; 574 template<> 575 RSB_EXPORT bool RSRenderAnimatableProperty<Vector3f>::IsNearEqual( 576 const std::shared_ptr<RSRenderPropertyBase>& value, float zeroThreshold) const; 577 template<> 578 RSB_EXPORT bool RSRenderAnimatableProperty<Matrix3f>::IsNearEqual( 579 const std::shared_ptr<RSRenderPropertyBase>& value, float zeroThreshold) const; 580 template<> 581 RSB_EXPORT bool RSRenderAnimatableProperty<Color>::IsNearEqual( 582 const std::shared_ptr<RSRenderPropertyBase>& value, float zeroThreshold) const; 583 template<> 584 RSB_EXPORT bool RSRenderAnimatableProperty<Vector4<Color>>::IsNearEqual( 585 const std::shared_ptr<RSRenderPropertyBase>& value, float zeroThreshold) const; 586 template<> 587 RSB_EXPORT bool RSRenderAnimatableProperty<RRect>::IsNearEqual( 588 const std::shared_ptr<RSRenderPropertyBase>& value, float zeroThreshold) const; 589 590 template<> 591 RSB_EXPORT size_t RSRenderProperty<Drawing::DrawCmdListPtr>::GetSize() const; 592 593 template<> 594 RSB_EXPORT void RSRenderProperty<std::shared_ptr<RSNGRenderFilterBase>>::OnAttach(RSRenderNode& node, 595 std::weak_ptr<ModifierNG::RSRenderModifier> modifier); 596 template<> 597 RSB_EXPORT void RSRenderProperty<std::shared_ptr<RSNGRenderFilterBase>>::OnDetach(); 598 template<> 599 RSB_EXPORT void RSRenderProperty<std::shared_ptr<RSNGRenderFilterBase>>::Set( 600 const std::shared_ptr<RSNGRenderFilterBase>& value, PropertyUpdateType type); 601 template<> 602 RSB_EXPORT void RSRenderProperty<std::shared_ptr<RSNGRenderShaderBase>>::OnAttach(RSRenderNode& node, 603 std::weak_ptr<ModifierNG::RSRenderModifier> modifier); 604 template<> 605 RSB_EXPORT void RSRenderProperty<std::shared_ptr<RSNGRenderShaderBase>>::OnDetach(); 606 template<> 607 RSB_EXPORT void RSRenderProperty<std::shared_ptr<RSNGRenderShaderBase>>::Set( 608 const std::shared_ptr<RSNGRenderShaderBase>& value, PropertyUpdateType type); 609 template<> 610 RSB_EXPORT void RSRenderProperty<std::shared_ptr<RSNGRenderMaskBase>>::OnAttach(RSRenderNode& node, 611 std::weak_ptr<ModifierNG::RSRenderModifier> modifier); 612 template<> 613 RSB_EXPORT void RSRenderProperty<std::shared_ptr<RSNGRenderMaskBase>>::OnDetach(); 614 template<> 615 RSB_EXPORT void RSRenderProperty<std::shared_ptr<RSNGRenderMaskBase>>::Set( 616 const std::shared_ptr<RSNGRenderMaskBase>& value, PropertyUpdateType type); 617 618 #if defined(_WIN32) 619 #define DECLARE_PROPERTY(T, TYPE_ENUM) extern template class RSRenderProperty<T> 620 #define DECLARE_ANIMATABLE_PROPERTY(T, TYPE_ENUM) \ 621 extern template class RSRenderAnimatableProperty<T>; \ 622 extern template class RSRenderProperty<T> 623 #else 624 #define DECLARE_PROPERTY(T, TYPE_ENUM) \ 625 template<> \ 626 inline const RSPropertyType RSRenderProperty<T>::type_ = RSPropertyType::TYPE_ENUM 627 #define DECLARE_ANIMATABLE_PROPERTY(T, TYPE_ENUM) DECLARE_PROPERTY(T, TYPE_ENUM) 628 #endif 629 630 #include "modifier/rs_property_def.in" 631 632 #undef DECLARE_PROPERTY 633 #undef DECLARE_ANIMATABLE_PROPERTY 634 635 636 } // namespace Rosen 637 } // namespace OHOS 638 639 #endif // RENDER_SERVICE_BASE_MODIFIER_RS_RENDER_PROPERTY_H 640