Matej Knopp 6988e291e1 Implement union and intersection for DlRegion (flutter/engine#42620)
Fixes https://github.com/flutter/flutter/issues/128412

Adds 
- `DlRegion DlRegion::MakeUnion(const Region &, const DlRegion &)`
- `DlRegion DlRegion::MakeIntersection(const Region &, const DlRegion
&)`
- `bool DlRegion::intersects(const DlRegion &)`
- `bool DlRegion::intersects(const SkIRect &)`

Instead of per span line vector all spans are stored in continuous
buffer.

Complete benchmarks:
```
-----------------------------------------------------------------------------------------------
Benchmark                                                     Time             CPU   Iterations
-----------------------------------------------------------------------------------------------
BM_DlRegion_IntersectsSingleRect/Tiny                      2688 ns         2687 ns       258580
BM_SkRegion_IntersectsSingleRect/Tiny                     85889 ns        85877 ns         8092
BM_DlRegion_IntersectsSingleRect/Small                     4814 ns         4813 ns       142874
BM_SkRegion_IntersectsSingleRect/Small                   101102 ns       101102 ns         6833
BM_DlRegion_IntersectsSingleRect/Medium                    2329 ns         2329 ns       302911
BM_SkRegion_IntersectsSingleRect/Medium                   60436 ns        60183 ns        11156
BM_DlRegion_IntersectsSingleRect/Large                     1243 ns         1243 ns       565209
BM_SkRegion_IntersectsSingleRect/Large                     2813 ns         2813 ns       252187
BM_DlRegion_IntersectsRegion/Tiny                          38.9 ns         38.9 ns     17913855
BM_SkRegion_IntersectsRegion/Tiny                           203 ns          203 ns      3480855
BM_DlRegion_IntersectsRegion/Small                          306 ns          306 ns      2295413
BM_SkRegion_IntersectsRegion/Small                         1057 ns         1057 ns       660826
BM_DlRegion_IntersectsRegion/Medium                        8.83 ns         8.83 ns     79128233
BM_SkRegion_IntersectsRegion/Medium                        43.3 ns         43.3 ns     16076912
BM_DlRegion_IntersectsRegion/Large                         6.96 ns         6.96 ns    101646676
BM_SkRegion_IntersectsRegion/Large                         31.8 ns         31.8 ns     22121517
BM_DlRegion_IntersectsRegion/TinyAsymmetric                54.2 ns         54.2 ns     12890870
BM_SkRegion_IntersectsRegion/TinyAsymmetric                4575 ns         4574 ns       155368
BM_DlRegion_IntersectsRegion/SmallAsymmetric                190 ns          189 ns      3748547
BM_SkRegion_IntersectsRegion/SmallAsymmetric               6157 ns         6157 ns       114403
BM_DlRegion_IntersectsRegion/MediumAsymmetric              20.9 ns         20.9 ns     33523941
BM_SkRegion_IntersectsRegion/MediumAsymmetric              3247 ns         3247 ns       214694
BM_DlRegion_IntersectsRegion/LargeAsymmetric               8.97 ns         8.97 ns     76827676
BM_SkRegion_IntersectsRegion/LargeAsymmetric                154 ns          154 ns      4757924
BM_DlRegion_Operation/Union_Tiny                           26.3 us         26.3 us        24534
BM_SkRegion_Operation/Union_Tiny                           37.9 us         37.9 us        17973
BM_DlRegion_Operation/Union_Small                          64.4 us         64.4 us        10657
BM_SkRegion_Operation/Union_Small                           105 us          105 us         6278
BM_DlRegion_Operation/Union_Medium                         22.0 us         22.0 us        31631
BM_SkRegion_Operation/Union_Medium                         64.8 us         64.8 us        10744
BM_DlRegion_Operation/Union_Large                          1.00 us         1.00 us       697406
BM_SkRegion_Operation/Union_Large                          1.29 us         1.29 us       547089
BM_DlRegion_Operation/Union_TinyAsymmetric                 10.3 us         10.3 us        68647
BM_SkRegion_Operation/Union_TinyAsymmetric                 20.6 us         20.6 us        33282
BM_DlRegion_Operation/Union_SmallAsymmetric                14.0 us         14.0 us        49944
BM_SkRegion_Operation/Union_SmallAsymmetric                34.4 us         34.4 us        19618
BM_DlRegion_Operation/Union_MediumAsymmetric               5.24 us         5.24 us       134097
BM_SkRegion_Operation/Union_MediumAsymmetric               12.7 us         12.7 us        55069
BM_DlRegion_Operation/Union_LargeAsymmetric               0.376 us        0.376 us      1808589
BM_SkRegion_Operation/Union_LargeAsymmetric               0.533 us        0.532 us      1283674
BM_DlRegion_Operation/Intersection_Tiny                    8.13 us         8.13 us        87199
BM_SkRegion_Operation/Intersection_Tiny                    31.8 us         31.8 us        21864
BM_DlRegion_Operation/Intersection_Small                   55.9 us         55.9 us        11888
BM_SkRegion_Operation/Intersection_Small                   98.4 us         98.3 us         6963
BM_DlRegion_Operation/Intersection_Medium                  40.0 us         40.0 us        17667
BM_SkRegion_Operation/Intersection_Medium                  69.8 us         69.8 us         9910
BM_DlRegion_Operation/Intersection_Large                   1.06 us         1.06 us       650957
BM_SkRegion_Operation/Intersection_Large                   1.26 us         1.26 us       559624
BM_DlRegion_Operation/Intersection_TinyAsymmetric          2.62 us         2.62 us       264565
BM_SkRegion_Operation/Intersection_TinyAsymmetric          15.3 us         15.3 us        45528
BM_DlRegion_Operation/Intersection_SmallAsymmetric         7.15 us         7.15 us        93482
BM_SkRegion_Operation/Intersection_SmallAsymmetric         27.5 us         27.5 us        24450
BM_DlRegion_Operation/Intersection_MediumAsymmetric        2.95 us         2.95 us       235133
BM_SkRegion_Operation/Intersection_MediumAsymmetric        10.5 us         10.5 us        65925
BM_DlRegion_Operation/Intersection_LargeAsymmetric        0.165 us        0.165 us      4016433
BM_SkRegion_Operation/Intersection_LargeAsymmetric        0.409 us        0.409 us      1719716
BM_DlRegion_Operation/Intersection_SingleRect_Tiny        0.105 us        0.105 us      7403099
BM_SkRegion_Operation/Intersection_SingleRect_Tiny         10.8 us         10.8 us        64185
BM_DlRegion_Operation/Intersection_SingleRect_Small       0.410 us        0.410 us      1724524
BM_SkRegion_Operation/Intersection_SingleRect_Small        16.2 us         16.2 us        43707
BM_DlRegion_Operation/Intersection_SingleRect_Medium      0.458 us        0.458 us      1540049
BM_SkRegion_Operation/Intersection_SingleRect_Medium       7.54 us         7.54 us        93407
BM_DlRegion_Operation/Intersection_SingleRect_Large       0.175 us        0.175 us      3984926
BM_SkRegion_Operation/Intersection_SingleRect_Large       0.351 us        0.351 us      1931946
BM_DlRegion_FromRects/Tiny                                  154 us          154 us         4383
BM_SkRegion_FromRects/Tiny                                69429 us        69419 us           10
BM_DlRegion_FromRects/Small                                 369 us          369 us         1932
BM_SkRegion_FromRects/Small                              117584 us       117578 us            6
BM_DlRegion_FromRects/Medium                                475 us          475 us         1477
BM_SkRegion_FromRects/Medium                              21611 us        21610 us           33
BM_DlRegion_FromRects/Large                                1329 us         1329 us          533
BM_SkRegion_FromRects/Large                                1409 us         1409 us          501
BM_DlRegion_GetRects/Tiny                                  39.2 us         39.2 us        18030
BM_SkRegion_GetRects/Tiny                                  84.2 us         84.2 us         9971
BM_DlRegion_GetRects/Small                                 88.9 us         88.9 us         7873
BM_SkRegion_GetRects/Small                                  212 us          212 us         3598
BM_DlRegion_GetRects/Medium                               0.845 us        0.813 us       881224
BM_SkRegion_GetRects/Medium                                3.10 us         3.09 us       223483
BM_DlRegion_GetRects/Large                                0.120 us        0.120 us      5954761
BM_SkRegion_GetRects/Large                                0.337 us        0.336 us      2068656
```

## Pre-launch Checklist

- [X] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [X] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [X] I read and followed the [Flutter Style Guide] and the [C++,
Objective-C, Java style guides].
- [X] I listed at least one issue that this PR fixes in the description
above.
- [X] I added new tests to check the change I am making or feature I am
adding, or Hixie said the PR is test-exempt. See [testing the engine]
for instructions on writing and running engine tests.
- [X] I updated/added relevant documentation (doc comments with `///`).
- [X] I signed the [CLA].
- [X] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2023-06-26 12:08:44 +02:00
..

Flutter Engine

OpenSSF Scorecard

Flutter is Google's SDK for crafting beautiful, fast user experiences for mobile, web, and desktop from a single codebase. Flutter works with existing code, is used by developers and organizations around the world, and is free and open source.

The Flutter Engine is a portable runtime for hosting Flutter applications. It implements Flutter's core libraries, including animation and graphics, file and network I/O, accessibility support, plugin architecture, and a Dart runtime and compile toolchain. Most developers will interact with Flutter via the Flutter Framework, which provides a modern, reactive framework, and a rich set of platform, layout and foundation widgets.

If you want to run/contribute to Flutter Web engine, more tooling can be found at felt. This is a tool written to make web engine development experience easy.

If you are new to Flutter, then you will find more general information on the Flutter project, including tutorials and samples, on our Web site at Flutter.dev. For specific information about Flutter's APIs, consider our API reference which can be found at the docs.flutter.dev.

Flutter is a fully open source project, and we welcome contributions. Information on how to get started can be found at our contributor guide.