forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlayer_snapshot_store.h
79 lines (56 loc) · 2.27 KB
/
layer_snapshot_store.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_FLOW_LAYER_SNAPSHOT_STORE_H_
#define FLUTTER_FLOW_LAYER_SNAPSHOT_STORE_H_
#include <vector>
#include "flutter/fml/logging.h"
#include "flutter/fml/time/time_delta.h"
#include "third_party/skia/include/core/SkImageEncoder.h"
#include "third_party/skia/include/core/SkPictureRecorder.h"
#include "third_party/skia/include/core/SkSerialProcs.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/core/SkSurfaceCharacterization.h"
#include "third_party/skia/include/utils/SkBase64.h"
namespace flutter {
/// Container for snapshot data pertaining to a given layer. A layer is
/// identified by it's unique id.
class LayerSnapshotData {
public:
LayerSnapshotData(int64_t layer_unique_id,
const fml::TimeDelta& duration,
const sk_sp<SkData>& snapshot,
const SkRect& bounds);
~LayerSnapshotData() = default;
int64_t GetLayerUniqueId() const { return layer_unique_id_; }
fml::TimeDelta GetDuration() const { return duration_; }
sk_sp<SkData> GetSnapshot() const { return snapshot_; }
SkRect GetBounds() const { return bounds_; }
private:
const int64_t layer_unique_id_;
const fml::TimeDelta duration_;
const sk_sp<SkData> snapshot_;
const SkRect bounds_;
};
/// Collects snapshots of layers during frame rasterization.
class LayerSnapshotStore {
public:
typedef std::vector<LayerSnapshotData> Snapshots;
LayerSnapshotStore() = default;
~LayerSnapshotStore() = default;
/// Clears all the stored snapshots.
void Clear();
/// Adds snapshots for a given layer. `duration` marks the time taken to
/// rasterize this one layer.
void Add(const LayerSnapshotData& data);
// Returns the number of snapshots collected.
size_t Size() const { return layer_snapshots_.size(); }
// make this class iterable
Snapshots::iterator begin() { return layer_snapshots_.begin(); }
Snapshots::iterator end() { return layer_snapshots_.end(); }
private:
Snapshots layer_snapshots_;
FML_DISALLOW_COPY_AND_ASSIGN(LayerSnapshotStore);
};
} // namespace flutter
#endif // FLUTTER_FLOW_LAYER_SNAPSHOT_STORE_H_