Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
skgpu::graphite::IntersectionTree::LeafNode Class Referencefinal

Inherits skgpu::graphite::IntersectionTree::Node.

Public Member Functions

 LeafNode ()
 
void popAll ()
 
bool intersects (Rect rect) override
 
NodeaddNonIntersecting (Rect rect, SkArenaAlloc *arena) override
 

Static Public Attributes

static constexpr int kMaxRectsInList = 64
 

Detailed Description

Definition at line 61 of file IntersectionTree.cpp.

Constructor & Destructor Documentation

◆ LeafNode()

skgpu::graphite::IntersectionTree::LeafNode::LeafNode ( )
inline

Definition at line 67 of file IntersectionTree.cpp.

67 {
68 this->popAll();
69 // Initialize our arrays with maximally negative rects. These have the advantage of always
70 // failing intersection tests, thus allowing us to test for intersection beyond fNumRects
71 // without failing.
72 constexpr static float infinity = std::numeric_limits<float>::infinity();
73 std::fill_n(fLefts, kMaxRectsInList, infinity);
74 std::fill_n(fTops, kMaxRectsInList, infinity);
75 std::fill_n(fNegRights, kMaxRectsInList, infinity);
76 std::fill_n(fNegBots, kMaxRectsInList, infinity);
77 }

Member Function Documentation

◆ addNonIntersecting()

Node * skgpu::graphite::IntersectionTree::LeafNode::addNonIntersecting ( Rect  rect,
SkArenaAlloc arena 
)
inlineoverride

Definition at line 110 of file IntersectionTree.cpp.

110 {
111 if (fNumRects == kMaxRectsInList) {
112 // The new rect doesn't fit. Split our rect list first and then add.
113 return this->split(arena)->addNonIntersecting(rect, arena);
114 }
115 this->appendToList(rect);
116 return this;
117 }

◆ intersects()

bool skgpu::graphite::IntersectionTree::LeafNode::intersects ( Rect  rect)
inlineoverride

Definition at line 88 of file IntersectionTree.cpp.

88 {
89 // Test for intersection in sets of 4. Since all the data in our rect arrays is either
90 // maximally negative, or valid from somewhere else in the tree, we can test beyond
91 // fNumRects without failing.
92 static_assert(kMaxRectsInList % 4 == 0);
93 SkASSERT(fNumRects <= kMaxRectsInList);
94 auto comp = Rect::ComplementRect(rect).fVals;
95 for (int i = 0; i < fNumRects; i += 4) {
96 auto l = skvx::float4::Load(fLefts + i);
97 auto t = skvx::float4::Load(fTops + i);
98 auto nr = skvx::float4::Load(fNegRights + i);
99 auto nb = skvx::float4::Load(fNegBots + i);
100 if (any((l < comp[0]) &
101 (t < comp[1]) &
102 (nr < comp[2]) &
103 (nb < comp[3]))) {
104 return true;
105 }
106 }
107 return false;
108 }
#define SkASSERT(cond)
Definition SkAssert.h:116
SIT bool any(const Vec< 1, T > &x)
Definition SkVx.h:530
static SKVX_ALWAYS_INLINE Vec Load(const void *ptr)
Definition SkVx.h:109

◆ popAll()

void skgpu::graphite::IntersectionTree::LeafNode::popAll ( )
inline

Definition at line 79 of file IntersectionTree.cpp.

79 {
80 fNumRects = 0;
81 fSplittableBounds = -std::numeric_limits<float>::infinity();
82 fRectValsSum = 0;
83 // Leave the rect arrays untouched. Since we know they are either already valid in the tree,
84 // or else maximally negative, this allows the future list to check for intersection beyond
85 // fNumRects without failing.
86 }

Member Data Documentation

◆ kMaxRectsInList

constexpr int skgpu::graphite::IntersectionTree::LeafNode::kMaxRectsInList = 64
staticconstexpr

Definition at line 65 of file IntersectionTree.cpp.


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