Flutter Engine
 
Loading...
Searching...
No Matches
impeller::DrawOrderResolver Class Reference

#include <draw_order_resolver.h>

Public Types

using ElementRefs = std::vector< size_t >
 

Public Member Functions

 DrawOrderResolver ()
 
void AddElement (size_t element_index, bool is_opaque)
 
void PushClip (size_t element_index)
 
void PopClip ()
 
void Flush ()
 
ElementRefs GetSortedDraws (size_t opaque_skip_count, size_t translucent_skip_count) const
 Returns the sorted draws for the current draw order layer. This should only be called after all recording has finished.
 

Detailed Description

Helper that records draw indices in painter's order and sorts the draws into an optimized order based on translucency and clips.

Definition at line 15 of file draw_order_resolver.h.

Member Typedef Documentation

◆ ElementRefs

using impeller::DrawOrderResolver::ElementRefs = std::vector<size_t>

Definition at line 17 of file draw_order_resolver.h.

Constructor & Destructor Documentation

◆ DrawOrderResolver()

impeller::DrawOrderResolver::DrawOrderResolver ( )

Definition at line 12 of file draw_order_resolver.cc.

12: draw_order_layers_({{}}) {};

Member Function Documentation

◆ AddElement()

void impeller::DrawOrderResolver::AddElement ( size_t  element_index,
bool  is_opaque 
)

Definition at line 14 of file draw_order_resolver.cc.

14 {
15 DrawOrderLayer& layer = draw_order_layers_.back();
16 if (is_opaque) {
17 layer.opaque_elements.push_back(element_index);
18 } else {
19 layer.dependent_elements.push_back(element_index);
20 }
21}

Referenced by impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), and impeller::testing::TEST().

◆ Flush()

void impeller::DrawOrderResolver::Flush ( )

Definition at line 44 of file draw_order_resolver.cc.

44 {
45 FML_DCHECK(draw_order_layers_.size() >= 1u);
46
47 size_t layer_count = draw_order_layers_.size();
48
49 // Pop all clip layers.
50 while (draw_order_layers_.size() > 1u) {
51 PopClip();
52 }
53
54 // Move the root layer items into the sorted list.
55 DrawOrderLayer& layer = draw_order_layers_.back();
56 if (!first_root_flush_.has_value()) {
57 // Record the first flush.
58 first_root_flush_ = std::move(layer);
59 layer = {};
60 } else {
61 // Write subsequent flushes into the sorted root list.
62 layer.WriteCombinedDraws(sorted_elements_, 0, 0);
63 layer.opaque_elements.clear();
64 layer.dependent_elements.clear();
65 }
66
67 // Refill with empty layers.
68 draw_order_layers_.resize(layer_count);
69}
#define FML_DCHECK(condition)
Definition logging.h:122

References FML_DCHECK, and PopClip().

Referenced by impeller::testing::TEST().

◆ GetSortedDraws()

DrawOrderResolver::ElementRefs impeller::DrawOrderResolver::GetSortedDraws ( size_t  opaque_skip_count,
size_t  translucent_skip_count 
) const

Returns the sorted draws for the current draw order layer. This should only be called after all recording has finished.

Parameters
[in]opaque_skip_countThe number of opaque elements to skip when appending the combined elements. This is used for the "clear color" optimization.
[in]translucent_skip_countThe number of translucent elements to skip when appending the combined elements. This is used for the "clear color" optimization.

Definition at line 71 of file draw_order_resolver.cc.

73 {
74 FML_DCHECK(draw_order_layers_.size() == 1u)
75 << "Attempted to get sorted draws before all clips were popped.";
76
77 ElementRefs sorted_elements;
78 sorted_elements.reserve(
79 (first_root_flush_.has_value()
80 ? first_root_flush_->opaque_elements.size() +
81 first_root_flush_->dependent_elements.size()
82 : 0u) +
83 sorted_elements_.size() +
84 draw_order_layers_.back().opaque_elements.size() +
85 draw_order_layers_.back().dependent_elements.size());
86
87 // Write all flushed items.
88 if (first_root_flush_.has_value()) {
89 first_root_flush_->WriteCombinedDraws(sorted_elements, opaque_skip_count,
90 translucent_skip_count);
91 }
92 sorted_elements.insert(sorted_elements.end(), sorted_elements_.begin(),
93 sorted_elements_.end());
94
95 // Write any remaining non-flushed items.
96 draw_order_layers_.back().WriteCombinedDraws(
97 sorted_elements, first_root_flush_.has_value() ? 0 : opaque_skip_count,
98 first_root_flush_.has_value() ? 0 : translucent_skip_count);
99
100 return sorted_elements;
101}
std::vector< size_t > ElementRefs
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size

References FML_DCHECK.

Referenced by impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), and impeller::testing::TEST().

◆ PopClip()

void impeller::DrawOrderResolver::PopClip ( )

Definition at line 27 of file draw_order_resolver.cc.

27 {
28 if (draw_order_layers_.size() == 1u) {
29 // This is likely recoverable, so don't assert.
30 VALIDATION_LOG << "Attemped to pop the first draw order clip layer. This "
31 "may be a bug in `EntityPass`.";
32 return;
33 }
34
35 DrawOrderLayer& layer = draw_order_layers_.back();
36 DrawOrderLayer& parent_layer =
37 draw_order_layers_[draw_order_layers_.size() - 2];
38
39 layer.WriteCombinedDraws(parent_layer.dependent_elements, 0, 0);
40
41 draw_order_layers_.pop_back();
42}
#define VALIDATION_LOG
Definition validation.h:91

References VALIDATION_LOG.

Referenced by Flush(), and impeller::testing::TEST().

◆ PushClip()

void impeller::DrawOrderResolver::PushClip ( size_t  element_index)

Definition at line 22 of file draw_order_resolver.cc.

22 {
23 draw_order_layers_.back().dependent_elements.push_back(element_index);
24 draw_order_layers_.push_back({});
25};

Referenced by impeller::testing::TEST().


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