Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 2b9835a

Browse files
committed
Replace addRects implementation, simplify SpanBuffer
1 parent f53319d commit 2b9835a

File tree

4 files changed

+404
-608
lines changed

4 files changed

+404
-608
lines changed

display_list/benchmarking/dl_region_benchmarks.cc

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ namespace {
1313

1414
class SkRegionAdapter {
1515
public:
16-
SkRegionAdapter() {}
17-
1816
explicit SkRegionAdapter(const std::vector<SkIRect>& rects) {
1917
for (const auto& rect : rects) {
2018
region_.op(rect, SkRegion::kUnion_Op);
@@ -23,8 +21,11 @@ class SkRegionAdapter {
2321

2422
SkIRect getBounds() { return region_.getBounds(); }
2523

26-
void addRegion(const SkRegionAdapter& region) {
27-
region_.op(region.region_, SkRegion::kUnion_Op);
24+
static SkRegionAdapter unionRegions(const SkRegionAdapter& a1,
25+
const SkRegionAdapter& a2) {
26+
SkRegionAdapter result(a1);
27+
result.region_.op(a2.region_, SkRegion::kUnion_Op);
28+
return result;
2829
}
2930

3031
bool intersects(const SkRegionAdapter& region) {
@@ -49,13 +50,13 @@ class SkRegionAdapter {
4950

5051
class DlRegionAdapter {
5152
public:
52-
DlRegionAdapter() {}
53-
5453
explicit DlRegionAdapter(const std::vector<SkIRect>& rects)
5554
: region_(rects) {}
5655

57-
void addRegion(const DlRegionAdapter& region) {
58-
region_.addRegion(region.region_);
56+
static DlRegionAdapter unionRegions(const DlRegionAdapter& a1,
57+
const DlRegionAdapter& a2) {
58+
return DlRegionAdapter(
59+
flutter::DlRegion::MakeUnion(a1.region_, a2.region_));
5960
}
6061

6162
SkIRect getBounds() { return region_.bounds(); }
@@ -68,9 +69,10 @@ class DlRegionAdapter {
6869

6970
std::vector<SkIRect> getRects() { return region_.getRects(false); }
7071

71-
DlRegionAdapter(const DlRegionAdapter& copy) : region_(copy.region_, true) {}
72-
7372
private:
73+
explicit DlRegionAdapter(flutter::DlRegion&& region)
74+
: region_(std::move(region)) {}
75+
7476
flutter::DlRegion region_;
7577
};
7678

@@ -120,10 +122,7 @@ void RunAddRegionBenchmark(benchmark::State& state, int maxSize) {
120122
Region region2(rects);
121123

122124
while (state.KeepRunning()) {
123-
Region copy_of_region1(region1);
124-
copy_of_region1.addRegion(region2);
125-
// Region copy_of_region2(region2);
126-
// copy_of_region2.addRegion(region1);
125+
Region::unionRegions(region1, region2);
127126
}
128127
}
129128

0 commit comments

Comments
 (0)