Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Attributes | List of all members
flutter::DisplayListLayer Class Reference

#include <display_list_layer.h>

Inheritance diagram for flutter::DisplayListLayer:
flutter::Layer

Public Member Functions

 DisplayListLayer (const SkPoint &offset, sk_sp< DisplayList > display_list, bool is_complex, bool will_change)
 
DisplayListdisplay_list () const
 
bool IsReplacing (DiffContext *context, const Layer *layer) const override
 
void Diff (DiffContext *context, const Layer *old_layer) override
 
const DisplayListLayeras_display_list_layer () const override
 
void Preroll (PrerollContext *frame) override
 
void Paint (PaintContext &context) const override
 
const DisplayListRasterCacheItemraster_cache_item () const
 
RasterCacheKeyID caching_key_id () const override
 
- Public Member Functions inherited from flutter::Layer
 Layer ()
 
virtual ~Layer ()
 
void AssignOldLayer (Layer *old_layer)
 
virtual bool IsReplacing (DiffContext *context, const Layer *old_layer) const
 
virtual void Diff (DiffContext *context, const Layer *old_layer)
 
virtual void PreservePaintRegion (DiffContext *context)
 
virtual void Preroll (PrerollContext *context)=0
 
virtual void Paint (PaintContext &context) const =0
 
virtual void PaintChildren (PaintContext &context) const
 
bool subtree_has_platform_view () const
 
void set_subtree_has_platform_view (bool value)
 
const SkRectpaint_bounds () const
 
void set_paint_bounds (const SkRect &paint_bounds)
 
bool is_empty () const
 
bool needs_painting (PaintContext &context) const
 
uint64_t original_layer_id () const
 
uint64_t unique_id () const
 
virtual RasterCacheKeyID caching_key_id () const
 
virtual const ContainerLayeras_container_layer () const
 
virtual const DisplayListLayeras_display_list_layer () const
 
virtual const TextureLayeras_texture_layer () const
 
virtual const PerformanceOverlayLayeras_performance_overlay_layer () const
 
virtual const testing::MockLayeras_mock_layer () const
 

Static Public Attributes

static constexpr size_t kMaxBytesToCompare = 10000
 
- Static Public Attributes inherited from flutter::Layer
static constexpr int kSaveLayerRenderFlags
 
static constexpr int kRasterCacheRenderFlags
 

Detailed Description

Definition at line 18 of file display_list_layer.h.

Constructor & Destructor Documentation

◆ DisplayListLayer()

flutter::DisplayListLayer::DisplayListLayer ( const SkPoint offset,
sk_sp< DisplayList display_list,
bool  is_complex,
bool  will_change 
)

Definition at line 18 of file display_list_layer.cc.

22 : offset_(offset), display_list_(std::move(display_list)) {
23 if (display_list_) {
24 bounds_ = display_list_->bounds().makeOffset(offset_.x(), offset_.y());
25#if !SLIMPELLER
26 display_list_raster_cache_item_ = DisplayListRasterCacheItem::Make(
27 display_list_, offset_, is_complex, will_change);
28#endif // !SLIMPELLER
29 }
30}
DisplayList * display_list() const
static std::unique_ptr< DisplayListRasterCacheItem > Make(const sk_sp< DisplayList > &, const SkPoint &offset, bool is_complex, bool will_change)
SeparatedVector2 offset
constexpr float y() const
Definition: SkPoint_impl.h:187
constexpr float x() const
Definition: SkPoint_impl.h:181

Member Function Documentation

◆ as_display_list_layer()

const DisplayListLayer * flutter::DisplayListLayer::as_display_list_layer ( ) const
inlineoverridevirtual

Reimplemented from flutter::Layer.

Definition at line 33 of file display_list_layer.h.

33 {
34 return this;
35 }

◆ caching_key_id()

RasterCacheKeyID flutter::DisplayListLayer::caching_key_id ( ) const
inlineoverridevirtual

Reimplemented from flutter::Layer.

Definition at line 46 of file display_list_layer.h.

46 {
47 return RasterCacheKeyID(display_list()->unique_id(),
49 }
uint64_t unique_id() const
Definition: layer.h:251

◆ Diff()

void flutter::DisplayListLayer::Diff ( DiffContext context,
const Layer old_layer 
)
overridevirtual

Reimplemented from flutter::Layer.

Definition at line 42 of file display_list_layer.cc.

42 {
43 DiffContext::AutoSubtreeRestore subtree(context);
44 if (!context->IsSubtreeDirty()) {
45#ifndef NDEBUG
46 FML_DCHECK(old_layer);
47 auto prev = old_layer->as_display_list_layer();
48 DiffContext::Statistics dummy_statistics;
49 // IsReplacing has already determined that the display list is same
50 FML_DCHECK(prev->offset_ == offset_ &&
51 Compare(dummy_statistics, this, prev));
52#endif
53 }
54 context->PushTransform(SkMatrix::Translate(offset_.x(), offset_.y()));
55 if (context->has_raster_cache()) {
56 context->WillPaintWithIntegralTransform();
57 }
58 context->AddLayerBounds(display_list()->bounds());
59 context->SetLayerPaintRegion(this, context->CurrentSubtreeRegion());
60}
static float prev(float f)
static SkMatrix Translate(SkScalar dx, SkScalar dy)
Definition: SkMatrix.h:91
#define FML_DCHECK(condition)
Definition: logging.h:103
Optional< SkRect > bounds
Definition: SkRecords.h:189

◆ display_list()

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

Definition at line 27 of file display_list_layer.h.

27{ return display_list_.get(); }

◆ IsReplacing()

bool flutter::DisplayListLayer::IsReplacing ( DiffContext context,
const Layer layer 
) const
overridevirtual

Reimplemented from flutter::Layer.

Definition at line 32 of file display_list_layer.cc.

33 {
34 // Only return true for identical display lists; This way
35 // ContainerLayer::DiffChildren can detect when a display list layer
36 // got inserted between other display list layers
37 auto old_layer = layer->as_display_list_layer();
38 return old_layer != nullptr && offset_ == old_layer->offset_ &&
39 Compare(context->statistics(), this, old_layer);
40}

◆ Paint()

void flutter::DisplayListLayer::Paint ( PaintContext context) const
overridevirtual

Implements flutter::Layer.

Definition at line 110 of file display_list_layer.cc.

110 {
111 FML_DCHECK(display_list_);
112 FML_DCHECK(needs_painting(context));
113
114 auto mutator = context.state_stack.save();
115 mutator.translate(offset_.x(), offset_.y());
116
117#if !SLIMPELLER
118 if (context.raster_cache) {
119 // Always apply the integral transform in the presence of a raster cache
120 // whether or not we successfully draw from the cache
121 mutator.integralTransform();
122
123 if (display_list_raster_cache_item_) {
125 if (display_list_raster_cache_item_->Draw(
126 context, context.state_stack.fill(paint))) {
127 TRACE_EVENT_INSTANT0("flutter", "raster cache hit");
128 return;
129 }
130 }
131 }
132#endif // !SLIMPELLER
133
134 SkScalar opacity = context.state_stack.outstanding_opacity();
135
136#if !SLIMPELLER
137 // Leaf layer tracing was never supported in the Impeller backend.
138 if (context.enable_leaf_layer_tracing) {
139 const auto canvas_size = context.canvas->GetBaseLayerSize();
140 auto offscreen_surface =
141 std::make_unique<OffscreenSurface>(context.gr_context, canvas_size);
142
143 const auto& ctm = context.canvas->GetTransform();
144
145 const auto start_time = fml::TimePoint::Now();
146 {
147 // render display list to offscreen surface.
148 auto* canvas = offscreen_surface->GetCanvas();
149 {
150 DlAutoCanvasRestore save(canvas, true);
151 canvas->Clear(DlColor::kTransparent());
152 canvas->SetTransform(ctm);
153 canvas->DrawDisplayList(display_list_, opacity);
154 }
155 canvas->Flush();
156 }
157 const fml::TimeDelta offscreen_render_time =
158 fml::TimePoint::Now() - start_time;
159
160 const SkRect device_bounds =
162 sk_sp<SkData> raster_data = offscreen_surface->GetRasterData(true);
163 LayerSnapshotData snapshot_data(unique_id(), offscreen_render_time,
164 raster_data, device_bounds);
165 context.layer_snapshot_store->Add(snapshot_data);
166 }
167#endif // !SLIMPELLER
168
169 context.canvas->DrawDisplayList(display_list_, opacity);
170}
const SkRect & paint_bounds() const
Definition: layer.h:210
bool needs_painting(PaintContext &context) const
Definition: layer.h:232
static TimePoint Now()
Definition: time_point.cc:49
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
flutter::DlPaint DlPaint
static constexpr DlColor kTransparent()
Definition: dl_color.h:21
static SkRect GetDeviceBounds(const SkRect &rect, const SkMatrix &ctm)
#define TRACE_EVENT_INSTANT0(category_group, name)
Definition: trace_event.h:175

◆ Preroll()

void flutter::DisplayListLayer::Preroll ( PrerollContext frame)
overridevirtual

Implements flutter::Layer.

Definition at line 97 of file display_list_layer.cc.

97 {
98 DisplayList* disp_list = display_list();
99
100#if !SLIMPELLER
101 AutoCache cache = AutoCache(display_list_raster_cache_item_.get(), context,
102 context->state_stack.transform_3x3());
103#endif // !SLIMPELLER
104 if (disp_list->can_apply_group_opacity()) {
105 context->renderable_state_flags = LayerStateStack::kCallerCanApplyOpacity;
106 }
107 set_paint_bounds(bounds_);
108}
static constexpr int kCallerCanApplyOpacity
void set_paint_bounds(const SkRect &paint_bounds)
Definition: layer.h:223
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets Path to the Flutter assets directory enable service port Allow the VM service to fallback to automatic port selection if binding to a specified port fails trace Trace early application lifecycle Automatically switches to an endless trace buffer trace skia Filters out all Skia trace event categories except those that are specified in this comma separated list dump skp on shader Automatically dump the skp that triggers new shader compilations This is useful for writing custom ShaderWarmUp to reduce jank By this is not enabled to reduce the overhead purge persistent cache
Definition: switches.h:191
flutter::DisplayList DisplayList

◆ raster_cache_item()

const DisplayListRasterCacheItem * flutter::DisplayListLayer::raster_cache_item ( ) const
inline

Definition at line 42 of file display_list_layer.h.

42 {
43 return display_list_raster_cache_item_.get();
44 }

Member Data Documentation

◆ kMaxBytesToCompare

constexpr size_t flutter::DisplayListLayer::kMaxBytesToCompare = 10000
staticconstexpr

Definition at line 20 of file display_list_layer.h.


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