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_DISPLAY_LIST_RASTER_CACHE_ITEM_H_ |
6 | #define FLUTTER_FLOW_DISPLAY_LIST_RASTER_CACHE_ITEM_H_ |
7 | |
8 | #include <memory> |
9 | #include <optional> |
10 | |
11 | #include "flutter/display_list/display_list.h" |
12 | #include "flutter/flow/embedded_views.h" |
13 | #include "flutter/flow/raster_cache_item.h" |
14 | #include "third_party/skia/include/core/SkMatrix.h" |
15 | #include "third_party/skia/include/core/SkPoint.h" |
16 | |
17 | namespace flutter { |
18 | |
19 | class DisplayListRasterCacheItem : public RasterCacheItem { |
20 | public: |
21 | DisplayListRasterCacheItem(const sk_sp<DisplayList>& display_list, |
22 | const SkPoint& offset, |
23 | bool is_complex = true, |
24 | bool will_change = false); |
25 | |
26 | static std::unique_ptr<DisplayListRasterCacheItem> Make( |
27 | const sk_sp<DisplayList>&, |
28 | const SkPoint& offset, |
29 | bool is_complex, |
30 | bool will_change); |
31 | |
32 | void PrerollSetup(PrerollContext* context, const SkMatrix& matrix) override; |
33 | |
34 | void PrerollFinalize(PrerollContext* context, |
35 | const SkMatrix& matrix) override; |
36 | |
37 | bool Draw(const PaintContext& context, const DlPaint* paint) const override; |
38 | |
39 | bool Draw(const PaintContext& context, |
40 | DlCanvas* canvas, |
41 | const DlPaint* paint) const override; |
42 | |
43 | bool TryToPrepareRasterCache(const PaintContext& context, |
44 | bool parent_cached = false) const override; |
45 | |
46 | void ModifyMatrix(SkPoint offset) const { |
47 | matrix_ = matrix_.preTranslate(dx: offset.x(), dy: offset.y()); |
48 | } |
49 | |
50 | const DisplayList* display_list() const { return display_list_.get(); } |
51 | |
52 | private: |
53 | SkMatrix transformation_matrix_; |
54 | sk_sp<DisplayList> display_list_; |
55 | SkPoint offset_; |
56 | bool is_complex_; |
57 | bool will_change_; |
58 | }; |
59 | |
60 | } // namespace flutter |
61 | |
62 | #endif // FLUTTER_FLOW_DISPLAY_LIST_RASTER_CACHE_ITEM_H_ |
63 | |