Flutter Engine
The Flutter Engine
layer_snapshot_store.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_LAYER_SNAPSHOT_STORE_H_
6#define FLUTTER_FLOW_LAYER_SNAPSHOT_STORE_H_
7
8#include <vector>
9
10#include "flutter/fml/logging.h"
11#include "flutter/fml/time/time_delta.h"
12
16
17namespace flutter {
18
19/// Container for snapshot data pertaining to a given layer. A layer is
20/// identified by it's unique id.
22 public:
23 LayerSnapshotData(int64_t layer_unique_id,
25 const sk_sp<SkData>& snapshot,
26 const SkRect& bounds);
27
28 ~LayerSnapshotData() = default;
29
30 int64_t GetLayerUniqueId() const { return layer_unique_id_; }
31
32 fml::TimeDelta GetDuration() const { return duration_; }
33
34 sk_sp<SkData> GetSnapshot() const { return snapshot_; }
35
36 SkRect GetBounds() const { return bounds_; }
37
38 private:
39 const int64_t layer_unique_id_;
40 const fml::TimeDelta duration_;
41 const sk_sp<SkData> snapshot_;
42 const SkRect bounds_;
43};
44
45/// Collects snapshots of layers during frame rasterization.
47 public:
48 typedef std::vector<LayerSnapshotData> Snapshots;
49
50 LayerSnapshotStore() = default;
51
53
54 /// Clears all the stored snapshots.
55 void Clear();
56
57 /// Adds snapshots for a given layer. `duration` marks the time taken to
58 /// rasterize this one layer.
59 void Add(const LayerSnapshotData& data);
60
61 // Returns the number of snapshots collected.
62 size_t Size() const { return layer_snapshots_.size(); }
63
64 // make this class iterable
65 Snapshots::iterator begin() { return layer_snapshots_.begin(); }
66 Snapshots::iterator end() { return layer_snapshots_.end(); }
67
68 private:
69 Snapshots layer_snapshots_;
70
71 FML_DISALLOW_COPY_AND_ASSIGN(LayerSnapshotStore);
72};
73
74} // namespace flutter
75
76#endif // FLUTTER_FLOW_LAYER_SNAPSHOT_STORE_H_
LayerSnapshotData(int64_t layer_unique_id, const fml::TimeDelta &duration, const sk_sp< SkData > &snapshot, const SkRect &bounds)
sk_sp< SkData > GetSnapshot() const
fml::TimeDelta GetDuration() const
Collects snapshots of layers during frame rasterization.
void Clear()
Clears all the stored snapshots.
void Add(const LayerSnapshotData &data)
std::vector< LayerSnapshotData > Snapshots
double duration
Definition: examples.cpp:30
Optional< SkRect > bounds
Definition: SkRecords.h:189
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition: switches.h:41