mirror of
https://github.com/zoriya/react-native-svg.git
synced 2025-12-05 22:56:11 +00:00
# Summary
There are two main things going on with the PR. Both involve a reworking
of the new arch implementation of rn-svg for windows.
The current implementation attempts to implement a svg renderer from
scratch. There are numerous edge cases that it wasn't handling
correctly, and the performance had some serious issues. This
implementation switches to use the svg rendering path built into
Direct2D. This brings significant performance improvements.
The 2nd issue is there have been various breaking changes in
react-native-windows for how new arch native components are implemented.
This brings the rn-svg implementation in line with those latest changes.
## Test Plan
Primary testing right now is loading up the example app in the repo.
New arch on react-native-windows is still in somewhat early days - so
there are not really current users of this code. I am integrating this
code into Microsoft Office, where I have tested some scenarios. But we
will get expanded testing as we roll out the new arch. I expect there to
be some follow-ups as we expand our usage. The version of rn-svg before
this PR doesn't build with the latest new arch react-native-windows
versions. - So its hard to get worse than that.
### What's required for testing (prerequisites)?
### What are the steps to reproduce (after prerequisites)?
## Compatibility
| OS | Implemented |
| ------- | :---------: |
| iOS | N/A |
| MacOS | N/A |
| Android | N/A |
| Web | ✅ |
## Checklist
- [x] I have tested this on a device and a simulator
- [ ] I added documentation in `README.md`
- [ ] I updated the typed files (typescript)
- [ ] I added a test for the API in the `__tests__` folder
59 lines
2.0 KiB
C++
59 lines
2.0 KiB
C++
#pragma once
|
|
#include "GroupView.g.h"
|
|
#include "RenderableView.h"
|
|
|
|
namespace winrt::RNSVG::implementation {
|
|
|
|
struct GroupView
|
|
: GroupViewT<GroupView, RNSVG::implementation::RenderableView> {
|
|
public:
|
|
GroupView() = default;
|
|
|
|
GroupView(Microsoft::ReactNative::IReactContext const & /*context*/) {}
|
|
|
|
Windows::Foundation::Collections::IVector<RNSVG::IRenderable> Children() { return m_children; }
|
|
|
|
// IRenderablePaper
|
|
virtual void UpdateProperties(Microsoft::ReactNative::IJSValueReader const &reader, bool forceUpdate, bool invalidate);
|
|
|
|
hstring FontFamily() { return m_fontFamily; }
|
|
void FontFamily(hstring const &value) { m_fontFamily = value; }
|
|
|
|
float FontSize() { return m_fontSize; }
|
|
void FontSize(float value) { m_fontSize = value; }
|
|
|
|
hstring FontWeight() { return m_fontWeight; }
|
|
void FontWeight(hstring const &value) { m_fontWeight = value; }
|
|
|
|
// IRenderable
|
|
virtual void CreateResources();
|
|
virtual void MergeProperties(RNSVG::IRenderable const &other);
|
|
virtual void SaveDefinition();
|
|
virtual void CreateGeometry(RNSVG::D2DDeviceContext const &context);
|
|
virtual void Unload();
|
|
virtual RNSVG::IRenderable HitTest(Windows::Foundation::Point const &point);
|
|
void Draw(RNSVG::D2DDeviceContext const &deviceContext, Windows::Foundation::Size const &size);
|
|
|
|
virtual void DrawGroup(RNSVG::D2DDeviceContext const &deviceContext, Windows::Foundation::Size const &size);
|
|
|
|
private:
|
|
|
|
Windows::Foundation::Collections::IVector<RNSVG::IRenderable> m_children{
|
|
winrt::single_threaded_vector<RNSVG::IRenderable>()};
|
|
|
|
float m_fontSize{12.0f};
|
|
hstring m_fontFamily{L"Segoe UI"};
|
|
hstring m_fontWeight{L"auto"};
|
|
|
|
std::map<RNSVG::FontProp, bool> m_fontPropMap{
|
|
{RNSVG::FontProp::FontSize, false},
|
|
{RNSVG::FontProp::FontWeight, false},
|
|
{RNSVG::FontProp::FontFamily, false},
|
|
};
|
|
};
|
|
} // namespace winrt::RNSVG::implementation
|
|
|
|
namespace winrt::RNSVG::factory_implementation {
|
|
struct GroupView : GroupViewT<GroupView, implementation::GroupView> {};
|
|
} // namespace winrt::RNSVG::factory_implementation
|