Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 void PreservePaintRegion (DiffContext *context)
 
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 const ContainerLayeras_container_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 17 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 display_list_raster_cache_item_ = DisplayListRasterCacheItem::Make(
26 display_list_, offset_, is_complex, will_change);
27 }
28}
DisplayList * display_list() const
static std::unique_ptr< DisplayListRasterCacheItem > Make(const sk_sp< DisplayList > &, const SkPoint &offset, bool is_complex, bool will_change)
Point offset
constexpr float y() const
constexpr float x() const

Member Function Documentation

◆ as_display_list_layer()

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

Reimplemented from flutter::Layer.

Definition at line 32 of file display_list_layer.h.

32 {
33 return this;
34 }

◆ caching_key_id()

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

Reimplemented from flutter::Layer.

Definition at line 44 of file display_list_layer.h.

44 {
45 return RasterCacheKeyID(display_list()->unique_id(),
47 }
uint64_t unique_id() const
Definition layer.h:250

◆ Diff()

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

Reimplemented from flutter::Layer.

Definition at line 40 of file display_list_layer.cc.

40 {
41 DiffContext::AutoSubtreeRestore subtree(context);
42 if (!context->IsSubtreeDirty()) {
43#ifndef NDEBUG
44 FML_DCHECK(old_layer);
45 auto prev = old_layer->as_display_list_layer();
46 DiffContext::Statistics dummy_statistics;
47 // IsReplacing has already determined that the display list is same
48 FML_DCHECK(prev->offset_ == offset_ &&
49 Compare(dummy_statistics, this, prev));
50#endif
51 }
52 context->PushTransform(SkMatrix::Translate(offset_.x(), offset_.y()));
53 if (context->has_raster_cache()) {
54 context->WillPaintWithIntegralTransform();
55 }
56 context->AddLayerBounds(display_list()->bounds());
57 context->SetLayerPaintRegion(this, context->CurrentSubtreeRegion());
58}
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 26 of file display_list_layer.h.

26{ return display_list_.get(); }

◆ IsReplacing()

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

Reimplemented from flutter::Layer.

Definition at line 30 of file display_list_layer.cc.

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

◆ Paint()

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

Implements flutter::Layer.

Definition at line 106 of file display_list_layer.cc.

106 {
107 FML_DCHECK(display_list_);
108 FML_DCHECK(needs_painting(context));
109
110 auto mutator = context.state_stack.save();
111 mutator.translate(offset_.x(), offset_.y());
112
113 if (context.raster_cache) {
114 // Always apply the integral transform in the presence of a raster cache
115 // whether or not we successfully draw from the cache
116 mutator.integralTransform();
117
118 if (display_list_raster_cache_item_) {
119 DlPaint paint;
120 if (display_list_raster_cache_item_->Draw(
121 context, context.state_stack.fill(paint))) {
122 TRACE_EVENT_INSTANT0("flutter", "raster cache hit");
123 return;
124 }
125 }
126 }
127
128 SkScalar opacity = context.state_stack.outstanding_opacity();
129
130 if (context.enable_leaf_layer_tracing) {
131 const auto canvas_size = context.canvas->GetBaseLayerSize();
132 auto offscreen_surface =
133 std::make_unique<OffscreenSurface>(context.gr_context, canvas_size);
134
135 const auto& ctm = context.canvas->GetTransform();
136
137 const auto start_time = fml::TimePoint::Now();
138 {
139 // render display list to offscreen surface.
140 auto* canvas = offscreen_surface->GetCanvas();
141 {
142 DlAutoCanvasRestore save(canvas, true);
143 canvas->Clear(DlColor::kTransparent());
144 canvas->SetTransform(ctm);
145 canvas->DrawDisplayList(display_list_, opacity);
146 }
147 canvas->Flush();
148 }
149 const fml::TimeDelta offscreen_render_time =
150 fml::TimePoint::Now() - start_time;
151
152 const SkRect device_bounds =
154 sk_sp<SkData> raster_data = offscreen_surface->GetRasterData(true);
155 LayerSnapshotData snapshot_data(unique_id(), offscreen_render_time,
156 raster_data, device_bounds);
157 context.layer_snapshot_store->Add(snapshot_data);
158 }
159
160 context.canvas->DrawDisplayList(display_list_, opacity);
161}
const SkRect & paint_bounds() const
Definition layer.h:209
bool needs_painting(PaintContext &context) const
Definition layer.h:231
static TimePoint Now()
Definition time_point.cc:49
const Paint & paint
float SkScalar
Definition extension.cpp:12
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)

◆ Preroll()

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

Implements flutter::Layer.

Definition at line 95 of file display_list_layer.cc.

95 {
96 DisplayList* disp_list = display_list();
97
98 AutoCache cache = AutoCache(display_list_raster_cache_item_.get(), context,
99 context->state_stack.transform_3x3());
100 if (disp_list->can_apply_group_opacity()) {
101 context->renderable_state_flags = LayerStateStack::kCallerCanApplyOpacity;
102 }
103 set_paint_bounds(bounds_);
104}
static constexpr int kCallerCanApplyOpacity
void set_paint_bounds(const SkRect &paint_bounds)
Definition layer.h:222
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

◆ raster_cache_item()

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

Definition at line 40 of file display_list_layer.h.

40 {
41 return display_list_raster_cache_item_.get();
42 }

Member Data Documentation

◆ kMaxBytesToCompare

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

Definition at line 19 of file display_list_layer.h.


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