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 #include "modifier/rs_property.h"
17
18 #include "sandbox_utils.h"
19 #include "ui_effect/property/include/rs_ui_filter_base.h"
20 #include "ui_effect/property/include/rs_ui_mask_base.h"
21 #include "ui_effect/property/include/rs_ui_shader_base.h"
22
23 #include "command/rs_node_command.h"
24 #include "modifier/rs_modifier_manager_map.h"
25 #include "modifier_ng/rs_modifier_ng.h"
26 #include "platform/common/rs_log.h"
27
28 namespace OHOS {
29 namespace Rosen {
30 namespace {
31 constexpr int PID_SHIFT = 32;
32
33 namespace {
34 constexpr float DEFAULT_NEAR_ZERO_THRESHOLD = 1.0f / 256.0f;
35 constexpr float FLOAT_NEAR_ZERO_COARSE_THRESHOLD = 1.0f / 256.0f;
36 constexpr float FLOAT_NEAR_ZERO_MEDIUM_THRESHOLD = 1.0f / 1000.0f;
37 constexpr float FLOAT_NEAR_ZERO_FINE_THRESHOLD = 1.0f / 3072.0f;
38 constexpr float COLOR_NEAR_ZERO_THRESHOLD = 0.0f;
39 constexpr float LAYOUT_NEAR_ZERO_THRESHOLD = 0.5f;
40 constexpr float ZERO = 0.0f;
41 } // namespace
42
GeneratePropertyId()43 PropertyId GeneratePropertyId()
44 {
45 static pid_t pid_ = GetRealPid();
46 static std::atomic<uint32_t> currentId_ = 1;
47
48 auto currentId = currentId_.fetch_add(1, std::memory_order_relaxed);
49 if (currentId == UINT32_MAX) {
50 // [PLANNING]:process the overflow situations
51 ROSEN_LOGE("Property Id overflow");
52 }
53
54 return ((PropertyId)pid_ << PID_SHIFT) | currentId;
55 }
56 } // namespace
57
RSPropertyBase()58 RSPropertyBase::RSPropertyBase() : id_(GeneratePropertyId())
59 {}
60
MarkCustomModifierDirty()61 void RSPropertyBase::MarkCustomModifierDirty()
62 {
63 if (auto modifier = modifierNG_.lock()) {
64 auto node = target_.lock();
65 if (node && node->GetRSUIContext()) {
66 modifier->SetDirty(true, node->GetRSUIContext()->GetRSModifierManager());
67 } else {
68 modifier->SetDirty(true, RSModifierManagerMap::Instance()->GetModifierManager(gettid()));
69 }
70 }
71 }
72
MarkNodeDirty()73 void RSPropertyBase::MarkNodeDirty()
74 {
75 if (auto modifier = modifierNG_.lock()) {
76 modifier->MarkNodeDirty();
77 }
78 }
79
UpdateExtendModifierForGeometry(const std::shared_ptr<RSNode> & node)80 void RSPropertyBase::UpdateExtendModifierForGeometry(const std::shared_ptr<RSNode>& node)
81 {
82 if (auto modifier = modifierNG_.lock()) {
83 if (modifier->GetType() == ModifierNG::RSModifierType::BOUNDS ||
84 modifier->GetType() == ModifierNG::RSModifierType::FRAME) {
85 node->MarkAllExtendModifierDirty();
86 }
87 }
88 }
89
GetThresholdByThresholdType(ThresholdType thresholdType) const90 float RSPropertyBase::GetThresholdByThresholdType(ThresholdType thresholdType) const
91 {
92 switch (thresholdType) {
93 case ThresholdType::LAYOUT:
94 return LAYOUT_NEAR_ZERO_THRESHOLD;
95 case ThresholdType::COARSE:
96 return FLOAT_NEAR_ZERO_COARSE_THRESHOLD;
97 case ThresholdType::MEDIUM:
98 return FLOAT_NEAR_ZERO_MEDIUM_THRESHOLD;
99 case ThresholdType::FINE:
100 return FLOAT_NEAR_ZERO_FINE_THRESHOLD;
101 case ThresholdType::COLOR:
102 return COLOR_NEAR_ZERO_THRESHOLD;
103 case ThresholdType::ZERO:
104 return ZERO;
105 default:
106 return DEFAULT_NEAR_ZERO_THRESHOLD;
107 }
108 }
109
operator +=(const std::shared_ptr<RSPropertyBase> & a,const std::shared_ptr<const RSPropertyBase> & b)110 std::shared_ptr<RSPropertyBase> operator+=(const std::shared_ptr<RSPropertyBase>& a,
111 const std::shared_ptr<const RSPropertyBase>& b)
112 {
113 if (a == nullptr) {
114 return {};
115 }
116
117 return a->Add(b);
118 }
119
operator -=(const std::shared_ptr<RSPropertyBase> & a,const std::shared_ptr<const RSPropertyBase> & b)120 std::shared_ptr<RSPropertyBase> operator-=(const std::shared_ptr<RSPropertyBase>& a,
121 const std::shared_ptr<const RSPropertyBase>& b)
122 {
123 if (a == nullptr) {
124 return {};
125 }
126
127 return a->Minus(b);
128 }
129
operator *=(const std::shared_ptr<RSPropertyBase> & value,const float scale)130 std::shared_ptr<RSPropertyBase> operator*=(const std::shared_ptr<RSPropertyBase>& value, const float scale)
131 {
132 if (value == nullptr) {
133 return {};
134 }
135
136 return value->Multiply(scale);
137 }
138
operator +(const std::shared_ptr<const RSPropertyBase> & a,const std::shared_ptr<const RSPropertyBase> & b)139 std::shared_ptr<RSPropertyBase> operator+(const std::shared_ptr<const RSPropertyBase>& a,
140 const std::shared_ptr<const RSPropertyBase>& b)
141 {
142 if (a == nullptr) {
143 return {};
144 }
145
146 const auto clone = a->Clone();
147 if (clone == nullptr) {
148 return {};
149 }
150 return clone->Add(b);
151 }
152
operator -(const std::shared_ptr<const RSPropertyBase> & a,const std::shared_ptr<const RSPropertyBase> & b)153 std::shared_ptr<RSPropertyBase> operator-(const std::shared_ptr<const RSPropertyBase>& a,
154 const std::shared_ptr<const RSPropertyBase>& b)
155 {
156 if (a == nullptr) {
157 return {};
158 }
159
160 const auto clone = a->Clone();
161 if (clone == nullptr) {
162 return {};
163 }
164 return clone->Minus(b);
165 }
166
operator *(const std::shared_ptr<const RSPropertyBase> & value,const float scale)167 std::shared_ptr<RSPropertyBase> operator*(const std::shared_ptr<const RSPropertyBase>& value, const float scale)
168 {
169 if (value == nullptr) {
170 return {};
171 }
172
173 const auto clone = value->Clone();
174 if (clone == nullptr) {
175 return {};
176 }
177 return clone->Multiply(scale);
178 }
179
operator ==(const std::shared_ptr<const RSPropertyBase> & a,const std::shared_ptr<const RSPropertyBase> & b)180 bool operator==(const std::shared_ptr<const RSPropertyBase>& a, const std::shared_ptr<const RSPropertyBase>& b)
181 {
182 if (a == nullptr) {
183 return false;
184 }
185
186 return a->IsEqual(b);
187 }
188
operator !=(const std::shared_ptr<const RSPropertyBase> & a,const std::shared_ptr<const RSPropertyBase> & b)189 bool operator!=(const std::shared_ptr<const RSPropertyBase>& a, const std::shared_ptr<const RSPropertyBase>& b)
190 {
191 if (a == nullptr) {
192 return false;
193 }
194
195 return !a->IsEqual(b);
196 }
197
198 template<>
OnAttach(RSNode & node,std::weak_ptr<ModifierNG::RSModifier> modifier)199 void RSProperty<std::shared_ptr<RSNGFilterBase>>::OnAttach(RSNode& node, std::weak_ptr<ModifierNG::RSModifier> modifier)
200 {
201 if (stagingValue_) {
202 stagingValue_->Attach(node, modifier);
203 }
204 }
205
206 template<>
OnDetach()207 void RSProperty<std::shared_ptr<RSNGFilterBase>>::OnDetach()
208 {
209 if (stagingValue_) {
210 stagingValue_->Detach();
211 }
212 }
213
214 template<>
Set(const std::shared_ptr<RSNGFilterBase> & value)215 void RSProperty<std::shared_ptr<RSNGFilterBase>>::Set(const std::shared_ptr<RSNGFilterBase>& value)
216 {
217 auto node = target_.lock();
218 if (node == nullptr) {
219 stagingValue_ = value;
220 return;
221 }
222
223 // Incremental update for filter properties, return if success
224 if (stagingValue_ && stagingValue_->SetValue(value, *node, modifierNG_)) {
225 return;
226 }
227
228 // failed to update filter properties, fallback to replace operation
229 if (stagingValue_) {
230 stagingValue_->Detach();
231 }
232 stagingValue_ = value;
233 if (stagingValue_) {
234 stagingValue_->Attach(*node, modifierNG_);
235 }
236
237 MarkNodeDirty();
238 UpdateToRender(stagingValue_, UPDATE_TYPE_OVERWRITE);
239 }
240
241 template<>
GetRenderProperty()242 RSC_EXPORT std::shared_ptr<RSRenderPropertyBase> RSProperty<std::shared_ptr<RSNGFilterBase>>::GetRenderProperty()
243 {
244 std::shared_ptr<RSNGRenderFilterBase> renderProp = stagingValue_ ? stagingValue_->GetRenderEffect() : nullptr;
245 return std::make_shared<RSRenderProperty<std::shared_ptr<RSNGRenderFilterBase>>>(renderProp, id_);
246 }
247
248 template<>
OnAttach(RSNode & node,std::weak_ptr<ModifierNG::RSModifier> modifier)249 void RSProperty<std::shared_ptr<RSNGShaderBase>>::OnAttach(RSNode& node, std::weak_ptr<ModifierNG::RSModifier> modifier)
250 {
251 if (stagingValue_) {
252 stagingValue_->Attach(node, modifier);
253 }
254 }
255
256 template<>
OnDetach()257 void RSProperty<std::shared_ptr<RSNGShaderBase>>::OnDetach()
258 {
259 if (stagingValue_) {
260 stagingValue_->Detach();
261 }
262 }
263
264 template<>
Set(const std::shared_ptr<RSNGShaderBase> & value)265 void RSProperty<std::shared_ptr<RSNGShaderBase>>::Set(const std::shared_ptr<RSNGShaderBase>& value)
266 {
267 auto node = target_.lock();
268 if (node == nullptr) {
269 stagingValue_ = value;
270 return;
271 }
272
273 // Incremental update for filter properties, return if success
274 if (stagingValue_ && stagingValue_->SetValue(value, *node, modifierNG_)) {
275 return;
276 }
277
278 // failed to update filter properties, fallback to replace operation
279 if (stagingValue_) {
280 stagingValue_->Detach();
281 }
282 stagingValue_ = value;
283 if (stagingValue_) {
284 stagingValue_->Attach(*node, modifierNG_);
285 }
286
287 MarkNodeDirty();
288 UpdateToRender(stagingValue_, UPDATE_TYPE_OVERWRITE);
289 }
290
291 template<>
GetRenderProperty()292 RSC_EXPORT std::shared_ptr<RSRenderPropertyBase> RSProperty<std::shared_ptr<RSNGShaderBase>>::GetRenderProperty()
293 {
294 std::shared_ptr<RSNGRenderShaderBase> renderProp = stagingValue_ ? stagingValue_->GetRenderEffect() : nullptr;
295 return std::make_shared<RSRenderProperty<std::shared_ptr<RSNGRenderShaderBase>>>(renderProp, id_);
296 }
297
298 template<>
OnAttach(RSNode & node,std::weak_ptr<ModifierNG::RSModifier> modifier)299 void RSProperty<std::shared_ptr<RSNGMaskBase>>::OnAttach(RSNode& node, std::weak_ptr<ModifierNG::RSModifier> modifier)
300 {
301 if (stagingValue_) {
302 stagingValue_->Attach(node, modifier);
303 }
304 }
305
306 template<>
OnDetach()307 void RSProperty<std::shared_ptr<RSNGMaskBase>>::OnDetach()
308 {
309 if (stagingValue_) {
310 stagingValue_->Detach();
311 }
312 }
313
314 template<>
Set(const std::shared_ptr<RSNGMaskBase> & value)315 void RSProperty<std::shared_ptr<RSNGMaskBase>>::Set(const std::shared_ptr<RSNGMaskBase>& value)
316 {
317 auto node = target_.lock();
318 if (node == nullptr) {
319 stagingValue_ = value;
320 return;
321 }
322
323 // Incremental update for mask properties, return if success
324 if (stagingValue_ && stagingValue_->SetValue(value, *node, modifierNG_)) {
325 return;
326 }
327
328 // failed to update mask properties, fallback to replace operation
329 if (stagingValue_) {
330 stagingValue_->Detach();
331 }
332 stagingValue_ = value;
333 if (stagingValue_) {
334 stagingValue_->Attach(*node, modifierNG_);
335 }
336
337 MarkNodeDirty();
338 UpdateToRender(stagingValue_, UPDATE_TYPE_OVERWRITE);
339 }
340
341 template<>
GetRenderProperty()342 RSC_EXPORT std::shared_ptr<RSRenderPropertyBase> RSProperty<std::shared_ptr<RSNGMaskBase>>::GetRenderProperty()
343 {
344 std::shared_ptr<RSNGRenderMaskBase> renderProp = stagingValue_ ? stagingValue_->GetRenderEffect() : nullptr;
345 return std::make_shared<RSRenderProperty<std::shared_ptr<RSNGRenderMaskBase>>>(renderProp, id_);
346 }
347
348 #define UPDATE_TO_RENDER(Command, value, type) \
349 auto node = target_.lock(); \
350 if (node != nullptr) { \
351 auto transaction = node->GetRSTransaction(); \
352 if (!transaction) { \
353 do { \
354 auto transactionProxy = RSTransactionProxy::GetInstance(); \
355 if (transactionProxy) { \
356 std::unique_ptr<RSCommand> command = std::make_unique<Command>(node->GetId(), value, id_, type); \
357 transactionProxy->AddCommand( \
358 command, node->IsRenderServiceNode(), node->GetFollowType(), node->GetId()); \
359 if (node->NeedForcedSendToRemote()) { \
360 std::unique_ptr<RSCommand> commandForRemote = \
361 std::make_unique<Command>(node->GetId(), value, id_, type); \
362 transactionProxy->AddCommand(commandForRemote, true, node->GetFollowType(), node->GetId()); \
363 } \
364 } \
365 } while (0); \
366 } else { \
367 do { \
368 std::unique_ptr<RSCommand> command = std::make_unique<Command>(node->GetId(), value, id_, type); \
369 transaction->AddCommand(command, node->IsRenderServiceNode(), node->GetFollowType(), node->GetId()); \
370 if (node->NeedForcedSendToRemote()) { \
371 std::unique_ptr<RSCommand> commandForRemote = \
372 std::make_unique<Command>(node->GetId(), value, id_, type); \
373 transaction->AddCommand(commandForRemote, true, node->GetFollowType(), node->GetId()); \
374 } \
375 } while (0); \
376 } \
377 }
378
379 template<>
UpdateToRender(const bool & value,PropertyUpdateType type) const380 void RSProperty<bool>::UpdateToRender(const bool& value, PropertyUpdateType type) const
381 {
382 UPDATE_TO_RENDER(RSUpdatePropertyBool, value, type);
383 }
384 template<>
UpdateToRender(const float & value,PropertyUpdateType type) const385 void RSProperty<float>::UpdateToRender(const float& value, PropertyUpdateType type) const
386 {
387 UPDATE_TO_RENDER(RSUpdatePropertyFloat, value, type);
388 }
389 template<>
UpdateToRender(const std::vector<float> & value,PropertyUpdateType type) const390 void RSProperty<std::vector<float>>::UpdateToRender(const std::vector<float>& value, PropertyUpdateType type) const
391 {
392 UPDATE_TO_RENDER(RSUpdatePropertyComplexShaderParam, value, type);
393 }
394 template<>
UpdateToRender(const int & value,PropertyUpdateType type) const395 void RSProperty<int>::UpdateToRender(const int& value, PropertyUpdateType type) const
396 {
397 UPDATE_TO_RENDER(RSUpdatePropertyInt, value, type);
398 }
399 template<>
UpdateToRender(const Color & value,PropertyUpdateType type) const400 void RSProperty<Color>::UpdateToRender(const Color& value, PropertyUpdateType type) const
401 {
402 UPDATE_TO_RENDER(RSUpdatePropertyColor, value, type);
403 }
404 template<>
UpdateToRender(const Gravity & value,PropertyUpdateType type) const405 void RSProperty<Gravity>::UpdateToRender(const Gravity& value, PropertyUpdateType type) const
406 {
407 UPDATE_TO_RENDER(RSUpdatePropertyGravity, value, type);
408 }
409 template<>
UpdateToRender(const Matrix3f & value,PropertyUpdateType type) const410 void RSProperty<Matrix3f>::UpdateToRender(const Matrix3f& value, PropertyUpdateType type) const
411 {
412 UPDATE_TO_RENDER(RSUpdatePropertyMatrix3f, value, type);
413 }
414 template<>
UpdateToRender(const Quaternion & value,PropertyUpdateType type) const415 void RSProperty<Quaternion>::UpdateToRender(const Quaternion& value, PropertyUpdateType type) const
416 {
417 UPDATE_TO_RENDER(RSUpdatePropertyQuaternion, value, type);
418 }
419 template<>
UpdateToRender(const std::shared_ptr<RSImage> & value,PropertyUpdateType type) const420 void RSProperty<std::shared_ptr<RSImage>>::UpdateToRender(
421 const std::shared_ptr<RSImage>& value, PropertyUpdateType type) const
422 {
423 UPDATE_TO_RENDER(RSUpdatePropertyImage, value, type);
424 }
425 template<>
UpdateToRender(const std::shared_ptr<RSMask> & value,PropertyUpdateType type) const426 void RSProperty<std::shared_ptr<RSMask>>::UpdateToRender(
427 const std::shared_ptr<RSMask>& value, PropertyUpdateType type) const
428 {
429 UPDATE_TO_RENDER(RSUpdatePropertyMask, value, type);
430 }
431 template<>
UpdateToRender(const std::shared_ptr<RSPath> & value,PropertyUpdateType type) const432 void RSProperty<std::shared_ptr<RSPath>>::UpdateToRender(
433 const std::shared_ptr<RSPath>& value, PropertyUpdateType type) const
434 {
435 UPDATE_TO_RENDER(RSUpdatePropertyPath, value, type);
436 }
437 template<>
UpdateToRender(const RSDynamicBrightnessPara & value,PropertyUpdateType type) const438 void RSProperty<RSDynamicBrightnessPara>::UpdateToRender(
439 const RSDynamicBrightnessPara& value, PropertyUpdateType type) const
440 {
441 UPDATE_TO_RENDER(RSUpdatePropertyDynamicBrightness, value, type);
442 }
443 template<>
UpdateToRender(const std::shared_ptr<RSLinearGradientBlurPara> & value,PropertyUpdateType type) const444 void RSProperty<std::shared_ptr<RSLinearGradientBlurPara>>::UpdateToRender(
445 const std::shared_ptr<RSLinearGradientBlurPara>& value, PropertyUpdateType type) const
446 {
447 UPDATE_TO_RENDER(RSUpdatePropertyLinearGradientBlurPara, value, type);
448 }
449 template<>
UpdateToRender(const RSWaterRipplePara & value,PropertyUpdateType type) const450 void RSProperty<RSWaterRipplePara>::UpdateToRender(
451 const RSWaterRipplePara& value, PropertyUpdateType type) const
452 {
453 UPDATE_TO_RENDER(RSUpdatePropertyWaterRipple, value, type);
454 }
455 template<>
UpdateToRender(const RSFlyOutPara & value,PropertyUpdateType type) const456 void RSProperty<RSFlyOutPara>::UpdateToRender(
457 const RSFlyOutPara& value, PropertyUpdateType type) const
458 {
459 UPDATE_TO_RENDER(RSUpdatePropertyFlyOut, value, type);
460 }
461 template<>
UpdateToRender(const std::shared_ptr<MotionBlurParam> & value,PropertyUpdateType type) const462 void RSProperty<std::shared_ptr<MotionBlurParam>>::UpdateToRender(
463 const std::shared_ptr<MotionBlurParam>& value, PropertyUpdateType type) const
464 {
465 UPDATE_TO_RENDER(RSUpdatePropertyMotionBlurPara, value, type);
466 }
467 template<>
UpdateToRender(const std::shared_ptr<RSMagnifierParams> & value,PropertyUpdateType type) const468 void RSProperty<std::shared_ptr<RSMagnifierParams>>::UpdateToRender(
469 const std::shared_ptr<RSMagnifierParams>& value, PropertyUpdateType type) const
470 {
471 UPDATE_TO_RENDER(RSUpdatePropertyMagnifierPara, value, type);
472 }
473 template<>
UpdateToRender(const std::vector<std::shared_ptr<EmitterUpdater>> & value,PropertyUpdateType type) const474 void RSProperty<std::vector<std::shared_ptr<EmitterUpdater>>>::UpdateToRender(
475 const std::vector<std::shared_ptr<EmitterUpdater>>& value, PropertyUpdateType type) const
476 {
477 UPDATE_TO_RENDER(RSUpdatePropertyEmitterUpdater, value, type);
478 }
479 template<>
UpdateToRender(const std::shared_ptr<ParticleNoiseFields> & value,PropertyUpdateType type) const480 void RSProperty<std::shared_ptr<ParticleNoiseFields>>::UpdateToRender(
481 const std::shared_ptr<ParticleNoiseFields>& value, PropertyUpdateType type) const
482 {
483 UPDATE_TO_RENDER(RSUpdatePropertyParticleNoiseFields, value, type);
484 }
485 template<>
UpdateToRender(const std::shared_ptr<RSShader> & value,PropertyUpdateType type) const486 void RSProperty<std::shared_ptr<RSShader>>::UpdateToRender(
487 const std::shared_ptr<RSShader>& value, PropertyUpdateType type) const
488 {
489 UPDATE_TO_RENDER(RSUpdatePropertyShader, value, type);
490 }
491 template<>
UpdateToRender(const Vector2f & value,PropertyUpdateType type) const492 void RSProperty<Vector2f>::UpdateToRender(const Vector2f& value, PropertyUpdateType type) const
493 {
494 UPDATE_TO_RENDER(RSUpdatePropertyVector2f, value, type);
495 }
496 template<>
UpdateToRender(const Vector3f & value,PropertyUpdateType type) const497 void RSProperty<Vector3f>::UpdateToRender(const Vector3f& value, PropertyUpdateType type) const
498 {
499 UPDATE_TO_RENDER(RSUpdatePropertyVector3f, value, type);
500 }
501 template<>
UpdateToRender(const Vector4<uint32_t> & value,PropertyUpdateType type) const502 void RSProperty<Vector4<uint32_t>>::UpdateToRender(const Vector4<uint32_t>& value,
503 PropertyUpdateType type) const
504 {
505 UPDATE_TO_RENDER(RSUpdatePropertyBorderStyle, value, type);
506 }
507 template<>
UpdateToRender(const Vector4<Color> & value,PropertyUpdateType type) const508 void RSProperty<Vector4<Color>>::UpdateToRender(const Vector4<Color>& value,
509 PropertyUpdateType type) const
510 {
511 UPDATE_TO_RENDER(RSUpdatePropertyVector4Color, value, type);
512 }
513 template<>
UpdateToRender(const Vector4f & value,PropertyUpdateType type) const514 void RSProperty<Vector4f>::UpdateToRender(const Vector4f& value, PropertyUpdateType type) const
515 {
516 UPDATE_TO_RENDER(RSUpdatePropertyVector4f, value, type);
517 }
518
519 template<>
UpdateToRender(const RRect & value,PropertyUpdateType type) const520 void RSProperty<RRect>::UpdateToRender(const RRect& value, PropertyUpdateType type) const
521 {
522 UPDATE_TO_RENDER(RSUpdatePropertyRRect, value, type);
523 }
524
525 template<>
UpdateToRender(const std::shared_ptr<RSNGFilterBase> & value,PropertyUpdateType type) const526 void RSProperty<std::shared_ptr<RSNGFilterBase>>::UpdateToRender(
527 const std::shared_ptr<RSNGFilterBase>& value, PropertyUpdateType type) const
528 {
529 UPDATE_TO_RENDER(RSUpdatePropertyNGFilterBase, value ? value->GetRenderEffect() : nullptr, type);
530 }
531
532 template<>
UpdateToRender(const std::shared_ptr<RSNGShaderBase> & value,PropertyUpdateType type) const533 void RSProperty<std::shared_ptr<RSNGShaderBase>>::UpdateToRender(
534 const std::shared_ptr<RSNGShaderBase>& value, PropertyUpdateType type) const
535 {
536 UPDATE_TO_RENDER(RSUpdatePropertyNGShaderBase, value ? value->GetRenderEffect() : nullptr, type);
537 }
538
539 template<>
UpdateToRender(const std::shared_ptr<RSNGMaskBase> & value,PropertyUpdateType type) const540 void RSProperty<std::shared_ptr<RSNGMaskBase>>::UpdateToRender(
541 const std::shared_ptr<RSNGMaskBase>& value, PropertyUpdateType type) const
542 {
543 UPDATE_TO_RENDER(RSUpdatePropertyNGMaskBase, value ? value->GetRenderEffect() : nullptr, type);
544 }
545
546 template<>
IsValid(const float & value)547 bool RSProperty<float>::IsValid(const float& value)
548 {
549 return !isinf(value);
550 }
551 template<>
IsValid(const Vector2f & value)552 bool RSProperty<Vector2f>::IsValid(const Vector2f& value)
553 {
554 return !value.IsInfinite();
555 }
556 template<>
IsValid(const Vector4f & value)557 bool RSProperty<Vector4f>::IsValid(const Vector4f& value)
558 {
559 return !value.IsInfinite();
560 }
561
562 #define DECLARE_PROPERTY(T, TYPE_ENUM) template class RSProperty<T>
563 #define DECLARE_ANIMATABLE_PROPERTY(T, TYPE_ENUM) \
564 template class RSAnimatableProperty<T>; \
565 template class RSProperty<T>
566
567 #include "modifier/rs_property_def.in"
568 #undef DECLARE_PROPERTY
569 #undef DECLARE_ANIMATABLE_PROPERTY
570 } // namespace Rosen
571 } // namespace OHOS
572