Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
flutter::DisplayListRasterCacheItem Class Reference

#include <display_list_raster_cache_item.h>

Inheritance diagram for flutter::DisplayListRasterCacheItem:
flutter::RasterCacheItem

Public Member Functions

 DisplayListRasterCacheItem (const sk_sp< DisplayList > &display_list, const SkPoint &offset, bool is_complex=true, bool will_change=false)
 
void PrerollSetup (PrerollContext *context, const SkMatrix &matrix) override
 
void PrerollFinalize (PrerollContext *context, const SkMatrix &matrix) override
 
bool Draw (const PaintContext &context, const DlPaint *paint) const override
 
bool Draw (const PaintContext &context, DlCanvas *canvas, const DlPaint *paint) const override
 
bool TryToPrepareRasterCache (const PaintContext &context, bool parent_cached=false) const override
 
void ModifyMatrix (SkPoint offset) const
 
const DisplayListdisplay_list () const
 
- Public Member Functions inherited from flutter::RasterCacheItem
 RasterCacheItem (RasterCacheKeyID key_id, CacheState cache_state=CacheState::kNone, unsigned child_entries=0)
 
virtual std::optional< RasterCacheKeyIDGetId () const
 
unsigned child_items () const
 
void set_matrix (const SkMatrix &matrix)
 
CacheState cache_state () const
 
bool need_caching () const
 
virtual ~RasterCacheItem ()=default
 

Static Public Member Functions

static std::unique_ptr< DisplayListRasterCacheItemMake (const sk_sp< DisplayList > &, const SkPoint &offset, bool is_complex, bool will_change)
 

Additional Inherited Members

- Public Types inherited from flutter::RasterCacheItem
enum  CacheState { kNone = 0 , kCurrent , kChildren }
 
- Protected Attributes inherited from flutter::RasterCacheItem
RasterCacheKeyID key_id_
 
CacheState cache_state_ = CacheState::kNone
 
SkMatrix matrix_
 
unsigned child_items_
 

Detailed Description

Definition at line 19 of file display_list_raster_cache_item.h.

Constructor & Destructor Documentation

◆ DisplayListRasterCacheItem()

flutter::DisplayListRasterCacheItem::DisplayListRasterCacheItem ( const sk_sp< DisplayList > &  display_list,
const SkPoint offset,
bool  is_complex = true,
bool  will_change = false 
)

Definition at line 49 of file display_list_raster_cache_item.cc.

54 : RasterCacheItem(RasterCacheKeyID(display_list->unique_id(),
57 display_list_(display_list),
58 offset_(offset),
59 is_complex_(is_complex),
60 will_change_(will_change) {}
uint32_t unique_id() const
RasterCacheItem(RasterCacheKeyID key_id, CacheState cache_state=CacheState::kNone, unsigned child_entries=0)
Point offset

Member Function Documentation

◆ display_list()

const DisplayList * flutter::DisplayListRasterCacheItem::display_list ( ) const
inline

Definition at line 50 of file display_list_raster_cache_item.h.

50{ return display_list_.get(); }

◆ Draw() [1/2]

bool flutter::DisplayListRasterCacheItem::Draw ( const PaintContext context,
const DlPaint paint 
) const
overridevirtual

Implements flutter::RasterCacheItem.

Definition at line 124 of file display_list_raster_cache_item.cc.

125 {
126 return Draw(context, context.canvas, paint);
127}
bool Draw(const PaintContext &context, const DlPaint *paint) const override
const Paint & paint

◆ Draw() [2/2]

bool flutter::DisplayListRasterCacheItem::Draw ( const PaintContext context,
DlCanvas canvas,
const DlPaint paint 
) const
overridevirtual

Implements flutter::RasterCacheItem.

Definition at line 129 of file display_list_raster_cache_item.cc.

131 {
132 if (!context.raster_cache || !canvas) {
133 return false;
134 }
136 return context.raster_cache->Draw(key_id_, *canvas, paint,
137 context.rendering_above_platform_view);
138 }
139 return false;
140}

◆ Make()

std::unique_ptr< DisplayListRasterCacheItem > flutter::DisplayListRasterCacheItem::Make ( const sk_sp< DisplayList > &  display_list,
const SkPoint offset,
bool  is_complex,
bool  will_change 
)
static

Definition at line 62 of file display_list_raster_cache_item.cc.

66 {
67 return std::make_unique<DisplayListRasterCacheItem>(display_list, offset,
68 is_complex, will_change);
69}

◆ ModifyMatrix()

void flutter::DisplayListRasterCacheItem::ModifyMatrix ( SkPoint  offset) const
inline

Definition at line 46 of file display_list_raster_cache_item.h.

46 {
48 }
SkMatrix & preTranslate(SkScalar dx, SkScalar dy)
Definition SkMatrix.cpp:263

◆ PrerollFinalize()

void flutter::DisplayListRasterCacheItem::PrerollFinalize ( PrerollContext context,
const SkMatrix matrix 
)
overridevirtual

Implements flutter::RasterCacheItem.

Definition at line 100 of file display_list_raster_cache_item.cc.

101 {
102 if (cache_state_ == CacheState::kNone || !context->raster_cache ||
103 !context->raster_cached_entries) {
104 return;
105 }
106 auto* raster_cache = context->raster_cache;
107 SkRect bounds = display_list_->bounds().makeOffset(offset_.x(), offset_.y());
108 bool visible = !context->state_stack.content_culled(bounds);
109 RasterCache::CacheInfo cache_info =
110 raster_cache->MarkSeen(key_id_, matrix, visible);
111 if (!visible ||
112 cache_info.accesses_since_visible <= raster_cache->access_threshold()) {
114 } else {
115 if (cache_info.has_image) {
116 context->renderable_state_flags |=
118 }
120 }
121 return;
122}
static constexpr int kCallerCanApplyOpacity
Optional< SkRect > bounds
Definition SkRecords.h:189
constexpr float y() const
constexpr float x() const

◆ PrerollSetup()

void flutter::DisplayListRasterCacheItem::PrerollSetup ( PrerollContext context,
const SkMatrix matrix 
)
overridevirtual

Implements flutter::RasterCacheItem.

Definition at line 71 of file display_list_raster_cache_item.cc.

72 {
74 DisplayListComplexityCalculator* complexity_calculator =
76 context->gr_context->backend())
77 : DisplayListComplexityCalculator::GetForSoftware();
78
79 if (!IsDisplayListWorthRasterizing(display_list(), will_change_, is_complex_,
80 complexity_calculator)) {
81 // We only deal with display lists that are worthy of rasterization.
82 return;
83 }
84
85 transformation_matrix_ = matrix;
86 transformation_matrix_.preTranslate(offset_.x(), offset_.y());
87
88 if (!transformation_matrix_.invert(nullptr)) {
89 // The matrix was singular. No point in going further.
90 return;
91 }
92
93 if (context->raster_cached_entries && context->raster_cache) {
94 context->raster_cached_entries->push_back(this);
96 }
97 return;
98}
bool invert(SkMatrix *inverse) const
Definition SkMatrix.h:1206
static DisplayListComplexityCalculator * GetForBackend(GrBackendApi backend)
unsigned useCenter Optional< SkMatrix > matrix
Definition SkRecords.h:258
static bool IsDisplayListWorthRasterizing(const DisplayList *display_list, bool will_change, bool is_complex, DisplayListComplexityCalculator *complexity_calculator)

◆ TryToPrepareRasterCache()

bool flutter::DisplayListRasterCacheItem::TryToPrepareRasterCache ( const PaintContext context,
bool  parent_cached = false 
) const
overridevirtual

Implements flutter::RasterCacheItem.

Definition at line 144 of file display_list_raster_cache_item.cc.

146 {
147 // If we don't have raster_cache we should not cache the current display_list.
148 // If the current node's ancestor has been cached we also should not cache the
149 // current node. In the current frame, the raster_cache will collect all
150 // display_list or picture_list to calculate the memory they used, we
151 // shouldn't cache the current node if the memory is more significant than the
152 // limit.
153 auto id = GetId();
154 FML_DCHECK(id.has_value());
155 if (cache_state_ == kNone || !context.raster_cache || parent_cached ||
156 !context.raster_cache->GenerateNewCacheInThisFrame() || !id.has_value()) {
157 return false;
158 }
159 SkRect bounds = display_list_->bounds().makeOffset(offset_.x(), offset_.y());
160 RasterCache::Context r_context = {
161 // clang-format off
162 .gr_context = context.gr_context,
163 .dst_color_space = context.dst_color_space,
164 .matrix = transformation_matrix_,
165 .logical_rect = bounds,
166 .flow_type = flow_type,
167 // clang-format on
168 };
169 return context.raster_cache->UpdateCacheEntry(
170 id.value(), r_context,
171 [display_list = display_list_](DlCanvas* canvas) {
172 canvas->DrawDisplayList(display_list);
173 },
174 display_list_->rtree());
175}
virtual std::optional< RasterCacheKeyID > GetId() const
uint8_t value
#define FML_DCHECK(condition)
Definition logging.h:103
static const auto * flow_type

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