forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
texture.h
72 lines (49 loc) · 1.51 KB
/
texture.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
// Copyright 2017 The Chromium 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_TEXTURE_H_
#define FLUTTER_FLOW_TEXTURE_H_
#include <map>
#include "flutter/fml/macros.h"
#include "flutter/fml/synchronization/waitable_event.h"
#include "third_party/skia/include/core/SkCanvas.h"
namespace flow {
class Texture {
protected:
Texture(int64_t id);
public:
// Called from GPU thread.
virtual ~Texture();
// Called from GPU thread.
virtual void Paint(SkCanvas& canvas, const SkRect& bounds) = 0;
// Called from GPU thread.
virtual void OnGrContextCreated() = 0;
// Called from GPU thread.
virtual void OnGrContextDestroyed() = 0;
// Called on GPU thread.
virtual void MarkNewFrameAvailable() = 0;
int64_t Id() { return id_; }
private:
int64_t id_;
FML_DISALLOW_COPY_AND_ASSIGN(Texture);
};
class TextureRegistry {
public:
TextureRegistry();
~TextureRegistry();
// Called from GPU thread.
void RegisterTexture(std::shared_ptr<Texture> texture);
// Called from GPU thread.
void UnregisterTexture(int64_t id);
// Called from GPU thread.
std::shared_ptr<Texture> GetTexture(int64_t id);
// Called from GPU thread.
void OnGrContextCreated();
// Called from GPU thread.
void OnGrContextDestroyed();
private:
std::map<int64_t, std::shared_ptr<Texture>> mapping_;
FML_DISALLOW_COPY_AND_ASSIGN(TextureRegistry);
};
} // namespace flow
#endif // FLUTTER_FLOW_TEXTURE_H_