Flutter Engine
The Flutter Engine
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
8#include <functional>
9
10#include "flutter/display_list/geometry/dl_geometry_types.h"
11#include "flutter/display_list/geometry/dl_rtree.h"
12#include "flutter/fml/logging.h"
13
14namespace flutter {
15
16// Utility class to collect bounds from a bunch of rectangles and points
17// while also noting if there might be any overlap between any of the data
18// point/rects. Note that the overlap protection is not sophisticated,
19// simply noting if the new data intersects with the already accumulated
20// bounds. This can successfully detect non-overlap of a linear sequence
21// of non-overlapping objects, or even a cross of non-overlapping objects
22// as long as they are built out from the center in the right order. True
23// detection of non-overlapping objects would require much more time and/or
24// space.
26 public:
28
30 void accumulate(SkPoint p) { accumulate(p.fX, p.fY); }
31 void accumulate(DlPoint p) { accumulate(p.x, p.y); }
32 void accumulate(SkRect r);
35
36 bool is_empty() const { return min_x_ >= max_x_ || min_y_ >= max_y_; }
37 bool is_not_empty() const { return min_x_ < max_x_ && min_y_ < max_y_; }
38
39 SkRect bounds() const;
40
41 void reset();
42
43 bool overlap_detected() const { return overlap_detected_; }
44 void record_overlapping_bounds() { overlap_detected_ = true; }
45
46 private:
47 DlScalar min_x_;
48 DlScalar min_y_;
49 DlScalar max_x_;
50 DlScalar max_y_;
51 bool overlap_detected_;
52};
53
54} // namespace flutter
55
56#endif // FLUTTER_DISPLAY_LIST_UTILS_DL_ACCUMULATION_RECT_H_
void accumulate(SkScalar x, SkScalar y)
float SkScalar
Definition: extension.cpp:12
double y
double x
impeller::Scalar DlScalar
const SkRect & ToSkRect(const DlRect &rect)