@react-native-ohos/react-native-svg 15.12.1-rc.1 → 15.12.1-rc.3
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.
- package/LICENSE +21 -21
- package/README.OpenSource +10 -10
- package/README.md +13 -13
- package/css/package.json +5 -5
- package/harmony/svg/BuildProfile.ets +16 -16
- package/harmony/svg/build-profile.json5 +9 -9
- package/harmony/svg/hvigorfile.ts +1 -1
- package/harmony/svg/index.ets +6 -6
- package/harmony/svg/oh-package.json5 +13 -13
- package/harmony/svg/src/main/cpp/SVGPackage.h +4 -0
- package/harmony/svg/src/main/cpp/SvgArkUINode.cpp +3 -0
- package/harmony/svg/src/main/cpp/SvgArkUINode.h +15 -9
- package/harmony/svg/src/main/cpp/SvgFilter.cpp +505 -505
- package/harmony/svg/src/main/cpp/SvgFilter.h +112 -112
- package/harmony/svg/src/main/cpp/SvgForeignObjectNode.cpp +74 -0
- package/harmony/svg/src/main/cpp/SvgForeignObjectNode.h +54 -0
- package/harmony/svg/src/main/cpp/SvgForeignObjectNodeDelegate.h +30 -0
- package/harmony/svg/src/main/cpp/SvgNode.cpp +64 -0
- package/harmony/svg/src/main/cpp/SvgNode.h +17 -1
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeBlendComponentInstance.cpp +40 -40
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeBlendComponentInstance.h +48 -48
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeColorMatrixComponentInstance.cpp +33 -33
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeColorMatrixComponentInstance.h +48 -48
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeCompositeComponentInstance.cpp +39 -39
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeCompositeComponentInstance.h +55 -55
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeFloodComponentInstance.cpp +33 -33
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeFloodComponentInstance.h +49 -49
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeGaussianBlurComponentInstance.cpp +34 -34
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeGaussianBlurComponentInstance.h +48 -48
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeOffsetComponentInstance.cpp +35 -35
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeOffsetComponentInstance.h +45 -45
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFilterComponentInstance.cpp +198 -198
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFilterComponentInstance.h +48 -48
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGForeignObjectComponentInstance.cpp +65 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGForeignObjectComponentInstance.h +50 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGGroupComponentInstance.h +8 -4
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGImageComponentInstance.cpp +4 -1
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGSvgViewComponentInstance.cpp +37 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGSvgViewComponentInstance.h +10 -2
- package/harmony/svg/src/main/cpp/downloadUtils/ImageSourceResolver.cpp +36 -15
- package/harmony/svg/src/main/cpp/downloadUtils/ImageSourceResolver.h +6 -10
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeBlendJSIBinder.h +26 -26
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeColorMatrixJSIBinder.h +26 -26
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeCompositeJSIBinder.h +30 -30
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeFloodJSIBinder.h +26 -26
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeGaussianBlurJSIBinder.h +26 -26
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeOffsetJSIBinder.h +26 -26
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFilterJSIBinder.h +44 -44
- package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/Props.cpp +977 -977
- package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/Props.h +1280 -1280
- package/harmony/svg/src/main/cpp/utils/DynamicUtils.h +55 -55
- package/harmony/svg/src/main/cpp/utils/FilterManager.h +190 -190
- package/harmony/svg/src/main/ets/RNSVGImageModule.ts +21 -21
- package/harmony/svg/src/main/ets/RNSVGRenderableModule.ts +16 -16
- package/harmony/svg/src/main/ets/RNSVGSvgViewModule.ts +18 -18
- package/harmony/svg/src/main/ets/SvgPackage.ts +57 -57
- package/harmony/svg/src/main/module.json5 +7 -7
- package/harmony/svg/src/main/resources/base/element/string.json +8 -8
- package/harmony/svg/src/main/resources/en_US/element/string.json +8 -8
- package/harmony/svg/src/main/resources/zh_CN/element/string.json +8 -8
- package/harmony/svg/ts.ts +7 -7
- package/harmony/svg.har +0 -0
- package/lib/commonjs/css/index.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/css/index.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/package.json +53 -54
- package/src/css/index.tsx +19 -19
- package/src/index.tsx +2 -2
- package/tsconfig.json +11 -11
|
@@ -1,55 +1,55 @@
|
|
|
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 <string>
|
|
10
|
-
#include <vector>
|
|
11
|
-
#include <folly/dynamic.h>
|
|
12
|
-
|
|
13
|
-
namespace rnoh {
|
|
14
|
-
namespace svg {
|
|
15
|
-
|
|
16
|
-
namespace DynamicUtils {
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Convert folly::dynamic to string
|
|
20
|
-
* Handles string, int, double, bool types
|
|
21
|
-
* Returns empty string for other types
|
|
22
|
-
*/
|
|
23
|
-
inline std::string DynamicToString(const folly::dynamic& d) {
|
|
24
|
-
if (d.isNull()) {
|
|
25
|
-
return "";
|
|
26
|
-
} else if (d.isString()) {
|
|
27
|
-
return d.asString();
|
|
28
|
-
} else if (d.isInt()) {
|
|
29
|
-
return std::to_string(d.asInt());
|
|
30
|
-
} else if (d.isDouble()) {
|
|
31
|
-
return std::to_string(d.asDouble());
|
|
32
|
-
} else if (d.isBool()) {
|
|
33
|
-
return d.asBool() ? "true" : "false";
|
|
34
|
-
} else {
|
|
35
|
-
return "";
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Convert folly::dynamic array to vector of strings
|
|
41
|
-
* Returns empty vector if not an array
|
|
42
|
-
*/
|
|
43
|
-
inline std::vector<std::string> DynamicToStringVector(const folly::dynamic& d) {
|
|
44
|
-
std::vector<std::string> result;
|
|
45
|
-
if (d.isArray()) {
|
|
46
|
-
for (const auto& item : d) {
|
|
47
|
-
result.push_back(DynamicToString(item));
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return result;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
} // namespace DynamicUtils
|
|
54
|
-
} // namespace svg
|
|
55
|
-
} // 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 <string>
|
|
10
|
+
#include <vector>
|
|
11
|
+
#include <folly/dynamic.h>
|
|
12
|
+
|
|
13
|
+
namespace rnoh {
|
|
14
|
+
namespace svg {
|
|
15
|
+
|
|
16
|
+
namespace DynamicUtils {
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Convert folly::dynamic to string
|
|
20
|
+
* Handles string, int, double, bool types
|
|
21
|
+
* Returns empty string for other types
|
|
22
|
+
*/
|
|
23
|
+
inline std::string DynamicToString(const folly::dynamic& d) {
|
|
24
|
+
if (d.isNull()) {
|
|
25
|
+
return "";
|
|
26
|
+
} else if (d.isString()) {
|
|
27
|
+
return d.asString();
|
|
28
|
+
} else if (d.isInt()) {
|
|
29
|
+
return std::to_string(d.asInt());
|
|
30
|
+
} else if (d.isDouble()) {
|
|
31
|
+
return std::to_string(d.asDouble());
|
|
32
|
+
} else if (d.isBool()) {
|
|
33
|
+
return d.asBool() ? "true" : "false";
|
|
34
|
+
} else {
|
|
35
|
+
return "";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Convert folly::dynamic array to vector of strings
|
|
41
|
+
* Returns empty vector if not an array
|
|
42
|
+
*/
|
|
43
|
+
inline std::vector<std::string> DynamicToStringVector(const folly::dynamic& d) {
|
|
44
|
+
std::vector<std::string> result;
|
|
45
|
+
if (d.isArray()) {
|
|
46
|
+
for (const auto& item : d) {
|
|
47
|
+
result.push_back(DynamicToString(item));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
} // namespace DynamicUtils
|
|
54
|
+
} // namespace svg
|
|
55
|
+
} // namespace rnoh
|
|
@@ -1,190 +1,190 @@
|
|
|
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 <string>
|
|
10
|
-
#include <vector>
|
|
11
|
-
#include <unordered_map>
|
|
12
|
-
#include <memory>
|
|
13
|
-
#include <glog/logging.h>
|
|
14
|
-
|
|
15
|
-
namespace rnoh {
|
|
16
|
-
namespace svg {
|
|
17
|
-
|
|
18
|
-
// FeColorMatrix信息结构
|
|
19
|
-
struct FeColorMatrixInfo {
|
|
20
|
-
std::string type = "saturate";
|
|
21
|
-
std::vector<float> values = {1.0f};
|
|
22
|
-
std::string in = "SourceGraphic"; // 默认输入源为 SourceGraphic
|
|
23
|
-
|
|
24
|
-
FeColorMatrixInfo() = default;
|
|
25
|
-
FeColorMatrixInfo(const std::string& t, const std::vector<float>& v) : type(t), values(v) {}
|
|
26
|
-
FeColorMatrixInfo(const std::string& t, const std::vector<float>& v, const std::string& inputSource)
|
|
27
|
-
: type(t), values(v), in(inputSource) {}
|
|
28
|
-
|
|
29
|
-
// 获取饱和度值(当type为"saturate"时)
|
|
30
|
-
float getSaturationValue() const {
|
|
31
|
-
if (type == "saturate" && !values.empty()) {
|
|
32
|
-
return values[0];
|
|
33
|
-
}
|
|
34
|
-
return 1.0f; // 默认饱和度
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// 获取颜色矩阵(当type为"matrix"时)
|
|
38
|
-
std::vector<float> getColorMatrix() const {
|
|
39
|
-
if (type == "matrix" && values.size() >= 20) {
|
|
40
|
-
return values;
|
|
41
|
-
}
|
|
42
|
-
// 返回单位矩阵
|
|
43
|
-
return {1,0,0,0,0, 0,1,0,0,0, 0,0,1,0,0, 0,0,0,1,0};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// 检查是否为有效的FeColorMatrix
|
|
47
|
-
bool isValid() const {
|
|
48
|
-
if (type == "saturate") {
|
|
49
|
-
return !values.empty();
|
|
50
|
-
} else if (type == "matrix") {
|
|
51
|
-
return values.size() >= 20;
|
|
52
|
-
} else if (type == "hueRotate") {
|
|
53
|
-
return !values.empty();
|
|
54
|
-
} else if (type == "luminanceToAlpha") {
|
|
55
|
-
return true; // 不需要values
|
|
56
|
-
}
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// 获取输入源类型
|
|
61
|
-
std::string getInputSource() const {
|
|
62
|
-
return in;
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
// FeBlend信息结构
|
|
67
|
-
struct FeBlendInfo {
|
|
68
|
-
std::string in = "SourceGraphic"; // 第一个输入源
|
|
69
|
-
std::string in2 = ""; // 第二个输入源
|
|
70
|
-
std::string mode = "normal"; // 混合模式
|
|
71
|
-
|
|
72
|
-
FeBlendInfo() = default;
|
|
73
|
-
FeBlendInfo(const std::string& input1, const std::string& input2, const std::string& blendMode)
|
|
74
|
-
: in(input1), in2(input2), mode(blendMode) {}
|
|
75
|
-
|
|
76
|
-
// 检查是否为有效的混合模式
|
|
77
|
-
bool isValidMode() const {
|
|
78
|
-
return mode == "normal" || mode == "multiply" || mode == "screen" ||
|
|
79
|
-
mode == "darken" || mode == "lighten";
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
// Filter管理器类
|
|
84
|
-
class FilterManager {
|
|
85
|
-
public:
|
|
86
|
-
// 单例模式
|
|
87
|
-
static FilterManager& getInstance() {
|
|
88
|
-
static FilterManager instance;
|
|
89
|
-
return instance;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// 注册Filter和FeColorMatrix的映射
|
|
93
|
-
void registerFilter(const std::string& filterId, std::shared_ptr<FeColorMatrixInfo> feColorMatrixInfo) {
|
|
94
|
-
if (!filterId.empty() && feColorMatrixInfo) {
|
|
95
|
-
filterMap_[filterId] = feColorMatrixInfo;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// 根据Filter ID获取FeColorMatrix信息
|
|
100
|
-
std::shared_ptr<FeColorMatrixInfo> getFeColorMatrixInfo(const std::string& filterId) const {
|
|
101
|
-
auto it = filterMap_.find(filterId);
|
|
102
|
-
if (it != filterMap_.end()) {
|
|
103
|
-
return it->second;
|
|
104
|
-
}
|
|
105
|
-
return nullptr;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// 检查Filter是否存在
|
|
109
|
-
bool hasFilter(const std::string& filterId) const {
|
|
110
|
-
return filterMap_.find(filterId) != filterMap_.end();
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// 清除所有Filter映射
|
|
114
|
-
void clearAllFilters() {
|
|
115
|
-
filterMap_.clear();
|
|
116
|
-
blendFilterMap_.clear();
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// 移除指定Filter
|
|
120
|
-
void removeFilter(const std::string& filterId) {
|
|
121
|
-
filterMap_.erase(filterId);
|
|
122
|
-
blendFilterMap_.erase(filterId);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// ========== FeBlend 相关方法 ==========
|
|
126
|
-
|
|
127
|
-
// 注册FeBlend过滤器
|
|
128
|
-
void registerBlendFilter(const std::string& filterId, std::shared_ptr<FeBlendInfo> feBlendInfo) {
|
|
129
|
-
if (!filterId.empty() && feBlendInfo) {
|
|
130
|
-
blendFilterMap_[filterId] = feBlendInfo;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// 获取FeBlend信息
|
|
135
|
-
std::shared_ptr<FeBlendInfo> getFeBlendInfo(const std::string& filterId) const {
|
|
136
|
-
auto it = blendFilterMap_.find(filterId);
|
|
137
|
-
if (it != blendFilterMap_.end()) {
|
|
138
|
-
return it->second;
|
|
139
|
-
}
|
|
140
|
-
return nullptr;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// 检查FeBlend Filter是否存在
|
|
144
|
-
bool hasBlendFilter(const std::string& filterId) const {
|
|
145
|
-
return blendFilterMap_.find(filterId) != blendFilterMap_.end();
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// 获取所有Filter ID
|
|
149
|
-
std::vector<std::string> getAllFilterIds() const {
|
|
150
|
-
std::vector<std::string> ids;
|
|
151
|
-
for (const auto& pair : filterMap_) {
|
|
152
|
-
ids.push_back(pair.first);
|
|
153
|
-
}
|
|
154
|
-
return ids;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// 解析Filter URL(例如:"url(#myFilter)" -> "myFilter")
|
|
158
|
-
static std::string parseFilterUrl(const std::string& filterUrl) {
|
|
159
|
-
if (filterUrl.empty()) return "";
|
|
160
|
-
|
|
161
|
-
// 查找"url(#"
|
|
162
|
-
size_t start = filterUrl.find("url(#");
|
|
163
|
-
if (start != std::string::npos) {
|
|
164
|
-
start += 5; // 跳过"url(#"
|
|
165
|
-
size_t end = filterUrl.find(")", start);
|
|
166
|
-
if (end != std::string::npos) {
|
|
167
|
-
return filterUrl.substr(start, end - start);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// 如果没有找到"url(#"格式,检查是否直接是ID
|
|
172
|
-
if (filterUrl.front() == '#') {
|
|
173
|
-
return filterUrl.substr(1);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return filterUrl;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
private:
|
|
180
|
-
FilterManager() = default;
|
|
181
|
-
~FilterManager() = default;
|
|
182
|
-
FilterManager(const FilterManager&) = delete;
|
|
183
|
-
FilterManager& operator=(const FilterManager&) = delete;
|
|
184
|
-
|
|
185
|
-
std::unordered_map<std::string, std::shared_ptr<FeColorMatrixInfo>> filterMap_;
|
|
186
|
-
std::unordered_map<std::string, std::shared_ptr<FeBlendInfo>> blendFilterMap_;
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
} // namespace svg
|
|
190
|
-
} // 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 <string>
|
|
10
|
+
#include <vector>
|
|
11
|
+
#include <unordered_map>
|
|
12
|
+
#include <memory>
|
|
13
|
+
#include <glog/logging.h>
|
|
14
|
+
|
|
15
|
+
namespace rnoh {
|
|
16
|
+
namespace svg {
|
|
17
|
+
|
|
18
|
+
// FeColorMatrix信息结构
|
|
19
|
+
struct FeColorMatrixInfo {
|
|
20
|
+
std::string type = "saturate";
|
|
21
|
+
std::vector<float> values = {1.0f};
|
|
22
|
+
std::string in = "SourceGraphic"; // 默认输入源为 SourceGraphic
|
|
23
|
+
|
|
24
|
+
FeColorMatrixInfo() = default;
|
|
25
|
+
FeColorMatrixInfo(const std::string& t, const std::vector<float>& v) : type(t), values(v) {}
|
|
26
|
+
FeColorMatrixInfo(const std::string& t, const std::vector<float>& v, const std::string& inputSource)
|
|
27
|
+
: type(t), values(v), in(inputSource) {}
|
|
28
|
+
|
|
29
|
+
// 获取饱和度值(当type为"saturate"时)
|
|
30
|
+
float getSaturationValue() const {
|
|
31
|
+
if (type == "saturate" && !values.empty()) {
|
|
32
|
+
return values[0];
|
|
33
|
+
}
|
|
34
|
+
return 1.0f; // 默认饱和度
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// 获取颜色矩阵(当type为"matrix"时)
|
|
38
|
+
std::vector<float> getColorMatrix() const {
|
|
39
|
+
if (type == "matrix" && values.size() >= 20) {
|
|
40
|
+
return values;
|
|
41
|
+
}
|
|
42
|
+
// 返回单位矩阵
|
|
43
|
+
return {1,0,0,0,0, 0,1,0,0,0, 0,0,1,0,0, 0,0,0,1,0};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// 检查是否为有效的FeColorMatrix
|
|
47
|
+
bool isValid() const {
|
|
48
|
+
if (type == "saturate") {
|
|
49
|
+
return !values.empty();
|
|
50
|
+
} else if (type == "matrix") {
|
|
51
|
+
return values.size() >= 20;
|
|
52
|
+
} else if (type == "hueRotate") {
|
|
53
|
+
return !values.empty();
|
|
54
|
+
} else if (type == "luminanceToAlpha") {
|
|
55
|
+
return true; // 不需要values
|
|
56
|
+
}
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// 获取输入源类型
|
|
61
|
+
std::string getInputSource() const {
|
|
62
|
+
return in;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// FeBlend信息结构
|
|
67
|
+
struct FeBlendInfo {
|
|
68
|
+
std::string in = "SourceGraphic"; // 第一个输入源
|
|
69
|
+
std::string in2 = ""; // 第二个输入源
|
|
70
|
+
std::string mode = "normal"; // 混合模式
|
|
71
|
+
|
|
72
|
+
FeBlendInfo() = default;
|
|
73
|
+
FeBlendInfo(const std::string& input1, const std::string& input2, const std::string& blendMode)
|
|
74
|
+
: in(input1), in2(input2), mode(blendMode) {}
|
|
75
|
+
|
|
76
|
+
// 检查是否为有效的混合模式
|
|
77
|
+
bool isValidMode() const {
|
|
78
|
+
return mode == "normal" || mode == "multiply" || mode == "screen" ||
|
|
79
|
+
mode == "darken" || mode == "lighten";
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// Filter管理器类
|
|
84
|
+
class FilterManager {
|
|
85
|
+
public:
|
|
86
|
+
// 单例模式
|
|
87
|
+
static FilterManager& getInstance() {
|
|
88
|
+
static FilterManager instance;
|
|
89
|
+
return instance;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// 注册Filter和FeColorMatrix的映射
|
|
93
|
+
void registerFilter(const std::string& filterId, std::shared_ptr<FeColorMatrixInfo> feColorMatrixInfo) {
|
|
94
|
+
if (!filterId.empty() && feColorMatrixInfo) {
|
|
95
|
+
filterMap_[filterId] = feColorMatrixInfo;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// 根据Filter ID获取FeColorMatrix信息
|
|
100
|
+
std::shared_ptr<FeColorMatrixInfo> getFeColorMatrixInfo(const std::string& filterId) const {
|
|
101
|
+
auto it = filterMap_.find(filterId);
|
|
102
|
+
if (it != filterMap_.end()) {
|
|
103
|
+
return it->second;
|
|
104
|
+
}
|
|
105
|
+
return nullptr;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// 检查Filter是否存在
|
|
109
|
+
bool hasFilter(const std::string& filterId) const {
|
|
110
|
+
return filterMap_.find(filterId) != filterMap_.end();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// 清除所有Filter映射
|
|
114
|
+
void clearAllFilters() {
|
|
115
|
+
filterMap_.clear();
|
|
116
|
+
blendFilterMap_.clear();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// 移除指定Filter
|
|
120
|
+
void removeFilter(const std::string& filterId) {
|
|
121
|
+
filterMap_.erase(filterId);
|
|
122
|
+
blendFilterMap_.erase(filterId);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// ========== FeBlend 相关方法 ==========
|
|
126
|
+
|
|
127
|
+
// 注册FeBlend过滤器
|
|
128
|
+
void registerBlendFilter(const std::string& filterId, std::shared_ptr<FeBlendInfo> feBlendInfo) {
|
|
129
|
+
if (!filterId.empty() && feBlendInfo) {
|
|
130
|
+
blendFilterMap_[filterId] = feBlendInfo;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// 获取FeBlend信息
|
|
135
|
+
std::shared_ptr<FeBlendInfo> getFeBlendInfo(const std::string& filterId) const {
|
|
136
|
+
auto it = blendFilterMap_.find(filterId);
|
|
137
|
+
if (it != blendFilterMap_.end()) {
|
|
138
|
+
return it->second;
|
|
139
|
+
}
|
|
140
|
+
return nullptr;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// 检查FeBlend Filter是否存在
|
|
144
|
+
bool hasBlendFilter(const std::string& filterId) const {
|
|
145
|
+
return blendFilterMap_.find(filterId) != blendFilterMap_.end();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// 获取所有Filter ID
|
|
149
|
+
std::vector<std::string> getAllFilterIds() const {
|
|
150
|
+
std::vector<std::string> ids;
|
|
151
|
+
for (const auto& pair : filterMap_) {
|
|
152
|
+
ids.push_back(pair.first);
|
|
153
|
+
}
|
|
154
|
+
return ids;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// 解析Filter URL(例如:"url(#myFilter)" -> "myFilter")
|
|
158
|
+
static std::string parseFilterUrl(const std::string& filterUrl) {
|
|
159
|
+
if (filterUrl.empty()) return "";
|
|
160
|
+
|
|
161
|
+
// 查找"url(#"
|
|
162
|
+
size_t start = filterUrl.find("url(#");
|
|
163
|
+
if (start != std::string::npos) {
|
|
164
|
+
start += 5; // 跳过"url(#"
|
|
165
|
+
size_t end = filterUrl.find(")", start);
|
|
166
|
+
if (end != std::string::npos) {
|
|
167
|
+
return filterUrl.substr(start, end - start);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// 如果没有找到"url(#"格式,检查是否直接是ID
|
|
172
|
+
if (filterUrl.front() == '#') {
|
|
173
|
+
return filterUrl.substr(1);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return filterUrl;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
private:
|
|
180
|
+
FilterManager() = default;
|
|
181
|
+
~FilterManager() = default;
|
|
182
|
+
FilterManager(const FilterManager&) = delete;
|
|
183
|
+
FilterManager& operator=(const FilterManager&) = delete;
|
|
184
|
+
|
|
185
|
+
std::unordered_map<std::string, std::shared_ptr<FeColorMatrixInfo>> filterMap_;
|
|
186
|
+
std::unordered_map<std::string, std::shared_ptr<FeBlendInfo>> blendFilterMap_;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
} // namespace svg
|
|
190
|
+
} // namespace rnoh
|
|
@@ -1,21 +1,21 @@
|
|
|
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
|
-
import { TurboModule } from "@rnoh/react-native-openharmony/ts";
|
|
8
|
-
|
|
9
|
-
export class RNSVGImageModule extends TurboModule {
|
|
10
|
-
public static readonly NAME = 'RNSVGImageModule';
|
|
11
|
-
|
|
12
|
-
constructor(ctx: any) {
|
|
13
|
-
super(ctx);
|
|
14
|
-
console.log('[kuang] RNSVGImageModule')
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
getCacheDir() {
|
|
19
|
-
return this.ctx.uiAbilityContext.cacheDir;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
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
|
+
import { TurboModule } from "@rnoh/react-native-openharmony/ts";
|
|
8
|
+
|
|
9
|
+
export class RNSVGImageModule extends TurboModule {
|
|
10
|
+
public static readonly NAME = 'RNSVGImageModule';
|
|
11
|
+
|
|
12
|
+
constructor(ctx: any) {
|
|
13
|
+
super(ctx);
|
|
14
|
+
console.log('[kuang] RNSVGImageModule')
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
getCacheDir() {
|
|
19
|
+
return this.ctx.uiAbilityContext.cacheDir;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
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
|
-
import { TurboModule } from '@rnoh/react-native-openharmony/ts';
|
|
8
|
-
|
|
9
|
-
export class RNSVGRenderableModule extends TurboModule {
|
|
10
|
-
public static readonly NAME = 'RNSVGRenderableModule';
|
|
11
|
-
|
|
12
|
-
constructor(ctx: any) {
|
|
13
|
-
super(ctx);
|
|
14
|
-
console.log('[kuang] RNSVGRenderableModule')
|
|
15
|
-
}
|
|
16
|
-
}
|
|
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
|
+
import { TurboModule } from '@rnoh/react-native-openharmony/ts';
|
|
8
|
+
|
|
9
|
+
export class RNSVGRenderableModule extends TurboModule {
|
|
10
|
+
public static readonly NAME = 'RNSVGRenderableModule';
|
|
11
|
+
|
|
12
|
+
constructor(ctx: any) {
|
|
13
|
+
super(ctx);
|
|
14
|
+
console.log('[kuang] RNSVGRenderableModule')
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
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
|
-
import { TurboModule } from '@rnoh/react-native-openharmony/ts';
|
|
8
|
-
|
|
9
|
-
export class RNSVGSvgViewModule extends TurboModule {
|
|
10
|
-
public static readonly NAME = 'RNSVGSvgViewModule';
|
|
11
|
-
|
|
12
|
-
constructor(ctx: any) {
|
|
13
|
-
super(ctx);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
console.log('[kuang] RNSVGSvgViewModule')
|
|
17
|
-
}
|
|
18
|
-
}
|
|
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
|
+
import { TurboModule } from '@rnoh/react-native-openharmony/ts';
|
|
8
|
+
|
|
9
|
+
export class RNSVGSvgViewModule extends TurboModule {
|
|
10
|
+
public static readonly NAME = 'RNSVGSvgViewModule';
|
|
11
|
+
|
|
12
|
+
constructor(ctx: any) {
|
|
13
|
+
super(ctx);
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
console.log('[kuang] RNSVGSvgViewModule')
|
|
17
|
+
}
|
|
18
|
+
}
|