Flutter Engine
 
Loading...
Searching...
No Matches
dl_accumulation_rect.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_DISPLAY_LIST_UTILS_DL_ACCUMULATION_RECT_H_
6#define FLUTTER_DISPLAY_LIST_UTILS_DL_ACCUMULATION_RECT_H_
7
9
10namespace flutter {
11
12// Utility class to collect bounds from a bunch of rectangles and points
13// while also noting if there might be any overlap between any of the data
14// point/rects. Note that the overlap protection is not sophisticated,
15// simply noting if the new data intersects with the already accumulated
16// bounds. This can successfully detect non-overlap of a linear sequence
17// of non-overlapping objects, or even a cross of non-overlapping objects
18// as long as they are built out from the center in the right order. True
19// detection of non-overlapping objects would require much more time and/or
20// space.
22 public:
24
26 void accumulate(DlPoint p) { accumulate(p.x, p.y); }
27 void accumulate(DlRect r);
29
30 bool is_empty() const { return min_x_ >= max_x_ || min_y_ >= max_y_; }
31 bool is_not_empty() const { return min_x_ < max_x_ && min_y_ < max_y_; }
32
33 DlRect GetBounds() const;
34
35 void reset();
36
37 bool overlap_detected() const { return overlap_detected_; }
38 void record_overlapping_bounds() { overlap_detected_ = true; }
39
40 private:
41 DlScalar min_x_;
42 DlScalar min_y_;
43 DlScalar max_x_;
44 DlScalar max_y_;
45 bool overlap_detected_;
46};
47
48} // namespace flutter
49
50#endif // FLUTTER_DISPLAY_LIST_UTILS_DL_ACCUMULATION_RECT_H_
void accumulate(DlScalar x, DlScalar y)
int32_t x
double y
impeller::Scalar DlScalar