Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
flutter::RTreeBoundsAccumulator Class Referencefinal

#include <dl_bounds_accumulator.h>

Inheritance diagram for flutter::RTreeBoundsAccumulator:
flutter::BoundsAccumulator

Public Member Functions

void accumulate (const SkRect &r, int index) override
 
void save () override
 
void restore () override
 
bool restore (std::function< bool(const SkRect &original, SkRect &modified)> map, const SkRect *clip=nullptr) override
 
SkRect bounds () const override
 
sk_sp< DlRTreertree () const override
 
BoundsAccumulatorType type () const override
 
- Public Member Functions inherited from flutter::BoundsAccumulator
virtual ~BoundsAccumulator ()=default
 

Additional Inherited Members

- Public Types inherited from flutter::BoundsAccumulator
typedef bool BoundsModifier(const SkRect &original, SkRect *dest)
 

Detailed Description

Definition at line 142 of file dl_bounds_accumulator.h.

Member Function Documentation

◆ accumulate()

void flutter::RTreeBoundsAccumulator::accumulate ( const SkRect r,
int  index 
)
overridevirtual

Implements flutter::BoundsAccumulator.

Definition at line 76 of file dl_bounds_accumulator.cc.

76 {
77 if (r.fLeft < r.fRight && r.fTop < r.fBottom) {
78 rects_.push_back(r);
79 rect_indices_.push_back(index);
80 }
81}
SkScalar fBottom
larger y-axis bounds
Definition extension.cpp:17
SkScalar fLeft
smaller x-axis bounds
Definition extension.cpp:14
SkScalar fRight
larger x-axis bounds
Definition extension.cpp:16
SkScalar fTop
smaller y-axis bounds
Definition extension.cpp:15

◆ bounds()

SkRect flutter::RTreeBoundsAccumulator::bounds ( ) const
overridevirtual

Implements flutter::BoundsAccumulator.

Definition at line 119 of file dl_bounds_accumulator.cc.

119 {
120 FML_DCHECK(saved_offsets_.empty());
121 RectBoundsAccumulator accumulator;
122 for (auto& rect : rects_) {
123 accumulator.accumulate(rect, 0);
124 }
125 return accumulator.bounds();
126}
#define FML_DCHECK(condition)
Definition logging.h:103

◆ restore() [1/2]

void flutter::RTreeBoundsAccumulator::restore ( )
overridevirtual

Restore to the previous accumulation and incorporate the bounds of the primitives that were recorded since the last save (if needed).

Implements flutter::BoundsAccumulator.

Definition at line 85 of file dl_bounds_accumulator.cc.

85 {
86 if (saved_offsets_.empty()) {
87 return;
88 }
89
90 saved_offsets_.pop_back();
91}

◆ restore() [2/2]

bool flutter::RTreeBoundsAccumulator::restore ( std::function< bool(const SkRect &original, SkRect &modified)>  map,
const SkRect clip = nullptr 
)
overridevirtual

Restore the previous set of accumulation rects/bounds and accumulate the current rects/bounds that were accumulated since the most recent call to |save| into them with modifications specified by the |map| parameter and clipping to the clip parameter if it is not null.

The indicated map function is applied to the various rects and bounds that have been accumulated in this save/restore cycle before they are then accumulated into the previous accumulations. The granularity of the application of the map function to the rectangles that were accumulated during the save period is left up to the implementation.

This method will return true if the map function returned true on every single invocation. A false return value means that the bounds accumulated during this restore may not be trusted (as determined by the map function).

If there are no saved accumulations to restore to, this method will NOP ignoring the map function and the optional clip entirely.

Implements flutter::BoundsAccumulator.

Definition at line 92 of file dl_bounds_accumulator.cc.

94 {
95 if (saved_offsets_.empty()) {
96 return true;
97 }
98
99 size_t previous_size = saved_offsets_.back();
100 saved_offsets_.pop_back();
101
102 bool success = true;
103 for (size_t i = previous_size; i < rects_.size(); i++) {
104 SkRect original = rects_[i];
105 if (!map(original, original)) {
106 success = false;
107 }
108 if (clip == nullptr || original.intersect(*clip)) {
109 rect_indices_[previous_size] = rect_indices_[i];
110 rects_[previous_size] = original;
111 previous_size++;
112 }
113 }
114 rects_.resize(previous_size);
115 rect_indices_.resize(previous_size);
116 return success;
117}
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition SkPath.cpp:3824
SI auto map(std::index_sequence< I... >, Fn &&fn, const Args &... args) -> skvx::Vec< sizeof...(I), decltype(fn(args[0]...))>
Definition SkVx.h:680
bool intersect(const SkRect &r)
Definition SkRect.cpp:114

◆ rtree()

sk_sp< DlRTree > flutter::RTreeBoundsAccumulator::rtree ( ) const
overridevirtual

Implements flutter::BoundsAccumulator.

Definition at line 128 of file dl_bounds_accumulator.cc.

128 {
129 FML_DCHECK(saved_offsets_.empty());
130 return sk_make_sp<DlRTree>(rects_.data(), rects_.size(), rect_indices_.data(),
131 [](int id) { return id >= 0; });
132}

◆ save()

void flutter::RTreeBoundsAccumulator::save ( )
overridevirtual

Save aside the rects/bounds currently being accumulated and start accumulating a new set of rects/bounds. When restore is called, some additional modifications may be applied to these new bounds before they are accumulated back into the surrounding bounds.

Implements flutter::BoundsAccumulator.

Definition at line 82 of file dl_bounds_accumulator.cc.

82 {
83 saved_offsets_.push_back(rects_.size());
84}

◆ type()

BoundsAccumulatorType flutter::RTreeBoundsAccumulator::type ( ) const
inlineoverridevirtual

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