@react-native-ohos/react-native-clippathview 1.1.9-rc.1
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 -0
- package/README.md +15 -0
- package/harmony/clipPath/BuildProfile.ets +6 -0
- package/harmony/clipPath/LICENSE +21 -0
- package/harmony/clipPath/OAT.xml +39 -0
- package/harmony/clipPath/README.OpenSource +11 -0
- package/harmony/clipPath/ResourceTable.txt +0 -0
- package/harmony/clipPath/build-profile.json5 +11 -0
- package/harmony/clipPath/consumer-rules.txt +0 -0
- package/harmony/clipPath/hvigorfile.ts +6 -0
- package/harmony/clipPath/index.ets +15 -0
- package/harmony/clipPath/obfuscation-rules.txt +18 -0
- package/harmony/clipPath/oh-package.json5 +14 -0
- package/harmony/clipPath/src/main/cpp/CMakeLists.txt +7 -0
- package/harmony/clipPath/src/main/cpp/ClipPathProps.h +127 -0
- package/harmony/clipPath/src/main/cpp/ClipPathViewComponentInstance.cpp +102 -0
- package/harmony/clipPath/src/main/cpp/ClipPathViewComponentInstance.h +33 -0
- package/harmony/clipPath/src/main/cpp/ClipPathViewJSIBinder.h +60 -0
- package/harmony/clipPath/src/main/cpp/ClipPathViewNapiBinder.h +79 -0
- package/harmony/clipPath/src/main/cpp/ClipPathViewNoneComponentInstance.cpp +102 -0
- package/harmony/clipPath/src/main/cpp/ClipPathViewNoneComponentInstance.h +38 -0
- package/harmony/clipPath/src/main/cpp/ClipPathViewNoneJSIBinder.h +61 -0
- package/harmony/clipPath/src/main/cpp/ClipPathViewNoneNapiBinder.h +80 -0
- package/harmony/clipPath/src/main/cpp/ClipPathViewNoneNode.cpp +381 -0
- package/harmony/clipPath/src/main/cpp/ClipPathViewNoneNode.h +98 -0
- package/harmony/clipPath/src/main/cpp/ClipPathViewPackage.h +85 -0
- package/harmony/clipPath/src/main/cpp/ComponentDescriptors.h +30 -0
- package/harmony/clipPath/src/main/cpp/ModUtil.cpp +47 -0
- package/harmony/clipPath/src/main/cpp/ModUtil.h +36 -0
- package/harmony/clipPath/src/main/cpp/Props.cpp +95 -0
- package/harmony/clipPath/src/main/cpp/Props.h +108 -0
- package/harmony/clipPath/src/main/cpp/RNCClipPathTurboModule.cpp +38 -0
- package/harmony/clipPath/src/main/cpp/RNCClipPathTurboModule.h +37 -0
- package/harmony/clipPath/src/main/cpp/SVGPathParser.cpp +617 -0
- package/harmony/clipPath/src/main/cpp/SVGPathParser.h +71 -0
- package/harmony/clipPath/src/main/cpp/SVGViewBox.cpp +94 -0
- package/harmony/clipPath/src/main/cpp/SVGViewBox.h +32 -0
- package/harmony/clipPath/src/main/cpp/ShadowNodes.cpp +22 -0
- package/harmony/clipPath/src/main/cpp/ShadowNodes.h +41 -0
- package/harmony/clipPath/src/main/cpp/pen_style_node.h +10 -0
- package/harmony/clipPath/src/main/ets/ClipPathPackage.ts +46 -0
- package/harmony/clipPath/src/main/ets/ClipPathTurboModule.ts +32 -0
- package/harmony/clipPath/src/main/module.json5 +7 -0
- package/harmony/clipPath/src/main/resources/base/element/string.json +8 -0
- package/harmony/clipPath/src/main/resources/en_US/element/string.json +8 -0
- package/harmony/clipPath/src/main/resources/zh_CN/element/string.json +8 -0
- package/harmony/clipPath/ts.ts +26 -0
- package/harmony/clipPath.har +0 -0
- package/index.d.ts +58 -0
- package/index.js +5 -0
- package/package.json +64 -0
- package/react-native-clippath.podspec +30 -0
- package/src/ClipPath.android.js +7 -0
- package/src/ClipPath.ios.js +5 -0
- package/src/ClipPath.web.js +5 -0
- package/src/ClipPathH.android.js +6 -0
- package/src/ClipPathH.ios.js +5 -0
- package/src/ClipPathH.web.js +5 -0
- package/src/ClipPathMobile.js +6 -0
- package/src/ClipPathMobileN.js +6 -0
- package/src/ClipPathNativeComponent.ts +48 -0
- package/src/ClipPathWeb.js +345 -0
- package/src/demo.jpg +0 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
#include "ClipPathViewNoneComponentInstance.h"
|
|
17
|
+
#include "ModUtil.h"
|
|
18
|
+
#include <glog/logging.h>
|
|
19
|
+
namespace rnoh {
|
|
20
|
+
ClipPathViewNoneComponentInstance::ClipPathViewNoneComponentInstance(Context context)
|
|
21
|
+
: CppComponentInstance(std::move(context)) {
|
|
22
|
+
auto rnInstancePtr = this->m_deps->rnInstance.lock();
|
|
23
|
+
if (rnInstancePtr != nullptr) {
|
|
24
|
+
auto turboModule = rnInstancePtr->getTurboModule("RNCClipPathContext");
|
|
25
|
+
auto arkTsTurboModule = std::dynamic_pointer_cast<rnoh::ArkTSTurboModule>(turboModule);
|
|
26
|
+
folly::dynamic result = arkTsTurboModule->callSync("getDensity", {});
|
|
27
|
+
ModUtil::setDensity(static_cast<float>(result.asDouble()));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
void ClipPathViewNoneComponentInstance::onChildInserted(ComponentInstance::Shared const &childComponentInstance,
|
|
31
|
+
std::size_t index) {
|
|
32
|
+
CppComponentInstance::onChildInserted(childComponentInstance, index);
|
|
33
|
+
mClipPathNode.insertChild(childComponentInstance->getLocalRootArkUINode(), index);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
void ClipPathViewNoneComponentInstance::onChildRemoved(ComponentInstance::Shared const &childComponentInstance) {
|
|
37
|
+
CppComponentInstance::onChildRemoved(childComponentInstance);
|
|
38
|
+
mClipPathNode.removeChild(childComponentInstance->getLocalRootArkUINode());
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
ClipPathViewNoneNode &ClipPathViewNoneComponentInstance::getLocalRootArkUINode() { return mClipPathNode; }
|
|
42
|
+
|
|
43
|
+
void ClipPathViewNoneComponentInstance::onPropsChanged(SharedConcreteProps const &props) {
|
|
44
|
+
CppComponentInstance::onPropsChanged(props);
|
|
45
|
+
if (auto p = std::dynamic_pointer_cast<const facebook::react::RNCClipPathViewNoneProps>(props)) {
|
|
46
|
+
mClipPathNode.setD(p->d);
|
|
47
|
+
mClipPathNode.setViewBox(p->viewBox);
|
|
48
|
+
if (p->translateZ != 0) {
|
|
49
|
+
mClipPathNode.setTranslateZ(p->translateZ);
|
|
50
|
+
}
|
|
51
|
+
mClipPathNode.setAlign(p->align);
|
|
52
|
+
mClipPathNode.setAspect(p->aspect);
|
|
53
|
+
|
|
54
|
+
mClipPathNode.setStrokeCap(p->strokeCap);
|
|
55
|
+
mClipPathNode.setStrokeJoin(p->strokeJoin);
|
|
56
|
+
mClipPathNode.setStrokeWidth(p->strokeWidth);
|
|
57
|
+
mClipPathNode.setStrokeMiter(p->strokeMiter);
|
|
58
|
+
mClipPathNode.setStrokeStart(p->strokeStart);
|
|
59
|
+
mClipPathNode.setStrokeEnd(p->strokeEnd);
|
|
60
|
+
mClipPathNode.setFillRule(p->fillRule);
|
|
61
|
+
|
|
62
|
+
if (p->rot != 0.0f) {
|
|
63
|
+
mClipPathNode.setRot(p->rot);
|
|
64
|
+
}
|
|
65
|
+
if (p->rotO != 0.0f) {
|
|
66
|
+
mClipPathNode.setRotO(p->rotO);
|
|
67
|
+
}
|
|
68
|
+
if (p->rotOx != 0.0f) {
|
|
69
|
+
mClipPathNode.setRotOx(p->rotOx);
|
|
70
|
+
}
|
|
71
|
+
if (p->rotOy != 0.0f) {
|
|
72
|
+
mClipPathNode.setRotOy(p->rotOy);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
mClipPathNode.setRotPercentageValue(p->rotPercentageValue);
|
|
76
|
+
if (p->sc != 1.0f) {
|
|
77
|
+
mClipPathNode.setSc(p->sc);
|
|
78
|
+
}
|
|
79
|
+
if (p->scX != 1.0f) {
|
|
80
|
+
mClipPathNode.setScX(p->scX);
|
|
81
|
+
}
|
|
82
|
+
if (p->scY != 1.0f) {
|
|
83
|
+
mClipPathNode.setScY(p->scY);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (p->scO != 0.0f) {
|
|
87
|
+
mClipPathNode.setScO(p->scO);
|
|
88
|
+
}
|
|
89
|
+
if (p->scOx != 0.0f) {
|
|
90
|
+
mClipPathNode.setScOx(p->scOx);
|
|
91
|
+
}
|
|
92
|
+
if (p->scOy != 0.0f) {
|
|
93
|
+
mClipPathNode.setScOy(p->scOy);
|
|
94
|
+
}
|
|
95
|
+
mClipPathNode.setScPercentageValue(p->scPercentageValue);
|
|
96
|
+
|
|
97
|
+
mClipPathNode.setTransX(p->transX);
|
|
98
|
+
mClipPathNode.setTransY(p->transY);
|
|
99
|
+
mClipPathNode.setTransPercentageValue(p->transPercentageValue);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
} // namespace rnoh
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
#ifndef HARMONY_CLIPPATHVIEWNONECOMPONENTINSTANCE_H
|
|
17
|
+
#define HARMONY_CLIPPATHVIEWNONECOMPONENTINSTANCE_H
|
|
18
|
+
|
|
19
|
+
#include "ClipPathViewNoneNode.h"
|
|
20
|
+
#include "RNOH/CppComponentInstance.h"
|
|
21
|
+
#include "ShadowNodes.h"
|
|
22
|
+
|
|
23
|
+
namespace rnoh {
|
|
24
|
+
class ClipPathViewNoneComponentInstance : public CppComponentInstance<facebook::react::RNCClipPathViewNoneShadowNode> {
|
|
25
|
+
private:
|
|
26
|
+
ClipPathViewNoneNode mClipPathNode;
|
|
27
|
+
|
|
28
|
+
public:
|
|
29
|
+
ClipPathViewNoneComponentInstance(Context context);
|
|
30
|
+
void onChildInserted(ComponentInstance::Shared const &childComponentInstance, std::size_t index) override;
|
|
31
|
+
|
|
32
|
+
void onChildRemoved(ComponentInstance::Shared const &childComponentInstance) override;
|
|
33
|
+
ClipPathViewNoneNode &getLocalRootArkUINode() override;
|
|
34
|
+
void onPropsChanged(SharedConcreteProps const &props) override;
|
|
35
|
+
};
|
|
36
|
+
} // namespace rnoh
|
|
37
|
+
|
|
38
|
+
#endif // HARMONY_CLIPPATHVIEWCOMPONENTINSTANCE_H
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
#ifndef HARMONY_CLIP_PATH_VIEW_SRC_MAIN_CPP_CLIPPATHVIEWNONEJSIBINDER_H
|
|
18
|
+
#define HARMONY_CLIP_PATH_VIEW_SRC_MAIN_CPP_CLIPPATHVIEWNONEJSIBINDER_H
|
|
19
|
+
|
|
20
|
+
#include "RNOHCorePackage/ComponentBinders/ViewComponentJSIBinder.h"
|
|
21
|
+
|
|
22
|
+
namespace rnoh {
|
|
23
|
+
class ClipPathViewNoneJSIBinder : public ViewComponentJSIBinder {
|
|
24
|
+
facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override {
|
|
25
|
+
auto object = ViewComponentJSIBinder::createNativeProps(rt);
|
|
26
|
+
object.setProperty(rt, "d", "string");
|
|
27
|
+
object.setProperty(rt, "viewBox", "array");
|
|
28
|
+
object.setProperty(rt, "aspect", "string");
|
|
29
|
+
object.setProperty(rt, "align", "string");
|
|
30
|
+
object.setProperty(rt, "translateZ", "float");
|
|
31
|
+
object.setProperty(rt, "fillRule", "string");
|
|
32
|
+
object.setProperty(rt, "strokeWidth", "float");
|
|
33
|
+
object.setProperty(rt, "strokeCap", "string");
|
|
34
|
+
object.setProperty(rt, "strokeJoin", "string");
|
|
35
|
+
object.setProperty(rt, "strokeMiter", "float");
|
|
36
|
+
object.setProperty(rt, "strokeStart", "float");
|
|
37
|
+
object.setProperty(rt, "strokeEnd", "float");
|
|
38
|
+
|
|
39
|
+
object.setProperty(rt, "sc", "float");
|
|
40
|
+
object.setProperty(rt, "scX", "float");
|
|
41
|
+
object.setProperty(rt, "scY", "float");
|
|
42
|
+
object.setProperty(rt, "scO", "float");
|
|
43
|
+
object.setProperty(rt, "scOx", "float");
|
|
44
|
+
object.setProperty(rt, "scOy", "float");
|
|
45
|
+
object.setProperty(rt, "scPercentageValue", "float");
|
|
46
|
+
|
|
47
|
+
object.setProperty(rt, "rot", "float");
|
|
48
|
+
object.setProperty(rt, "rotO", "float");
|
|
49
|
+
object.setProperty(rt, "rotOx", "float");
|
|
50
|
+
object.setProperty(rt, "rotOy", "float");
|
|
51
|
+
object.setProperty(rt, "rotPercentageValue", "bool");
|
|
52
|
+
|
|
53
|
+
object.setProperty(rt, "transX", "float");
|
|
54
|
+
object.setProperty(rt, "transY", "float");
|
|
55
|
+
object.setProperty(rt, "transPercentageValue", "bool");
|
|
56
|
+
|
|
57
|
+
return object;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
} // namespace rnoh
|
|
61
|
+
#endif
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
#ifndef HARMONY_CLIP_PATH_VIEW_SRC_MAIN_CPP_CLIPPATHVIEWNONENAPIBINDER_H
|
|
17
|
+
#define HARMONY_CLIP_PATH_VIEW_SRC_MAIN_CPP_CLIPPATHVIEWNONENAPIBINDER_H
|
|
18
|
+
#include "RNOHCorePackage/ComponentBinders/ViewComponentNapiBinder.h"
|
|
19
|
+
#include "Props.h"
|
|
20
|
+
|
|
21
|
+
namespace rnoh {
|
|
22
|
+
|
|
23
|
+
class ClipPathViewNoneNapiBinder : public ViewComponentNapiBinder {
|
|
24
|
+
public:
|
|
25
|
+
napi_value createProps(napi_env env, facebook::react::ShadowView const shadowView) override {
|
|
26
|
+
napi_value napiViewProps = ViewComponentNapiBinder::createProps(env, shadowView);
|
|
27
|
+
auto propsObjBuilder = ArkJS(env).getObjectBuilder(napiViewProps);
|
|
28
|
+
|
|
29
|
+
if (auto props = std::dynamic_pointer_cast<const facebook::react::RNCClipPathViewNoneProps>(shadowView.props)) {
|
|
30
|
+
propsObjBuilder.addProperty("d", props->d);
|
|
31
|
+
propsObjBuilder.addProperty("aspect", props->aspect);
|
|
32
|
+
propsObjBuilder.addProperty("align", props->align);
|
|
33
|
+
propsObjBuilder.addProperty("translateZ", props->translateZ);
|
|
34
|
+
|
|
35
|
+
propsObjBuilder.addProperty("fillRule", props->fillRule);
|
|
36
|
+
propsObjBuilder.addProperty("strokeWidth", props->strokeWidth);
|
|
37
|
+
propsObjBuilder.addProperty("strokeCap", props->strokeCap);
|
|
38
|
+
propsObjBuilder.addProperty("strokeJoin", props->strokeJoin);
|
|
39
|
+
propsObjBuilder.addProperty("strokeMiter", props->strokeMiter);
|
|
40
|
+
propsObjBuilder.addProperty("strokeStart", props->strokeStart);
|
|
41
|
+
propsObjBuilder.addProperty("strokeEnd", props->strokeEnd);
|
|
42
|
+
|
|
43
|
+
propsObjBuilder.addProperty("sc", props->sc);
|
|
44
|
+
propsObjBuilder.addProperty("scX", props->scX);
|
|
45
|
+
propsObjBuilder.addProperty("scY", props->scY);
|
|
46
|
+
propsObjBuilder.addProperty("scO", props->scO);
|
|
47
|
+
propsObjBuilder.addProperty("scOx", props->scOx);
|
|
48
|
+
propsObjBuilder.addProperty("scOy", props->scOy);
|
|
49
|
+
propsObjBuilder.addProperty("scPercentageValue", props->scPercentageValue);
|
|
50
|
+
|
|
51
|
+
propsObjBuilder.addProperty("rot", props->rot);
|
|
52
|
+
propsObjBuilder.addProperty("rotO", props->rotO);
|
|
53
|
+
propsObjBuilder.addProperty("rotOx", props->rotOx);
|
|
54
|
+
propsObjBuilder.addProperty("rotOy", props->rotOy);
|
|
55
|
+
propsObjBuilder.addProperty("rotPercentageValue", props->rotPercentageValue);
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
propsObjBuilder.addProperty("transX", props->transX);
|
|
59
|
+
propsObjBuilder.addProperty("transY", props->transY);
|
|
60
|
+
propsObjBuilder.addProperty("transPercentageValue", props->transPercentageValue);
|
|
61
|
+
auto boxArray = std::vector<napi_value>();
|
|
62
|
+
auto boxArrayRaw = props->viewBox;
|
|
63
|
+
|
|
64
|
+
for (auto item : boxArrayRaw) {
|
|
65
|
+
auto itemObjBuilder = ArkJS(env).createDouble(item);
|
|
66
|
+
boxArray.push_back(itemObjBuilder);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
auto boxArrayArray = ArkJS(env).createArray(boxArray);
|
|
70
|
+
|
|
71
|
+
propsObjBuilder.addProperty("viewBox", boxArrayArray);
|
|
72
|
+
|
|
73
|
+
return propsObjBuilder.build();
|
|
74
|
+
}
|
|
75
|
+
return napiViewProps;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
} // namespace rnoh
|
|
80
|
+
#endif
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created on 2024/6/25.
|
|
3
|
+
//
|
|
4
|
+
// Node APIs are not fully supported. To solve the compilation error of the interface cannot be found,
|
|
5
|
+
// please include "napi/native_api.h".
|
|
6
|
+
|
|
7
|
+
#include "ModUtil.h"
|
|
8
|
+
#include "RNOH/arkui/NativeNodeApi.h"
|
|
9
|
+
#include "ClipPathViewNoneNode.h"
|
|
10
|
+
#include "SVGPathParser.h"
|
|
11
|
+
#include "SVGViewBox.h"
|
|
12
|
+
#include "pen_style_node.h"
|
|
13
|
+
#include <native_drawing/drawing_brush.h>
|
|
14
|
+
#include <native_drawing/drawing_canvas.h>
|
|
15
|
+
#include <native_drawing/drawing_color.h>
|
|
16
|
+
#include <native_drawing/drawing_path.h>
|
|
17
|
+
#include <native_drawing/drawing_pen.h>
|
|
18
|
+
#include <native_drawing/drawing_point.h>
|
|
19
|
+
#include <native_drawing/drawing_rect.h>
|
|
20
|
+
#include <native_drawing/drawing_shader_effect.h>
|
|
21
|
+
#include <native_drawing/drawing_types.h>
|
|
22
|
+
|
|
23
|
+
namespace rnoh {
|
|
24
|
+
ClipPathViewNoneNode::ClipPathViewNoneNode()
|
|
25
|
+
: ArkUINode(NativeNodeApi::getInstance()->createNode(ArkUI_NodeType::ARKUI_NODE_CUSTOM)) {
|
|
26
|
+
canvasCallback_ = new CanvasCallback();
|
|
27
|
+
canvasCallback_->callback = [this](ArkUI_NodeCustomEvent *event) {
|
|
28
|
+
auto type = OH_ArkUI_NodeCustomEvent_GetEventType(event);
|
|
29
|
+
switch (type) {
|
|
30
|
+
case ARKUI_NODE_CUSTOM_EVENT_ON_FOREGROUND_DRAW:
|
|
31
|
+
OnDraw(event);
|
|
32
|
+
break;
|
|
33
|
+
case ARKUI_NODE_CUSTOM_EVENT_ON_MEASURE: {
|
|
34
|
+
int32_t width = getSavedWidth();
|
|
35
|
+
int32_t height = getSavedHeight();
|
|
36
|
+
maybeThrow(NativeNodeApi::getInstance()->setMeasuredSize(m_nodeHandle, width, height));
|
|
37
|
+
setRectF(mBounds, 0, 0, width, height);
|
|
38
|
+
} break;
|
|
39
|
+
default:
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
eventReceiver = [](ArkUI_NodeCustomEvent *event) {
|
|
44
|
+
int32_t targetId = OH_ArkUI_NodeCustomEvent_GetEventTargetId(event);
|
|
45
|
+
if (targetId == 10001 || targetId == 10002) {
|
|
46
|
+
auto *userData = reinterpret_cast<CanvasCallback *>(OH_ArkUI_NodeCustomEvent_GetUserData(event));
|
|
47
|
+
if (userData != nullptr && userData->callback != nullptr) {
|
|
48
|
+
userData->callback(event);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
maybeThrow(NativeNodeApi::getInstance()->addNodeCustomEventReceiver(m_nodeHandle, eventReceiver));
|
|
53
|
+
maybeThrow(NativeNodeApi::getInstance()->registerNodeCustomEvent(
|
|
54
|
+
m_nodeHandle, ARKUI_NODE_CUSTOM_EVENT_ON_FOREGROUND_DRAW, 10001, canvasCallback_));
|
|
55
|
+
maybeThrow(NativeNodeApi::getInstance()->registerNodeCustomEvent(m_nodeHandle, ARKUI_NODE_CUSTOM_EVENT_ON_MEASURE,
|
|
56
|
+
10002, canvasCallback_));
|
|
57
|
+
OH_Drawing_PenIsAntiAlias(mPaint);
|
|
58
|
+
OH_Drawing_PenIsAntiAlias(mPaintStroke);
|
|
59
|
+
OH_Drawing_PenSetColor(mPaint, 0xffffffff);
|
|
60
|
+
OH_Drawing_PenSetColor(mPaintStroke, 0xffffffff);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
ClipPathViewNoneNode::~ClipPathViewNoneNode() {
|
|
64
|
+
NativeNodeApi::getInstance()->removeNodeCustomEventReceiver(m_nodeHandle, eventReceiver);
|
|
65
|
+
NativeNodeApi::getInstance()->unregisterNodeCustomEvent(m_nodeHandle, ARKUI_NODE_CUSTOM_EVENT_ON_FOREGROUND_DRAW);
|
|
66
|
+
NativeNodeApi::getInstance()->unregisterNodeCustomEvent(m_nodeHandle, ARKUI_NODE_CUSTOM_EVENT_ON_MEASURE);
|
|
67
|
+
OH_Drawing_RectDestroy(mRectVb);
|
|
68
|
+
OH_Drawing_RectDestroy(mRectVbDensity);
|
|
69
|
+
OH_Drawing_RectDestroy(mBounds);
|
|
70
|
+
OH_Drawing_RectDestroy(mRectPath);
|
|
71
|
+
OH_Drawing_PathDestroy(mPath);
|
|
72
|
+
OH_Drawing_PathDestroy(mPath2);
|
|
73
|
+
OH_Drawing_MatrixDestroy(mMatrix);
|
|
74
|
+
OH_Drawing_PenDestroy(mPaint);
|
|
75
|
+
OH_Drawing_PenDestroy(mPaintStroke);
|
|
76
|
+
delete canvasCallback_;
|
|
77
|
+
delete mProps;
|
|
78
|
+
canvasCallback_ = nullptr;
|
|
79
|
+
mProps = nullptr;
|
|
80
|
+
canvas =nullptr;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
void ClipPathViewNoneNode::insertChild(ArkUINode &child, std::size_t index) {
|
|
84
|
+
maybeThrow(NativeNodeApi::getInstance()->insertChildAt(m_nodeHandle, child.getArkUINodeHandle(), index));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
void ClipPathViewNoneNode::removeChild(ArkUINode &child) {
|
|
88
|
+
maybeThrow(NativeNodeApi::getInstance()->removeChild(m_nodeHandle, child.getArkUINodeHandle()));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
void ClipPathViewNoneNode::setPanStyleMode(OH_Drawing_Canvas *canvas, int type) {
|
|
92
|
+
|
|
93
|
+
auto cBrush = OH_Drawing_BrushCreate();
|
|
94
|
+
switch (type) {
|
|
95
|
+
case CLIP_PEN_STYLE_FILL:
|
|
96
|
+
OH_Drawing_BrushSetColor(cBrush, OH_Drawing_ColorSetArgb(0xff, 0xff, 0xff, 0xff));
|
|
97
|
+
break;
|
|
98
|
+
case CLIP_PEN_STYLE_STROKE:
|
|
99
|
+
OH_Drawing_BrushSetColor(cBrush, OH_Drawing_ColorSetArgb(0x00, 0x00, 0x00, 0x00));
|
|
100
|
+
break;
|
|
101
|
+
default:
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
OH_Drawing_CanvasAttachBrush(canvas, cBrush);
|
|
105
|
+
OH_Drawing_BrushDestroy(cBrush);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
void ClipPathViewNoneNode::OnDraw(ArkUI_NodeCustomEvent *event) {
|
|
109
|
+
auto *drawContext = OH_ArkUI_NodeCustomEvent_GetDrawContextInDraw(event);
|
|
110
|
+
canvas = reinterpret_cast<OH_Drawing_Canvas *>(OH_ArkUI_DrawContext_GetCanvas(drawContext));
|
|
111
|
+
auto width_ = OH_Drawing_CanvasGetWidth(canvas);
|
|
112
|
+
auto height_ = OH_Drawing_CanvasGetHeight(canvas);
|
|
113
|
+
|
|
114
|
+
auto canvasRect = OH_Drawing_RectCreate(0.0f, 0.0f, width_, height_);
|
|
115
|
+
OH_Drawing_CanvasSaveLayer(canvas, canvasRect, nullptr);
|
|
116
|
+
OH_Drawing_Brush *cBrush_back = OH_Drawing_BrushCreate();
|
|
117
|
+
OH_Drawing_BrushSetColor(cBrush_back, OH_Drawing_ColorSetArgb(0xff, 0xff, 0xff, 0xff));
|
|
118
|
+
OH_Drawing_CanvasDrawBackground(canvas, cBrush_back);
|
|
119
|
+
|
|
120
|
+
OH_Drawing_Brush *cBrush_ = OH_Drawing_BrushCreate();
|
|
121
|
+
OH_Drawing_BrushSetBlendMode(cBrush_, BLEND_MODE_DST_OUT);
|
|
122
|
+
OH_Drawing_CanvasSaveLayer(canvas, canvasRect, cBrush_);
|
|
123
|
+
|
|
124
|
+
drawPath(canvas);
|
|
125
|
+
OH_Drawing_RectDestroy(canvasRect);
|
|
126
|
+
OH_Drawing_BrushDestroy(cBrush_back);
|
|
127
|
+
OH_Drawing_BrushDestroy(cBrush_);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
void ClipPathViewNoneNode::drawPath(OH_Drawing_Canvas *canvas) {
|
|
131
|
+
setupPath(canvas);
|
|
132
|
+
viewBoxTransform();
|
|
133
|
+
setPaintStrokeProps();
|
|
134
|
+
canvasTransform();
|
|
135
|
+
OH_Drawing_CanvasSave(canvas);
|
|
136
|
+
OH_Drawing_CanvasConcatMatrix(canvas, mMatrix);
|
|
137
|
+
|
|
138
|
+
uint32_t count = OH_Drawing_CanvasGetSaveCount(canvas);
|
|
139
|
+
OH_Drawing_CanvasAttachPen(canvas, mPaint);
|
|
140
|
+
setPanStyleMode(canvas, CLIP_PEN_STYLE_FILL);
|
|
141
|
+
OH_Drawing_CanvasDrawPath(canvas, mPath);
|
|
142
|
+
OH_Drawing_CanvasDetachPen(canvas);
|
|
143
|
+
|
|
144
|
+
OH_Drawing_CanvasAttachPen(canvas, mPaintStroke);
|
|
145
|
+
setPanStyleMode(canvas, CLIP_PEN_STYLE_STROKE);
|
|
146
|
+
OH_Drawing_CanvasDrawPath(canvas, mPath2);
|
|
147
|
+
OH_Drawing_CanvasDetachPen(canvas);
|
|
148
|
+
|
|
149
|
+
OH_Drawing_CanvasRestoreToCount(canvas, count);
|
|
150
|
+
OH_Drawing_CanvasRestore(canvas);
|
|
151
|
+
OH_Drawing_CanvasRestore(canvas);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
void ClipPathViewNoneNode::setupPath(OH_Drawing_Canvas *canvas) {
|
|
155
|
+
if (!canvas || mD.empty()) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
if (mPath) {
|
|
159
|
+
OH_Drawing_PathReset(mPath);
|
|
160
|
+
}
|
|
161
|
+
SVGPathParser::mScale = ModUtil::getDensity();
|
|
162
|
+
mPath = SVGPathParser::parse(mD);
|
|
163
|
+
}
|
|
164
|
+
void ClipPathViewNoneNode::setD(const std::string d) {
|
|
165
|
+
mD = d;
|
|
166
|
+
markDirty();
|
|
167
|
+
}
|
|
168
|
+
void ClipPathViewNoneNode::setStrokeWidth(float const width) { mProps->mStrokeWidth = width; }
|
|
169
|
+
void ClipPathViewNoneNode::setStrokeCap(std::string const cap) { mProps->mStrokeCap = cap; }
|
|
170
|
+
void ClipPathViewNoneNode::setStrokeJoin(std::string const join) { mProps->mStrokeJoin = join; }
|
|
171
|
+
void ClipPathViewNoneNode::setStrokeMiter(float const miter) { mProps->mStrokeMiter = miter; }
|
|
172
|
+
void ClipPathViewNoneNode::setStrokeStart(float const start) { mProps->mStrokeStart = start; }
|
|
173
|
+
void ClipPathViewNoneNode::setStrokeEnd(float const end) { mProps->mStrokeEnd = end; }
|
|
174
|
+
float ClipPathViewNoneNode::toDip(float value) { return value * ModUtil::getDensity(); }
|
|
175
|
+
void ClipPathViewNoneNode::setFillRule(std::string v) { mProps->mFillRule = v.empty() ? "none" : v; }
|
|
176
|
+
void ClipPathViewNoneNode::setAlign(std::string v) { mAlign = v.empty() ? "xMidYMid" : v; }
|
|
177
|
+
void ClipPathViewNoneNode::setAspect(std::string v) {
|
|
178
|
+
mAspect = v.empty()
|
|
179
|
+
? SVGViewBox::MOS_MEET
|
|
180
|
+
: (v.compare("slice") == 0 ? SVGViewBox::MOS_SLICE
|
|
181
|
+
: (v.compare("none") == 0 ? SVGViewBox::MOS_NONE : SVGViewBox::MOS_MEET));
|
|
182
|
+
}
|
|
183
|
+
void ClipPathViewNoneNode::setRect(OH_Drawing_Rect *target, OH_Drawing_Rect *src) {
|
|
184
|
+
OH_Drawing_RectSetLeft(target, OH_Drawing_RectGetLeft(src));
|
|
185
|
+
OH_Drawing_RectSetTop(target, OH_Drawing_RectGetTop(src));
|
|
186
|
+
OH_Drawing_RectSetRight(target, OH_Drawing_RectGetRight(src));
|
|
187
|
+
OH_Drawing_RectSetBottom(target, OH_Drawing_RectGetBottom(src));
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
void ClipPathViewNoneNode::setRectF(OH_Drawing_Rect *target, float left, float top, float right, float bottom) {
|
|
191
|
+
setRect(target, OH_Drawing_RectCreate(left, top, right, bottom));
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
void ClipPathViewNoneNode::setTranslateZ(float z) {
|
|
195
|
+
ArkUI_NumberValue translateValue[] = {{.f32 = z}};
|
|
196
|
+
ArkUI_AttributeItem translateItem = {translateValue, sizeof(translateValue) / sizeof(ArkUI_NumberValue)};
|
|
197
|
+
uint32_t code = NativeNodeApi::getInstance()->setAttribute(m_nodeHandle, NODE_Z_INDEX, &translateItem);
|
|
198
|
+
}
|
|
199
|
+
void ClipPathViewNoneNode::setTransX(float v) {
|
|
200
|
+
if (mTranslationX != v) {
|
|
201
|
+
mTranslationX = v;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
void ClipPathViewNoneNode::setTransY(float v) {
|
|
205
|
+
if (mTranslationY != v) {
|
|
206
|
+
mTranslationY = v;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
void ClipPathViewNoneNode::setTransPercentageValue(bool v) {
|
|
210
|
+
if (mTranslationIsPercent != v) {
|
|
211
|
+
mTranslationIsPercent = v;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
void ClipPathViewNoneNode::setRot(float v) {
|
|
216
|
+
if (mRotation != v) {
|
|
217
|
+
mRotation = v;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
void ClipPathViewNoneNode::setRotO(float v) {
|
|
221
|
+
if (mRotationOx != v || mRotationOy != v) {
|
|
222
|
+
mRotationOx = v;
|
|
223
|
+
mRotationOy = v;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
void ClipPathViewNoneNode::setRotOx(float v) {
|
|
227
|
+
if (mRotationOx != v) {
|
|
228
|
+
mRotationOx = v;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
void ClipPathViewNoneNode::setRotOy(float v) {
|
|
232
|
+
if (mRotationOy != v) {
|
|
233
|
+
mRotationOy = v;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
void ClipPathViewNoneNode::setRotPercentageValue(bool v) {
|
|
237
|
+
if (mRotationIsPercent != v) {
|
|
238
|
+
mRotationIsPercent = v;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
void ClipPathViewNoneNode::setSc(float v) {
|
|
242
|
+
if (mScaleX != v || mScaleY != v) {
|
|
243
|
+
mScaleX = v;
|
|
244
|
+
mScaleY = v;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
void ClipPathViewNoneNode::setScX(float v) {
|
|
248
|
+
if (mScaleX != v) {
|
|
249
|
+
mScaleX = v;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
void ClipPathViewNoneNode::setScY(float v) {
|
|
254
|
+
if (mScaleY != v) {
|
|
255
|
+
mScaleY = v;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
void ClipPathViewNoneNode::setScO(float v) {
|
|
260
|
+
if (mScaleOriginX != v || mScaleOriginY != v) {
|
|
261
|
+
mScaleOriginX = v;
|
|
262
|
+
mScaleOriginY = v;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
void ClipPathViewNoneNode::setScOx(float v) {
|
|
266
|
+
if (mScaleOriginX != v) {
|
|
267
|
+
mScaleOriginX = v;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
void ClipPathViewNoneNode::setScOy(float v) {
|
|
271
|
+
if (mScaleOriginY != v) {
|
|
272
|
+
mScaleOriginY = v;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
void ClipPathViewNoneNode::setScPercentageValue(bool v) {
|
|
276
|
+
if (mScaleIsPercent != v) {
|
|
277
|
+
mScaleIsPercent = v;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
void ClipPathViewNoneNode::setViewBox(std::vector<float> viewBox) {
|
|
282
|
+
if (viewBox.empty()) {
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
float density = ModUtil::getDensity();
|
|
286
|
+
setRectF(mRectVb, viewBox[0], viewBox[1], (viewBox[0] + viewBox[2]), (viewBox[1] + viewBox[3]));
|
|
287
|
+
setRectF(mRectVbDensity, viewBox[0] * density, viewBox[1] * density, (viewBox[0] + viewBox[2]) * density,
|
|
288
|
+
(viewBox[1] + viewBox[3]) * density);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
void ClipPathViewNoneNode::viewBoxTransform() {
|
|
292
|
+
float density = ModUtil::getDensity();
|
|
293
|
+
if (validateViewBox()) {
|
|
294
|
+
setRect(mRectPath, mRectVbDensity);
|
|
295
|
+
SVGViewBox::transform(mRectVb, mBounds, mAlign, mAspect, density, mMatrix);
|
|
296
|
+
OH_Drawing_PathTransform(mPath, mMatrix);
|
|
297
|
+
OH_Drawing_MatrixMapRect(mMatrix, mRectPath, mRectPath);
|
|
298
|
+
|
|
299
|
+
} else {
|
|
300
|
+
setRect(mRectPath, mBounds);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
bool ClipPathViewNoneNode::validateViewBox() {
|
|
304
|
+
return OH_Drawing_RectGetWidth(mRectVb) >= 0.0f && OH_Drawing_RectGetHeight(mRectVb) >= 0.0f;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
void ClipPathViewNoneNode::setPaintStrokeProps() {
|
|
308
|
+
OH_Drawing_PathSetFillType(mPath, mProps->getFillRule());
|
|
309
|
+
float sw = validateViewBox()
|
|
310
|
+
? ModUtil::viewBoxToMax(mProps->getStrokeWidth(), mRectVb, OH_Drawing_RectGetWidth(mRectPath),
|
|
311
|
+
OH_Drawing_RectGetHeight(mRectPath))
|
|
312
|
+
: toDip(mProps->getStrokeWidth());
|
|
313
|
+
OH_Drawing_PenSetWidth(mPaintStroke, sw);
|
|
314
|
+
OH_Drawing_PenSetCap(mPaintStroke, mProps->getStrokeCap());
|
|
315
|
+
OH_Drawing_PenSetJoin(mPaintStroke, mProps->getStrokeJoin());
|
|
316
|
+
OH_Drawing_PenSetMiterLimit(mPaintStroke, mProps->getStrokeMiter());
|
|
317
|
+
OH_Drawing_PathReset(mPath2);
|
|
318
|
+
mPath2 = OH_Drawing_PathCopy(mPath);
|
|
319
|
+
if (mProps->getStrokeStart() != 0.0f || mProps->getStrokeEnd() != 1.0f) {
|
|
320
|
+
OH_Drawing_PathMoveTo(mPath2, OH_Drawing_PathGetLength(mPath2, false) * mProps->getStrokeStart(),
|
|
321
|
+
OH_Drawing_PathGetLength(mPath2, false) * mProps->getStrokeEnd());
|
|
322
|
+
OH_Drawing_PathLineTo(mPath2, 0.0f, 0.0f);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
void ClipPathViewNoneNode::canvasTransform() {
|
|
327
|
+
OH_Drawing_MatrixReset(mMatrix);
|
|
328
|
+
if (mRotation != 0.0f) {
|
|
329
|
+
float rotX;
|
|
330
|
+
float rotY;
|
|
331
|
+
if (mRotationIsPercent) {
|
|
332
|
+
rotX = (mRotationOx * getSavedWidth());
|
|
333
|
+
rotY = (mRotationOy * getSavedHeight());
|
|
334
|
+
} else if (validateViewBox()) {
|
|
335
|
+
rotX = OH_Drawing_RectGetLeft(mRectPath) +
|
|
336
|
+
ModUtil::viewBoxToWidth(mRotationOx, mRectVb, OH_Drawing_RectGetWidth(mRectPath));
|
|
337
|
+
rotY = OH_Drawing_RectGetTop(mRectPath) +
|
|
338
|
+
ModUtil::viewBoxToHeight(mRotationOy, mRectVb, OH_Drawing_RectGetHeight(mRectPath));
|
|
339
|
+
} else {
|
|
340
|
+
rotX = toDip(mRotationOx);
|
|
341
|
+
rotY = toDip(mRotationOy);
|
|
342
|
+
}
|
|
343
|
+
OH_Drawing_MatrixPostRotate(mMatrix, mRotation, rotX, rotY);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
if (mScaleX != 1.0f || mScaleY != 1.0f) {
|
|
347
|
+
float oX;
|
|
348
|
+
float oY;
|
|
349
|
+
if (mScaleIsPercent) {
|
|
350
|
+
oX = (mScaleOriginX * getSavedWidth());
|
|
351
|
+
oY = (mScaleOriginY * getSavedHeight());
|
|
352
|
+
} else if (validateViewBox()) {
|
|
353
|
+
oX = OH_Drawing_RectGetLeft(mRectPath) +
|
|
354
|
+
ModUtil::viewBoxToWidth(mScaleOriginX, mRectVb, OH_Drawing_RectGetWidth(mRectPath));
|
|
355
|
+
oY = OH_Drawing_RectGetTop(mRectPath) +
|
|
356
|
+
ModUtil::viewBoxToHeight(mScaleOriginY, mRectVb, OH_Drawing_RectGetHeight(mRectPath));
|
|
357
|
+
} else {
|
|
358
|
+
oX = toDip(mScaleOriginX);
|
|
359
|
+
oY = toDip(mScaleOriginY);
|
|
360
|
+
}
|
|
361
|
+
OH_Drawing_MatrixPostScale(mMatrix, mScaleX, mScaleY, oX, oY);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
if (mTranslationX != 0.0f || mTranslationY != 0.0f) {
|
|
365
|
+
float transX;
|
|
366
|
+
float transY;
|
|
367
|
+
if (mTranslationIsPercent) {
|
|
368
|
+
transX = (mTranslationX * getSavedWidth());
|
|
369
|
+
transY = (mTranslationY * getSavedHeight());
|
|
370
|
+
} else if (validateViewBox()) {
|
|
371
|
+
transX = (mTranslationX / OH_Drawing_RectGetWidth(mRectVb)) * OH_Drawing_RectGetWidth(mRectPath);
|
|
372
|
+
transY = (mTranslationY / OH_Drawing_RectGetHeight(mRectVb)) * OH_Drawing_RectGetHeight(mRectPath);
|
|
373
|
+
} else {
|
|
374
|
+
transX = toDip(mTranslationX);
|
|
375
|
+
transY = toDip(mTranslationY);
|
|
376
|
+
}
|
|
377
|
+
OH_Drawing_MatrixPostTranslate(mMatrix, transX, transY);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
} // namespace rnoh
|