• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_render_property.h"
17 
18 #include "pipeline/rs_render_node.h"
19 #include "platform/common/rs_log.h"
20 #include "rs_profiler.h"
21 
22 namespace OHOS {
23 namespace Rosen {
24 
OnChange() const25 void RSRenderPropertyBase::OnChange() const
26 {
27     if (auto node = node_.lock()) {
28         node->SetDirty();
29         node->AddDirtyType(modifierType_);
30         if (modifierType_ < RSModifierType::BOUNDS || modifierType_ > RSModifierType::TRANSLATE_Z ||
31             modifierType_ == RSModifierType::POSITION_Z) {
32             node->MarkNonGeometryChanged();
33         }
34         if (modifierType_ > RSModifierType::EXTENDED) {
35             node->SetContentDirty();
36         }
37         if (modifierType_ == RSModifierType::POSITION_Z) {
38             node->MarkParentNeedRegenerateChildren();
39         }
40     }
41 }
42 
UpdatePropertyUnit(RSModifierType type)43 void RSRenderPropertyBase::UpdatePropertyUnit(RSModifierType type)
44 {
45     switch (type) {
46         case RSModifierType::FRAME:
47         case RSModifierType::TRANSLATE:
48             SetPropertyUnit(RSPropertyUnit::PIXEL_POSITION);
49             break;
50         case RSModifierType::SCALE:
51             SetPropertyUnit(RSPropertyUnit::RATIO_SCALE);
52             break;
53         case RSModifierType::ROTATION_X:
54         case RSModifierType::ROTATION_Y:
55         case RSModifierType::ROTATION:
56             SetPropertyUnit(RSPropertyUnit::ANGLE_ROTATION);
57             break;
58         default:
59             SetPropertyUnit(RSPropertyUnit::UNKNOWN);
60             break;
61     }
62 }
63 
Marshalling(Parcel & parcel,const std::shared_ptr<RSRenderPropertyBase> & val)64 bool RSRenderPropertyBase::Marshalling(Parcel& parcel, const std::shared_ptr<RSRenderPropertyBase>& val)
65 {
66     if (val == nullptr) {
67         parcel.WriteUint16(static_cast<int16_t>(RSModifierType::INVALID));
68         return true;
69     }
70     RSRenderPropertyType type = val->GetPropertyType();
71     if (!(parcel.WriteInt16(static_cast<int16_t>(type)))) {
72         return false;
73     }
74     RSPropertyUnit unit = val->GetPropertyUnit();
75     if (!(parcel.WriteInt16(static_cast<int16_t>(unit)))) {
76         return false;
77     }
78     switch (type) {
79         case RSRenderPropertyType::PROPERTY_FLOAT: {
80             auto property = std::static_pointer_cast<RSRenderAnimatableProperty<float>>(val);
81             if (property == nullptr) {
82                 return false;
83             }
84             return parcel.WriteUint64(property->GetId()) && RSMarshallingHelper::Marshalling(parcel, property->Get());
85         }
86         case RSRenderPropertyType::PROPERTY_COLOR: {
87             auto property = std::static_pointer_cast<RSRenderAnimatableProperty<Color>>(val);
88             if (property == nullptr) {
89                 return false;
90             }
91             return parcel.WriteUint64(property->GetId()) && RSMarshallingHelper::Marshalling(parcel, property->Get());
92         }
93         case RSRenderPropertyType::PROPERTY_MATRIX3F: {
94             auto property = std::static_pointer_cast<RSRenderAnimatableProperty<Matrix3f>>(val);
95             if (property == nullptr) {
96                 return false;
97             }
98             return parcel.WriteUint64(property->GetId()) && RSMarshallingHelper::Marshalling(parcel, property->Get());
99         }
100         case RSRenderPropertyType::PROPERTY_QUATERNION: {
101             auto property = std::static_pointer_cast<RSRenderAnimatableProperty<Quaternion>>(val);
102             if (property == nullptr) {
103                 return false;
104             }
105             return parcel.WriteUint64(property->GetId()) && RSMarshallingHelper::Marshalling(parcel, property->Get());
106         }
107         case RSRenderPropertyType::PROPERTY_FILTER: {
108             auto property = std::static_pointer_cast<RSRenderAnimatableProperty<std::shared_ptr<RSFilter>>>(val);
109             if (property == nullptr) {
110                 return false;
111             }
112             return parcel.WriteUint64(property->GetId()) && RSMarshallingHelper::Marshalling(parcel, property->Get());
113         }
114         case RSRenderPropertyType::PROPERTY_VECTOR2F: {
115             auto property = std::static_pointer_cast<RSRenderAnimatableProperty<Vector2f>>(val);
116             if (property == nullptr) {
117                 return false;
118             }
119             return parcel.WriteUint64(property->GetId()) && RSMarshallingHelper::Marshalling(parcel, property->Get());
120         }
121         case RSRenderPropertyType::PROPERTY_VECTOR4F: {
122             auto property = std::static_pointer_cast<RSRenderAnimatableProperty<Vector4f>>(val);
123             if (property == nullptr) {
124                 return false;
125             }
126             return parcel.WriteUint64(property->GetId()) && RSMarshallingHelper::Marshalling(parcel, property->Get());
127         }
128         case RSRenderPropertyType::PROPERTY_VECTOR4_COLOR: {
129             auto property = std::static_pointer_cast<RSRenderAnimatableProperty<Vector4<Color>>>(val);
130             if (property == nullptr) {
131                 return false;
132             }
133             return parcel.WriteUint64(property->GetId()) && RSMarshallingHelper::Marshalling(parcel, property->Get());
134         }
135         case RSRenderPropertyType::PROPERTY_RRECT: {
136             auto property = std::static_pointer_cast<RSRenderAnimatableProperty<RRect>>(val);
137             if (property == nullptr) {
138                 return false;
139             }
140             return parcel.WriteUint64(property->GetId()) && RSMarshallingHelper::Marshalling(parcel, property->Get());
141         }
142         default: {
143             return false;
144         }
145     }
146     return true;
147 }
148 
Unmarshalling(Parcel & parcel,std::shared_ptr<RSRenderPropertyBase> & val)149 bool RSRenderPropertyBase::Unmarshalling(Parcel& parcel, std::shared_ptr<RSRenderPropertyBase>& val)
150 {
151     int16_t typeId = 0;
152     if (!parcel.ReadInt16(typeId)) {
153         return false;
154     }
155     RSRenderPropertyType type = static_cast<RSRenderPropertyType>(typeId);
156     if (type == RSRenderPropertyType::INVALID) {
157         val.reset();
158         return true;
159     }
160     int16_t unitId = 0;
161     if (!parcel.ReadInt16(unitId)) {
162         return false;
163     }
164     RSPropertyUnit unit = static_cast<RSPropertyUnit>(unitId);
165     PropertyId id = 0;
166     if (!parcel.ReadUint64(id)) {
167         return false;
168     }
169     RS_PROFILER_PATCH_NODE_ID(parcel, id);
170     switch (type) {
171         case RSRenderPropertyType::PROPERTY_FLOAT: {
172             float value;
173             if (!RSMarshallingHelper::Unmarshalling(parcel, value)) {
174                 return false;
175             }
176             val.reset(new RSRenderAnimatableProperty<float>(value, id, type, unit));
177             break;
178         }
179         case RSRenderPropertyType::PROPERTY_COLOR: {
180             Color value;
181             if (!RSMarshallingHelper::Unmarshalling(parcel, value)) {
182                 return false;
183             }
184             val.reset(new RSRenderAnimatableProperty<Color>(value, id, type, unit));
185             break;
186         }
187         case RSRenderPropertyType::PROPERTY_MATRIX3F: {
188             Matrix3f value;
189             if (!RSMarshallingHelper::Unmarshalling(parcel, value)) {
190                 return false;
191             }
192             val.reset(new RSRenderAnimatableProperty<Matrix3f>(value, id, type, unit));
193             break;
194         }
195         case RSRenderPropertyType::PROPERTY_QUATERNION: {
196             Quaternion value;
197             if (!RSMarshallingHelper::Unmarshalling(parcel, value)) {
198                 return false;
199             }
200             val.reset(new RSRenderAnimatableProperty<Quaternion>(value, id, type, unit));
201             break;
202         }
203         case RSRenderPropertyType::PROPERTY_FILTER: {
204             std::shared_ptr<RSFilter> value;
205             if (!RSMarshallingHelper::Unmarshalling(parcel, value)) {
206                 return false;
207             }
208             val.reset(new RSRenderAnimatableProperty<std::shared_ptr<RSFilter>>(value, id, type, unit));
209             break;
210         }
211         case RSRenderPropertyType::PROPERTY_VECTOR2F: {
212             Vector2f value;
213             if (!RSMarshallingHelper::Unmarshalling(parcel, value)) {
214                 return false;
215             }
216             val.reset(new RSRenderAnimatableProperty<Vector2f>(value, id, type, unit));
217             break;
218         }
219         case RSRenderPropertyType::PROPERTY_VECTOR4F: {
220             Vector4f value;
221             if (!RSMarshallingHelper::Unmarshalling(parcel, value)) {
222                 return false;
223             }
224             val.reset(new RSRenderAnimatableProperty<Vector4f>(value, id, type, unit));
225             break;
226         }
227         case RSRenderPropertyType::PROPERTY_VECTOR4_COLOR: {
228             Vector4<Color> value;
229             if (!RSMarshallingHelper::Unmarshalling(parcel, value)) {
230                 return false;
231             }
232             val.reset(new RSRenderAnimatableProperty<Vector4<Color>>(value, id, type, unit));
233             break;
234         }
235         case RSRenderPropertyType::PROPERTY_RRECT: {
236             RRect value;
237             if (!RSMarshallingHelper::Unmarshalling(parcel, value)) {
238                 return false;
239             }
240             val.reset(new RSRenderAnimatableProperty<RRect>(value, id, type, unit));
241             break;
242         }
243         default: {
244             return false;
245         }
246     }
247     return val != nullptr;
248 }
249 
250 template<>
ToFloat() const251 float RSRenderAnimatableProperty<float>::ToFloat() const
252 {
253     return std::fabs(RSRenderProperty<float>::stagingValue_);
254 }
255 
256 template<>
ToFloat() const257 float RSRenderAnimatableProperty<Vector4f>::ToFloat() const
258 {
259     return RSRenderProperty<Vector4f>::stagingValue_.GetLength();
260 }
261 
262 template<>
ToFloat() const263 float RSRenderAnimatableProperty<Quaternion>::ToFloat() const
264 {
265     return RSRenderProperty<Quaternion>::stagingValue_.GetLength();
266 }
267 
268 template<>
ToFloat() const269 float RSRenderAnimatableProperty<Vector2f>::ToFloat() const
270 {
271     return RSRenderProperty<Vector2f>::stagingValue_.GetLength();
272 }
273 
operator +=(const std::shared_ptr<RSRenderPropertyBase> & a,const std::shared_ptr<const RSRenderPropertyBase> & b)274 std::shared_ptr<RSRenderPropertyBase> operator+=(
275     const std::shared_ptr<RSRenderPropertyBase>& a, const std::shared_ptr<const RSRenderPropertyBase>& b)
276 {
277     if (a == nullptr) {
278         return {};
279     }
280 
281     return a->Add(b);
282 }
283 
operator -=(const std::shared_ptr<RSRenderPropertyBase> & a,const std::shared_ptr<const RSRenderPropertyBase> & b)284 std::shared_ptr<RSRenderPropertyBase> operator-=(
285     const std::shared_ptr<RSRenderPropertyBase>& a, const std::shared_ptr<const RSRenderPropertyBase>& b)
286 {
287     if (a == nullptr) {
288         return {};
289     }
290 
291     return a->Minus(b);
292 }
293 
operator *=(const std::shared_ptr<RSRenderPropertyBase> & value,const float scale)294 std::shared_ptr<RSRenderPropertyBase> operator*=(const std::shared_ptr<RSRenderPropertyBase>& value, const float scale)
295 {
296     if (value == nullptr) {
297         return {};
298     }
299 
300     return value->Multiply(scale);
301 }
302 
operator +(const std::shared_ptr<const RSRenderPropertyBase> & a,const std::shared_ptr<const RSRenderPropertyBase> & b)303 std::shared_ptr<RSRenderPropertyBase> operator+(
304     const std::shared_ptr<const RSRenderPropertyBase>& a, const std::shared_ptr<const RSRenderPropertyBase>& b)
305 {
306     if (a == nullptr) {
307         return {};
308     }
309 
310     return a->Clone()->Add(b);
311 }
312 
operator -(const std::shared_ptr<const RSRenderPropertyBase> & a,const std::shared_ptr<const RSRenderPropertyBase> & b)313 std::shared_ptr<RSRenderPropertyBase> operator-(
314     const std::shared_ptr<const RSRenderPropertyBase>& a, const std::shared_ptr<const RSRenderPropertyBase>& b)
315 {
316     if (a == nullptr) {
317         return {};
318     }
319 
320     return a->Clone()->Minus(b);
321 }
322 
operator *(const std::shared_ptr<const RSRenderPropertyBase> & value,const float scale)323 std::shared_ptr<RSRenderPropertyBase> operator*(
324     const std::shared_ptr<const RSRenderPropertyBase>& value, const float scale)
325 {
326     if (value == nullptr) {
327         return {};
328     }
329 
330     return value->Clone()->Multiply(scale);
331 }
332 
operator ==(const std::shared_ptr<const RSRenderPropertyBase> & a,const std::shared_ptr<const RSRenderPropertyBase> & b)333 bool operator==(
334     const std::shared_ptr<const RSRenderPropertyBase>& a, const std::shared_ptr<const RSRenderPropertyBase>& b)
335 {
336     if (a == nullptr) {
337         return {};
338     }
339 
340     return a->IsEqual(b);
341 }
342 
operator !=(const std::shared_ptr<const RSRenderPropertyBase> & a,const std::shared_ptr<const RSRenderPropertyBase> & b)343 bool operator!=(
344     const std::shared_ptr<const RSRenderPropertyBase>& a, const std::shared_ptr<const RSRenderPropertyBase>& b)
345 {
346     if (a == nullptr) {
347         return {};
348     }
349 
350     return !a->IsEqual(b);
351 }
352 
353 template<>
Dump(std::string & out) const354 void RSRenderProperty<float>::Dump(std::string& out) const
355 {
356     out += "[" + std::to_string(Get()) + "]";
357 }
358 
359 template<>
Dump(std::string & out) const360 void RSRenderProperty<Vector4f>::Dump(std::string& out) const
361 {
362     Vector4f v4f = Get();
363     switch (modifierType_) {
364         case RSModifierType::BOUNDS: {
365             out += "[x:" + std::to_string(v4f.x_) + " y:";
366             out += std::to_string(v4f.y_) + " width:";
367             out += std::to_string(v4f.z_) + " height:";
368             out += std::to_string(v4f.w_) + "]";
369             break;
370         }
371         default: {
372             out += "[x:" + std::to_string(v4f.x_) + " y:";
373             out += std::to_string(v4f.y_) + " z:";
374             out += std::to_string(v4f.z_) + " w:";
375             out += std::to_string(v4f.w_) + "]";
376             break;
377         }
378     }
379 }
380 
381 template<>
Dump(std::string & out) const382 void RSRenderProperty<Quaternion>::Dump(std::string& out) const
383 {
384 }
385 
386 template<>
Dump(std::string & out) const387 void RSRenderProperty<Vector2f>::Dump(std::string& out) const
388 {
389     Vector2f v2f = Get();
390     out += "[x:" + std::to_string(v2f.x_) + " y:";
391     out += std::to_string(v2f.y_) + "]";
392 }
393 
394 template<>
Dump(std::string & out) const395 void RSRenderProperty<Matrix3f>::Dump(std::string& out) const
396 {
397 }
398 
399 template<>
Dump(std::string & out) const400 void RSRenderProperty<Color>::Dump(std::string& out) const
401 {
402     std::ostringstream ss;
403     ss << "0x" << std::hex << Get().AsRgbaInt();
404     out += "[RGBA-";
405     out += ss.str();
406     out += "]";
407 }
408 
409 template<>
Dump(std::string & out) const410 void RSRenderProperty<std::shared_ptr<RSFilter>>::Dump(std::string& out) const
411 {
412 }
413 
414 template<>
Dump(std::string & out) const415 void RSRenderProperty<Vector4<Color>>::Dump(std::string& out) const
416 {
417 }
418 
419 template<>
Dump(std::string & out) const420 void RSRenderProperty<RRect>::Dump(std::string& out) const
421 {
422 }
423 
424 template<>
Dump(std::string & out) const425 void RSRenderProperty<Drawing::DrawCmdListPtr>::Dump(std::string& out) const
426 {
427     out += "drawCmdList[";
428     Get()->Dump(out);
429     out += "]";
430 }
431 
432 template<>
Dump(std::string & out) const433 void RSRenderProperty<ForegroundColorStrategyType>::Dump(std::string& out) const
434 {
435     out += "ENV_FOREGROUND_COLOR_STRATEGY[";
436     out += std::to_string(static_cast<int>(Get()));
437     out += "]";
438 }
439 
440 template<>
Dump(std::string & out) const441 void RSRenderProperty<SkMatrix>::Dump(std::string& out) const
442 {
443     out += "GEOMETRYTRANS[";
444     Get().dump(out, 0);
445     out += "]";
446 }
447 
448 template<>
IsNearEqual(const std::shared_ptr<RSRenderPropertyBase> & value,float zeroThreshold) const449 bool RSRenderAnimatableProperty<float>::IsNearEqual(
450     const std::shared_ptr<RSRenderPropertyBase>& value, float zeroThreshold) const
451 {
452     auto animatableProperty = std::static_pointer_cast<const RSRenderAnimatableProperty<float>>(value);
453     if (animatableProperty != nullptr) {
454         return fabs(RSRenderProperty<float>::stagingValue_ - animatableProperty->stagingValue_) <= zeroThreshold;
455     }
456     ROSEN_LOGE("RSRenderAnimatableProperty<float>::IsNearEqual: the value of the comparison is a null pointer!");
457     return true;
458 }
459 
460 template<>
IsNearEqual(const std::shared_ptr<RSRenderPropertyBase> & value,float zeroThreshold) const461 bool RSRenderAnimatableProperty<Vector2f>::IsNearEqual(
462     const std::shared_ptr<RSRenderPropertyBase>& value, float zeroThreshold) const
463 {
464     auto animatableProperty = std::static_pointer_cast<const RSRenderAnimatableProperty<Vector2f>>(value);
465     if (animatableProperty != nullptr) {
466         return RSRenderProperty<Vector2f>::stagingValue_.IsNearEqual(animatableProperty->Get(), zeroThreshold);
467     }
468     ROSEN_LOGE("RSRenderAnimatableProperty<Vector2f>::IsNearEqual: the value of the comparison is a null pointer!");
469     return true;
470 }
471 
472 template<>
IsNearEqual(const std::shared_ptr<RSRenderPropertyBase> & value,float zeroThreshold) const473 bool RSRenderAnimatableProperty<Quaternion>::IsNearEqual(
474     const std::shared_ptr<RSRenderPropertyBase>& value, float zeroThreshold) const
475 {
476     auto animatableProperty = std::static_pointer_cast<const RSRenderAnimatableProperty<Quaternion>>(value);
477     if (animatableProperty != nullptr) {
478         return RSRenderProperty<Quaternion>::stagingValue_.IsNearEqual(animatableProperty->Get(), zeroThreshold);
479     }
480     ROSEN_LOGE("RSRenderAnimatableProperty<Quaternion>::IsNearEqual: the value of the comparison is a null pointer!");
481     return true;
482 }
483 
484 template<>
IsNearEqual(const std::shared_ptr<RSRenderPropertyBase> & value,float zeroThreshold) const485 bool RSRenderAnimatableProperty<Vector4f>::IsNearEqual(
486     const std::shared_ptr<RSRenderPropertyBase>& value, float zeroThreshold) const
487 {
488     auto animatableProperty = std::static_pointer_cast<const RSRenderAnimatableProperty<Vector4f>>(value);
489     if (animatableProperty != nullptr) {
490         return RSRenderProperty<Vector4f>::stagingValue_.IsNearEqual(animatableProperty->Get(), zeroThreshold);
491     }
492     ROSEN_LOGE("RSRenderAnimatableProperty<Vector4f>::IsNearEqual: the value of the comparison is a null pointer!");
493     return true;
494 }
495 
496 template<>
IsNearEqual(const std::shared_ptr<RSRenderPropertyBase> & value,float zeroThreshold) const497 bool RSRenderAnimatableProperty<Matrix3f>::IsNearEqual(
498     const std::shared_ptr<RSRenderPropertyBase>& value, float zeroThreshold) const
499 {
500     auto animatableProperty = std::static_pointer_cast<const RSRenderAnimatableProperty<Matrix3f>>(value);
501     if (animatableProperty != nullptr) {
502         return RSRenderProperty<Matrix3f>::stagingValue_.IsNearEqual(animatableProperty->Get(), zeroThreshold);
503     }
504     ROSEN_LOGE("RSRenderAnimatableProperty<Matrix3f>::IsNearEqual: the value of the comparison is a null pointer!");
505     return true;
506 }
507 
508 template<>
IsNearEqual(const std::shared_ptr<RSRenderPropertyBase> & value,float zeroThreshold) const509 bool RSRenderAnimatableProperty<Color>::IsNearEqual(
510     const std::shared_ptr<RSRenderPropertyBase>& value, float zeroThreshold) const
511 {
512     auto animatableProperty = std::static_pointer_cast<const RSRenderAnimatableProperty<Color>>(value);
513     if (animatableProperty != nullptr) {
514         return RSRenderProperty<Color>::stagingValue_.IsNearEqual(
515             animatableProperty->Get(), static_cast<int16_t>(zeroThreshold));
516     }
517     ROSEN_LOGE("RSRenderAnimatableProperty<Color>::IsNearEqual: the value of the comparison is a null pointer!");
518     return true;
519 }
520 
521 template<>
IsNearEqual(const std::shared_ptr<RSRenderPropertyBase> & value,float zeroThreshold) const522 bool RSRenderAnimatableProperty<std::shared_ptr<RSFilter>>::IsNearEqual(
523     const std::shared_ptr<RSRenderPropertyBase>& value, float zeroThreshold) const
524 {
525     auto animatableProperty =
526         std::static_pointer_cast<const RSRenderAnimatableProperty<std::shared_ptr<RSFilter>>>(value);
527     if (animatableProperty == nullptr) {
528         return true;
529     }
530 
531     auto filter = RSRenderProperty<std::shared_ptr<RSFilter>>::stagingValue_;
532     auto otherFilter = animatableProperty->Get();
533     if ((filter != nullptr) && (otherFilter != nullptr)) {
534         return filter->IsNearEqual(otherFilter, zeroThreshold);
535     } else if ((filter == nullptr) && (otherFilter == nullptr)) {
536         ROSEN_LOGE("RSRenderAnimatableProperty<std::shared_ptr<RSFilter>>::IsNearEqual: "
537             "both values compared are null Pointers!");
538         return true;
539     } else if (filter == nullptr) {
540         ROSEN_LOGE(
541             "RSRenderAnimatableProperty<std::shared_ptr<RSFilter>>::IsNearEqual: the staging value is a null pointer!");
542         return otherFilter->IsNearZero(zeroThreshold);
543     } else {
544         ROSEN_LOGE("RSRenderAnimatableProperty<std::shared_ptr<RSFilter>>::IsNearEqual: "
545             "the value of the comparison is a null pointer!");
546         return filter->IsNearZero(zeroThreshold);
547     }
548 }
549 
550 template<>
IsNearEqual(const std::shared_ptr<RSRenderPropertyBase> & value,float zeroThreshold) const551 bool RSRenderAnimatableProperty<Vector4<Color>>::IsNearEqual(
552     const std::shared_ptr<RSRenderPropertyBase>& value, float zeroThreshold) const
553 {
554     auto animatableProperty = std::static_pointer_cast<const RSRenderAnimatableProperty<Vector4<Color>>>(value);
555     if (animatableProperty != nullptr) {
556         auto thisData = RSRenderProperty<Vector4<Color>>::stagingValue_.data_;
557         auto otherValue = animatableProperty->Get();
558         auto& otherData = otherValue.data_;
559         int16_t threshold = static_cast<int16_t>(zeroThreshold);
560         return thisData[0].IsNearEqual(otherData[0], threshold) && thisData[2].IsNearEqual(otherData[2], threshold) &&
561                thisData[2].IsNearEqual(otherData[2], threshold) && thisData[3].IsNearEqual(otherData[3], threshold);
562     }
563     ROSEN_LOGE(
564         "RSRenderAnimatableProperty<Vector4<Color>>::IsNearEqual: the value of the comparison is a null pointer!");
565     return true;
566 }
567 
568 template<>
IsNearEqual(const std::shared_ptr<RSRenderPropertyBase> & value,float zeroThreshold) const569 bool RSRenderAnimatableProperty<RRect>::IsNearEqual(
570     const std::shared_ptr<RSRenderPropertyBase>& value, float zeroThreshold) const
571 {
572     auto animatableProperty = std::static_pointer_cast<const RSRenderAnimatableProperty<RRect>>(value);
573     if (animatableProperty != nullptr) {
574         return RSRenderProperty<RRect>::stagingValue_.IsNearEqual(animatableProperty->Get(), zeroThreshold);
575     }
576     ROSEN_LOGE("RSRenderAnimatableProperty<RRect>::IsNearEqual: the value of the comparison is a null pointer!");
577     return true;
578 }
579 
580 template<>
IsEqual(const std::shared_ptr<const RSRenderPropertyBase> & value) const581 bool RSRenderAnimatableProperty<std::shared_ptr<RSFilter>>::IsEqual(
582     const std::shared_ptr<const RSRenderPropertyBase>& value) const
583 {
584     auto animatableProperty =
585         std::static_pointer_cast<const RSRenderAnimatableProperty<std::shared_ptr<RSFilter>>>(value);
586     if (animatableProperty == nullptr) {
587         return true;
588     }
589 
590     auto filter = RSRenderProperty<std::shared_ptr<RSFilter>>::stagingValue_;
591     auto otherFilter = animatableProperty->Get();
592     if ((filter != nullptr) && (otherFilter != nullptr)) {
593         return filter->IsEqual(otherFilter);
594     } else if ((filter == nullptr) && (otherFilter == nullptr)) {
595         ROSEN_LOGE("RSRenderAnimatableProperty<std::shared_ptr<RSFilter>>::IsEqual: "
596             "both values compared are null Pointers!");
597         return true;
598     } else if (filter == nullptr) {
599         ROSEN_LOGE(
600             "RSRenderAnimatableProperty<std::shared_ptr<RSFilter>>::IsEqual: the staging value is a null pointer!");
601         return otherFilter->IsEqualZero();
602     } else {
603         ROSEN_LOGE("RSRenderAnimatableProperty<std::shared_ptr<RSFilter>>::IsEqual: "
604             "the value of the comparison is a null pointer!");
605         return filter->IsEqualZero();
606     }
607 }
608 
609 template class RSRenderProperty<float>;
610 template class RSRenderProperty<Vector4f>;
611 template class RSRenderProperty<Quaternion>;
612 template class RSRenderProperty<Vector2f>;
613 template class RSRenderProperty<Matrix3f>;
614 template class RSRenderProperty<Color>;
615 template class RSRenderProperty<std::shared_ptr<RSFilter>>;
616 template class RSRenderProperty<Vector4<Color>>;
617 template class RSRenderProperty<RRect>;
618 template class RSRenderProperty<Drawing::DrawCmdListPtr>;
619 template class RSRenderProperty<ForegroundColorStrategyType>;
620 template class RSRenderProperty<SkMatrix>;
621 
622 template class RSRenderAnimatableProperty<float>;
623 template class RSRenderAnimatableProperty<Vector4f>;
624 template class RSRenderAnimatableProperty<Quaternion>;
625 template class RSRenderAnimatableProperty<Vector2f>;
626 template class RSRenderAnimatableProperty<Matrix3f>;
627 template class RSRenderAnimatableProperty<Color>;
628 template class RSRenderAnimatableProperty<std::shared_ptr<RSFilter>>;
629 template class RSRenderAnimatableProperty<Vector4<Color>>;
630 template class RSRenderAnimatableProperty<RRect>;
631 } // namespace Rosen
632 } // namespace OHOS
633