Skip to content

Commit 2f5c881

Browse files
authored
feat: svg improve (#543)
svg improve - [x] svg refactor & fix - [x] rect - [x] defs - [x] linearGradient - [x] stop - [x] clipPath - [x] svg support scale by width/height
2 parents 4421faf + adb3616 commit 2f5c881

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+741
-170
lines changed

.github/workflows/integration_test_flutter.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on: [workflow_dispatch, pull_request]
55
env:
66
nodeVersion: "16"
77
cmakeVersion: "3.22.x"
8-
flutter310: "3.13.5"
8+
flutter: "3.19.3"
99

1010
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1111
jobs:
@@ -67,7 +67,7 @@ jobs:
6767
submodules: recursive
6868
- uses: subosito/flutter-action@v2
6969
with:
70-
flutter-version: ${{ env.flutter310 }}
70+
flutter-version: ${{ env.flutter }}
7171
- run: flutter config --enable-macos-desktop
7272
- run: flutter doctor -v
7373
- run: cd webf && flutter test
@@ -88,7 +88,7 @@ jobs:
8888
node-version: ${{ env.nodeVersion }}
8989
- uses: subosito/flutter-action@v2
9090
with:
91-
flutter-version: ${{ env.flutter310 }}
91+
flutter-version: ${{ env.flutter }}
9292
- run: flutter config --enable-macos-desktop
9393
- run: flutter doctor -v
9494
- uses: actions/download-artifact@v2
@@ -124,11 +124,11 @@ jobs:
124124
path: bridge/build/macos/
125125
- uses: subosito/flutter-action@v2
126126
with:
127-
flutter-version: ${{ env.flutter310 }}
127+
flutter-version: ${{ env.flutter }}
128128
- run: flutter config --enable-macos-desktop
129129
- run: flutter doctor -v
130130
- name: Run MultiplePageTest Test
131-
run: cd integration_tests && npm run multiple_page_test
131+
run: cd integration_tests && LOAD_MODE=prerendering node scripts/preload_prerendering_page_integration.js
132132
id: test
133133
continue-on-error: true
134134
- name: Check on failures
@@ -151,7 +151,7 @@ jobs:
151151
path: bridge/build/macos/
152152
- uses: subosito/flutter-action@v2
153153
with:
154-
flutter-version: ${{ env.flutter310 }}
154+
flutter-version: ${{ env.flutter }}
155155
- run: flutter config --enable-macos-desktop
156156
- run: flutter doctor -v
157157
- name: Run MultiplePageTest Test
@@ -177,7 +177,7 @@ jobs:
177177
path: bridge/build/macos/
178178
- uses: subosito/flutter-action@v2
179179
with:
180-
flutter-version: ${{ env.flutter310 }}
180+
flutter-version: ${{ env.flutter }}
181181
- run: flutter config --enable-macos-desktop
182182
- run: flutter doctor -v
183183
- name: Run MultiplePageTest Test
@@ -204,7 +204,7 @@ jobs:
204204
path: bridge/build/macos/
205205
- uses: subosito/flutter-action@v2
206206
with:
207-
flutter-version: ${{ env.flutter310 }}
207+
flutter-version: ${{ env.flutter }}
208208
- run: flutter config --enable-macos-desktop
209209
- run: flutter doctor -v
210210
- name: Run MemoryLeak Test

bridge/foundation/shared_ui_command.cc

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,17 @@ void SharedUICommand::SyncToReserve() {
7070
if (waiting_buffer_->empty())
7171
return;
7272

73+
size_t waiting_size = waiting_buffer_->size();
74+
size_t origin_reserve_size = reserve_buffer_->size();
75+
7376
if (reserve_buffer_->empty()) {
74-
swap(waiting_buffer_, reserve_buffer_);
77+
swap(reserve_buffer_, waiting_buffer_);
7578
} else {
7679
appendCommand(reserve_buffer_, waiting_buffer_);
7780
}
81+
82+
assert(waiting_buffer_->empty());
83+
assert(reserve_buffer_->size() == waiting_size + origin_reserve_size);
7884
}
7985

8086
void SharedUICommand::ConfigureSyncCommandBufferSize(size_t size) {
@@ -84,33 +90,33 @@ void SharedUICommand::ConfigureSyncCommandBufferSize(size_t size) {
8490
void SharedUICommand::SyncToActive() {
8591
SyncToReserve();
8692

93+
assert(waiting_buffer_->empty());
94+
8795
if (reserve_buffer_->empty())
8896
return;
8997

9098
ui_command_sync_strategy_->Reset();
9199
context_->dartMethodPtr()->requestBatchUpdate(context_->isDedicated(), context_->contextId());
92100

93-
if (active_buffer->empty()) {
94-
swap(reserve_buffer_, active_buffer);
95-
} else {
96-
appendCommand(reserve_buffer_, active_buffer);
97-
}
101+
size_t reserve_size = reserve_buffer_->size();
102+
size_t origin_active_size = active_buffer->size();
103+
appendCommand(active_buffer, reserve_buffer_);
104+
assert(reserve_buffer_->empty());
105+
assert(active_buffer->size() == reserve_size + origin_active_size);
98106
}
99107

100-
void SharedUICommand::swap(std::unique_ptr<UICommandBuffer>& original, std::unique_ptr<UICommandBuffer>& target) {
108+
void SharedUICommand::swap(std::unique_ptr<UICommandBuffer>& target, std::unique_ptr<UICommandBuffer>& original) {
101109
is_blocking_writing_.store(true, std::memory_order::memory_order_release);
102110
std::swap(target, original);
103111
is_blocking_writing_.store(false, std::memory_order::memory_order_release);
104112
}
105113

106-
void SharedUICommand::appendCommand(std::unique_ptr<UICommandBuffer>& original,
107-
std::unique_ptr<UICommandBuffer>& target) {
114+
void SharedUICommand::appendCommand(std::unique_ptr<UICommandBuffer>& target,
115+
std::unique_ptr<UICommandBuffer>& original) {
108116
is_blocking_writing_.store(true, std::memory_order::memory_order_release);
109117

110-
for (int i = 0; i < original->size(); i++) {
111-
UICommandItem* command_item = original->data();
112-
target->addCommand(command_item[i]);
113-
}
118+
UICommandItem* command_item = original->data();
119+
target->addCommands(command_item, original->size());
114120

115121
original->clear();
116122

bridge/foundation/ui_command_buffer.cc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,28 @@ void UICommandBuffer::addCommand(const UICommandItem& item, bool request_ui_upda
8686
size_++;
8787
}
8888

89+
void UICommandBuffer::addCommands(const webf::UICommandItem* items, int64_t item_size, bool request_ui_update) {
90+
if (UNLIKELY(!context_->dartIsolateContext()->valid())) {
91+
return;
92+
}
93+
94+
int64_t target_size = size_ + item_size;
95+
if (target_size > max_size_) {
96+
buffer_ = (UICommandItem*)realloc(buffer_, sizeof(UICommandItem) * target_size * 2);
97+
max_size_ = target_size * 2;
98+
}
99+
100+
#if FLUTTER_BACKEND
101+
if (UNLIKELY(request_ui_update && !update_batched_ && context_->IsContextValid())) {
102+
context_->dartMethodPtr()->requestBatchUpdate(context_->isDedicated(), context_->contextId());
103+
update_batched_ = true;
104+
}
105+
#endif
106+
107+
std::memcpy(buffer_ + size_, items, sizeof(UICommandItem) * item_size);
108+
size_ = target_size;
109+
}
110+
89111
UICommandItem* UICommandBuffer::data() {
90112
return buffer_;
91113
}

bridge/foundation/ui_command_buffer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class UICommandBuffer {
8383

8484
private:
8585
void addCommand(const UICommandItem& item, bool request_ui_update = true);
86+
void addCommands(const UICommandItem* items, int64_t item_size, bool request_ui_update = true);
8687
void updateFlags(UICommand command);
8788

8889
ExecutingContext* context_{nullptr};

integration_tests/scripts/core_integration_starter.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function startIntegrationTest() {
1717
const shouldSkipBuild = /skip\-build/.test(process.argv);
1818
if (!shouldSkipBuild) {
1919
console.log('Building integration tests macOS application from "lib/main.dart"...');
20-
spawnSync('flutter', ['build', getRunningPlatform(), '--profile'], {
20+
spawnSync('flutter', ['build', getRunningPlatform(), '--debug'], {
2121
stdio: 'inherit'
2222
});
2323
}
@@ -27,9 +27,9 @@ function startIntegrationTest() {
2727
if (platform === 'linux') {
2828
testExecutable = path.join(__dirname, '../build/linux/x64/debug/bundle/app');
2929
} else if (platform === 'darwin') {
30-
testExecutable = path.join(__dirname, '../build/macos/Build/Products/Profile/tests.app/Contents/MacOS/tests');
30+
testExecutable = path.join(__dirname, '../build/macos/Build/Products/Debug/tests.app/Contents/MacOS/tests');
3131
} else if (platform == 'win32') {
32-
testExecutable = path.join(__dirname, '../build/windows/runner/Profile/app.exe');
32+
testExecutable = path.join(__dirname, '../build/windows/runner/Debug/app.exe');
3333
} else {
3434
throw new Error('Unsupported platform:' + platform);
3535
}
-945 Bytes
Loading
480 Bytes
Loading
-244 Bytes
Loading
2.34 KB
Loading
3.15 KB
Loading

0 commit comments

Comments
 (0)