@react-native-ohos/react-native-svg 15.12.1-rc.1 → 15.12.1-rc.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/LICENSE +21 -21
  2. package/README.OpenSource +10 -10
  3. package/README.md +13 -13
  4. package/css/package.json +5 -5
  5. package/harmony/svg/BuildProfile.ets +16 -16
  6. package/harmony/svg/build-profile.json5 +9 -9
  7. package/harmony/svg/hvigorfile.ts +1 -1
  8. package/harmony/svg/index.ets +6 -6
  9. package/harmony/svg/oh-package.json5 +13 -13
  10. package/harmony/svg/src/main/cpp/CMakeLists.txt +6 -1
  11. package/harmony/svg/src/main/cpp/SVGPackage.h +14 -0
  12. package/harmony/svg/src/main/cpp/SvgArkUINode.cpp +3 -0
  13. package/harmony/svg/src/main/cpp/SvgArkUINode.h +15 -9
  14. package/harmony/svg/src/main/cpp/SvgFilter.cpp +505 -505
  15. package/harmony/svg/src/main/cpp/SvgFilter.h +112 -112
  16. package/harmony/svg/src/main/cpp/SvgForeignObjectNode.cpp +86 -0
  17. package/harmony/svg/src/main/cpp/SvgForeignObjectNode.h +81 -0
  18. package/harmony/svg/src/main/cpp/SvgForeignObjectNodeDelegate.h +30 -0
  19. package/harmony/svg/src/main/cpp/SvgForeignProps.h +39 -0
  20. package/harmony/svg/src/main/cpp/SvgGradient.cpp +1 -0
  21. package/harmony/svg/src/main/cpp/SvgGroup.cpp +8 -1
  22. package/harmony/svg/src/main/cpp/SvgNode.cpp +109 -3
  23. package/harmony/svg/src/main/cpp/SvgNode.h +43 -13
  24. package/harmony/svg/src/main/cpp/SvgViewManager.cpp +3 -0
  25. package/harmony/svg/src/main/cpp/SvgViewManager.h +2 -0
  26. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeBlendComponentInstance.cpp +40 -40
  27. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeBlendComponentInstance.h +48 -48
  28. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeColorMatrixComponentInstance.cpp +33 -33
  29. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeColorMatrixComponentInstance.h +48 -48
  30. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeCompositeComponentInstance.cpp +39 -39
  31. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeCompositeComponentInstance.h +55 -55
  32. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeFloodComponentInstance.cpp +33 -33
  33. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeFloodComponentInstance.h +49 -49
  34. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeGaussianBlurComponentInstance.cpp +34 -34
  35. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeGaussianBlurComponentInstance.h +48 -48
  36. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeOffsetComponentInstance.cpp +35 -35
  37. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeOffsetComponentInstance.h +45 -45
  38. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFilterComponentInstance.cpp +198 -198
  39. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFilterComponentInstance.h +48 -48
  40. package/harmony/svg/src/main/cpp/componentInstances/RNSVGForeignObjectComponentInstance.cpp +93 -0
  41. package/harmony/svg/src/main/cpp/componentInstances/RNSVGForeignObjectComponentInstance.h +55 -0
  42. package/harmony/svg/src/main/cpp/componentInstances/RNSVGGroupComponentInstance.h +8 -4
  43. package/harmony/svg/src/main/cpp/componentInstances/RNSVGImageComponentInstance.cpp +4 -1
  44. package/harmony/svg/src/main/cpp/componentInstances/RNSVGSvgViewComponentInstance.cpp +38 -0
  45. package/harmony/svg/src/main/cpp/componentInstances/RNSVGSvgViewComponentInstance.h +11 -2
  46. package/harmony/svg/src/main/cpp/downloadUtils/HttpTaskProcessor.cpp +69 -10
  47. package/harmony/svg/src/main/cpp/downloadUtils/ImageSourceResolver.cpp +54 -26
  48. package/harmony/svg/src/main/cpp/downloadUtils/ImageSourceResolver.h +6 -10
  49. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeBlendJSIBinder.h +26 -26
  50. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeColorMatrixJSIBinder.h +26 -26
  51. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeCompositeJSIBinder.h +30 -30
  52. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeFloodJSIBinder.h +26 -26
  53. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeGaussianBlurJSIBinder.h +26 -26
  54. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeOffsetJSIBinder.h +26 -26
  55. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFilterJSIBinder.h +44 -44
  56. package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/Props.cpp +977 -977
  57. package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/Props.h +1280 -1280
  58. package/harmony/svg/src/main/cpp/properties/Dimension.h +14 -0
  59. package/harmony/svg/src/main/cpp/turboModules/RNSVGImageModule.cpp +30 -1
  60. package/harmony/svg/src/main/cpp/utils/DynamicUtils.h +55 -55
  61. package/harmony/svg/src/main/cpp/utils/FilterManager.h +190 -190
  62. package/harmony/svg/src/main/ets/RNSVGImageModule.ts +21 -21
  63. package/harmony/svg/src/main/ets/RNSVGRenderableModule.ts +16 -16
  64. package/harmony/svg/src/main/ets/RNSVGSvgViewModule.ts +18 -18
  65. package/harmony/svg/src/main/ets/SvgPackage.ts +57 -57
  66. package/harmony/svg/src/main/module.json5 +7 -7
  67. package/harmony/svg/src/main/resources/base/element/string.json +8 -8
  68. package/harmony/svg/src/main/resources/en_US/element/string.json +8 -8
  69. package/harmony/svg/src/main/resources/zh_CN/element/string.json +8 -8
  70. package/harmony/svg/ts.ts +7 -7
  71. package/harmony/svg.har +0 -0
  72. package/lib/commonjs/css/index.js.map +1 -1
  73. package/lib/commonjs/index.js.map +1 -1
  74. package/lib/module/css/index.js.map +1 -1
  75. package/lib/module/index.js.map +1 -1
  76. package/package.json +53 -54
  77. package/src/css/index.tsx +19 -19
  78. package/src/index.tsx +2 -2
  79. package/tsconfig.json +11 -11
@@ -1,199 +1,199 @@
1
- /*
2
- * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
- * Use of this source code is governed by a MIT license that can be
4
- * found in the LICENSE file.
5
- */
6
-
7
- #include "RNSVGFilterComponentInstance.h"
8
- #include "RNSVGFeColorMatrixComponentInstance.h"
9
- #include "RNSVGFeBlendComponentInstance.h"
10
- #include "RNSVGFeCompositeComponentInstance.h"
11
- #include "RNSVGFeFloodComponentInstance.h"
12
- #include "RNSVGFeOffsetComponentInstance.h"
13
- #include "RNSVGFeGaussianBlurComponentInstance.h"
14
- #include "utils/FilterManager.h"
15
- #include <sstream>
16
- #include <utility>
17
- #include <folly/dynamic.h>
18
- #include <cmath>
19
- #include <iomanip>
20
- #include <string>
21
- namespace rnoh {
22
- namespace svg {
23
-
24
- RNSVGFilterComponentInstance::RNSVGFilterComponentInstance(Context context)
25
- : RNSVGBaseComponentInstance(std::move(context)) {
26
- SetSvgNode(m_svgFilter);
27
- }
28
-
29
- void RNSVGFilterComponentInstance::onPropsChanged(SharedConcreteProps const &props) {}
30
-
31
- void RNSVGFilterComponentInstance::UpdateElementProps() {
32
- m_svgFilter->UpdateCommonProps(m_props);
33
- // Set the name as the ID for the SvgNode using the UpdateHrefRenderProps method
34
- m_svgFilter->UpdateHrefRenderProps(m_props);
35
- parseFilterId();
36
- collectFilterEffectsInOrder();
37
- }
38
-
39
- void RNSVGFilterComponentInstance::parseFilterId() {
40
- if (m_props) {
41
- filterId_ = m_props->name;
42
- }
43
- }
44
-
45
- void RNSVGFilterComponentInstance::collectFilterEffectsInOrder()
46
- {
47
- if (m_svgFilter) {
48
- m_svgFilter->ClearFilterEffects();
49
- }
50
-
51
- auto children = getChildren();
52
- if (collectFeDropShadowInfo()) {
53
- return;
54
- }
55
-
56
- for (const auto& child : children) {
57
- if (auto childInstance = std::dynamic_pointer_cast<ComponentInstance>(child)) {
58
- std::string childComponentName = childInstance->getComponentName();
59
- if (childComponentName.find("FeColorMatrix") != std::string::npos) {
60
- collectSingleFeColorMatrix(childInstance);
61
- } else if (childComponentName.find("FeFlood") != std::string::npos) {
62
- collectSingleFeFlood(childInstance);
63
- } else if (childComponentName.find("FeOffset") != std::string::npos) {
64
- collectSingleFeOffset(childInstance);
65
- } else if (childComponentName.find("FeComposite") != std::string::npos) {
66
- collectSingleFeComposite(childInstance);
67
- } else if (childComponentName.find("FeGaussianBlur") != std::string::npos) {
68
- collectSingleFeGaussianBlur(childInstance);
69
- } else if (childComponentName.find("FeBlend") != std::string::npos) {
70
- collectSingleFeBlend(childInstance);
71
- }
72
- }
73
- }
74
- }
75
-
76
- bool RNSVGFilterComponentInstance::collectFeDropShadowInfo()
77
- {
78
- auto children = getChildren();
79
-
80
- std::shared_ptr<RNSVGFeGaussianBlurComponentInstance> blurInstance = nullptr;
81
- std::shared_ptr<RNSVGFeOffsetComponentInstance> offsetInstance = nullptr;
82
- std::shared_ptr<RNSVGFeFloodComponentInstance> floodInstance = nullptr;
83
- std::shared_ptr<RNSVGFeCompositeComponentInstance> compositeInstance = nullptr;
84
-
85
- for (const auto& child : children) {
86
- if (auto childInstance = std::dynamic_pointer_cast<ComponentInstance>(child)) {
87
- std::string childComponentName = childInstance->getComponentName();
88
- if (childComponentName.find("FeGaussianBlur") != std::string::npos) {
89
- blurInstance = std::dynamic_pointer_cast<RNSVGFeGaussianBlurComponentInstance>(childInstance);
90
- } else if (childComponentName.find("FeOffset") != std::string::npos) {
91
- offsetInstance = std::dynamic_pointer_cast<RNSVGFeOffsetComponentInstance>(childInstance);
92
- } else if (childComponentName.find("FeFlood") != std::string::npos) {
93
- floodInstance = std::dynamic_pointer_cast<RNSVGFeFloodComponentInstance>(childInstance);
94
- }
95
- }
96
- }
97
-
98
- if (blurInstance && offsetInstance && floodInstance) {
99
- std::string in = blurInstance->getIn();
100
- float dx = offsetInstance->getDx();
101
- float dy = offsetInstance->getDy();
102
- float stdDeviation = blurInstance->getStdDeviationX();
103
- std::string floodColorStr = floodInstance->getFloodColor();
104
- if (floodColorStr.empty()) {
105
- floodColorStr = "black";
106
- }
107
- float floodOpacity = floodInstance->getFloodOpacity();
108
- FilterEffect dropShadowEffect(FilterType::DROP_SHADOW, in, dx, dy, stdDeviation, floodColorStr, floodOpacity);
109
- m_svgFilter->AddFilterEffect(dropShadowEffect);
110
- return true;
111
- }
112
- return false;
113
- }
114
-
115
- void RNSVGFilterComponentInstance::collectSingleFeColorMatrix(std::shared_ptr<ComponentInstance> childInstance)
116
- {
117
- if (auto feColorMatrixInstance = std::dynamic_pointer_cast<RNSVGFeColorMatrixComponentInstance>(childInstance)) {
118
- std::string in = feColorMatrixInstance->getIn();
119
- std::string type = feColorMatrixInstance->getType();
120
- std::vector<float> values = feColorMatrixInstance->getValues();
121
- std::string result = feColorMatrixInstance->getResult();
122
- FilterEffect colorMatrixEffect(FilterType::COLOR_MATRIX, values, in, type, result);
123
- m_svgFilter->AddFilterEffect(colorMatrixEffect);
124
- }
125
- }
126
-
127
- void RNSVGFilterComponentInstance::collectSingleFeFlood(std::shared_ptr<ComponentInstance> childInstance)
128
- {
129
- auto feFloodInstance = std::dynamic_pointer_cast<RNSVGFeFloodComponentInstance>(childInstance);
130
- if (feFloodInstance) {
131
- std::string in = feFloodInstance->getIn();
132
- std::string floodColorStr = feFloodInstance->getFloodColor();
133
- if (floodColorStr.empty()) {
134
- floodColorStr = "black";
135
- }
136
- float floodOpacity = feFloodInstance->getFloodOpacity();
137
- std::string result = feFloodInstance->getResult();
138
- FilterEffect floodEffect(FilterType::FEFLOOD, in, floodColorStr, floodOpacity, result);
139
- m_svgFilter->AddFilterEffect(floodEffect);
140
- }
141
- }
142
-
143
- void RNSVGFilterComponentInstance::collectSingleFeOffset(std::shared_ptr<ComponentInstance> childInstance)
144
- {
145
- if (auto feOffsetInstance = std::dynamic_pointer_cast<RNSVGFeOffsetComponentInstance>(childInstance)) {
146
- std::string in = feOffsetInstance->getIn();
147
- std::string result = feOffsetInstance->getResult();
148
- float dx = feOffsetInstance->getDx();
149
- float dy = feOffsetInstance->getDy();
150
- FilterEffect offsetEffect(FilterType::FEOFFSET, in, dx, dy, result);
151
- m_svgFilter->AddFilterEffect(offsetEffect);
152
- }
153
- }
154
-
155
- void RNSVGFilterComponentInstance::collectSingleFeComposite(std::shared_ptr<ComponentInstance> childInstance)
156
- {
157
- if (auto feCompositeInstance = std::dynamic_pointer_cast<RNSVGFeCompositeComponentInstance>(childInstance)) {
158
- std::string in = feCompositeInstance->getIn();
159
- std::string in2 = feCompositeInstance->getIn2();
160
- std::string operatorType = feCompositeInstance->getOperator();
161
- std::string k1 = "0", k2 = "0", k3 = "0", k4 = "0";
162
- if (operatorType == "arithmetic") {
163
- k1 = feCompositeInstance->getK1();
164
- k2 = feCompositeInstance->getK2();
165
- k3 = feCompositeInstance->getK3();
166
- k4 = feCompositeInstance->getK4();
167
- }
168
- std::string result = feCompositeInstance->getResult();
169
- FilterEffect compositeEffect(FilterType::COMPOSITE, in, in2, operatorType, k1, k2, k3, k4, result);
170
- m_svgFilter->AddFilterEffect(compositeEffect);
171
- }
172
- }
173
-
174
- void RNSVGFilterComponentInstance::collectSingleFeGaussianBlur(std::shared_ptr<ComponentInstance> childInstance)
175
- {
176
- if (auto feGaussianBlurInstance = std::dynamic_pointer_cast<RNSVGFeGaussianBlurComponentInstance>(childInstance)) {
177
- std::string in = feGaussianBlurInstance->getIn();
178
- float stdDeviationX = feGaussianBlurInstance->getStdDeviationX();
179
- float stdDeviationY = feGaussianBlurInstance->getStdDeviationY();
180
- std::string edgeMode = feGaussianBlurInstance->getEdgeMode();
181
- std::string result = feGaussianBlurInstance->getResult();
182
- FilterEffect gaussianBlurEffect(FilterType::GAUSSIAN_BLUR, in, stdDeviationX, stdDeviationY, edgeMode, result);
183
- m_svgFilter->AddFilterEffect(gaussianBlurEffect);
184
- }
185
- }
186
-
187
- void RNSVGFilterComponentInstance::collectSingleFeBlend(std::shared_ptr<ComponentInstance> childInstance)
188
- {
189
- if (auto feBlendInstance = std::dynamic_pointer_cast<RNSVGFeBlendComponentInstance>(childInstance)) {
190
- std::string in = feBlendInstance->getIn();
191
- std::string in2 = feBlendInstance->getIn2();
192
- std::string mode = feBlendInstance->getMode();
193
- std::string result = feBlendInstance->getResult();
194
- FilterEffect blendEffect(FilterType::BLEND, in, in2, mode, result);
195
- m_svgFilter->AddFilterEffect(blendEffect);
196
- }
197
- }
198
- }
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ #include "RNSVGFilterComponentInstance.h"
8
+ #include "RNSVGFeColorMatrixComponentInstance.h"
9
+ #include "RNSVGFeBlendComponentInstance.h"
10
+ #include "RNSVGFeCompositeComponentInstance.h"
11
+ #include "RNSVGFeFloodComponentInstance.h"
12
+ #include "RNSVGFeOffsetComponentInstance.h"
13
+ #include "RNSVGFeGaussianBlurComponentInstance.h"
14
+ #include "utils/FilterManager.h"
15
+ #include <sstream>
16
+ #include <utility>
17
+ #include <folly/dynamic.h>
18
+ #include <cmath>
19
+ #include <iomanip>
20
+ #include <string>
21
+ namespace rnoh {
22
+ namespace svg {
23
+
24
+ RNSVGFilterComponentInstance::RNSVGFilterComponentInstance(Context context)
25
+ : RNSVGBaseComponentInstance(std::move(context)) {
26
+ SetSvgNode(m_svgFilter);
27
+ }
28
+
29
+ void RNSVGFilterComponentInstance::onPropsChanged(SharedConcreteProps const &props) {}
30
+
31
+ void RNSVGFilterComponentInstance::UpdateElementProps() {
32
+ m_svgFilter->UpdateCommonProps(m_props);
33
+ // Set the name as the ID for the SvgNode using the UpdateHrefRenderProps method
34
+ m_svgFilter->UpdateHrefRenderProps(m_props);
35
+ parseFilterId();
36
+ collectFilterEffectsInOrder();
37
+ }
38
+
39
+ void RNSVGFilterComponentInstance::parseFilterId() {
40
+ if (m_props) {
41
+ filterId_ = m_props->name;
42
+ }
43
+ }
44
+
45
+ void RNSVGFilterComponentInstance::collectFilterEffectsInOrder()
46
+ {
47
+ if (m_svgFilter) {
48
+ m_svgFilter->ClearFilterEffects();
49
+ }
50
+
51
+ auto children = getChildren();
52
+ if (collectFeDropShadowInfo()) {
53
+ return;
54
+ }
55
+
56
+ for (const auto& child : children) {
57
+ if (auto childInstance = std::dynamic_pointer_cast<ComponentInstance>(child)) {
58
+ std::string childComponentName = childInstance->getComponentName();
59
+ if (childComponentName.find("FeColorMatrix") != std::string::npos) {
60
+ collectSingleFeColorMatrix(childInstance);
61
+ } else if (childComponentName.find("FeFlood") != std::string::npos) {
62
+ collectSingleFeFlood(childInstance);
63
+ } else if (childComponentName.find("FeOffset") != std::string::npos) {
64
+ collectSingleFeOffset(childInstance);
65
+ } else if (childComponentName.find("FeComposite") != std::string::npos) {
66
+ collectSingleFeComposite(childInstance);
67
+ } else if (childComponentName.find("FeGaussianBlur") != std::string::npos) {
68
+ collectSingleFeGaussianBlur(childInstance);
69
+ } else if (childComponentName.find("FeBlend") != std::string::npos) {
70
+ collectSingleFeBlend(childInstance);
71
+ }
72
+ }
73
+ }
74
+ }
75
+
76
+ bool RNSVGFilterComponentInstance::collectFeDropShadowInfo()
77
+ {
78
+ auto children = getChildren();
79
+
80
+ std::shared_ptr<RNSVGFeGaussianBlurComponentInstance> blurInstance = nullptr;
81
+ std::shared_ptr<RNSVGFeOffsetComponentInstance> offsetInstance = nullptr;
82
+ std::shared_ptr<RNSVGFeFloodComponentInstance> floodInstance = nullptr;
83
+ std::shared_ptr<RNSVGFeCompositeComponentInstance> compositeInstance = nullptr;
84
+
85
+ for (const auto& child : children) {
86
+ if (auto childInstance = std::dynamic_pointer_cast<ComponentInstance>(child)) {
87
+ std::string childComponentName = childInstance->getComponentName();
88
+ if (childComponentName.find("FeGaussianBlur") != std::string::npos) {
89
+ blurInstance = std::dynamic_pointer_cast<RNSVGFeGaussianBlurComponentInstance>(childInstance);
90
+ } else if (childComponentName.find("FeOffset") != std::string::npos) {
91
+ offsetInstance = std::dynamic_pointer_cast<RNSVGFeOffsetComponentInstance>(childInstance);
92
+ } else if (childComponentName.find("FeFlood") != std::string::npos) {
93
+ floodInstance = std::dynamic_pointer_cast<RNSVGFeFloodComponentInstance>(childInstance);
94
+ }
95
+ }
96
+ }
97
+
98
+ if (blurInstance && offsetInstance && floodInstance) {
99
+ std::string in = blurInstance->getIn();
100
+ float dx = offsetInstance->getDx();
101
+ float dy = offsetInstance->getDy();
102
+ float stdDeviation = blurInstance->getStdDeviationX();
103
+ std::string floodColorStr = floodInstance->getFloodColor();
104
+ if (floodColorStr.empty()) {
105
+ floodColorStr = "black";
106
+ }
107
+ float floodOpacity = floodInstance->getFloodOpacity();
108
+ FilterEffect dropShadowEffect(FilterType::DROP_SHADOW, in, dx, dy, stdDeviation, floodColorStr, floodOpacity);
109
+ m_svgFilter->AddFilterEffect(dropShadowEffect);
110
+ return true;
111
+ }
112
+ return false;
113
+ }
114
+
115
+ void RNSVGFilterComponentInstance::collectSingleFeColorMatrix(std::shared_ptr<ComponentInstance> childInstance)
116
+ {
117
+ if (auto feColorMatrixInstance = std::dynamic_pointer_cast<RNSVGFeColorMatrixComponentInstance>(childInstance)) {
118
+ std::string in = feColorMatrixInstance->getIn();
119
+ std::string type = feColorMatrixInstance->getType();
120
+ std::vector<float> values = feColorMatrixInstance->getValues();
121
+ std::string result = feColorMatrixInstance->getResult();
122
+ FilterEffect colorMatrixEffect(FilterType::COLOR_MATRIX, values, in, type, result);
123
+ m_svgFilter->AddFilterEffect(colorMatrixEffect);
124
+ }
125
+ }
126
+
127
+ void RNSVGFilterComponentInstance::collectSingleFeFlood(std::shared_ptr<ComponentInstance> childInstance)
128
+ {
129
+ auto feFloodInstance = std::dynamic_pointer_cast<RNSVGFeFloodComponentInstance>(childInstance);
130
+ if (feFloodInstance) {
131
+ std::string in = feFloodInstance->getIn();
132
+ std::string floodColorStr = feFloodInstance->getFloodColor();
133
+ if (floodColorStr.empty()) {
134
+ floodColorStr = "black";
135
+ }
136
+ float floodOpacity = feFloodInstance->getFloodOpacity();
137
+ std::string result = feFloodInstance->getResult();
138
+ FilterEffect floodEffect(FilterType::FEFLOOD, in, floodColorStr, floodOpacity, result);
139
+ m_svgFilter->AddFilterEffect(floodEffect);
140
+ }
141
+ }
142
+
143
+ void RNSVGFilterComponentInstance::collectSingleFeOffset(std::shared_ptr<ComponentInstance> childInstance)
144
+ {
145
+ if (auto feOffsetInstance = std::dynamic_pointer_cast<RNSVGFeOffsetComponentInstance>(childInstance)) {
146
+ std::string in = feOffsetInstance->getIn();
147
+ std::string result = feOffsetInstance->getResult();
148
+ float dx = feOffsetInstance->getDx();
149
+ float dy = feOffsetInstance->getDy();
150
+ FilterEffect offsetEffect(FilterType::FEOFFSET, in, dx, dy, result);
151
+ m_svgFilter->AddFilterEffect(offsetEffect);
152
+ }
153
+ }
154
+
155
+ void RNSVGFilterComponentInstance::collectSingleFeComposite(std::shared_ptr<ComponentInstance> childInstance)
156
+ {
157
+ if (auto feCompositeInstance = std::dynamic_pointer_cast<RNSVGFeCompositeComponentInstance>(childInstance)) {
158
+ std::string in = feCompositeInstance->getIn();
159
+ std::string in2 = feCompositeInstance->getIn2();
160
+ std::string operatorType = feCompositeInstance->getOperator();
161
+ std::string k1 = "0", k2 = "0", k3 = "0", k4 = "0";
162
+ if (operatorType == "arithmetic") {
163
+ k1 = feCompositeInstance->getK1();
164
+ k2 = feCompositeInstance->getK2();
165
+ k3 = feCompositeInstance->getK3();
166
+ k4 = feCompositeInstance->getK4();
167
+ }
168
+ std::string result = feCompositeInstance->getResult();
169
+ FilterEffect compositeEffect(FilterType::COMPOSITE, in, in2, operatorType, k1, k2, k3, k4, result);
170
+ m_svgFilter->AddFilterEffect(compositeEffect);
171
+ }
172
+ }
173
+
174
+ void RNSVGFilterComponentInstance::collectSingleFeGaussianBlur(std::shared_ptr<ComponentInstance> childInstance)
175
+ {
176
+ if (auto feGaussianBlurInstance = std::dynamic_pointer_cast<RNSVGFeGaussianBlurComponentInstance>(childInstance)) {
177
+ std::string in = feGaussianBlurInstance->getIn();
178
+ float stdDeviationX = feGaussianBlurInstance->getStdDeviationX();
179
+ float stdDeviationY = feGaussianBlurInstance->getStdDeviationY();
180
+ std::string edgeMode = feGaussianBlurInstance->getEdgeMode();
181
+ std::string result = feGaussianBlurInstance->getResult();
182
+ FilterEffect gaussianBlurEffect(FilterType::GAUSSIAN_BLUR, in, stdDeviationX, stdDeviationY, edgeMode, result);
183
+ m_svgFilter->AddFilterEffect(gaussianBlurEffect);
184
+ }
185
+ }
186
+
187
+ void RNSVGFilterComponentInstance::collectSingleFeBlend(std::shared_ptr<ComponentInstance> childInstance)
188
+ {
189
+ if (auto feBlendInstance = std::dynamic_pointer_cast<RNSVGFeBlendComponentInstance>(childInstance)) {
190
+ std::string in = feBlendInstance->getIn();
191
+ std::string in2 = feBlendInstance->getIn2();
192
+ std::string mode = feBlendInstance->getMode();
193
+ std::string result = feBlendInstance->getResult();
194
+ FilterEffect blendEffect(FilterType::BLEND, in, in2, mode, result);
195
+ m_svgFilter->AddFilterEffect(blendEffect);
196
+ }
197
+ }
198
+ }
199
199
  }
@@ -1,48 +1,48 @@
1
- /*
2
- * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
- * Use of this source code is governed by a MIT license that can be
4
- * found in the LICENSE file.
5
- */
6
-
7
- #pragma once
8
-
9
- #include "RNSVGBaseComponentInstance.h"
10
- #include "SvgFilter.h"
11
- #include "utils/FilterManager.h"
12
- #include <react/renderer/components/react_native_svg/ShadowNodes.h>
13
-
14
- namespace rnoh {
15
- namespace svg {
16
-
17
-
18
- class RNSVGFilterComponentInstance : public RNSVGBaseComponentInstance<facebook::react::RNSVGFilterShadowNode> {
19
- public:
20
- RNSVGFilterComponentInstance(Context context);
21
-
22
- void onPropsChanged(SharedConcreteProps const &props) override;
23
- void UpdateElementProps() override;
24
-
25
- private:
26
- std::shared_ptr<SvgFilter> m_svgFilter = std::make_shared<SvgFilter>();
27
- std::string filterId_;
28
-
29
- void parseFilterId();
30
- void collectFilterEffectsInOrder();
31
- bool collectFeDropShadowInfo();
32
- void collectSingleFeColorMatrix(std::shared_ptr<ComponentInstance> childInstance);
33
- void collectSingleFeFlood(std::shared_ptr<ComponentInstance> childInstance);
34
- void collectSingleFeOffset(std::shared_ptr<ComponentInstance> childInstance);
35
- void collectSingleFeComposite(std::shared_ptr<ComponentInstance> childInstance);
36
- void collectSingleFeGaussianBlur(std::shared_ptr<ComponentInstance> childInstance);
37
- void collectSingleFeBlend(std::shared_ptr<ComponentInstance> childInstance);
38
- std::vector<float> generateColorMatrix(const std::string& type, const std::vector<float>& values);
39
- std::vector<float> convertBlendModeToValues(const std::string& mode);
40
- std::vector<float> convertCompositeOperatorToValues(const std::string& operatorType,
41
- const std::string& k1,
42
- const std::string& k2,
43
- const std::string& k3,
44
- const std::string& k4);
45
- };
46
-
47
- } // namespace svg
48
- } // namespace rnoh
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ #pragma once
8
+
9
+ #include "RNSVGBaseComponentInstance.h"
10
+ #include "SvgFilter.h"
11
+ #include "utils/FilterManager.h"
12
+ #include <react/renderer/components/react_native_svg/ShadowNodes.h>
13
+
14
+ namespace rnoh {
15
+ namespace svg {
16
+
17
+
18
+ class RNSVGFilterComponentInstance : public RNSVGBaseComponentInstance<facebook::react::RNSVGFilterShadowNode> {
19
+ public:
20
+ RNSVGFilterComponentInstance(Context context);
21
+
22
+ void onPropsChanged(SharedConcreteProps const &props) override;
23
+ void UpdateElementProps() override;
24
+
25
+ private:
26
+ std::shared_ptr<SvgFilter> m_svgFilter = std::make_shared<SvgFilter>();
27
+ std::string filterId_;
28
+
29
+ void parseFilterId();
30
+ void collectFilterEffectsInOrder();
31
+ bool collectFeDropShadowInfo();
32
+ void collectSingleFeColorMatrix(std::shared_ptr<ComponentInstance> childInstance);
33
+ void collectSingleFeFlood(std::shared_ptr<ComponentInstance> childInstance);
34
+ void collectSingleFeOffset(std::shared_ptr<ComponentInstance> childInstance);
35
+ void collectSingleFeComposite(std::shared_ptr<ComponentInstance> childInstance);
36
+ void collectSingleFeGaussianBlur(std::shared_ptr<ComponentInstance> childInstance);
37
+ void collectSingleFeBlend(std::shared_ptr<ComponentInstance> childInstance);
38
+ std::vector<float> generateColorMatrix(const std::string& type, const std::vector<float>& values);
39
+ std::vector<float> convertBlendModeToValues(const std::string& mode);
40
+ std::vector<float> convertCompositeOperatorToValues(const std::string& operatorType,
41
+ const std::string& k1,
42
+ const std::string& k2,
43
+ const std::string& k3,
44
+ const std::string& k4);
45
+ };
46
+
47
+ } // namespace svg
48
+ } // namespace rnoh
@@ -0,0 +1,93 @@
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ *
6
+ * This file incorporates from the OpenHarmony project, licensed under
7
+ * the Apache License, Version 2.0. Specifically:
8
+ * - [OpenHarmony/arkui_ace_engine] (https://gitee.com/openharmony/arkui_ace_engine)
9
+ *
10
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
11
+ * use this file except in compliance with the License. You may obtain a copy
12
+ * of the License at:
13
+ * http://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software
16
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18
+ * License for the specific language governing permissions and limitations
19
+ * under the License.
20
+ */
21
+
22
+ #include "RNSVGForeignObjectComponentInstance.h"
23
+ namespace rnoh {
24
+ namespace svg {
25
+
26
+ RNSVGForeignObjectComponentInstance::RNSVGForeignObjectComponentInstance(Context context)
27
+ : CppComponentInstance(std::move(context)) {
28
+ DLOG(INFO) << "RNSVGForeignObjectComponentInstance";
29
+ NativeNodeApi::getInstance()->registerNodeEvent(mForeignStackNode.getArkUINodeHandle(), NODE_EVENT_ON_AREA_CHANGE,
30
+ NODE_EVENT_ON_AREA_CHANGE, this);
31
+ mForeignStackNode.insertChild(node, 0);
32
+ }
33
+
34
+
35
+ RNSVGForeignObjectComponentInstance::~RNSVGForeignObjectComponentInstance() {
36
+ NativeNodeApi::getInstance()->unregisterNodeEvent(mForeignStackNode.getArkUINodeHandle(),
37
+ NODE_EVENT_ON_AREA_CHANGE);
38
+ }
39
+
40
+ void RNSVGForeignObjectComponentInstance::onFinalizeUpdates() {
41
+ ComponentInstance::onFinalizeUpdates();
42
+ if (m_props) {
43
+ mForeignStackNode.SetPointScaleFactor(getLayoutMetrics().pointScaleFactor);
44
+ mForeignStackNode.SetSnapPosition(propsConversionValue(m_props->x), propsConversionValue(m_props->y));
45
+ mForeignStackNode.SetSnapWidth(propsConversionValue(m_props->width));
46
+ mForeignStackNode.SetSnapHeight(propsConversionValue(m_props->height));
47
+
48
+ mForeignStackNode.SetClipPath(m_props->clipPath, m_props->clipRule);
49
+ mForeignStackNode.SetMask(m_props->mask);
50
+ mForeignStackNode.SetTransform(m_props->matrix);
51
+ auto childs = getChildren();
52
+ if (childs.size() > 0) {
53
+ for (ComponentInstance::Shared c : childs) {
54
+ if ((m_props->opacity > 0 && m_props->opacity != 1)) {
55
+ setOpacity(c->getLocalRootArkUINode(), m_props->opacity);
56
+ }
57
+ }
58
+ }
59
+ mForeignStackNode.SetGeneratedPixelMap(true);
60
+ }
61
+ }
62
+
63
+ Dimension RNSVGForeignObjectComponentInstance::propsConversionValue(const folly::dynamic &d) {
64
+ if (d.isNull()) {
65
+ return Dimension(0, DimensionUnit::INVALID);
66
+ }
67
+ return StringUtils::StringToDimension(d.asString(), true);
68
+ }
69
+
70
+ void RNSVGForeignObjectComponentInstance::setOpacity(ArkUINode &node, float op) {
71
+ if (op != 1) {
72
+ node.setOpacity(m_props->opacity);
73
+ }
74
+ }
75
+
76
+ void RNSVGForeignObjectComponentInstance::onChildInserted(ComponentInstance::Shared const &childComponentInstance,
77
+ std::size_t index) {
78
+ CppComponentInstance::onChildInserted(childComponentInstance, index);
79
+ float width = childComponentInstance->getLayoutMetrics().frame.size.width;
80
+ float height = childComponentInstance->getLayoutMetrics().frame.size.height;
81
+ mForeignStackNode.setNodeSize(width, height);
82
+ node.insertChild(childComponentInstance->getLocalRootArkUINode(), index);
83
+ }
84
+
85
+ void RNSVGForeignObjectComponentInstance::onChildRemoved(ComponentInstance::Shared const &childComponentInstance) {
86
+ CppComponentInstance::onChildRemoved(childComponentInstance);
87
+ }
88
+
89
+ SvgForeignObjectNode &RNSVGForeignObjectComponentInstance::getLocalRootArkUINode() { return mForeignStackNode; }
90
+
91
+
92
+ } // namespace svg
93
+ }
@@ -0,0 +1,55 @@
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ *
6
+ * This file incorporates from the OpenHarmony project, licensed under
7
+ * the Apache License, Version 2.0. Specifically:
8
+ * - [OpenHarmony/arkui_ace_engine] (https://gitee.com/openharmony/arkui_ace_engine)
9
+ *
10
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
11
+ * use this file except in compliance with the License. You may obtain a copy
12
+ * of the License at:
13
+ * http://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software
16
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18
+ * License for the specific language governing permissions and limitations
19
+ * under the License.
20
+ */
21
+
22
+ #ifndef RNSVG_FOREIGN_OBJECT_COMPONENT_INSTANCE_H
23
+ #define RNSVG_FOREIGN_OBJECT_COMPONENT_INSTANCE_H
24
+ #include "RNOH/CppComponentInstance.h"
25
+ #include "SvgForeignObjectNode.h"
26
+ #include <react/renderer/components/react_native_svg/ShadowNodes.h>
27
+ #include "RNOH/arkui/ColumnNode.h"
28
+ #include "RNOH/arkui/NativeNodeApi.h"
29
+ #include "utils/DynamicUtils.h"
30
+ #include "properties/Dimension.h"
31
+ #include "utils/StringUtils.h"
32
+ namespace rnoh {
33
+ namespace svg {
34
+ class RNSVGForeignObjectComponentInstance : public CppComponentInstance<facebook::react::RNSVGForeignObjectShadowNode> {
35
+ public:
36
+ RNSVGForeignObjectComponentInstance(Context context);
37
+ ~RNSVGForeignObjectComponentInstance();
38
+
39
+ void onFinalizeUpdates() override;
40
+ void onChildInserted(ComponentInstance::Shared const &childComponentInstance, std::size_t index) override;
41
+
42
+ void onChildRemoved(ComponentInstance::Shared const &childComponentInstance) override;
43
+
44
+ SvgForeignObjectNode &getLocalRootArkUINode() override;
45
+
46
+ void setOpacity(ArkUINode &node, float op);
47
+
48
+ Dimension propsConversionValue(const folly::dynamic& d);
49
+ private:
50
+ SvgForeignObjectNode mForeignStackNode;
51
+ ColumnNode node;
52
+ };
53
+ } // namespace svg
54
+ } // namespace rnoh
55
+ #endif // RNSVG_FOREIGN_OBJECT_COMPONENT_INSTANCE_H