Flutter Engine
The Flutter Engine
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
14#include "flutter/display_list/dl_canvas.h"
15#include "flutter/flow/raster_cache_key.h"
16
17namespace flutter {
18
19struct PrerollContext;
20struct PaintContext;
21class DisplayList;
22class RasterCache;
23class LayerRasterCacheItem;
24class DisplayListRasterCacheItem;
25
27 public:
29 kNone = 0,
32 };
33
36 unsigned child_entries = 0)
37 : key_id_(std::move(key_id)),
39 child_items_(child_entries) {}
40
41 virtual void PrerollSetup(PrerollContext* context,
42 const SkMatrix& matrix) = 0;
43
44 virtual void PrerollFinalize(PrerollContext* context,
45 const SkMatrix& matrix) = 0;
46
47 virtual bool Draw(const PaintContext& context,
48 const DlPaint* paint) const = 0;
49
50 virtual bool Draw(const PaintContext& context,
51 DlCanvas* canvas,
52 const DlPaint* paint) const = 0;
53
54 virtual std::optional<RasterCacheKeyID> GetId() const { return key_id_; }
55
56 virtual bool TryToPrepareRasterCache(const PaintContext& context,
57 bool parent_cached = false) const = 0;
58
59 unsigned child_items() const { return child_items_; }
60
62
64
65 bool need_caching() const { return cache_state_ != CacheState::kNone; }
66
67 virtual ~RasterCacheItem() = default;
68
69 protected:
70 // The id for cache the layer self.
74 unsigned child_items_;
75};
76
77} // namespace flutter
78
79#endif // !SLIMPELLER
80
81#endif // FLUTTER_FLOW_RASTER_CACHE_ITEM_H_
Developer-facing API for rendering anything within the engine.
Definition: dl_canvas.h:38
virtual void PrerollFinalize(PrerollContext *context, const SkMatrix &matrix)=0
virtual ~RasterCacheItem()=default
void set_matrix(const SkMatrix &matrix)
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)
unsigned child_items() const
virtual void PrerollSetup(PrerollContext *context, const SkMatrix &matrix)=0
virtual bool Draw(const PaintContext &context, const DlPaint *paint) const =0
CacheState cache_state() const
virtual std::optional< RasterCacheKeyID > GetId() const
virtual bool TryToPrepareRasterCache(const PaintContext &context, bool parent_cached=false) const =0
const Paint & paint
Definition: color_source.cc:38
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
@ kNone
Definition: layer.h:53
Definition: ref_ptr.h:256
flutter::DisplayList DisplayList