Flutter Engine
 
Loading...
Searching...
No Matches
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_RASTER_CACHE_ITEM_H_
6#define FLUTTER_FLOW_RASTER_CACHE_ITEM_H_
7
8#if !SLIMPELLER
9
10#include <memory>
11#include <optional>
12#include <utility>
13
17
18namespace flutter {
19
20struct PrerollContext;
21struct PaintContext;
22class DisplayList;
23class RasterCache;
24class LayerRasterCacheItem;
25class DisplayListRasterCacheItem;
26
28 public:
34
37 unsigned child_entries = 0)
38 : key_id_(std::move(key_id)),
40 child_items_(child_entries) {}
41
42 virtual void PrerollSetup(PrerollContext* context,
43 const DlMatrix& matrix) = 0;
44
45 virtual void PrerollFinalize(PrerollContext* context,
46 const DlMatrix& matrix) = 0;
47
48 virtual bool Draw(const PaintContext& context,
49 const DlPaint* paint) const = 0;
50
51 virtual bool Draw(const PaintContext& context,
52 DlCanvas* canvas,
53 const DlPaint* paint) const = 0;
54
55 virtual std::optional<RasterCacheKeyID> GetId() const { return key_id_; }
56
57 virtual bool TryToPrepareRasterCache(const PaintContext& context,
58 bool parent_cached = false) const = 0;
59
60 unsigned child_items() const { return child_items_; }
61
62 void set_matrix(const DlMatrix& matrix) { matrix_ = ToSkMatrix(matrix); }
63 void set_matrix(const SkMatrix& matrix) { matrix_ = matrix; }
64
66
67 bool need_caching() const { return cache_state_ != CacheState::kNone; }
68
69 virtual ~RasterCacheItem() = default;
70
71 protected:
72 // The id for cache the layer self.
75 mutable SkMatrix matrix_;
76 unsigned child_items_;
77};
78
79} // namespace flutter
80
81#endif // !SLIMPELLER
82
83#endif // FLUTTER_FLOW_RASTER_CACHE_ITEM_H_
Developer-facing API for rendering anything within the engine.
Definition dl_canvas.h:32
virtual ~RasterCacheItem()=default
void set_matrix(const SkMatrix &matrix)
virtual void PrerollFinalize(PrerollContext *context, const DlMatrix &matrix)=0
virtual bool Draw(const PaintContext &context, DlCanvas *canvas, const DlPaint *paint) const =0
RasterCacheItem(RasterCacheKeyID key_id, CacheState cache_state=CacheState::kNone, unsigned child_entries=0)
void set_matrix(const DlMatrix &matrix)
virtual bool Draw(const PaintContext &context, const DlPaint *paint) const =0
virtual void PrerollSetup(PrerollContext *context, const DlMatrix &matrix)=0
CacheState cache_state() const
virtual std::optional< RasterCacheKeyID > GetId() const
virtual bool TryToPrepareRasterCache(const PaintContext &context, bool parent_cached=false) const =0
SkMatrix ToSkMatrix(const DlMatrix &matrix)
Definition ref_ptr.h:261
flutter::DisplayList DisplayList
A 4x4 matrix using column-major storage.
Definition matrix.h:37