Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
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
15#include "flutter/fml/macros.h"
17
18class GrDirectContext;
19
20namespace flutter {
21
22class LayerTree {
23 public:
24 LayerTree(const std::shared_ptr<Layer>& root_layer,
25 const DlISize& frame_size);
26
27 // Perform a preroll pass on the tree and return information about
28 // the tree that affects rendering this frame.
29 //
30 // Returns:
31 // - a boolean indicating whether or not the top level of the
32 // layer tree performs any operations that require readback
33 // from the root surface.
35 bool ignore_raster_cache = false,
36 DlRect cull_rect = kGiantRect);
37
38#if !SLIMPELLER
39 static void TryToRasterCache(
40 const std::vector<RasterCacheItem*>& raster_cached_entries,
41 const PaintContext* paint_context,
42 bool ignore_raster_cache = false);
43#endif // !SLIMPELLER
44
46 bool ignore_raster_cache = false) const;
47
48 sk_sp<DisplayList> Flatten(
49 const DlRect& bounds,
50 const std::shared_ptr<TextureRegistry>& texture_registry = nullptr,
51 GrDirectContext* gr_context = nullptr);
52
53 Layer* root_layer() const { return root_layer_.get(); }
54 const DlISize& frame_size() const { return frame_size_; }
55
56 const PaintRegionMap& paint_region_map() const { return paint_region_map_; }
57 PaintRegionMap& paint_region_map() { return paint_region_map_; }
58
59 private:
60 std::shared_ptr<Layer> root_layer_;
61 DlISize frame_size_; // Physical pixels.
62
63 PaintRegionMap paint_region_map_;
64
65 std::vector<RasterCacheItem*> raster_cache_items_;
66
68};
69
70// The information to draw a layer tree to a specified view.
72 public:
74 std::unique_ptr<LayerTree> layer_tree,
79
80 /// The target view to draw to.
81 int64_t view_id;
82 /// The target layer tree to be drawn.
83 std::unique_ptr<LayerTree> layer_tree;
84 /// The pixel ratio of the target view.
86
87 private:
89};
90
91} // namespace flutter
92
93#endif // FLUTTER_FLOW_LAYERS_LAYER_TREE_H_
Layer * root_layer() const
Definition layer_tree.h:53
sk_sp< DisplayList > Flatten(const DlRect &bounds, const std::shared_ptr< TextureRegistry > &texture_registry=nullptr, GrDirectContext *gr_context=nullptr)
const PaintRegionMap & paint_region_map() const
Definition layer_tree.h:56
const DlISize & frame_size() const
Definition layer_tree.h:54
static void TryToRasterCache(const std::vector< RasterCacheItem * > &raster_cached_entries, const PaintContext *paint_context, bool ignore_raster_cache=false)
Definition layer_tree.cc:67
PaintRegionMap & paint_region_map()
Definition layer_tree.h:57
bool Preroll(CompositorContext::ScopedFrame &frame, bool ignore_raster_cache=false, DlRect cull_rect=kGiantRect)
Definition layer_tree.cc:28
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
std::map< uint64_t, PaintRegion > PaintRegionMap
static constexpr DlRect kGiantRect
Definition layer.h:40
Definition ref_ptr.h:261
std::unique_ptr< LayerTree > layer_tree
The target layer tree to be drawn.
Definition layer_tree.h:83
int64_t view_id
The target view to draw to.
Definition layer_tree.h:81
float device_pixel_ratio
The pixel ratio of the target view.
Definition layer_tree.h:85
LayerTreeTask(int64_t view_id, std::unique_ptr< LayerTree > layer_tree, float device_pixel_ratio)
Definition layer_tree.h:73