Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
layer_raster_cache_item.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_RASTER_CACHE_ITEM_H_
6#define FLUTTER_FLOW_LAYERS_LAYER_RASTER_CACHE_ITEM_H_
7
8#include <memory>
9#include <optional>
10
11#include "flutter/flow/raster_cache_item.h"
12
13namespace flutter {
14
16 public:
17 explicit LayerRasterCacheItem(Layer* layer,
18 int layer_cached_threshold = 1,
19 bool can_cache_children = false);
20
21 /**
22 * @brief Create a LayerRasterCacheItem, connect a layer and manage the
23 * Layer's raster cache
24 *
25 * @param layer_cache_threshold after how many frames to start trying to
26 * cache the layer self
27 * @param can_cache_children the layer can do a cache for his children
28 */
29 static std::unique_ptr<LayerRasterCacheItem>
30 Make(Layer*, int layer_cache_threshold, bool can_cache_children = false);
31
32 std::optional<RasterCacheKeyID> GetId() const override;
33
34 void PrerollSetup(PrerollContext* context, const SkMatrix& matrix) override;
35
36 void PrerollFinalize(PrerollContext* context,
37 const SkMatrix& matrix) override;
38
39 bool Draw(const PaintContext& context, const DlPaint* paint) const override;
40
41 bool Draw(const PaintContext& context,
42 DlCanvas* canvas,
43 const DlPaint* paint) const override;
44
45 bool TryToPrepareRasterCache(const PaintContext& context,
46 bool parent_cached = false) const override;
47
49
51
53
54 protected:
55 const SkRect* GetPaintBoundsFromLayer() const;
56
58
59 // The id for cache the layer's children.
60 std::optional<RasterCacheKeyID> layer_children_id_;
61
63
64 // if the layer's children can be directly cache, set the param is true;
65 bool can_cache_children_ = false;
66
67 mutable int num_cache_attempts_ = 1;
68};
69
70} // namespace flutter
71
72#endif // FLUTTER_FLOW_LAYERS_LAYER_RASTER_CACHE_ITEM_H_
Developer-facing API for rendering anything within the engine.
Definition dl_canvas.h:37
std::optional< RasterCacheKeyID > layer_children_id_
static std::unique_ptr< LayerRasterCacheItem > Make(Layer *, int layer_cache_threshold, bool can_cache_children=false)
Create a LayerRasterCacheItem, connect a layer and manage the Layer's raster cache.
std::optional< RasterCacheKeyID > GetId() const override
void PrerollSetup(PrerollContext *context, const SkMatrix &matrix) override
bool Draw(const PaintContext &context, const DlPaint *paint) const override
bool TryToPrepareRasterCache(const PaintContext &context, bool parent_cached=false) const override
const SkRect * GetPaintBoundsFromLayer() const
void PrerollFinalize(PrerollContext *context, const SkMatrix &matrix) override
const Paint & paint