Flutter Engine
The Flutter Engine
|
#include <dl_rtree.h>
Public Member Functions | |
DlRTree (const SkRect rects[], int N, const int ids[]=nullptr, bool predicate(int id)=[](int) { return true;}, int invalid_id=-1) | |
void | search (const SkRect &query, std::vector< int > *results) const |
int | id (int result_index) const |
const SkRect & | bounds () const |
const SkRect & | bounds (int result_index) const |
size_t | bytes_used () const |
Returns the bytes used by the object and all of its node data. More... | |
int | leaf_count () const |
int | node_count () const |
std::list< SkRect > | searchAndConsolidateRects (const SkRect &query, bool deband=true) const |
const DlRegion & | region () const |
DlRegion | region (const SkRect &query) const |
Public Member Functions inherited from SkRefCntBase | |
SkRefCntBase () | |
virtual | ~SkRefCntBase () |
bool | unique () const |
void | ref () const |
void | unref () const |
An R-Tree that stores a list of bounding rectangles with optional associated IDs.
The R-Tree can be searched in one of two ways:
Definition at line 29 of file dl_rtree.h.
flutter::DlRTree::DlRTree | ( | const SkRect | rects[], |
int | N, | ||
const int | ids[] = nullptr , |
||
bool | predicateint id = [](int) { return true; } , |
||
int | invalid_id = -1 |
||
) |
Construct an R-Tree from the list of rectangles respecting the order in which they appear in the list. An optional array of IDs can be provided to tag each rectangle with information needed by the caller as well as an optional predicate that can filter out rectangles with IDs that should not be stored in the R-Tree.
If an array of IDs is not specified then all leaf nodes will be represented by the |invalid_id| (which defaults to -1).
Invalid rects that are empty or contain a NaN value will not be stored in the R-Tree. And, if a |predicate| function is provided, that function will be called to query if the rectangle associated with the ID should be included.
Duplicate rectangles and IDs are allowed and not processed in any way except to eliminate invalid rectangles and IDs that are rejected by the optional predicate function.
Definition at line 12 of file dl_rtree.cc.
const SkRect & flutter::DlRTree::bounds | ( | ) | const |
Returns maximum and minimum axis values of rectangles in this R-Tree. If R-Tree is empty returns an empty SkRect.
Definition at line 216 of file dl_rtree.cc.
Return the rectangle bounds for the indicated result of a query or an empty rect if the index is not a valid leaf node index.
Definition at line 97 of file dl_rtree.h.
|
inline |
Returns the bytes used by the object and all of its node data.
Definition at line 104 of file dl_rtree.h.
Return the ID for the indicated result of a query or invalid_id if the index is not a valid leaf node index.
Definition at line 85 of file dl_rtree.h.
|
inline |
Returns the number of leaf nodes corresponding to non-empty rectangles that were passed in the constructor and not filtered out by the predicate.
Definition at line 111 of file dl_rtree.h.
|
inline |
Return the total number of nodes used in the R-Tree, both leaf and internal consolidation nodes.
Definition at line 115 of file dl_rtree.h.
const DlRegion & flutter::DlRTree::region | ( | ) | const |
Returns DlRegion that represents the union of all rectangles in the R-Tree.
Definition at line 204 of file dl_rtree.cc.
Returns DlRegion that represents the union of all rectangles in the R-Tree intersected with the query rect.
Definition at line 135 of file dl_rtree.h.
Search the rectangles and return a vector of leaf node indices for rectangles that intersect the query.
Note that the indices are internal indices of the stored data and not the index of the rectangles or ids in the constructor. The returned indices may not themselves be in numerical order, but they will represent the rectangles and IDs in the order in which they were passed into the constructor. The actual rectangle and ID associated with each index can be retrieved using the |DlRTreeid| and |DlRTree::bounds| methods.
Definition at line 142 of file dl_rtree.cc.
std::list< SkRect > flutter::DlRTree::searchAndConsolidateRects | ( | const SkRect & | query, |
bool | deband = true |
||
) | const |
Finds the rects in the tree that intersect with the query rect.
The returned list of rectangles will be non-overlapping. In other words, the bounds of each rect in the result list are mutually exclusive.
If |deband| is true, then matching rectangles from adjacent DlRegion spanlines will be joined together. This reduces the number of rectangles returned, but requires some extra computation.
Definition at line 163 of file dl_rtree.cc.