Flutter Engine
picture_layer.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_LAYERS_PICTURE_LAYER_H_
6 #define FLUTTER_FLOW_LAYERS_PICTURE_LAYER_H_
7 
8 #include <memory>
9 
10 #include "flutter/flow/layers/layer.h"
11 #include "flutter/flow/raster_cache.h"
12 #include "flutter/flow/skia_gpu_object.h"
13 
14 namespace flutter {
15 
16 class PictureLayer : public Layer {
17  public:
18  PictureLayer(const SkPoint& offset,
20  bool is_complex,
21  bool will_change);
22 
23  SkPicture* picture() const { return picture_.skia_object().get(); }
24 
25 #ifdef FLUTTER_ENABLE_DIFF_CONTEXT
26 
27  bool IsReplacing(DiffContext* context, const Layer* layer) const override;
28 
29  void Diff(DiffContext* context, const Layer* old_layer) override;
30 
31  const PictureLayer* as_picture_layer() const override { return this; }
32 
33 #endif // FLUTTER_ENABLE_DIFF_CONTEXT
34 
35  void Preroll(PrerollContext* frame, const SkMatrix& matrix) override;
36 
37  void Paint(PaintContext& context) const override;
38 
39  private:
40  SkPoint offset_;
41  // Even though pictures themselves are not GPU resources, they may reference
42  // images that have a reference to a GPU resource.
43  SkiaGPUObject<SkPicture> picture_;
44  bool is_complex_ = false;
45  bool will_change_ = false;
46 
47 #ifdef FLUTTER_ENABLE_DIFF_CONTEXT
48 
49  sk_sp<SkData> SerializedPicture() const;
50  mutable sk_sp<SkData> cached_serialized_picture_;
51  static bool Compare(DiffContext::Statistics& statistics,
52  const PictureLayer* l1,
53  const PictureLayer* l2);
54 
55 #endif // FLUTTER_ENABLE_DIFF_CONTEXT
56 
57  FML_DISALLOW_COPY_AND_ASSIGN(PictureLayer);
58 };
59 
60 } // namespace flutter
61 
62 #endif // FLUTTER_FLOW_LAYERS_PICTURE_LAYER_H_
void Preroll(PrerollContext *frame, const SkMatrix &matrix) override
void Paint(PaintContext &context) const override
sk_sp< SkiaObjectType > skia_object() const
PictureLayer(const SkPoint &offset, SkiaGPUObject< SkPicture > picture, bool is_complex, bool will_change)
SkPicture * picture() const
Definition: picture_layer.h:23