1 #include "ABI47_0_0EXGLNativeApi.h"
2 #include "ABI47_0_0EXGLNativeContext.h"
3 #include "ABI47_0_0EXGLContextManager.h"
4
5 using namespace ABI47_0_0expo::gl_cpp;
6
ABI47_0_0EXGLContextCreate()7 ABI47_0_0EXGLContextId ABI47_0_0EXGLContextCreate() {
8 return ContextCreate();
9 }
10
ABI47_0_0EXGLContextPrepare(void * jsiPtr,ABI47_0_0EXGLContextId exglCtxId,std::function<void (void)> flushMethod)11 void ABI47_0_0EXGLContextPrepare(void *jsiPtr, ABI47_0_0EXGLContextId exglCtxId, std::function<void(void)> flushMethod) {
12 auto [exglCtx, lock] = ContextGet(exglCtxId);
13 if (exglCtx) {
14 exglCtx->prepareContext(*reinterpret_cast<jsi::Runtime *>(jsiPtr), flushMethod);
15 }
16 }
17
ABI47_0_0EXGLContextNeedsRedraw(ABI47_0_0EXGLContextId exglCtxId)18 bool ABI47_0_0EXGLContextNeedsRedraw(ABI47_0_0EXGLContextId exglCtxId) {
19 auto [exglCtx, lock] = ContextGet(exglCtxId);
20 if (exglCtx) {
21 return exglCtx->needsRedraw;
22 }
23 return false;
24 }
25
ABI47_0_0EXGLContextDrawEnded(ABI47_0_0EXGLContextId exglCtxId)26 void ABI47_0_0EXGLContextDrawEnded(ABI47_0_0EXGLContextId exglCtxId) {
27 auto [exglCtx, lock] = ContextGet(exglCtxId);
28 if (exglCtx) {
29 exglCtx->needsRedraw = false;
30 }
31 }
32
ABI47_0_0EXGLContextDestroy(ABI47_0_0EXGLContextId exglCtxId)33 void ABI47_0_0EXGLContextDestroy(ABI47_0_0EXGLContextId exglCtxId) {
34 ContextDestroy(exglCtxId);
35 }
36
ABI47_0_0EXGLContextFlush(ABI47_0_0EXGLContextId exglCtxId)37 void ABI47_0_0EXGLContextFlush(ABI47_0_0EXGLContextId exglCtxId) {
38 auto [exglCtx, lock] = ContextGet(exglCtxId);
39 if (exglCtx) {
40 exglCtx->flush();
41 }
42 }
43
ABI47_0_0EXGLContextSetDefaultFramebuffer(ABI47_0_0EXGLContextId exglCtxId,GLint framebuffer)44 void ABI47_0_0EXGLContextSetDefaultFramebuffer(ABI47_0_0EXGLContextId exglCtxId, GLint framebuffer) {
45 auto [exglCtx, lock] = ContextGet(exglCtxId);
46 if (exglCtx) {
47 exglCtx->defaultFramebuffer = framebuffer;
48 }
49 }
50
ABI47_0_0EXGLContextCreateObject(ABI47_0_0EXGLContextId exglCtxId)51 ABI47_0_0EXGLObjectId ABI47_0_0EXGLContextCreateObject(ABI47_0_0EXGLContextId exglCtxId) {
52 auto [exglCtx, lock] = ContextGet(exglCtxId);
53 if (exglCtx) {
54 return exglCtx->createObject();
55 }
56 return 0;
57 }
58
ABI47_0_0EXGLContextDestroyObject(ABI47_0_0EXGLContextId exglCtxId,ABI47_0_0EXGLObjectId exglObjId)59 void ABI47_0_0EXGLContextDestroyObject(ABI47_0_0EXGLContextId exglCtxId, ABI47_0_0EXGLObjectId exglObjId) {
60 auto [exglCtx, lock] = ContextGet(exglCtxId);
61 if (exglCtx) {
62 exglCtx->destroyObject(exglObjId);
63 }
64 }
65
ABI47_0_0EXGLContextMapObject(ABI47_0_0EXGLContextId exglCtxId,ABI47_0_0EXGLObjectId exglObjId,GLuint glObj)66 void ABI47_0_0EXGLContextMapObject(ABI47_0_0EXGLContextId exglCtxId, ABI47_0_0EXGLObjectId exglObjId, GLuint glObj) {
67 auto [exglCtx, lock] = ContextGet(exglCtxId);
68 if (exglCtx) {
69 exglCtx->mapObject(exglObjId, glObj);
70 }
71 }
72
ABI47_0_0EXGLContextGetObject(ABI47_0_0EXGLContextId exglCtxId,ABI47_0_0EXGLObjectId exglObjId)73 GLuint ABI47_0_0EXGLContextGetObject(ABI47_0_0EXGLContextId exglCtxId, ABI47_0_0EXGLObjectId exglObjId) {
74 auto [exglCtx, lock] = ContextGet(exglCtxId);
75 if (exglCtx) {
76 return exglCtx->lookupObject(exglObjId);
77 }
78 return 0;
79 }
80