forked from homuler/MediaPipeUnityPlugin
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgl_texture_buffer.cc
More file actions
95 lines (77 loc) · 3.71 KB
/
Copy pathgl_texture_buffer.cc
File metadata and controls
95 lines (77 loc) · 3.71 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// Copyright (c) 2021 homuler
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
#include "mediapipe_api/gpu/gl_texture_buffer.h"
void mp_SharedGlTextureBuffer__delete(SharedGlTextureBuffer* gl_texture_buffer) { delete gl_texture_buffer; }
mediapipe::GlTextureBuffer* mp_SharedGlTextureBuffer__get(SharedGlTextureBuffer* gl_texture_buffer) { return gl_texture_buffer->get(); }
void mp_SharedGlTextureBuffer__reset(SharedGlTextureBuffer* gl_texture_buffer) { gl_texture_buffer->reset(); }
MpReturnCode mp_SharedGlTextureBuffer__ui_ui_i_i_ui_PF_PSgc(GLenum target, GLuint name, int width, int height, mediapipe::GpuBufferFormat format,
GlTextureBufferDeletionCallback* deletion_callback,
std::shared_ptr<mediapipe::GlContext>* producer_context,
SharedGlTextureBuffer** gl_texture_buffer_out) {
TRY
auto callback = [name, deletion_callback](mediapipe::GlSyncToken token) -> void {
deletion_callback(name, new mediapipe::GlSyncToken{token});
};
*gl_texture_buffer_out = new SharedGlTextureBuffer{new mediapipe::GlTextureBuffer{
GL_TEXTURE_2D,
name,
width,
height,
format,
callback,
*producer_context,
}};
RETURN_CODE(MpReturnCode::Success);
CATCH_EXCEPTION
}
GLuint mp_GlTextureBuffer__name(mediapipe::GlTextureBuffer* gl_texture_buffer) { return gl_texture_buffer->name(); }
GLenum mp_GlTextureBuffer__target(mediapipe::GlTextureBuffer* gl_texture_buffer) { return gl_texture_buffer->target(); }
int mp_GlTextureBuffer__width(mediapipe::GlTextureBuffer* gl_texture_buffer) { return gl_texture_buffer->width(); }
int mp_GlTextureBuffer__height(mediapipe::GlTextureBuffer* gl_texture_buffer) { return gl_texture_buffer->height(); }
mediapipe::GpuBufferFormat mp_GlTextureBuffer__format(mediapipe::GlTextureBuffer* gl_texture_buffer) { return gl_texture_buffer->format(); }
MpReturnCode mp_GlTextureBuffer__WaitUntilComplete(mediapipe::GlTextureBuffer* gl_texture_buffer) {
TRY_ALL
gl_texture_buffer->WaitUntilComplete();
RETURN_CODE(MpReturnCode::Success);
CATCH_ALL
}
MpReturnCode mp_GlTextureBuffer__WaitOnGpu(mediapipe::GlTextureBuffer* gl_texture_buffer) {
TRY_ALL
gl_texture_buffer->WaitOnGpu();
RETURN_CODE(MpReturnCode::Success);
CATCH_ALL
}
MpReturnCode mp_GlTextureBuffer__Reuse(mediapipe::GlTextureBuffer* gl_texture_buffer) {
TRY_ALL
gl_texture_buffer->Reuse();
RETURN_CODE(MpReturnCode::Success);
CATCH_ALL
}
MpReturnCode mp_GlTextureBuffer__Updated__Pgst(mediapipe::GlTextureBuffer* gl_texture_buffer, mediapipe::GlSyncToken* prod_token) {
TRY_ALL
gl_texture_buffer->Updated(*prod_token);
RETURN_CODE(MpReturnCode::Success);
CATCH_ALL
}
MpReturnCode mp_GlTextureBuffer__DidRead__Pgst(mediapipe::GlTextureBuffer* gl_texture_buffer, mediapipe::GlSyncToken* cons_token) {
TRY_ALL
gl_texture_buffer->DidRead(*cons_token);
RETURN_CODE(MpReturnCode::Success);
CATCH_ALL
}
MpReturnCode mp_GlTextureBuffer__WaitForConsumers(mediapipe::GlTextureBuffer* gl_texture_buffer) {
TRY_ALL
gl_texture_buffer->WaitForConsumers();
RETURN_CODE(MpReturnCode::Success);
CATCH_ALL
}
MpReturnCode mp_GlTextureBuffer__WaitForConsumersOnGpu(mediapipe::GlTextureBuffer* gl_texture_buffer) {
TRY_ALL
gl_texture_buffer->WaitForConsumersOnGpu();
RETURN_CODE(MpReturnCode::Success);
CATCH_ALL
}
const SharedGlContext& mp_GlTextureBuffer__GetProducerContext(mediapipe::GlTextureBuffer* gl_texture_buffer) { return gl_texture_buffer->GetProducerContext(); }