Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
flutter::RTree Class Reference

#include <rtree.h>

Inheritance diagram for flutter::RTree:
SkBBoxHierarchy SkRefCnt SkRefCntBase

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< SkRectsearchNonOverlappingDrawnRects (const SkRect &query) const
 
int getCount () const
 
virtual void insert (const SkRect[], int N)=0
 
virtual void insert (const SkRect[], const Metadata[], int N)
 
virtual void search (const SkRect &query, std::vector< int > *results) const =0
 
virtual size_t bytesUsed () const =0
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Additional Inherited Members

- Protected Member Functions inherited from SkBBoxHierarchy
 SkBBoxHierarchy ()=default
 
 SkBBoxHierarchy (const SkBBoxHierarchy &)=delete
 
SkBBoxHierarchyoperator= (const SkBBoxHierarchy &)=delete
 

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 16 of file rtree.cc.

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

Member Function Documentation

◆ bytesUsed()

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

Return approximate size in memory of *this.

Implements SkBBoxHierarchy.

Definition at line 66 of file rtree.cc.

66 {
67 return bbh_->bytesUsed();
68}
virtual size_t bytesUsed() const =0

◆ 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 
)
overridevirtual

Reimplemented from SkBBoxHierarchy.

Definition at line 18 of file rtree.cc.

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

◆ insert() [2/2]

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

Insert N bounding boxes into the hierarchy.

Implements SkBBoxHierarchy.

Definition at line 31 of file rtree.cc.

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

◆ search()

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

Populate results with the indices of bounding boxes intersecting that query.

Implements SkBBoxHierarchy.

Definition at line 35 of file rtree.cc.

35 {
36 bbh_->search(query, results);
37}
virtual void search(const SkRect &query, std::vector< int > *results) const =0

◆ searchNonOverlappingDrawnRects()

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

Definition at line 39 of file rtree.cc.

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

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