Flutter Engine
 
Loading...
Searching...
No Matches
flutter::RTree Class Reference

#include <rtree.h>

Inheritance diagram for flutter::RTree:

Public Member Functions

 RTree ()
 
void insert (const SkRect[], const SkBBoxHierarchy::Metadata[], int N) override
 
void insert (const SkRect[], int N) override
 
void search (const SkRect &query, std::vector< int > *results) const override
 
size_t bytesUsed () const override
 
std::list< SkRect > searchNonOverlappingDrawnRects (const SkRect &query) const
 
int getCount () const
 

Detailed Description

An R-Tree implementation that forwards calls to an SkRTree.

This implementation provides a searchNonOverlappingDrawnRects method, which can be used to query the rects for the operations recorded in the tree.

Definition at line 21 of file rtree.h.

Constructor & Destructor Documentation

◆ RTree()

flutter::RTree::RTree ( )

Definition at line 17 of file rtree.cc.

17: bbh_{SkRTreeFactory{}()}, all_ops_count_(0) {}

Member Function Documentation

◆ bytesUsed()

size_t flutter::RTree::bytesUsed ( ) const
override

Definition at line 67 of file rtree.cc.

67 {
68 return bbh_->bytesUsed();
69}

◆ getCount()

int flutter::RTree::getCount ( ) const
inline

Definition at line 41 of file rtree.h.

41{ return all_ops_count_; }

◆ insert() [1/2]

void flutter::RTree::insert ( const SkRect  boundsArray[],
const SkBBoxHierarchy::Metadata  metadata[],
int  N 
)
override

Definition at line 19 of file rtree.cc.

21 {
22 FML_DCHECK(0 == all_ops_count_);
23 bbh_->insert(boundsArray, metadata, N);
24 for (int i = 0; i < N; i++) {
25 if (metadata != nullptr && metadata[i].isDraw) {
26 draw_op_[i] = boundsArray[i];
27 }
28 }
29 all_ops_count_ = N;
30}
#define FML_DCHECK(condition)
Definition logging.h:122

References FML_DCHECK, and i.

Referenced by insert().

◆ insert() [2/2]

void flutter::RTree::insert ( const SkRect  boundsArray[],
int  N 
)
override

Definition at line 32 of file rtree.cc.

32 {
33 insert(boundsArray, nullptr, N);
34}
void insert(const SkRect[], const SkBBoxHierarchy::Metadata[], int N) override
Definition rtree.cc:19

References insert().

◆ search()

void flutter::RTree::search ( const SkRect &  query,
std::vector< int > *  results 
) const
override

Definition at line 36 of file rtree.cc.

36 {
37 bbh_->search(query, results);
38}

Referenced by searchNonOverlappingDrawnRects().

◆ searchNonOverlappingDrawnRects()

std::list< SkRect > flutter::RTree::searchNonOverlappingDrawnRects ( const SkRect &  query) const

Definition at line 40 of file rtree.cc.

41 {
42 // Get the indexes for the operations that intersect with the query rect.
43 std::vector<int> intermediary_results;
44 search(query, &intermediary_results);
45
46 std::vector<DlIRect> rects;
47 for (int index : intermediary_results) {
48 auto draw_op = draw_op_.find(index);
49 // Ignore records that don't draw anything.
50 if (draw_op == draw_op_.end()) {
51 continue;
52 }
53 SkIRect current_record_rect;
54 draw_op->second.roundOut(&current_record_rect);
55 rects.push_back(ToDlIRect(current_record_rect));
56 }
57
58 DlRegion region(rects);
59 auto non_overlapping_rects = region.getRects(true);
60 std::list<SkRect> final_results;
61 for (const auto& rect : non_overlapping_rects) {
62 final_results.push_back(SkRect::Make(ToSkIRect(rect)));
63 }
64 return final_results;
65}
void search(const SkRect &query, std::vector< int > *results) const override
Definition rtree.cc:36
const SkIRect & ToSkIRect(const DlIRect &rect)
const DlIRect & ToDlIRect(const SkIRect &rect)

References flutter::DlRegion::getRects(), search(), flutter::ToDlIRect(), and flutter::ToSkIRect().


The documentation for this class was generated from the following files: