|
1 | 1 | #include "SDL_internal.h"
|
| 2 | +#include <EGL/egl.h> |
| 3 | +#include <EGL/eglplatform.h> |
2 | 4 |
|
3 | 5 | #ifdef SDL_PLATFORM_OHOS
|
4 | 6 |
|
5 | 7 | #include "napi/native_api.h"
|
6 | 8 | #include "SDL_ohos.h"
|
7 | 9 | #include <ace/xcomponent/native_interface_xcomponent.h>
|
8 | 10 | #include "../../video/ohos/SDL_ohosvideo.h"
|
| 11 | +#include "SDL3/SDL_mutex.h" |
9 | 12 |
|
10 | 13 | OHNativeWindow *nativeWindow;
|
11 | 14 | SDL_Mutex *g_ohosPageMutex = NULL;
|
12 | 15 | static OH_NativeXComponent_Callback callback;
|
13 | 16 | static OH_NativeXComponent_MouseEvent_Callback mouseCallback;
|
14 |
| -SDL_WindowData data; |
| 17 | +SDL_WindowData windowData; |
| 18 | +SDL_VideoData videoData; |
15 | 19 |
|
16 | 20 | static napi_value minus(napi_env env, napi_callback_info info)
|
17 | 21 | {
|
@@ -51,14 +55,40 @@ static void OnSurfaceCreatedCB(OH_NativeXComponent *component, void *window)
|
51 | 55 |
|
52 | 56 | SDL_Log("Native Window: %p", nativeWindow);
|
53 | 57 |
|
54 |
| - data.native_window = nativeWindow; |
55 |
| - data.width = width; |
56 |
| - data.height = height; |
57 |
| - data.x = offsetX; |
58 |
| - data.y = offsetY; |
| 58 | + SDL_LockMutex(g_ohosPageMutex); |
| 59 | + windowData.native_window = nativeWindow; |
| 60 | + windowData.width = width; |
| 61 | + windowData.height = height; |
| 62 | + windowData.x = offsetX; |
| 63 | + windowData.y = offsetY; |
| 64 | + SDL_UnlockMutex(g_ohosPageMutex); |
| 65 | +} |
| 66 | +static void OnSurfaceChangedCB(OH_NativeXComponent *component, void *window) |
| 67 | +{ |
| 68 | + nativeWindow = (OHNativeWindow *)window; |
| 69 | + |
| 70 | + uint64_t width; |
| 71 | + uint64_t height; |
| 72 | + double offsetX; |
| 73 | + double offsetY; |
| 74 | + OH_NativeXComponent_GetXComponentSize(component, window, &width, &height); |
| 75 | + OH_NativeXComponent_GetXComponentOffset(component, window, &offsetX, &offsetY); |
| 76 | + |
| 77 | + SDL_Log("Native Window: %p", nativeWindow); |
| 78 | + |
| 79 | + SDL_LockMutex(g_ohosPageMutex); |
| 80 | + windowData.native_window = nativeWindow; |
| 81 | + windowData.width = width; |
| 82 | + windowData.height = height; |
| 83 | + windowData.x = offsetX; |
| 84 | + windowData.y = offsetY; |
| 85 | + |
| 86 | + SDL_UnlockMutex(g_ohosPageMutex); |
| 87 | +} |
| 88 | +static void OnSurfaceDestroyedCB(OH_NativeXComponent *component, void *window) |
| 89 | +{ |
| 90 | + // SDL_VideoDevice* _this = SDL_GetVideoDevice(); |
59 | 91 | }
|
60 |
| -static void OnSurfaceChangedCB(OH_NativeXComponent *component, void *window) {} |
61 |
| -static void OnSurfaceDestroyedCB(OH_NativeXComponent *component, void *window) {} |
62 | 92 | static void onKeyEvent(OH_NativeXComponent *component, void *window) {}
|
63 | 93 | static void onNativeTouch(OH_NativeXComponent *component, void *window) {}
|
64 | 94 | static void onNativeMouse(OH_NativeXComponent *component, void *window) {}
|
|
0 commit comments