@react-native-ohos/react-native-svg 15.12.1-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.OpenSource +11 -0
- package/README.md +13 -0
- package/css/package.json +6 -0
- package/harmony/svg/BuildProfile.ets +17 -0
- package/harmony/svg/build-profile.json5 +9 -0
- package/harmony/svg/hvigorfile.ts +2 -0
- package/harmony/svg/index.ets +7 -0
- package/harmony/svg/oh-package.json5 +13 -0
- package/harmony/svg/src/main/cpp/Attribute.h +52 -0
- package/harmony/svg/src/main/cpp/CMakeLists.txt +32 -0
- package/harmony/svg/src/main/cpp/FallbackProps.h +0 -0
- package/harmony/svg/src/main/cpp/FontHolderBase.cpp +22 -0
- package/harmony/svg/src/main/cpp/FontHolderBase.h +54 -0
- package/harmony/svg/src/main/cpp/SVGPackage.cpp +135 -0
- package/harmony/svg/src/main/cpp/SVGPackage.h +153 -0
- package/harmony/svg/src/main/cpp/SvgArkUINode.cpp +75 -0
- package/harmony/svg/src/main/cpp/SvgArkUINode.h +45 -0
- package/harmony/svg/src/main/cpp/SvgBaseAttribute.h +83 -0
- package/harmony/svg/src/main/cpp/SvgCircle.cpp +29 -0
- package/harmony/svg/src/main/cpp/SvgCircle.h +29 -0
- package/harmony/svg/src/main/cpp/SvgClipPath.h +22 -0
- package/harmony/svg/src/main/cpp/SvgContext.cpp +56 -0
- package/harmony/svg/src/main/cpp/SvgContext.h +71 -0
- package/harmony/svg/src/main/cpp/SvgDefs.h +46 -0
- package/harmony/svg/src/main/cpp/SvgEllipse.cpp +32 -0
- package/harmony/svg/src/main/cpp/SvgEllipse.h +34 -0
- package/harmony/svg/src/main/cpp/SvgFilter.cpp +505 -0
- package/harmony/svg/src/main/cpp/SvgFilter.h +112 -0
- package/harmony/svg/src/main/cpp/SvgGradient.cpp +116 -0
- package/harmony/svg/src/main/cpp/SvgGradient.h +49 -0
- package/harmony/svg/src/main/cpp/SvgGraphic.cpp +553 -0
- package/harmony/svg/src/main/cpp/SvgGraphic.h +77 -0
- package/harmony/svg/src/main/cpp/SvgGroup.cpp +86 -0
- package/harmony/svg/src/main/cpp/SvgGroup.h +41 -0
- package/harmony/svg/src/main/cpp/SvgHost.cpp +27 -0
- package/harmony/svg/src/main/cpp/SvgHost.h +38 -0
- package/harmony/svg/src/main/cpp/SvgImage.cpp +168 -0
- package/harmony/svg/src/main/cpp/SvgImage.h +52 -0
- package/harmony/svg/src/main/cpp/SvgLine.cpp +28 -0
- package/harmony/svg/src/main/cpp/SvgLine.h +32 -0
- package/harmony/svg/src/main/cpp/SvgMarker.cpp +61 -0
- package/harmony/svg/src/main/cpp/SvgMarker.h +86 -0
- package/harmony/svg/src/main/cpp/SvgMask.cpp +72 -0
- package/harmony/svg/src/main/cpp/SvgMask.h +68 -0
- package/harmony/svg/src/main/cpp/SvgNode.cpp +289 -0
- package/harmony/svg/src/main/cpp/SvgNode.h +347 -0
- package/harmony/svg/src/main/cpp/SvgPath.cpp +42 -0
- package/harmony/svg/src/main/cpp/SvgPath.h +29 -0
- package/harmony/svg/src/main/cpp/SvgPattern.cpp +77 -0
- package/harmony/svg/src/main/cpp/SvgPattern.h +64 -0
- package/harmony/svg/src/main/cpp/SvgQuote.h +87 -0
- package/harmony/svg/src/main/cpp/SvgRect.cpp +58 -0
- package/harmony/svg/src/main/cpp/SvgRect.h +33 -0
- package/harmony/svg/src/main/cpp/SvgSvg.cpp +83 -0
- package/harmony/svg/src/main/cpp/SvgSvg.h +52 -0
- package/harmony/svg/src/main/cpp/SvgSymbol.cpp +25 -0
- package/harmony/svg/src/main/cpp/SvgSymbol.h +37 -0
- package/harmony/svg/src/main/cpp/SvgTSpan.cpp +501 -0
- package/harmony/svg/src/main/cpp/SvgTSpan.h +101 -0
- package/harmony/svg/src/main/cpp/SvgText.cpp +48 -0
- package/harmony/svg/src/main/cpp/SvgText.h +29 -0
- package/harmony/svg/src/main/cpp/SvgTextPath.cpp +35 -0
- package/harmony/svg/src/main/cpp/SvgTextPath.h +51 -0
- package/harmony/svg/src/main/cpp/SvgUse.cpp +65 -0
- package/harmony/svg/src/main/cpp/SvgUse.h +46 -0
- package/harmony/svg/src/main/cpp/SvgViewManager.cpp +36 -0
- package/harmony/svg/src/main/cpp/SvgViewManager.h +37 -0
- package/harmony/svg/src/main/cpp/TextBase.cpp +20 -0
- package/harmony/svg/src/main/cpp/TextBase.h +114 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGBaseComponentInstance.h +212 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGCircleComponentInstance.cpp +31 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGCircleComponentInstance.h +27 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGClipPathComponentInstance.cpp +23 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGClipPathComponentInstance.h +27 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGDefsComponentInstance.cpp +23 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGDefsComponentInstance.h +28 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGEllipseComponentInstance.cpp +27 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGEllipseComponentInstance.h +27 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeBlendComponentInstance.cpp +40 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeBlendComponentInstance.h +48 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeColorMatrixComponentInstance.cpp +33 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeColorMatrixComponentInstance.h +48 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeCompositeComponentInstance.cpp +39 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeCompositeComponentInstance.h +55 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeFloodComponentInstance.cpp +33 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeFloodComponentInstance.h +49 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeGaussianBlurComponentInstance.cpp +34 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeGaussianBlurComponentInstance.h +48 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeOffsetComponentInstance.cpp +35 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeOffsetComponentInstance.h +46 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFilterComponentInstance.cpp +199 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGFilterComponentInstance.h +48 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGGroupComponentInstance.cpp +32 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGGroupComponentInstance.h +27 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGImageComponentInstance.cpp +100 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGImageComponentInstance.h +43 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGLineComponentInstance.cpp +27 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGLineComponentInstance.h +27 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGLinearGradientComponentInstance.cpp +30 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGLinearGradientComponentInstance.h +28 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGMarkerComponentInstance.cpp +35 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGMarkerComponentInstance.h +27 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGMaskComponentInstance.cpp +30 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGMaskComponentInstance.h +27 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGPathComponentInstance.cpp +33 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGPathComponentInstance.h +29 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGPatternComponentInstance.cpp +40 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGPatternComponentInstance.h +27 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGRadialGradientComponentInstance.cpp +32 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGRadialGradientComponentInstance.h +28 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGRectComponentInstance.cpp +36 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGRectComponentInstance.h +27 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGSvgViewComponentInstance.cpp +86 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGSvgViewComponentInstance.h +47 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGSymbolComponentInstance.cpp +30 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGSymbolComponentInstance.h +27 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGTSpanComponentInstance.cpp +27 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGTSpanComponentInstance.h +27 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGTextComponentInstance.cpp +25 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGTextComponentInstance.h +27 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGTextPathComponentInstance.cpp +32 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGTextPathComponentInstance.h +27 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGUseComponentInstance.cpp +32 -0
- package/harmony/svg/src/main/cpp/componentInstances/RNSVGUseComponentInstance.h +32 -0
- package/harmony/svg/src/main/cpp/downloadUtils/HttpTaskProcessor.cpp +207 -0
- package/harmony/svg/src/main/cpp/downloadUtils/HttpTaskProcessor.h +88 -0
- package/harmony/svg/src/main/cpp/downloadUtils/ImageSourceResolver.cpp +106 -0
- package/harmony/svg/src/main/cpp/downloadUtils/ImageSourceResolver.h +97 -0
- package/harmony/svg/src/main/cpp/downloadUtils/LRUCache.h +98 -0
- package/harmony/svg/src/main/cpp/drawing/Brush.cpp +50 -0
- package/harmony/svg/src/main/cpp/drawing/Brush.h +52 -0
- package/harmony/svg/src/main/cpp/drawing/GlyPathBag.cpp +20 -0
- package/harmony/svg/src/main/cpp/drawing/GlyPathBag.h +31 -0
- package/harmony/svg/src/main/cpp/drawing/Matrix.cpp +100 -0
- package/harmony/svg/src/main/cpp/drawing/Matrix.h +68 -0
- package/harmony/svg/src/main/cpp/drawing/Path.cpp +173 -0
- package/harmony/svg/src/main/cpp/drawing/Path.h +127 -0
- package/harmony/svg/src/main/cpp/drawing/Pen.cpp +57 -0
- package/harmony/svg/src/main/cpp/drawing/Pen.h +59 -0
- package/harmony/svg/src/main/cpp/drawing/Rect.cpp +47 -0
- package/harmony/svg/src/main/cpp/drawing/Rect.h +56 -0
- package/harmony/svg/src/main/cpp/drawing/RoundRect.cpp +24 -0
- package/harmony/svg/src/main/cpp/drawing/RoundRect.h +39 -0
- package/harmony/svg/src/main/cpp/drawing/ShaderEffect.cpp +37 -0
- package/harmony/svg/src/main/cpp/drawing/ShaderEffect.h +51 -0
- package/harmony/svg/src/main/cpp/drawing/TextStyle.cpp +49 -0
- package/harmony/svg/src/main/cpp/drawing/TextStyle.h +41 -0
- package/harmony/svg/src/main/cpp/drawing/Typography.cpp +9 -0
- package/harmony/svg/src/main/cpp/drawing/Typography.h +25 -0
- package/harmony/svg/src/main/cpp/drawing/TypographyStyle.cpp +31 -0
- package/harmony/svg/src/main/cpp/drawing/TypographyStyle.h +41 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGCircleJSIBinder.h +54 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGClipPathJSIBinder.h +54 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGDefsJSIBinder.h +38 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGEllipseJSIBinder.h +55 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeBlendJSIBinder.h +26 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeColorMatrixJSIBinder.h +26 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeCompositeJSIBinder.h +30 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeFloodJSIBinder.h +26 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeGaussianBlurJSIBinder.h +27 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeOffsetJSIBinder.h +26 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFilterJSIBinder.h +44 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGForeignObjectJSIBinder.h +57 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGGroupJSIBinder.h +54 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGImageJSIBinder.h +58 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGLineJSIBinder.h +55 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGLinearGradientJSIBinder.h +45 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGMarkerJSIBinder.h +66 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGMaskJSIBinder.h +60 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGPathJSIBinder.h +52 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGPatternJSIBinder.h +67 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGRadialGradientJSIBinder.h +47 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGRectJSIBinder.h +57 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGSvgViewAndroidJSIBinder.h +67 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGSvgViewJSIBinder.h +36 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGSymbolJSIBinder.h +60 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGTSpanJSIBinder.h +66 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGTextJSIBinder.h +65 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGTextPathJSIBinder.h +71 -0
- package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGUseJSIBinder.h +56 -0
- package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/ComponentDescriptors.h +48 -0
- package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/EventEmitters.cpp +20 -0
- package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/EventEmitters.h +253 -0
- package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/Props.cpp +977 -0
- package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/Props.h +1280 -0
- package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/ShadowNodes.cpp +45 -0
- package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/ShadowNodes.h +331 -0
- package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/States.cpp +18 -0
- package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/States.h +441 -0
- package/harmony/svg/src/main/cpp/properties/Color.cpp +458 -0
- package/harmony/svg/src/main/cpp/properties/Color.h +144 -0
- package/harmony/svg/src/main/cpp/properties/Decoration.cpp +41 -0
- package/harmony/svg/src/main/cpp/properties/Decoration.h +483 -0
- package/harmony/svg/src/main/cpp/properties/Dimension.cpp +64 -0
- package/harmony/svg/src/main/cpp/properties/Dimension.h +243 -0
- package/harmony/svg/src/main/cpp/properties/Font.cpp +166 -0
- package/harmony/svg/src/main/cpp/properties/Font.h +163 -0
- package/harmony/svg/src/main/cpp/properties/Offset.h +119 -0
- package/harmony/svg/src/main/cpp/properties/PaintState.h +240 -0
- package/harmony/svg/src/main/cpp/properties/Rect.h +423 -0
- package/harmony/svg/src/main/cpp/properties/Size.h +246 -0
- package/harmony/svg/src/main/cpp/properties/SvgPaintState.h +452 -0
- package/harmony/svg/src/main/cpp/properties/TextProperties.cpp +91 -0
- package/harmony/svg/src/main/cpp/properties/TextProperties.h +56 -0
- package/harmony/svg/src/main/cpp/properties/ViewBox.h +108 -0
- package/harmony/svg/src/main/cpp/svgImage/RNSVGImageComponentDescriptor.h +41 -0
- package/harmony/svg/src/main/cpp/svgImage/RNSVGImageShadowNode.cpp +62 -0
- package/harmony/svg/src/main/cpp/svgImage/RNSVGImageShadowNode.h +63 -0
- package/harmony/svg/src/main/cpp/svgImage/RNSVGImageState.cpp +17 -0
- package/harmony/svg/src/main/cpp/svgImage/RNSVGImageState.h +58 -0
- package/harmony/svg/src/main/cpp/turboModules/RNSVGImageModule.cpp +54 -0
- package/harmony/svg/src/main/cpp/turboModules/RNSVGImageModule.h +32 -0
- package/harmony/svg/src/main/cpp/turboModules/RNSVGRenderableModule.cpp +101 -0
- package/harmony/svg/src/main/cpp/turboModules/RNSVGRenderableModule.h +32 -0
- package/harmony/svg/src/main/cpp/turboModules/RNSVGSvgViewModule.cpp +71 -0
- package/harmony/svg/src/main/cpp/turboModules/RNSVGSvgViewModule.h +32 -0
- package/harmony/svg/src/main/cpp/utils/DynamicUtils.h +55 -0
- package/harmony/svg/src/main/cpp/utils/FilterManager.h +190 -0
- package/harmony/svg/src/main/cpp/utils/GlyphContext.cpp +221 -0
- package/harmony/svg/src/main/cpp/utils/GlyphContext.h +106 -0
- package/harmony/svg/src/main/cpp/utils/LinearMap.h +69 -0
- package/harmony/svg/src/main/cpp/utils/PathParserUtils.cpp +591 -0
- package/harmony/svg/src/main/cpp/utils/PathParserUtils.h +93 -0
- package/harmony/svg/src/main/cpp/utils/StringUtils.cpp +134 -0
- package/harmony/svg/src/main/cpp/utils/StringUtils.h +644 -0
- package/harmony/svg/src/main/cpp/utils/SvgAttributesParser.cpp +239 -0
- package/harmony/svg/src/main/cpp/utils/SvgAttributesParser.h +277 -0
- package/harmony/svg/src/main/cpp/utils/SvgMarkerPositionUtils.h +200 -0
- package/harmony/svg/src/main/cpp/utils/SvgUtils.h +176 -0
- package/harmony/svg/src/main/cpp/utils/TextPathHelper.cpp +94 -0
- package/harmony/svg/src/main/cpp/utils/TextPathHelper.h +61 -0
- package/harmony/svg/src/main/ets/RNSVGImageModule.ts +21 -0
- package/harmony/svg/src/main/ets/RNSVGRenderableModule.ts +16 -0
- package/harmony/svg/src/main/ets/RNSVGSvgViewModule.ts +18 -0
- package/harmony/svg/src/main/ets/SvgPackage.ts +58 -0
- package/harmony/svg/src/main/module.json5 +7 -0
- package/harmony/svg/src/main/resources/base/element/string.json +8 -0
- package/harmony/svg/src/main/resources/en_US/element/string.json +8 -0
- package/harmony/svg/src/main/resources/zh_CN/element/string.json +8 -0
- package/harmony/svg/ts.ts +8 -0
- package/harmony/svg.har +0 -0
- package/lib/commonjs/css/index.js +55 -0
- package/lib/commonjs/css/index.js.map +1 -0
- package/lib/commonjs/index.js +26 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/css/index.js +4 -0
- package/lib/module/css/index.js.map +1 -0
- package/lib/module/index.js +3 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/babel.config.d.ts +8 -0
- package/lib/typescript/babel.config.d.ts.map +1 -0
- package/lib/typescript/example/babel.config.d.ts +3 -0
- package/lib/typescript/example/babel.config.d.ts.map +1 -0
- package/lib/typescript/example/contexts.d.ts +3 -0
- package/lib/typescript/example/contexts.d.ts.map +1 -0
- package/lib/typescript/example/harmony/entry/hvigorfile.d.ts +2 -0
- package/lib/typescript/example/harmony/entry/hvigorfile.d.ts.map +1 -0
- package/lib/typescript/example/harmony/hvigorfile.d.ts +2 -0
- package/lib/typescript/example/harmony/hvigorfile.d.ts.map +1 -0
- package/lib/typescript/example/index.d.ts +2 -0
- package/lib/typescript/example/index.d.ts.map +1 -0
- package/lib/typescript/example/jest.config.d.ts +3 -0
- package/lib/typescript/example/jest.config.d.ts.map +1 -0
- package/lib/typescript/example/metro.config.d.ts +3 -0
- package/lib/typescript/example/metro.config.d.ts.map +1 -0
- package/lib/typescript/example/react-native.config.d.ts +3 -0
- package/lib/typescript/example/react-native.config.d.ts.map +1 -0
- package/lib/typescript/example/scripts/create-build-profile.d.ts +2 -0
- package/lib/typescript/example/scripts/create-build-profile.d.ts.map +1 -0
- package/lib/typescript/example/src/index.d.ts +3 -0
- package/lib/typescript/example/src/index.d.ts.map +1 -0
- package/lib/typescript/src/css/index.d.ts +4 -0
- package/lib/typescript/src/css/index.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +54 -0
- package/src/css/index.tsx +20 -0
- package/src/index.tsx +3 -0
- package/tsconfig.json +12 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
#include "SvgGroup.h"
|
|
8
|
+
#include "SvgFilter.h"
|
|
9
|
+
|
|
10
|
+
namespace rnoh {
|
|
11
|
+
namespace svg {
|
|
12
|
+
|
|
13
|
+
void SvgGroup::InitGroupFlag() {
|
|
14
|
+
hrefFill_ = true;
|
|
15
|
+
hrefRender_ = true;
|
|
16
|
+
passStyle_ = true;
|
|
17
|
+
inheritStyle_ = true;
|
|
18
|
+
drawTraversed_ = true;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
void SvgGroup::OnInitStyle() {
|
|
22
|
+
if (!font_) {
|
|
23
|
+
InitFont(GetScale());
|
|
24
|
+
}
|
|
25
|
+
for (auto &child : children_) {
|
|
26
|
+
if (auto childG = std::dynamic_pointer_cast<FontHolderBase>(child)) {
|
|
27
|
+
childG->InheritFont(font_, child->GetScale());
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
void SvgGroup::OnDraw(OH_Drawing_Canvas *canvas) {
|
|
33
|
+
OnDrawTraversed(canvas);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
void SvgGroup::ApplyFilterToChildren(std::shared_ptr<SvgFilter> filter) {
|
|
37
|
+
if (!filter) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
originalFilters_.clear();
|
|
41
|
+
|
|
42
|
+
for (auto& child : children_) {
|
|
43
|
+
if (child) {
|
|
44
|
+
originalFilters_.push_back(child->GetBaseAttributes().filterId);
|
|
45
|
+
auto childAttrs = child->GetBaseAttributes();
|
|
46
|
+
childAttrs.filterId = attributes_.filterId;
|
|
47
|
+
childAttrs.hasInheritedFilter = true;
|
|
48
|
+
child->SetBaseAttributes(childAttrs);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
void SvgGroup::RestoreChildrenFilter() {
|
|
54
|
+
for (size_t i = 0; i < children_.size() && i < originalFilters_.size(); ++i) {
|
|
55
|
+
if (children_[i]) {
|
|
56
|
+
auto childAttrs = children_[i]->GetBaseAttributes();
|
|
57
|
+
childAttrs.filterId = originalFilters_[i];
|
|
58
|
+
childAttrs.hasInheritedFilter = false;
|
|
59
|
+
children_[i]->SetBaseAttributes(childAttrs);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
originalFilters_.clear();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
Rect SvgGroup::AsBounds() {
|
|
67
|
+
if (children_.empty()) {
|
|
68
|
+
return Rect(0, 0, 0, 0);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
auto bounds = children_[0]->AsBounds();
|
|
72
|
+
for (size_t i = 1; i < children_.size(); ++i) {
|
|
73
|
+
auto childBounds = children_[i]->AsBounds();
|
|
74
|
+
// 合并边界
|
|
75
|
+
float left = std::min(bounds.Left(), childBounds.Left());
|
|
76
|
+
float top = std::min(bounds.Top(), childBounds.Top());
|
|
77
|
+
float right = std::max(bounds.Right(), childBounds.Right());
|
|
78
|
+
float bottom = std::max(bounds.Bottom(), childBounds.Bottom());
|
|
79
|
+
bounds = Rect(left, top, right - left, bottom - top);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return bounds;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
} // namespace svg
|
|
86
|
+
} // namespace rnoh
|
|
@@ -0,0 +1,41 @@
|
|
|
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 "properties/Font.h"
|
|
11
|
+
#include "FontHolderBase.h"
|
|
12
|
+
#include <native_drawing/drawing_canvas.h>
|
|
13
|
+
|
|
14
|
+
namespace rnoh {
|
|
15
|
+
namespace svg {
|
|
16
|
+
|
|
17
|
+
class SvgFilter; // 前置声明
|
|
18
|
+
|
|
19
|
+
class SvgGroup : public SvgNode, public FontHolderBase {
|
|
20
|
+
|
|
21
|
+
public:
|
|
22
|
+
SvgGroup() : SvgNode() { InitGroupFlag(); }
|
|
23
|
+
~SvgGroup() override = default;
|
|
24
|
+
|
|
25
|
+
Rect AsBounds() override;
|
|
26
|
+
|
|
27
|
+
protected:
|
|
28
|
+
void OnDraw(OH_Drawing_Canvas *canvas) override;
|
|
29
|
+
|
|
30
|
+
private:
|
|
31
|
+
// svg g, use
|
|
32
|
+
void InitGroupFlag();
|
|
33
|
+
void OnInitStyle() override;
|
|
34
|
+
void ApplyFilterToChildren(std::shared_ptr<SvgFilter> filter);
|
|
35
|
+
void RestoreChildrenFilter();
|
|
36
|
+
// 用于保存子节点的原始filter设置
|
|
37
|
+
std::vector<std::string> originalFilters_;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
} // namespace svg
|
|
41
|
+
} // namespace rnoh
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
#include "SvgHost.h"
|
|
8
|
+
|
|
9
|
+
namespace rnoh {
|
|
10
|
+
namespace svg {
|
|
11
|
+
|
|
12
|
+
void SvgHost::OnChildInsertCommon(const std::shared_ptr<SvgHost> &childSvgHost) {
|
|
13
|
+
if (!childSvgHost) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
GetSvgNode()->AppendChild(childSvgHost->GetSvgNode());
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
void SvgHost::OnChildRemoveCommon(const std::shared_ptr<SvgHost> &childSvgHost) {
|
|
20
|
+
if (!childSvgHost) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
GetSvgNode()->removeChild(childSvgHost->GetSvgNode());
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
} // namespace svg
|
|
27
|
+
} // namespace rnoh
|
|
@@ -0,0 +1,38 @@
|
|
|
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 <memory>
|
|
10
|
+
#include "SvgNode.h"
|
|
11
|
+
|
|
12
|
+
namespace rnoh {
|
|
13
|
+
namespace svg {
|
|
14
|
+
|
|
15
|
+
class SvgHost {
|
|
16
|
+
public:
|
|
17
|
+
SvgHost() = default;
|
|
18
|
+
virtual ~SvgHost() = default;
|
|
19
|
+
void SetSvgNode(const std::shared_ptr<SvgNode> &svgNode) {
|
|
20
|
+
std::lock_guard<std::mutex> lock(mtx);
|
|
21
|
+
m_svgNode = svgNode;
|
|
22
|
+
};
|
|
23
|
+
const std::shared_ptr<SvgNode> &GetSvgNode() const {
|
|
24
|
+
std::lock_guard<std::mutex> lock(mtx);
|
|
25
|
+
return m_svgNode;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
void OnChildInsertCommon(const std::shared_ptr<SvgHost> &childSvgHost);
|
|
29
|
+
|
|
30
|
+
void OnChildRemoveCommon(const std::shared_ptr<SvgHost> &childSvgHost);
|
|
31
|
+
|
|
32
|
+
private:
|
|
33
|
+
std::shared_ptr<SvgNode> m_svgNode{nullptr};
|
|
34
|
+
mutable std::mutex mtx;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
} // namespace svg
|
|
38
|
+
} // namespace rnoh
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
#include "SvgImage.h"
|
|
8
|
+
#include "SvgFilter.h"
|
|
9
|
+
#include "utils/StringUtils.h"
|
|
10
|
+
#include "properties/ViewBox.h"
|
|
11
|
+
#include <multimedia/image_framework/image_mdk_common.h>
|
|
12
|
+
#include <multimedia/image_framework/image/image_source_native.h>
|
|
13
|
+
#include <multimedia/image_framework/image_pixel_map_mdk.h>
|
|
14
|
+
#include <glog/logging.h>
|
|
15
|
+
#include <native_drawing/drawing_image.h>
|
|
16
|
+
#include <native_drawing/drawing_rect.h>
|
|
17
|
+
#include <native_drawing/drawing_pixel_map.h>
|
|
18
|
+
#include <native_drawing/drawing_sampling_options.h>
|
|
19
|
+
#include <native_drawing/drawing_filter.h>
|
|
20
|
+
#include <rawfile/raw_file.h>
|
|
21
|
+
|
|
22
|
+
const char *ASSET_PREFIX = "asset://";
|
|
23
|
+
const char *RAWFILE_PREFIX = "assets/";
|
|
24
|
+
|
|
25
|
+
namespace rnoh {
|
|
26
|
+
namespace svg {
|
|
27
|
+
|
|
28
|
+
void SvgImage::OnDraw(OH_Drawing_Canvas *canvas) {
|
|
29
|
+
auto uriString = imageAttribute_.src.uri;
|
|
30
|
+
|
|
31
|
+
if (uriString.empty()) {
|
|
32
|
+
DLOG(WARNING) << "[SvgImage] imageAttribute_.src.uri is empty!";
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
double width =
|
|
37
|
+
imageAttribute_.width.Value() == 0 ? imageAttribute_.src.size.width : relativeOnWidth(imageAttribute_.width);
|
|
38
|
+
double height = imageAttribute_.height.Value() == 0 ? imageAttribute_.src.size.height
|
|
39
|
+
: relativeOnHeight(imageAttribute_.height);
|
|
40
|
+
double x = relativeOnWidth(imageAttribute_.x);
|
|
41
|
+
double y = relativeOnHeight(imageAttribute_.y);
|
|
42
|
+
|
|
43
|
+
if (!uriString.empty() && uriString.find("http", 0) != 0) {
|
|
44
|
+
OH_ImageSourceNative *res;
|
|
45
|
+
OH_PixelmapNative *pixelMap;
|
|
46
|
+
OH_DecodingOptions *options;
|
|
47
|
+
|
|
48
|
+
char *srcUri = const_cast<char *>(uriString.c_str());
|
|
49
|
+
|
|
50
|
+
OH_DecodingOptions_Create(&options);
|
|
51
|
+
|
|
52
|
+
Image_ErrorCode createFromUriStatus;
|
|
53
|
+
if (uriString.find(ASSET_PREFIX, 0) == 0) {
|
|
54
|
+
auto file = uriString.replace(0, 8, RAWFILE_PREFIX);
|
|
55
|
+
DLOG(INFO) << "[SvgImage] file: " << file;
|
|
56
|
+
auto rawFile = OH_ResourceManager_OpenRawFile(mgr_, file.c_str());
|
|
57
|
+
if (rawFile == nullptr) {
|
|
58
|
+
LOG(ERROR) << "[SvgImage] get rawfile fail";
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
RawFileDescriptor descriptor;
|
|
62
|
+
auto getRawFileStatus = OH_ResourceManager_GetRawFileDescriptor(rawFile, descriptor);
|
|
63
|
+
if (!getRawFileStatus) {
|
|
64
|
+
LOG(ERROR) << "[SvgImage] get rawfile descriptor fail";
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
createFromUriStatus = OH_ImageSourceNative_CreateFromRawFile(&descriptor, &res);
|
|
68
|
+
} else {
|
|
69
|
+
createFromUriStatus = OH_ImageSourceNative_CreateFromUri(srcUri, uriString.size(), &res);
|
|
70
|
+
}
|
|
71
|
+
auto createPixelmapStatus = OH_ImageSourceNative_CreatePixelmap(res, options, &pixelMap);
|
|
72
|
+
DLOG(INFO) << "[SvgImage] code: " << createPixelmapStatus;
|
|
73
|
+
|
|
74
|
+
if (createPixelmapStatus == IMAGE_SUCCESS) {
|
|
75
|
+
/* Temporarily disable the feature to set opacity.
|
|
76
|
+
* Currently, there is an issue where setting opacity on
|
|
77
|
+
* transparent pixels results in them turning black.
|
|
78
|
+
*/
|
|
79
|
+
if (LessNotEqual(attributes_.opacity, 1.0f)) {
|
|
80
|
+
OH_PixelmapNative_Opacity(pixelMap, attributes_.opacity);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// get the real width and height from pixelmap(OH_PixelmapNative *).
|
|
84
|
+
OH_Pixelmap_ImageInfo *info;
|
|
85
|
+
OH_PixelmapImageInfo_Create(&info);
|
|
86
|
+
OH_PixelmapNative_GetImageInfo(pixelMap, info);
|
|
87
|
+
|
|
88
|
+
// get the resource properties: width and height
|
|
89
|
+
uint32_t *imageWidth_ = new uint32_t;
|
|
90
|
+
uint32_t *imageHeight_ = new uint32_t;
|
|
91
|
+
OH_PixelmapImageInfo_GetWidth(info, imageWidth_);
|
|
92
|
+
OH_PixelmapImageInfo_GetHeight(info, imageHeight_);
|
|
93
|
+
|
|
94
|
+
auto imageWidth = static_cast<double>(*imageWidth_);
|
|
95
|
+
auto imageHeight = static_cast<double>(*imageHeight_);
|
|
96
|
+
delete imageWidth_;
|
|
97
|
+
delete imageHeight_;
|
|
98
|
+
|
|
99
|
+
const auto vbRect = Rect(0, 0, imageWidth, imageHeight);
|
|
100
|
+
const auto renderRect = Rect(x, y, width, height);
|
|
101
|
+
|
|
102
|
+
drawing::Matrix transformMatrix;
|
|
103
|
+
if (vbRect.IsValid()) {
|
|
104
|
+
transformMatrix =
|
|
105
|
+
ViewBox::getTransform(vbRect, renderRect, imageAttribute_.align, imageAttribute_.meetOrSlice);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// set source Rect and destination Rect
|
|
109
|
+
OH_Drawing_PixelMap *ohPixelMap = OH_Drawing_PixelMapGetFromOhPixelMapNative(pixelMap);
|
|
110
|
+
drawing::Rect srcPixelMap(0, 0, imageWidth, imageHeight);
|
|
111
|
+
auto dstPixelMap = transformMatrix.MapRect(srcPixelMap);
|
|
112
|
+
|
|
113
|
+
// set SamplingOptions
|
|
114
|
+
OH_Drawing_FilterMode filterMode = FILTER_MODE_NEAREST;
|
|
115
|
+
OH_Drawing_MipmapMode mipMapMode = MIPMAP_MODE_NONE;
|
|
116
|
+
OH_Drawing_SamplingOptions *samplingOptions = OH_Drawing_SamplingOptionsCreate(filterMode, mipMapMode);
|
|
117
|
+
|
|
118
|
+
// Draw picture by type OH_Drawing_PixelMap
|
|
119
|
+
OH_Drawing_CanvasSave(canvas);
|
|
120
|
+
|
|
121
|
+
drawing::Rect clipRect(x, y, x + width, y + height);
|
|
122
|
+
OH_Drawing_CanvasClipRect(canvas, clipRect.get(), OH_Drawing_CanvasClipOp::INTERSECT, true);
|
|
123
|
+
|
|
124
|
+
// Apply SVG filter if specified
|
|
125
|
+
if (!attributes_.filterId.empty()) {
|
|
126
|
+
DLOG(INFO) << "[SvgImage] Applying filter: " << attributes_.filterId;
|
|
127
|
+
auto svgContext = GetContext();
|
|
128
|
+
if (svgContext) {
|
|
129
|
+
auto filterNode = svgContext->GetSvgNodeById(attributes_.filterId);
|
|
130
|
+
auto svgFilter = std::dynamic_pointer_cast<SvgFilter>(filterNode);
|
|
131
|
+
if (svgFilter) {
|
|
132
|
+
// Create a temporary brush and apply filter to it
|
|
133
|
+
drawing::Brush tmpBrush;
|
|
134
|
+
svgFilter->ApplyToBrush(tmpBrush, "image");
|
|
135
|
+
|
|
136
|
+
// Attach the filtered brush to canvas
|
|
137
|
+
OH_Drawing_CanvasAttachBrush(canvas, tmpBrush.get());
|
|
138
|
+
DLOG(INFO) << "[SvgImage] Filter applied to brush successfully";
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Draw the pixelmap
|
|
144
|
+
OH_Drawing_CanvasDrawPixelMapRect(canvas, ohPixelMap, srcPixelMap.get(), dstPixelMap.get(),
|
|
145
|
+
samplingOptions);
|
|
146
|
+
|
|
147
|
+
// Detach brush if filter was applied
|
|
148
|
+
if (!attributes_.filterId.empty()) {
|
|
149
|
+
OH_Drawing_CanvasDetachBrush(canvas);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
OH_Drawing_CanvasRestore(canvas);
|
|
153
|
+
|
|
154
|
+
// clear data
|
|
155
|
+
OH_PixelmapImageInfo_Release(info);
|
|
156
|
+
OH_Drawing_SamplingOptionsDestroy(samplingOptions);
|
|
157
|
+
OH_Drawing_PixelMapDissolve(ohPixelMap);
|
|
158
|
+
OH_PixelmapNative_Release(pixelMap);
|
|
159
|
+
}
|
|
160
|
+
if (createFromUriStatus == IMAGE_SUCCESS) {
|
|
161
|
+
OH_ImageSourceNative_Release(res);
|
|
162
|
+
}
|
|
163
|
+
OH_DecodingOptions_Release(options);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
} // namespace svg
|
|
168
|
+
} // namespace rnoh
|
|
@@ -0,0 +1,52 @@
|
|
|
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 "SvgGraphic.h"
|
|
11
|
+
#include <rawfile/raw_file_manager.h>
|
|
12
|
+
|
|
13
|
+
namespace rnoh {
|
|
14
|
+
namespace svg {
|
|
15
|
+
|
|
16
|
+
class SvgImage : public svg::SvgGraphic {
|
|
17
|
+
public:
|
|
18
|
+
SvgImage() = default;
|
|
19
|
+
~SvgImage() override = default;
|
|
20
|
+
|
|
21
|
+
using SvgNode::relativeOnWidth;
|
|
22
|
+
using SvgNode::relativeOnHeight;
|
|
23
|
+
|
|
24
|
+
void SetX(const std::string &x) { imageAttribute_.x = SvgAttributesParser::ParseDimension(x, true); }
|
|
25
|
+
|
|
26
|
+
void SetY(const std::string &y) { imageAttribute_.y = SvgAttributesParser::ParseDimension(y, true); }
|
|
27
|
+
|
|
28
|
+
void SetHeight(const std::string &height) {
|
|
29
|
+
imageAttribute_.height = SvgAttributesParser::ParseDimension(height, true);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
void SetWidth(const std::string &width) {
|
|
33
|
+
imageAttribute_.width = SvgAttributesParser::ParseDimension(width, true);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
void SetAlign(const std::string &align) { imageAttribute_.align = align; }
|
|
37
|
+
|
|
38
|
+
void SetMeetOrSlice(const int &meetOrSlice) { imageAttribute_.meetOrSlice = meetOrSlice; }
|
|
39
|
+
|
|
40
|
+
void SetImageSource(const facebook::react::ImageSource &src) { imageAttribute_.src = src; }
|
|
41
|
+
|
|
42
|
+
void setNativeResourceManager(const NativeResourceManager *mgr) { mgr_ = mgr; }
|
|
43
|
+
|
|
44
|
+
void OnDraw(OH_Drawing_Canvas *canvas) override;
|
|
45
|
+
|
|
46
|
+
private:
|
|
47
|
+
SvgImageAttribute imageAttribute_;
|
|
48
|
+
const NativeResourceManager *mgr_;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
} // namespace svg
|
|
52
|
+
} // namespace rnoh
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
#include "SvgLine.h"
|
|
8
|
+
|
|
9
|
+
namespace rnoh {
|
|
10
|
+
namespace svg {
|
|
11
|
+
|
|
12
|
+
drawing::Path SvgLine::AsPath() {
|
|
13
|
+
drawing::Path path;
|
|
14
|
+
double x1 = relativeOnWidth(lineAttribute_.x1);
|
|
15
|
+
double y1 = relativeOnHeight(lineAttribute_.y1);
|
|
16
|
+
double x2 = relativeOnWidth(lineAttribute_.x2);
|
|
17
|
+
double y2 = relativeOnHeight(lineAttribute_.y2);
|
|
18
|
+
|
|
19
|
+
path.MoveTo(x1, y1);
|
|
20
|
+
path.LineTo(x2, y2);
|
|
21
|
+
|
|
22
|
+
elements_ = {PathElement(ElementType::kCGPathElementMoveToPoint, {Point(x1, y1)}),
|
|
23
|
+
PathElement(ElementType::kCGPathElementAddLineToPoint, {Point(x2, y2)})};
|
|
24
|
+
return path;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
} // namespace svg
|
|
28
|
+
} // namespace rnoh
|
|
@@ -0,0 +1,32 @@
|
|
|
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 "SvgGraphic.h"
|
|
10
|
+
#include "utils/SvgAttributesParser.h"
|
|
11
|
+
|
|
12
|
+
namespace rnoh {
|
|
13
|
+
namespace svg {
|
|
14
|
+
|
|
15
|
+
class SvgLine : public SvgGraphic {
|
|
16
|
+
public:
|
|
17
|
+
using Float = facebook::react::Float;
|
|
18
|
+
SvgLine() = default;
|
|
19
|
+
~SvgLine() override = default;
|
|
20
|
+
|
|
21
|
+
drawing::Path AsPath() override;
|
|
22
|
+
void SetX1(const std::string &x1) { lineAttribute_.x1 = SvgAttributesParser::ParseDimension(x1, true); }
|
|
23
|
+
void SetY1(const std::string &y1) { lineAttribute_.y1 = SvgAttributesParser::ParseDimension(y1, true); }
|
|
24
|
+
void SetX2(const std::string &x2) { lineAttribute_.x2 = SvgAttributesParser::ParseDimension(x2, true); }
|
|
25
|
+
void SetY2(const std::string &y2) { lineAttribute_.y2 = SvgAttributesParser::ParseDimension(y2, true); }
|
|
26
|
+
|
|
27
|
+
private:
|
|
28
|
+
SvgLineAttribute lineAttribute_;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
} // namespace svg
|
|
32
|
+
} // namespace rnoh
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
#include "SvgMarker.h"
|
|
8
|
+
#include "properties/Rect.h"
|
|
9
|
+
#include "properties/ViewBox.h"
|
|
10
|
+
#include <string>
|
|
11
|
+
#include <cstdlib>
|
|
12
|
+
#include <vector>
|
|
13
|
+
|
|
14
|
+
namespace rnoh {
|
|
15
|
+
namespace svg {
|
|
16
|
+
|
|
17
|
+
void SvgMarker::renderMarker(OH_Drawing_Canvas *canvas, const SvgMarkerPosition &position, float strokeWidth) {
|
|
18
|
+
const auto count = OH_Drawing_CanvasGetSaveCount(canvas);
|
|
19
|
+
saveAndSetupCanvas(canvas, cTM_);
|
|
20
|
+
|
|
21
|
+
if (markerTransform.get() != nullptr) {
|
|
22
|
+
markerTransform.Reset();
|
|
23
|
+
}
|
|
24
|
+
Point origin = position.origin;
|
|
25
|
+
markerTransform.Translate(origin.x, origin.y);
|
|
26
|
+
double markerAngle = (markerAttribute_.orient == "auto") ? -1 : std::atof(markerAttribute_.orient.c_str());
|
|
27
|
+
float degrees = 180 + (markerAngle == -1 ? position.angle : static_cast<float>(markerAngle));
|
|
28
|
+
// fix me? float rad = deg2rad(angle); this code only in ios
|
|
29
|
+
markerTransform.PreRotate(degrees, 0, 0);
|
|
30
|
+
|
|
31
|
+
if (markerAttribute_.markerUnits == "strokeWidth") {
|
|
32
|
+
markerTransform.PreScale(strokeWidth / scale_, strokeWidth / scale_, 0, 0);
|
|
33
|
+
}
|
|
34
|
+
if (!markerAttribute_.align.empty()) {
|
|
35
|
+
double width = relativeOnWidth(markerAttribute_.markerWidth) / scale_;
|
|
36
|
+
double height = relativeOnHeight(markerAttribute_.markerHeight) / scale_;
|
|
37
|
+
Rect eRect(0, 0, width, height);
|
|
38
|
+
Rect vbRect(markerAttribute_.minX.ConvertToPx(scale_), markerAttribute_.minY.ConvertToPx(scale_),
|
|
39
|
+
markerAttribute_.minX.ConvertToPx(scale_) + markerAttribute_.vbWidth.ConvertToPx(scale_),
|
|
40
|
+
markerAttribute_.minY.ConvertToPx(scale_) + markerAttribute_.vbHeight.ConvertToPx(scale_));
|
|
41
|
+
if (vbRect.IsValid()) {
|
|
42
|
+
drawing::Matrix viewBoxMatrix =
|
|
43
|
+
ViewBox::getTransform(vbRect, eRect, markerAttribute_.align, markerAttribute_.meetOrSlice);
|
|
44
|
+
float sx = viewBoxMatrix.GetValue(0);
|
|
45
|
+
float sy = viewBoxMatrix.GetValue(4);
|
|
46
|
+
markerTransform.PreScale(sx, sy, 0, 0);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
double x = relativeOnWidth(markerAttribute_.refX);
|
|
51
|
+
double y = relativeOnHeight(markerAttribute_.refY);
|
|
52
|
+
markerTransform.PreTranslate(-x, -y);
|
|
53
|
+
OH_Drawing_CanvasConcatMatrix(canvas, markerTransform.get());
|
|
54
|
+
|
|
55
|
+
OnDrawTraversed(canvas);
|
|
56
|
+
|
|
57
|
+
OH_Drawing_CanvasRestoreToCount(canvas, count);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
} // namespace svg
|
|
61
|
+
} // namespace rnoh
|
|
@@ -0,0 +1,86 @@
|
|
|
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 "SvgQuote.h"
|
|
10
|
+
#include "properties/Dimension.h"
|
|
11
|
+
#include "utils/SvgAttributesParser.h"
|
|
12
|
+
#include "utils/SvgMarkerPositionUtils.h"
|
|
13
|
+
#include <sstream>
|
|
14
|
+
#include <string>
|
|
15
|
+
#include <native_drawing/drawing_register_font.h>
|
|
16
|
+
#include <native_drawing/drawing_text_typography.h>
|
|
17
|
+
#include <native_drawing/drawing_matrix.h>
|
|
18
|
+
|
|
19
|
+
namespace rnoh {
|
|
20
|
+
namespace svg {
|
|
21
|
+
|
|
22
|
+
class SvgMarker : public SvgQuote {
|
|
23
|
+
public:
|
|
24
|
+
SvgMarker() = default;
|
|
25
|
+
~SvgMarker() override = default;
|
|
26
|
+
|
|
27
|
+
void setRefX(const std::string &refX) { markerAttribute_.refX = SvgAttributesParser::ParseDimension(refX, true); }
|
|
28
|
+
|
|
29
|
+
void setRefY(const std::string &refY) { markerAttribute_.refY = SvgAttributesParser::ParseDimension(refY, true); }
|
|
30
|
+
|
|
31
|
+
void setMarkerWidth(const std::string &markerWidth) {
|
|
32
|
+
markerAttribute_.markerWidth = SvgAttributesParser::ParseDimension(markerWidth, true);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
void setMarkerHeight(const std::string &markerHeight) {
|
|
36
|
+
markerAttribute_.markerHeight = SvgAttributesParser::ParseDimension(markerHeight, true);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
void setMarkerUnits(const std::string &markerUnits) { markerAttribute_.markerUnits = markerUnits; }
|
|
40
|
+
|
|
41
|
+
void setOrient(const std::string &orient) { markerAttribute_.orient = orient; }
|
|
42
|
+
|
|
43
|
+
void setMinX(double minX) { markerAttribute_.minX = Dimension(minX, DimensionUnit::VP); }
|
|
44
|
+
|
|
45
|
+
void setMinY(double minY) { markerAttribute_.minY = Dimension(minY, DimensionUnit::VP); }
|
|
46
|
+
|
|
47
|
+
void setVbWidth(double vbWidth) { markerAttribute_.vbWidth = Dimension(vbWidth, DimensionUnit::VP); }
|
|
48
|
+
|
|
49
|
+
void setVbHeight(double vbHeight) { markerAttribute_.vbHeight = Dimension(vbHeight, DimensionUnit::VP); }
|
|
50
|
+
|
|
51
|
+
void setAlign(std::string align) { markerAttribute_.align = align; }
|
|
52
|
+
|
|
53
|
+
void setMeetOrSlice(int meetOrSlice) { markerAttribute_.meetOrSlice = meetOrSlice; }
|
|
54
|
+
|
|
55
|
+
void renderMarker(OH_Drawing_Canvas *canvas, const SvgMarkerPosition &position, float strokeWidth);
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* from VirtualView.saveAndSetupCanvas
|
|
59
|
+
*
|
|
60
|
+
* Sets up the transform matrix on the canvas before an element is drawn.
|
|
61
|
+
*
|
|
62
|
+
* <p>NB: for perf reasons this does not apply opacity, as that would mean creating a new canvas
|
|
63
|
+
* layer (which allocates an offscreen bitmap) and having it composited afterwards. Instead, the
|
|
64
|
+
* drawing code should apply opacity recursively.
|
|
65
|
+
*
|
|
66
|
+
* @param canvas the canvas to set up
|
|
67
|
+
* @param ctm current transformation matrix
|
|
68
|
+
*/
|
|
69
|
+
void saveAndSetupCanvas(OH_Drawing_Canvas *canvas, drawing::Matrix ctm) {
|
|
70
|
+
OH_Drawing_CanvasSave(canvas);
|
|
71
|
+
cTM_ = mMatrix.Concat(mTransform);
|
|
72
|
+
OH_Drawing_CanvasConcatMatrix(canvas, cTM_.get());
|
|
73
|
+
cTM_ = cTM_.Concat(ctm);
|
|
74
|
+
mInvCTM = cTM_.Invert();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
private:
|
|
78
|
+
SvgMarkerAttribute markerAttribute_;
|
|
79
|
+
drawing::Matrix markerTransform;
|
|
80
|
+
drawing::Matrix mMatrix;
|
|
81
|
+
drawing::Matrix mTransform;
|
|
82
|
+
std::optional<drawing::Matrix> mInvCTM;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
} // namespace svg
|
|
86
|
+
} // namespace rnoh
|