Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
layer_tree.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_FLOW_LAYERS_LAYER_TREE_H_
6#define FLUTTER_FLOW_LAYERS_LAYER_TREE_H_
7
8#include <cstdint>
9#include <memory>
10
11#include "flutter/common/graphics/texture.h"
12#include "flutter/flow/compositor_context.h"
13#include "flutter/flow/layers/layer.h"
14#include "flutter/flow/raster_cache.h"
15#include "flutter/fml/macros.h"
16#include "flutter/fml/time/time_delta.h"
17
18class GrDirectContext;
19
20namespace flutter {
21
22class LayerTree {
23 public:
24 struct Config {
25 std::shared_ptr<Layer> root_layer;
29 };
30
31 LayerTree(const Config& config, const SkISize& frame_size);
32
33 // Perform a preroll pass on the tree and return information about
34 // the tree that affects rendering this frame.
35 //
36 // Returns:
37 // - a boolean indicating whether or not the top level of the
38 // layer tree performs any operations that require readback
39 // from the root surface.
41 bool ignore_raster_cache = false,
42 SkRect cull_rect = kGiantRect);
43
44 static void TryToRasterCache(
45 const std::vector<RasterCacheItem*>& raster_cached_entries,
46 const PaintContext* paint_context,
47 bool ignore_raster_cache = false);
48
50 bool ignore_raster_cache = false) const;
51
53 const SkRect& bounds,
54 const std::shared_ptr<TextureRegistry>& texture_registry = nullptr,
55 GrDirectContext* gr_context = nullptr);
56
57 Layer* root_layer() const { return root_layer_.get(); }
58 const SkISize& frame_size() const { return frame_size_; }
59
60 const PaintRegionMap& paint_region_map() const { return paint_region_map_; }
61 PaintRegionMap& paint_region_map() { return paint_region_map_; }
62
63 // The number of frame intervals missed after which the compositor must
64 // trace the rasterized picture to a trace file. 0 stands for disabling all
65 // tracing.
67 return rasterizer_tracing_threshold_;
68 }
69
70 /// When `Paint` is called, if leaf layer tracing is enabled, additional
71 /// metadata around raterization of leaf layers is collected.
72 ///
73 /// This is not supported in the Impeller backend.
74 ///
75 /// See: `LayerSnapshotStore`
76 void enable_leaf_layer_tracing(bool enable) {
77 enable_leaf_layer_tracing_ = enable;
78 }
79
81 return enable_leaf_layer_tracing_;
82 }
83
84 private:
85 std::shared_ptr<Layer> root_layer_;
86 SkISize frame_size_ = SkISize::MakeEmpty(); // Physical pixels.
87 uint32_t rasterizer_tracing_threshold_;
88 bool checkerboard_raster_cache_images_;
89 bool checkerboard_offscreen_layers_;
90 bool enable_leaf_layer_tracing_ = false;
91
92 PaintRegionMap paint_region_map_;
93
94 std::vector<RasterCacheItem*> raster_cache_items_;
95
97};
98
99// The information to draw a layer tree to a specified view.
101 public:
103 std::unique_ptr<LayerTree> layer_tree,
104 float device_pixel_ratio)
105 : view_id(view_id),
106 layer_tree(std::move(layer_tree)),
108
109 /// The target view to draw to.
110 int64_t view_id;
111 /// The target layer tree to be drawn.
112 std::unique_ptr<LayerTree> layer_tree;
113 /// The pixel ratio of the target view.
115
116 private:
118};
119
120} // namespace flutter
121
122#endif // FLUTTER_FLOW_LAYERS_LAYER_TREE_H_
Layer * root_layer() const
Definition layer_tree.h:57
bool Preroll(CompositorContext::ScopedFrame &frame, bool ignore_raster_cache=false, SkRect cull_rect=kGiantRect)
Definition layer_tree.cc:33
uint32_t rasterizer_tracing_threshold() const
Definition layer_tree.h:66
const SkISize & frame_size() const
Definition layer_tree.h:58
void enable_leaf_layer_tracing(bool enable)
Definition layer_tree.h:76
const PaintRegionMap & paint_region_map() const
Definition layer_tree.h:60
bool is_leaf_layer_tracing_enabled() const
Definition layer_tree.h:80
sk_sp< DisplayList > Flatten(const SkRect &bounds, const std::shared_ptr< TextureRegistry > &texture_registry=nullptr, GrDirectContext *gr_context=nullptr)
static void TryToRasterCache(const std::vector< RasterCacheItem * > &raster_cached_entries, const PaintContext *paint_context, bool ignore_raster_cache=false)
Definition layer_tree.cc:73
PaintRegionMap & paint_region_map()
Definition layer_tree.h:61
double frame
Definition examples.cpp:31
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
std::map< uint64_t, PaintRegion > PaintRegionMap
static constexpr SkRect kGiantRect
Definition layer.h:49
Definition ref_ptr.h:256
static constexpr SkISize MakeEmpty()
Definition SkSize.h:22
std::unique_ptr< LayerTree > layer_tree
The target layer tree to be drawn.
Definition layer_tree.h:112
int64_t view_id
The target view to draw to.
Definition layer_tree.h:110
float device_pixel_ratio
The pixel ratio of the target view.
Definition layer_tree.h:114
LayerTreeTask(int64_t view_id, std::unique_ptr< LayerTree > layer_tree, float device_pixel_ratio)
Definition layer_tree.h:102
std::shared_ptr< Layer > root_layer
Definition layer_tree.h:25
uint32_t rasterizer_tracing_threshold
Definition layer_tree.h:26