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