@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.
- 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/CMakeLists.txt +6 -1
- package/harmony/svg/src/main/cpp/SVGPackage.h +14 -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 +86 -0
- package/harmony/svg/src/main/cpp/SvgForeignObjectNode.h +81 -0
- package/harmony/svg/src/main/cpp/SvgForeignObjectNodeDelegate.h +30 -0
- package/harmony/svg/src/main/cpp/SvgForeignProps.h +39 -0
- package/harmony/svg/src/main/cpp/SvgGradient.cpp +1 -0
- package/harmony/svg/src/main/cpp/SvgGroup.cpp +8 -1
- package/harmony/svg/src/main/cpp/SvgNode.cpp +109 -3
- package/harmony/svg/src/main/cpp/SvgNode.h +43 -13
- package/harmony/svg/src/main/cpp/SvgViewManager.cpp +3 -0
- package/harmony/svg/src/main/cpp/SvgViewManager.h +2 -0
- 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 +93 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGForeignObjectComponentInstance.h +55 -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 +38 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGSvgViewComponentInstance.h +11 -2
- package/harmony/svg/src/main/cpp/downloadUtils/HttpTaskProcessor.cpp +69 -10
- package/harmony/svg/src/main/cpp/downloadUtils/ImageSourceResolver.cpp +54 -26
- 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/properties/Dimension.h +14 -0
- package/harmony/svg/src/main/cpp/turboModules/RNSVGImageModule.cpp +30 -1
- 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,112 +1,112 @@
|
|
|
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 "SvgNode.h"
|
|
10
|
-
#include "drawing/Brush.h"
|
|
11
|
-
#include "drawing/Pen.h"
|
|
12
|
-
#include <native_drawing/drawing_canvas.h>
|
|
13
|
-
#include <native_drawing/drawing_filter.h>
|
|
14
|
-
|
|
15
|
-
namespace rnoh {
|
|
16
|
-
namespace svg {
|
|
17
|
-
|
|
18
|
-
enum class FilterType {
|
|
19
|
-
BLUR,
|
|
20
|
-
GAUSSIAN_BLUR,
|
|
21
|
-
DROP_SHADOW,
|
|
22
|
-
COLOR_MATRIX,
|
|
23
|
-
FEOFFSET,
|
|
24
|
-
FEFLOOD,
|
|
25
|
-
BLEND,
|
|
26
|
-
COMPOSITE,
|
|
27
|
-
MERGE,
|
|
28
|
-
UNKNOWN
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
struct FilterEffect {
|
|
32
|
-
FilterType filterType = FilterType::UNKNOWN;
|
|
33
|
-
std::vector<float> values;
|
|
34
|
-
std::string type = "";
|
|
35
|
-
std::string in = "SourceGraphic";
|
|
36
|
-
std::string in2 = "";
|
|
37
|
-
std::string result = "";
|
|
38
|
-
|
|
39
|
-
std::string mode = "";
|
|
40
|
-
std::string operator_ = "";
|
|
41
|
-
std::string floodColor = "black";
|
|
42
|
-
float floodOpacity = 1.0f;
|
|
43
|
-
|
|
44
|
-
float dx_ = 0.0f;
|
|
45
|
-
float dy_ = 0.0f;
|
|
46
|
-
float stdDeviationX_ = 0.0f;
|
|
47
|
-
float stdDeviationY_ = 0.0f;
|
|
48
|
-
std::string edgeMode_ = "duplicate";
|
|
49
|
-
std::string k1 = "";
|
|
50
|
-
std::string k2 = "";
|
|
51
|
-
std::string k3 = "";
|
|
52
|
-
std::string k4 = "";
|
|
53
|
-
|
|
54
|
-
FilterEffect() = default;
|
|
55
|
-
FilterEffect(FilterType t, const std::vector<float>& v) : filterType(t), values(v) {}
|
|
56
|
-
FilterEffect(FilterType t, const std::vector<float>& v, const std::string& inputSource, const std::string& inputType, const std::string& resultId)
|
|
57
|
-
: filterType(t), values(v), in(inputSource), type(inputType), result(resultId) {}
|
|
58
|
-
FilterEffect(FilterType t, const std::string& inputSource, const std::string& inputSource2, const std::string& blendMode, const std::string& resultId)
|
|
59
|
-
: filterType(t), in(inputSource), in2(inputSource2), mode(blendMode), result(resultId) {}
|
|
60
|
-
FilterEffect(FilterType t, const std::string& inputSource, const std::string& color, float opacity, const std::string& resultId)
|
|
61
|
-
: filterType(t), in(inputSource), floodColor(color), floodOpacity(opacity), result(resultId) {}
|
|
62
|
-
FilterEffect(FilterType t, const std::string& inputSource, float dx, float dy, const std::string& resultId)
|
|
63
|
-
: filterType(t), in(inputSource), dx_(dx), dy_(dy), result(resultId) {}
|
|
64
|
-
FilterEffect(FilterType t, const std::string& inputSource, const std::string& inputSource2, const std::string& op,
|
|
65
|
-
const std::string& k1_, const std::string& k2_, const std::string& k3_, const std::string& k4_, const std::string& resultId)
|
|
66
|
-
: filterType(t), in(inputSource), in2(inputSource2), operator_(op), k1(k1_), k2(k2_), k3(k3_), k4(k4_), result(resultId) {}
|
|
67
|
-
FilterEffect(FilterType t, const std::string& inputSource, float stdDeviationX, float stdDeviationY, const std::string& edgeMode, const std::string& resultId)
|
|
68
|
-
: filterType(t), in(inputSource), stdDeviationX_(stdDeviationX), stdDeviationY_(stdDeviationY), edgeMode_(edgeMode), result(resultId) {}
|
|
69
|
-
|
|
70
|
-
// DropShadow specific constructor
|
|
71
|
-
FilterEffect(FilterType t, const std::string& inputSource, float dx, float dy, float stdDeviation, const std::string& color, float opacity)
|
|
72
|
-
: filterType(t), in(inputSource), dx_(dx), dy_(dy), stdDeviationX_(stdDeviation), floodColor(color), floodOpacity(opacity) {}
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
class SvgFilter : virtual public SvgNode {
|
|
76
|
-
public:
|
|
77
|
-
SvgFilter() : SvgNode() {}
|
|
78
|
-
~SvgFilter() noexcept override = default;
|
|
79
|
-
void ApplyToBrush(rnoh::drawing::Brush& brush, const std::string& extra = "");
|
|
80
|
-
void ApplyToPen(rnoh::drawing::Pen& pen);
|
|
81
|
-
|
|
82
|
-
void AddFilterEffect(const FilterEffect& effect);
|
|
83
|
-
void ClearFilterEffects() {
|
|
84
|
-
effects_.clear();
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
void Draw(OH_Drawing_Canvas *canvas) override {}
|
|
88
|
-
private:
|
|
89
|
-
std::vector<FilterEffect> effects_;
|
|
90
|
-
void ApplySingleEffectToFilter(OH_Drawing_Filter* filter, const FilterEffect& effect,
|
|
91
|
-
rnoh::drawing::Brush* brush = nullptr, rnoh::drawing::Pen* pen = nullptr, const std::string& extra = "");
|
|
92
|
-
|
|
93
|
-
OH_Drawing_ImageFilter* CreateGaussianBlurFilter(const FilterEffect& effect);
|
|
94
|
-
OH_Drawing_MaskFilter* CreateBlurFilter(const FilterEffect& effect);
|
|
95
|
-
OH_Drawing_ColorFilter* CreateColorMatrixFilter(const FilterEffect& effect);
|
|
96
|
-
OH_Drawing_ShadowLayer* CreateDropShadowFilter(const FilterEffect& effect);
|
|
97
|
-
|
|
98
|
-
OH_Drawing_ColorFilter* CreateMatrixFilter(const std::vector<float>& values);
|
|
99
|
-
OH_Drawing_ColorFilter* CreateSaturateFilter(const std::vector<float>& values);
|
|
100
|
-
OH_Drawing_ColorFilter* CreateHueRotateFilter(const std::vector<float>& values);
|
|
101
|
-
OH_Drawing_ColorFilter* CreateLuminanceToAlphaFilter();
|
|
102
|
-
|
|
103
|
-
OH_Drawing_ImageFilter* GetInputImageFilter(const std::string& inputName);
|
|
104
|
-
OH_Drawing_ColorFilter* GetInputColorFilter(const std::string& inputName);
|
|
105
|
-
OH_Drawing_Filter* GetInputFilter(const std::string& inputName);
|
|
106
|
-
OH_Drawing_ColorFilter* CombineWithInputColor(OH_Drawing_ColorFilter* newFilter, const std::string& inputName);
|
|
107
|
-
void RegisterFilterResult(const std::string& resultId, OH_Drawing_ImageFilter* imageFilter = nullptr,
|
|
108
|
-
OH_Drawing_ColorFilter* colorFilter = nullptr, OH_Drawing_MaskFilter* maskFilter = nullptr);
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
} // namespace svg
|
|
112
|
-
} // 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 "SvgNode.h"
|
|
10
|
+
#include "drawing/Brush.h"
|
|
11
|
+
#include "drawing/Pen.h"
|
|
12
|
+
#include <native_drawing/drawing_canvas.h>
|
|
13
|
+
#include <native_drawing/drawing_filter.h>
|
|
14
|
+
|
|
15
|
+
namespace rnoh {
|
|
16
|
+
namespace svg {
|
|
17
|
+
|
|
18
|
+
enum class FilterType {
|
|
19
|
+
BLUR,
|
|
20
|
+
GAUSSIAN_BLUR,
|
|
21
|
+
DROP_SHADOW,
|
|
22
|
+
COLOR_MATRIX,
|
|
23
|
+
FEOFFSET,
|
|
24
|
+
FEFLOOD,
|
|
25
|
+
BLEND,
|
|
26
|
+
COMPOSITE,
|
|
27
|
+
MERGE,
|
|
28
|
+
UNKNOWN
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
struct FilterEffect {
|
|
32
|
+
FilterType filterType = FilterType::UNKNOWN;
|
|
33
|
+
std::vector<float> values;
|
|
34
|
+
std::string type = "";
|
|
35
|
+
std::string in = "SourceGraphic";
|
|
36
|
+
std::string in2 = "";
|
|
37
|
+
std::string result = "";
|
|
38
|
+
|
|
39
|
+
std::string mode = "";
|
|
40
|
+
std::string operator_ = "";
|
|
41
|
+
std::string floodColor = "black";
|
|
42
|
+
float floodOpacity = 1.0f;
|
|
43
|
+
|
|
44
|
+
float dx_ = 0.0f;
|
|
45
|
+
float dy_ = 0.0f;
|
|
46
|
+
float stdDeviationX_ = 0.0f;
|
|
47
|
+
float stdDeviationY_ = 0.0f;
|
|
48
|
+
std::string edgeMode_ = "duplicate";
|
|
49
|
+
std::string k1 = "";
|
|
50
|
+
std::string k2 = "";
|
|
51
|
+
std::string k3 = "";
|
|
52
|
+
std::string k4 = "";
|
|
53
|
+
|
|
54
|
+
FilterEffect() = default;
|
|
55
|
+
FilterEffect(FilterType t, const std::vector<float>& v) : filterType(t), values(v) {}
|
|
56
|
+
FilterEffect(FilterType t, const std::vector<float>& v, const std::string& inputSource, const std::string& inputType, const std::string& resultId)
|
|
57
|
+
: filterType(t), values(v), in(inputSource), type(inputType), result(resultId) {}
|
|
58
|
+
FilterEffect(FilterType t, const std::string& inputSource, const std::string& inputSource2, const std::string& blendMode, const std::string& resultId)
|
|
59
|
+
: filterType(t), in(inputSource), in2(inputSource2), mode(blendMode), result(resultId) {}
|
|
60
|
+
FilterEffect(FilterType t, const std::string& inputSource, const std::string& color, float opacity, const std::string& resultId)
|
|
61
|
+
: filterType(t), in(inputSource), floodColor(color), floodOpacity(opacity), result(resultId) {}
|
|
62
|
+
FilterEffect(FilterType t, const std::string& inputSource, float dx, float dy, const std::string& resultId)
|
|
63
|
+
: filterType(t), in(inputSource), dx_(dx), dy_(dy), result(resultId) {}
|
|
64
|
+
FilterEffect(FilterType t, const std::string& inputSource, const std::string& inputSource2, const std::string& op,
|
|
65
|
+
const std::string& k1_, const std::string& k2_, const std::string& k3_, const std::string& k4_, const std::string& resultId)
|
|
66
|
+
: filterType(t), in(inputSource), in2(inputSource2), operator_(op), k1(k1_), k2(k2_), k3(k3_), k4(k4_), result(resultId) {}
|
|
67
|
+
FilterEffect(FilterType t, const std::string& inputSource, float stdDeviationX, float stdDeviationY, const std::string& edgeMode, const std::string& resultId)
|
|
68
|
+
: filterType(t), in(inputSource), stdDeviationX_(stdDeviationX), stdDeviationY_(stdDeviationY), edgeMode_(edgeMode), result(resultId) {}
|
|
69
|
+
|
|
70
|
+
// DropShadow specific constructor
|
|
71
|
+
FilterEffect(FilterType t, const std::string& inputSource, float dx, float dy, float stdDeviation, const std::string& color, float opacity)
|
|
72
|
+
: filterType(t), in(inputSource), dx_(dx), dy_(dy), stdDeviationX_(stdDeviation), floodColor(color), floodOpacity(opacity) {}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
class SvgFilter : virtual public SvgNode {
|
|
76
|
+
public:
|
|
77
|
+
SvgFilter() : SvgNode() {}
|
|
78
|
+
~SvgFilter() noexcept override = default;
|
|
79
|
+
void ApplyToBrush(rnoh::drawing::Brush& brush, const std::string& extra = "");
|
|
80
|
+
void ApplyToPen(rnoh::drawing::Pen& pen);
|
|
81
|
+
|
|
82
|
+
void AddFilterEffect(const FilterEffect& effect);
|
|
83
|
+
void ClearFilterEffects() {
|
|
84
|
+
effects_.clear();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
void Draw(OH_Drawing_Canvas *canvas) override {}
|
|
88
|
+
private:
|
|
89
|
+
std::vector<FilterEffect> effects_;
|
|
90
|
+
void ApplySingleEffectToFilter(OH_Drawing_Filter* filter, const FilterEffect& effect,
|
|
91
|
+
rnoh::drawing::Brush* brush = nullptr, rnoh::drawing::Pen* pen = nullptr, const std::string& extra = "");
|
|
92
|
+
|
|
93
|
+
OH_Drawing_ImageFilter* CreateGaussianBlurFilter(const FilterEffect& effect);
|
|
94
|
+
OH_Drawing_MaskFilter* CreateBlurFilter(const FilterEffect& effect);
|
|
95
|
+
OH_Drawing_ColorFilter* CreateColorMatrixFilter(const FilterEffect& effect);
|
|
96
|
+
OH_Drawing_ShadowLayer* CreateDropShadowFilter(const FilterEffect& effect);
|
|
97
|
+
|
|
98
|
+
OH_Drawing_ColorFilter* CreateMatrixFilter(const std::vector<float>& values);
|
|
99
|
+
OH_Drawing_ColorFilter* CreateSaturateFilter(const std::vector<float>& values);
|
|
100
|
+
OH_Drawing_ColorFilter* CreateHueRotateFilter(const std::vector<float>& values);
|
|
101
|
+
OH_Drawing_ColorFilter* CreateLuminanceToAlphaFilter();
|
|
102
|
+
|
|
103
|
+
OH_Drawing_ImageFilter* GetInputImageFilter(const std::string& inputName);
|
|
104
|
+
OH_Drawing_ColorFilter* GetInputColorFilter(const std::string& inputName);
|
|
105
|
+
OH_Drawing_Filter* GetInputFilter(const std::string& inputName);
|
|
106
|
+
OH_Drawing_ColorFilter* CombineWithInputColor(OH_Drawing_ColorFilter* newFilter, const std::string& inputName);
|
|
107
|
+
void RegisterFilterResult(const std::string& resultId, OH_Drawing_ImageFilter* imageFilter = nullptr,
|
|
108
|
+
OH_Drawing_ColorFilter* colorFilter = nullptr, OH_Drawing_MaskFilter* maskFilter = nullptr);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
} // namespace svg
|
|
112
|
+
} // namespace rnoh
|
|
@@ -0,0 +1,86 @@
|
|
|
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 "SvgForeignObjectNode.h"
|
|
23
|
+
#include "RNOH/arkui/NativeNodeApi.h"
|
|
24
|
+
#include <deviceinfo.h>
|
|
25
|
+
#include <info/application_target_sdk_version.h>
|
|
26
|
+
namespace rnoh {
|
|
27
|
+
namespace svg {
|
|
28
|
+
SvgForeignObjectNode::SvgForeignObjectNode()
|
|
29
|
+
: ArkUINode(NativeNodeApi::getInstance()->createNode(ArkUI_NodeType::ARKUI_NODE_STACK)) {
|
|
30
|
+
mStackNode.setVisibility(ArkUI_Visibility::ARKUI_VISIBILITY_HIDDEN);
|
|
31
|
+
mStackNode.setClip(true);
|
|
32
|
+
maybeThrow(NativeNodeApi::getInstance()->addChild(m_nodeHandle, mStackNode.getArkUINodeHandle()));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
SvgForeignObjectNode::~SvgForeignObjectNode() {
|
|
36
|
+
if (m_NodeDelegate) {
|
|
37
|
+
m_NodeDelegate = nullptr;
|
|
38
|
+
}
|
|
39
|
+
_isGeneratedPixelMap = false;
|
|
40
|
+
}
|
|
41
|
+
void SvgForeignObjectNode::insertChild(ArkUINode &child, std::size_t index) { mStackNode.insertChild(child, index); }
|
|
42
|
+
|
|
43
|
+
void SvgForeignObjectNode::SetSnapHeight(Dimension height) { _height = height; }
|
|
44
|
+
|
|
45
|
+
void SvgForeignObjectNode::SetSnapWidth(Dimension width) { _width = width; }
|
|
46
|
+
|
|
47
|
+
void SvgForeignObjectNode::SetSnapPosition(Dimension x, Dimension y) {
|
|
48
|
+
_positionX = x;
|
|
49
|
+
_positionY = y;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
void SvgForeignObjectNode::onNodeEvent(ArkUI_NodeEventType eventType, EventArgs &eventArgs) {
|
|
53
|
+
if (eventType == ArkUI_NodeEventType::NODE_EVENT_ON_AREA_CHANGE) {
|
|
54
|
+
if (m_NodeDelegate && _isGeneratedPixelMap) {
|
|
55
|
+
OH_PixelmapNative *pixelMap = GetNodePixelMap();
|
|
56
|
+
if (!pixelMap) {
|
|
57
|
+
LOG(ERROR) << "[svgForeignNode] get node snapshot pixelMap is null";
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
_isGeneratedPixelMap = false;
|
|
61
|
+
ForeignProps foreignProps = {pixelMap, _width, _height, _positionX,
|
|
62
|
+
_positionY, _path, _clipRule, _mask, pointScaleFactor_, transform_};
|
|
63
|
+
m_NodeDelegate->onDrawForeignImage(foreignProps);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
OH_PixelmapNative *SvgForeignObjectNode::GetNodePixelMap() {
|
|
69
|
+
#ifdef OH_CURRENT_API_VERSION
|
|
70
|
+
if (OH_CURRENT_API_VERSION < 15 || OH_GetSdkApiVersion() < 15) {
|
|
71
|
+
LOG(ERROR) << "[svgForeignNode] current sdk or rom cannot support ForeignObject";
|
|
72
|
+
return nullptr;
|
|
73
|
+
}
|
|
74
|
+
OH_PixelmapNative *pixelMap;
|
|
75
|
+
ArkUI_SnapshotOptions *options = OH_ArkUI_CreateSnapshotOptions();
|
|
76
|
+
OH_ArkUI_SnapshotOptions_SetScale(options, 1);
|
|
77
|
+
int32_t code = OH_ArkUI_GetNodeSnapshot(mStackNode.getArkUINodeHandle(), options, &pixelMap);
|
|
78
|
+
if (code == ARKUI_ERROR_CODE_NO_ERROR) {
|
|
79
|
+
return pixelMap;
|
|
80
|
+
}
|
|
81
|
+
#endif
|
|
82
|
+
return nullptr;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
} // namespace svg
|
|
86
|
+
} // namespace rnoh
|
|
@@ -0,0 +1,81 @@
|
|
|
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 HARMONY_SVGFOREIGNOBJECTNODE_H
|
|
23
|
+
#define HARMONY_SVGFOREIGNOBJECTNODE_H
|
|
24
|
+
#include "RNOH/arkui/ArkUINode.h"
|
|
25
|
+
#include "RNOH/arkui/StackNode.h"
|
|
26
|
+
#include "SvgForeignObjectNodeDelegate.h"
|
|
27
|
+
#include "properties/Dimension.h"
|
|
28
|
+
|
|
29
|
+
namespace rnoh {
|
|
30
|
+
namespace svg {
|
|
31
|
+
class SvgForeignObjectNode : public ArkUINode {
|
|
32
|
+
public:
|
|
33
|
+
SvgForeignObjectNode();
|
|
34
|
+
~SvgForeignObjectNode() override;
|
|
35
|
+
void onNodeEvent(ArkUI_NodeEventType eventType, EventArgs &eventArgs) override;
|
|
36
|
+
StackNode &getSnapNode() { return mStackNode; }
|
|
37
|
+
void insertChild(ArkUINode &child, std::size_t index);
|
|
38
|
+
void SetSnapPosition(Dimension x, Dimension y);
|
|
39
|
+
void SetSnapWidth(Dimension width);
|
|
40
|
+
void SetSnapHeight(Dimension height);
|
|
41
|
+
void SetPointScaleFactor(float pointScaleFactor) {
|
|
42
|
+
pointScaleFactor_ = pointScaleFactor;
|
|
43
|
+
}
|
|
44
|
+
void SetTransform(std::vector<double> transform) {
|
|
45
|
+
transform_ = transform;
|
|
46
|
+
}
|
|
47
|
+
void setNodeSize(float w, float h){
|
|
48
|
+
mStackNode.setSize({w, h});
|
|
49
|
+
}
|
|
50
|
+
OH_PixelmapNative *GetNodePixelMap();
|
|
51
|
+
void SetForeignNodeDelegate(SvgForeignObjectNodeDelegate *delegate) { m_NodeDelegate = delegate; };
|
|
52
|
+
void SetGeneratedPixelMap(bool isNeed) {
|
|
53
|
+
_isGeneratedPixelMap = isNeed;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
void SetClipPath(std::string path,int clipRule) {
|
|
57
|
+
_path = path;
|
|
58
|
+
_clipRule = clipRule;
|
|
59
|
+
}
|
|
60
|
+
void SetMask(std::string mask) {
|
|
61
|
+
_mask = mask;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
private:
|
|
65
|
+
StackNode mStackNode;
|
|
66
|
+
SvgForeignObjectNodeDelegate *m_NodeDelegate;
|
|
67
|
+
Dimension _width{0};
|
|
68
|
+
Dimension _height{0};
|
|
69
|
+
Dimension _positionX{0};
|
|
70
|
+
Dimension _positionY{0};
|
|
71
|
+
std::string _path{""};
|
|
72
|
+
std::string _mask{""};
|
|
73
|
+
std::vector<double> transform_;
|
|
74
|
+
int _clipRule{0};
|
|
75
|
+
float pointScaleFactor_{0};
|
|
76
|
+
bool _isGeneratedPixelMap{false}; //防止快照生成多次,导致性能影响
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
} // namespace svg
|
|
80
|
+
} // namespace rnoh
|
|
81
|
+
#endif // HARMONY_SVGFOREIGNOBJECTNODE_H
|
|
@@ -0,0 +1,30 @@
|
|
|
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 HARMONY_SVGFOREIGNOBJECTNODEDELEGATE_H
|
|
23
|
+
#define HARMONY_SVGFOREIGNOBJECTNODEDELEGATE_H
|
|
24
|
+
#include "SvgForeignProps.h"
|
|
25
|
+
class SvgForeignObjectNodeDelegate {
|
|
26
|
+
public:
|
|
27
|
+
virtual ~SvgForeignObjectNodeDelegate() = default;
|
|
28
|
+
virtual void onDrawForeignImage(ForeignProps props){};
|
|
29
|
+
};
|
|
30
|
+
#endif //HARMONY_SVGFOREIGNOBJECTNODEDELEGATE_H
|
|
@@ -0,0 +1,39 @@
|
|
|
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 HARMONY_FOREIGNPROPS_H
|
|
23
|
+
#define HARMONY_FOREIGNPROPS_H
|
|
24
|
+
#include "properties/Dimension.h"
|
|
25
|
+
#include <multimedia/image_framework/image/pixelmap_native.h>
|
|
26
|
+
#include <string>
|
|
27
|
+
struct ForeignProps {
|
|
28
|
+
OH_PixelmapNative *foreignPixelMap{nullptr};
|
|
29
|
+
rnoh::svg::Dimension width;
|
|
30
|
+
rnoh::svg::Dimension height;
|
|
31
|
+
rnoh::svg::Dimension x;
|
|
32
|
+
rnoh::svg::Dimension y;
|
|
33
|
+
std::string path;
|
|
34
|
+
int clipRule;
|
|
35
|
+
std::string mask;
|
|
36
|
+
float pointScaleFactor;
|
|
37
|
+
std::vector<double> transform;
|
|
38
|
+
};
|
|
39
|
+
#endif //HARMONY_FOREIGNPROPS_H
|
|
@@ -70,6 +70,7 @@ void SvgGradient::SetAttrRy(const std::string& ry) {
|
|
|
70
70
|
|
|
71
71
|
void SvgGradient::SetAttrGradient(std::vector<Float> gradient) {
|
|
72
72
|
auto stopCount = gradient.size() / 2;
|
|
73
|
+
gradientAttr_.gradient.ClearColors();
|
|
73
74
|
for (auto i = 0; i < stopCount; i++) {
|
|
74
75
|
auto stopIndex = i * 2;
|
|
75
76
|
GradientColor gradientColor;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
#include "SvgGroup.h"
|
|
8
8
|
#include "SvgFilter.h"
|
|
9
|
+
#include "drawing/Brush.h"
|
|
9
10
|
|
|
10
11
|
namespace rnoh {
|
|
11
12
|
namespace svg {
|
|
@@ -30,7 +31,13 @@ void SvgGroup::OnInitStyle() {
|
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
void SvgGroup::OnDraw(OH_Drawing_Canvas *canvas) {
|
|
33
|
-
|
|
34
|
+
if (attributes_.selfOpacity < 1.0) {
|
|
35
|
+
drawing::Brush layerBrush;
|
|
36
|
+
uint8_t alpha= static_cast<uint8_t>(attributes_.selfOpacity* 255);
|
|
37
|
+
layerBrush.SetAlpha(alpha);
|
|
38
|
+
OH_Drawing_CanvasSaveLayer(canvas, nullptr, layerBrush.get());
|
|
39
|
+
}
|
|
40
|
+
SvgNode::OnDraw(canvas);
|
|
34
41
|
}
|
|
35
42
|
|
|
36
43
|
void SvgGroup::ApplyFilterToChildren(std::shared_ptr<SvgFilter> filter) {
|
|
@@ -23,11 +23,13 @@
|
|
|
23
23
|
#include "utils/SvgUtils.h"
|
|
24
24
|
#include "SvgGradient.h"
|
|
25
25
|
#include "SvgPattern.h"
|
|
26
|
+
#include "properties/ViewBox.h"
|
|
26
27
|
#include "SvgFilter.h"
|
|
27
28
|
#include <native_drawing/drawing_matrix.h>
|
|
28
29
|
#include <native_drawing/drawing_path.h>
|
|
29
30
|
#include <regex>
|
|
30
31
|
#include <string>
|
|
32
|
+
#include <native_drawing/drawing_pixel_map.h>
|
|
31
33
|
|
|
32
34
|
namespace rnoh {
|
|
33
35
|
namespace svg {
|
|
@@ -75,6 +77,7 @@ void SvgNode::InitStyle(const SvgBaseAttribute &attr) {
|
|
|
75
77
|
}
|
|
76
78
|
}
|
|
77
79
|
}
|
|
80
|
+
OnInitStyle();
|
|
78
81
|
if (passStyle_) {
|
|
79
82
|
for (auto &node : children_) {
|
|
80
83
|
if (node) {
|
|
@@ -138,9 +141,8 @@ void SvgNode::OnMask(OH_Drawing_Canvas *canvas) {
|
|
|
138
141
|
refMask->Draw(canvas);
|
|
139
142
|
}
|
|
140
143
|
|
|
141
|
-
void SvgNode::OnTransform(OH_Drawing_Canvas *canvas) {
|
|
144
|
+
void SvgNode::OnTransform(OH_Drawing_Canvas *canvas, std::vector<double> transform) {
|
|
142
145
|
// input transfrom: (float scaleX, float skewY, float skewX, float scaleY, float transX, float transY)
|
|
143
|
-
const auto &transform = attributes_.transform;
|
|
144
146
|
/* (OH_Drawing_Matrix* , float scaleX, float skewX, float transX, float skewY, float scaleY, float transY, float
|
|
145
147
|
persp0, float persp1, float persp2 )
|
|
146
148
|
*/
|
|
@@ -189,7 +191,7 @@ void SvgNode::Draw(OH_Drawing_Canvas *canvas) {
|
|
|
189
191
|
const auto count = OH_Drawing_CanvasGetSaveCount(canvas);
|
|
190
192
|
OH_Drawing_CanvasSave(canvas);
|
|
191
193
|
if (!attributes_.transform.empty()) {
|
|
192
|
-
OnTransform(canvas);
|
|
194
|
+
OnTransform(canvas, attributes_.transform);
|
|
193
195
|
}
|
|
194
196
|
if (!hrefClipPath_.empty()) {
|
|
195
197
|
OnClipPath(canvas);
|
|
@@ -204,6 +206,13 @@ void SvgNode::Draw(OH_Drawing_Canvas *canvas) {
|
|
|
204
206
|
// on marker
|
|
205
207
|
|
|
206
208
|
OnDrawTraversed(canvas);
|
|
209
|
+
|
|
210
|
+
if (_foreignPropsArray.size() > 0) {
|
|
211
|
+
for (ForeignProps _foreignProps : _foreignPropsArray) {
|
|
212
|
+
DrawForeignPixelMap(canvas, _foreignProps);
|
|
213
|
+
}
|
|
214
|
+
_foreignPropsArray.clear();
|
|
215
|
+
}
|
|
207
216
|
OH_Drawing_CanvasRestoreToCount(canvas, count);
|
|
208
217
|
}
|
|
209
218
|
|
|
@@ -285,5 +294,102 @@ double SvgNode::getCanvasDiagonal() {
|
|
|
285
294
|
canvasDiagonal_ = sqrt(powX + powY) * M_SQRT1_2l;
|
|
286
295
|
return canvasDiagonal_;
|
|
287
296
|
}
|
|
297
|
+
|
|
298
|
+
void SvgNode::DrawForeignClip(OH_Drawing_Canvas *canvas,const std::string &id,int clipRule) {
|
|
299
|
+
if (!context_) {
|
|
300
|
+
DLOG(INFO) << "[svgForeignNode] NO CONTEXT";
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
auto refSvgNode = context_->GetSvgNodeById(id);
|
|
304
|
+
if (!refSvgNode) {
|
|
305
|
+
DLOG(WARNING) << "[svgForeignNode] clipPath: SvgNode is null!";
|
|
306
|
+
return;
|
|
307
|
+
};
|
|
308
|
+
auto clipPath = refSvgNode->AsPath();
|
|
309
|
+
drawing::Path::FillType fillType = clipRule == 0
|
|
310
|
+
? OH_Drawing_PathFillType::PATH_FILL_TYPE_EVEN_ODD
|
|
311
|
+
: OH_Drawing_PathFillType::PATH_FILL_TYPE_WINDING;
|
|
312
|
+
clipPath.SetFillType(fillType);
|
|
313
|
+
OH_Drawing_CanvasClipPath(canvas, clipPath.get(), OH_Drawing_CanvasClipOp::INTERSECT, true);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
void SvgNode::DrawForeignMask(OH_Drawing_Canvas *canvas, const std::string &id) {
|
|
317
|
+
if (!context_) {
|
|
318
|
+
DLOG(INFO) << "[svgForeignNode] NO CONTEXT";
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
auto refMask = context_->GetSvgNodeById(id);
|
|
322
|
+
if (!refMask) {
|
|
323
|
+
return;
|
|
324
|
+
};
|
|
325
|
+
refMask->Draw(canvas);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
void SvgNode::DrawForeignPixelMap(OH_Drawing_Canvas *canvas, ForeignProps _foreignProps) {
|
|
329
|
+
if (!_foreignProps.foreignPixelMap) {
|
|
330
|
+
DLOG(INFO) << "[svgForeignNode] foreignPixelMap is null";
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
if (!_foreignProps.transform.empty()) {
|
|
334
|
+
OnTransform(canvas, _foreignProps.transform);
|
|
335
|
+
}
|
|
336
|
+
if (!_foreignProps.path.empty()) {
|
|
337
|
+
DrawForeignClip(canvas,_foreignProps.path, _foreignProps.clipRule);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
if (!_foreignProps.mask.empty()) {
|
|
341
|
+
DrawForeignMask(canvas,_foreignProps.mask);
|
|
342
|
+
}
|
|
343
|
+
double postionX = _foreignProps.x.ParsePropsToPx(OH_Drawing_CanvasGetWidth(canvas), _foreignProps.pointScaleFactor);
|
|
344
|
+
double postionY = _foreignProps.y.ParsePropsToPx(OH_Drawing_CanvasGetHeight(canvas), _foreignProps.pointScaleFactor);
|
|
345
|
+
double foreignW = _foreignProps.width.ParsePropsToPx(OH_Drawing_CanvasGetWidth(canvas), _foreignProps.pointScaleFactor);
|
|
346
|
+
double foreignH = _foreignProps.height.ParsePropsToPx(OH_Drawing_CanvasGetHeight(canvas), _foreignProps.pointScaleFactor);
|
|
347
|
+
OH_Pixelmap_ImageInfo *imageInfo;
|
|
348
|
+
OH_PixelmapImageInfo_Create(&imageInfo);
|
|
349
|
+
|
|
350
|
+
OH_PixelmapNative_GetImageInfo(_foreignProps.foreignPixelMap, imageInfo);
|
|
351
|
+
uint32_t originalWidth = 0, originalHeight = 0;
|
|
352
|
+
OH_PixelmapImageInfo_GetWidth(imageInfo, &originalWidth);
|
|
353
|
+
OH_PixelmapImageInfo_GetHeight(imageInfo, &originalHeight);
|
|
354
|
+
OH_PixelmapImageInfo_Release(imageInfo);
|
|
355
|
+
|
|
356
|
+
if (originalWidth == 0 || originalHeight == 0) {
|
|
357
|
+
DLOG(WARNING) << "[svgForeignNode] Invalid pixelmap size";
|
|
358
|
+
OH_PixelmapNative_Release(_foreignProps.foreignPixelMap);
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
float originalRelWidth = originalWidth > foreignW ? foreignW : originalWidth;
|
|
362
|
+
float originalRelHeight = originalHeight > foreignH ? foreignH : originalHeight;
|
|
363
|
+
DLOG(INFO) << "[svgForeignNode] DrawForeignPixelMap start , foreignH:" << foreignH << ";originalHeight:" << originalHeight <<";originalRelHeight:" << originalRelHeight;
|
|
364
|
+
OH_Drawing_PixelMap *ohPixelMap = OH_Drawing_PixelMapGetFromOhPixelMapNative(_foreignProps.foreignPixelMap);
|
|
365
|
+
if (!ohPixelMap) {
|
|
366
|
+
DLOG(WARNING) << "[svgForeignNode] Failed to get OH_Drawing_PixelMap";
|
|
367
|
+
OH_PixelmapNative_Release(_foreignProps.foreignPixelMap);
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
OH_Drawing_CanvasSave(canvas);
|
|
372
|
+
|
|
373
|
+
OH_Drawing_CanvasTranslate(canvas, postionX, postionY);
|
|
374
|
+
|
|
375
|
+
OH_Drawing_CanvasScale(canvas, 1, 1);
|
|
376
|
+
|
|
377
|
+
OH_Drawing_Rect *srcRect = OH_Drawing_RectCreate(0, 0, originalRelWidth, originalRelHeight);
|
|
378
|
+
OH_Drawing_Rect *dstRect = OH_Drawing_RectCreate(0, 0, originalRelWidth, originalRelHeight);
|
|
379
|
+
OH_Drawing_SamplingOptions *sampling = OH_Drawing_SamplingOptionsCreate(FILTER_MODE_LINEAR, MIPMAP_MODE_LINEAR);
|
|
380
|
+
OH_Drawing_CanvasDrawPixelMapRect(canvas, ohPixelMap, srcRect, dstRect, sampling);
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
OH_Drawing_CanvasRestore(canvas);
|
|
384
|
+
OH_Drawing_PixelMapDissolve(ohPixelMap);
|
|
385
|
+
OH_PixelmapNative_Release(_foreignProps.foreignPixelMap);
|
|
386
|
+
OH_Drawing_RectDestroy(srcRect);
|
|
387
|
+
OH_Drawing_RectDestroy(dstRect);
|
|
388
|
+
OH_Drawing_SamplingOptionsDestroy(sampling);
|
|
389
|
+
|
|
390
|
+
_foreignProps.foreignPixelMap = nullptr;
|
|
391
|
+
DLOG(INFO) << "[svgForeignNode] DrawForeignPixelMap end";
|
|
392
|
+
}
|
|
393
|
+
|
|
288
394
|
} // namespace svg
|
|
289
395
|
} // namespace rnoh
|