@@ -20,6 +20,7 @@ std::shared_ptr<GlobalPathId> add_clip_path_to_batch(Scene &scene,
2020 uint32_t clip_level,
2121 const Transform2 &transform,
2222 LastSceneInfo &last_scene,
23+ uint32_t &next_batch_id,
2324 ClipBatchesD3D11 &clip_batches_d3d11);
2425
2526std::shared_ptr<BuiltDrawPath> prepare_draw_path_for_gpu_binning (Scene &scene,
@@ -61,13 +62,19 @@ PreparedClipPath prepare_clip_path_for_gpu_binning(Scene &scene,
6162 const Transform2 &transform,
6263 LastSceneInfo &last_scene,
6364 size_t clip_level,
65+ uint32_t &next_batch_id,
6466 ClipBatchesD3D11 &clip_batches_d3d11) {
6567 auto effective_view_box = scene.get_view_box ();
6668 auto clip_path = scene.clip_paths [clip_path_id];
6769
6870 // Add subclip path if necessary.
69- auto subclip_id =
70- add_clip_path_to_batch (scene, clip_path.clip_path , clip_level + 1 , transform, last_scene, clip_batches_d3d11);
71+ auto subclip_id = add_clip_path_to_batch (scene,
72+ clip_path.clip_path ,
73+ clip_level + 1 ,
74+ transform,
75+ last_scene,
76+ next_batch_id,
77+ clip_batches_d3d11);
7178
7279 auto path_bounds = transform * clip_path.outline .bounds ;
7380
@@ -87,42 +94,42 @@ std::shared_ptr<GlobalPathId> add_clip_path_to_batch(Scene &scene,
8794 uint32_t clip_level,
8895 const Transform2 &transform,
8996 LastSceneInfo &last_scene,
97+ uint32_t &next_batch_id,
9098 ClipBatchesD3D11 &clip_batches_d3d11) {
91- if (clip_path_id) {
92- auto &map = clip_batches_d3d11.clip_id_to_path_batch_index ;
93-
94- if (map.find (*clip_path_id) != map.end ()) {
95- auto clip_path_batch_index = map[*clip_path_id];
96- return std::make_shared<GlobalPathId>(GlobalPathId{clip_level, clip_path_batch_index});
97- } else {
98- auto prepared_clip_path = prepare_clip_path_for_gpu_binning (scene,
99- *clip_path_id,
100- transform,
101- last_scene,
102- clip_level,
103- clip_batches_d3d11);
104-
105- auto clip_path = prepared_clip_path.built_path ;
106- auto subclip_id = prepared_clip_path.subclip_id ;
107-
108- while (clip_level >= clip_batches_d3d11.prepare_batches .size ()) {
109- auto clip_tile_batch_id = clip_batches_d3d11.prepare_batches .size ();
110- clip_batches_d3d11.prepare_batches .emplace_back (clip_tile_batch_id, PathSource::Clip);
111- }
112-
113- auto clip_path_batch_index = clip_batches_d3d11.prepare_batches [clip_level].push (clip_path,
114- *clip_path_id,
115- subclip_id,
116- true ,
117- last_scene);
118-
119- map[*clip_path_id] = clip_path_batch_index;
120-
121- return std::make_shared<GlobalPathId>(GlobalPathId{clip_level, clip_path_batch_index});
122- }
99+ if (!clip_path_id) {
100+ return nullptr ;
101+ }
102+
103+ auto &map = clip_batches_d3d11.clip_id_to_path_batch_index ;
104+ if (map.find (*clip_path_id) != map.end ()) {
105+ auto clip_path_batch_index = map[*clip_path_id];
106+ auto &batch = clip_batches_d3d11.prepare_batches [clip_level];
107+ return std::make_shared<GlobalPathId>(GlobalPathId{batch.batch_id , clip_path_batch_index});
108+ }
109+
110+ auto prepared_clip_path = prepare_clip_path_for_gpu_binning (scene,
111+ *clip_path_id,
112+ transform,
113+ last_scene,
114+ clip_level,
115+ next_batch_id,
116+ clip_batches_d3d11);
117+
118+ auto clip_path = prepared_clip_path.built_path ;
119+ auto subclip_id = prepared_clip_path.subclip_id ;
120+
121+ while (clip_level >= clip_batches_d3d11.prepare_batches .size ()) {
122+ auto clip_tile_batch_id = next_batch_id++;
123+ clip_batches_d3d11.prepare_batches .emplace_back (clip_tile_batch_id, PathSource::Clip);
123124 }
124125
125- return nullptr ;
126+ auto clip_path_batch_index =
127+ clip_batches_d3d11.prepare_batches [clip_level].push (clip_path, *clip_path_id, subclip_id, true , last_scene);
128+
129+ map[*clip_path_id] = clip_path_batch_index;
130+
131+ auto &batch = clip_batches_d3d11.prepare_batches [clip_level];
132+ return std::make_shared<GlobalPathId>(GlobalPathId{batch.batch_id , clip_path_batch_index});
126133}
127134
128135// / Create tile batches.
@@ -176,8 +183,13 @@ std::vector<DrawTileBatchD3D11> build_tile_batches_for_draw_path_display_item(
176183 // Add clip path if necessary.
177184 std::shared_ptr<GlobalPathId> clip_path;
178185 if (clip_batches_d3d11) {
179- clip_path =
180- add_clip_path_to_batch (scene, draw_path->clip_path_id , 0 , transform, last_scene, *clip_batches_d3d11);
186+ clip_path = add_clip_path_to_batch (scene,
187+ draw_path->clip_path_id ,
188+ 0 ,
189+ transform,
190+ last_scene,
191+ next_batch_id,
192+ *clip_batches_d3d11);
181193 }
182194
183195 draw_tile_batch->tile_batch_data .push (draw_path->path ,
0 commit comments