Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@flar
Copy link
Contributor

@flar flar commented Jul 21, 2022

Fixes flutter/flutter#108083

This PR simply adds a new rtree() method on DisplayList that will return an RTree implementation representing its contents, primarily for use in PlatformView embedders. No other optimizations are added that leverage the RTree.

@flar
Copy link
Contributor Author

flar commented Jul 21, 2022

I'll note that I had to make one change to the flow/rtree code when I copied it to DisplayList as it was assuming that the RTree was created with supplementary data (see lines following 22c19):

Diff of rtree.cc against display_list_rtree.cc
5,7c5
< #include "rtree.h"
< 
< #include <list>
---
> #include "flutter/display_list/display_list_rtree.h"
10d7
< #include "third_party/skia/include/core/SkBBHFactory.h"
14c11
< RTree::RTree() : bbh_{SkRTreeFactory{}()}, all_ops_count_(0) {}
---
> DlRTree::DlRTree() : bbh_{SkRTreeFactory{}()}, all_ops_count_(0) {}
16,18c13,15
< void RTree::insert(const SkRect boundsArray[],
<                    const SkBBoxHierarchy::Metadata metadata[],
<                    int N) {
---
> void DlRTree::insert(const SkRect boundsArray[],
>                      const SkBBoxHierarchy::Metadata metadata[],
>                      int N) {
22c19
<     if (metadata != nullptr && metadata[i].isDraw) {
---
>     if (metadata == nullptr || metadata[i].isDraw) {
29c26
< void RTree::insert(const SkRect boundsArray[], int N) {
---
> void DlRTree::insert(const SkRect boundsArray[], int N) {
33c30
< void RTree::search(const SkRect& query, std::vector<int>* results) const {
---
> void DlRTree::search(const SkRect& query, std::vector<int>* results) const {
37c34
< std::list<SkRect> RTree::searchNonOverlappingDrawnRects(
---
> std::list<SkRect> DlRTree::searchNonOverlappingDrawnRects(
84c81
< size_t RTree::bytesUsed() const {
---
> size_t DlRTree::bytesUsed() const {
88,89c85,86
< RTreeFactory::RTreeFactory() {
<   r_tree_ = sk_make_sp<RTree>();
---
> DlRTreeFactory::DlRTreeFactory() {
>   r_tree_ = sk_make_sp<DlRTree>();
92c89
< sk_sp<RTree> RTreeFactory::getInstance() {
---
> sk_sp<DlRTree> DlRTreeFactory::getInstance() {
96c93
< sk_sp<SkBBoxHierarchy> RTreeFactory::operator()() const {
---
> sk_sp<SkBBoxHierarchy> DlRTreeFactory::operator()() const {

@ColdPaleLight
Copy link
Member

This PR LGTM once it LGT @chinmaygarde ( except for the misuse of saved_offsets_).

@flar
Copy link
Contributor Author

flar commented Jul 21, 2022

Discovered during writing tests for the conditions that @ColdPaleLight identified - we were only applying the saveLayer image filter if there was also a clip to apply. In practice, since we have a default cull rect here, we'll always have a clip to apply anyway.

@flar flar requested a review from ColdPaleLight July 21, 2022 18:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for producing an RTree from a DisplayList

3 participants