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_DISPLAY_LIST_LAYER_H_
6#define FLUTTER_FLOW_LAYERS_DISPLAY_LIST_LAYER_H_
7
8#include <memory>
9
10#include "flutter/display_list/display_list.h"
11#include "flutter/flow/layers/display_list_raster_cache_item.h"
12#include "flutter/flow/layers/layer.h"
13#include "flutter/flow/raster_cache_item.h"
14
15namespace flutter {
16
17class DisplayListLayer : public Layer {
18 public:
19 static constexpr size_t kMaxBytesToCompare = 10000;
20
21 DisplayListLayer(const SkPoint& offset,
22 sk_sp<DisplayList> display_list,
23 bool is_complex,
24 bool will_change);
25
26 DisplayList* display_list() const { return display_list_.get(); }
27
28 bool IsReplacing(DiffContext* context, const Layer* layer) const override;
29
30 void Diff(DiffContext* context, const Layer* old_layer) override;
31
32 const DisplayListLayer* as_display_list_layer() const override {
33 return this;
34 }
35
36 void Preroll(PrerollContext* frame) override;
37
38 void Paint(PaintContext& context) const override;
39
40 const DisplayListRasterCacheItem* raster_cache_item() const {
41 return display_list_raster_cache_item_.get();
42 }
43
44 RasterCacheKeyID caching_key_id() const override {
45 return RasterCacheKeyID(display_list()->unique_id(),
46 RasterCacheKeyType::kDisplayList);
47 }
48
49 private:
50 std::unique_ptr<DisplayListRasterCacheItem> display_list_raster_cache_item_;
51
52 SkPoint offset_;
53 SkRect bounds_;
54
55 sk_sp<DisplayList> display_list_;
56
57 static bool Compare(DiffContext::Statistics& statistics,
58 const DisplayListLayer* l1,
59 const DisplayListLayer* l2);
60
61 FML_DISALLOW_COPY_AND_ASSIGN(DisplayListLayer);
62};
63
64} // namespace flutter
65
66#endif // FLUTTER_FLOW_LAYERS_DISPLAY_LIST_LAYER_H_
67

source code of flutter_engine/flutter/flow/layers/display_list_layer.h