Skip to content

Commit 0981d59

Browse files
committed
Harmony port: video vulkan library
1 parent e94e7ff commit 0981d59

File tree

5 files changed

+44
-1
lines changed

5 files changed

+44
-1
lines changed

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,6 +1520,15 @@ elseif(OHOS)
15201520
set(HAVE_VULKAN ON)
15211521
set(SDL_VIDEO_VULKAN ON)
15221522
set(HAVE_RENDER_VULKAN TRUE)
1523+
1524+
if(SDL_OPENGLES)
1525+
set(SDL_VIDEO_OPENGL_EGL 1)
1526+
set(HAVE_OPENGLES TRUE)
1527+
set(SDL_VIDEO_OPENGL_ES2 1)
1528+
set(SDL_VIDEO_RENDER_OGL_ES2 1)
1529+
1530+
sdl_link_dependency(opengles LIBS GLESv2)
1531+
endif()
15231532
endif()
15241533

15251534
set(SDL_LOADSO_DLOPEN 1)

src/core/ohos/SDL_ohos.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
#include "napi/native_api.h"
66
#include "SDL_ohos.h"
77
#include <ace/xcomponent/native_interface_xcomponent.h>
8+
#include "../../video/ohos/SDL_ohosvideo.h"
89

910
OHNativeWindow *nativeWindow;
1011
SDL_Mutex *g_ohosPageMutex = NULL;
1112
static OH_NativeXComponent_Callback callback;
1213
static OH_NativeXComponent_MouseEvent_Callback mouseCallback;
14+
SDL_WindowData data;
1315

1416
static napi_value minus(napi_env env, napi_callback_info info)
1517
{
@@ -40,7 +42,20 @@ static void OnSurfaceCreatedCB(OH_NativeXComponent *component, void *window)
4042
{
4143
nativeWindow = (OHNativeWindow *)window;
4244

45+
uint64_t width;
46+
uint64_t height;
47+
double offsetX;
48+
double offsetY;
49+
OH_NativeXComponent_GetXComponentSize(component, window, &width, &height);
50+
OH_NativeXComponent_GetXComponentOffset(component, window, &offsetX, &offsetY);
51+
4352
SDL_Log("Native Window: %p", nativeWindow);
53+
54+
data.native_window = nativeWindow;
55+
data.width = width;
56+
data.height = height;
57+
data.x = offsetX;
58+
data.y = offsetY;
4459
}
4560
static void OnSurfaceChangedCB(OH_NativeXComponent *component, void *window) {}
4661
static void OnSurfaceDestroyedCB(OH_NativeXComponent *component, void *window) {}

src/core/ohos/SDL_ohos.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77

88
extern SDL_Mutex *g_ohosPageMutex;
99
extern OHNativeWindow *nativeWindow;
10+
extern SDL_WindowData data;
1011

1112
#endif

src/video/ohos/SDL_ohosvideo.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ static SDL_VideoDevice *OHOS_CreateDevice(void)
3030
device->Vulkan_DestroySurface = OHOS_Vulkan_DestroySurface;
3131
#endif
3232

33-
3433
return device;
3534
}
3635
VideoBootStrap OHOS_bootstrap = {

src/video/ohos/SDL_ohosvideo.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#ifndef SDL_OHOSVIDEO_H
2+
#define SDL_OHOSVIDEO_H
3+
4+
#include "../SDL_egl_c.h"
5+
#include "../../core/ohos/SDL_ohos.h"
6+
struct SDL_WindowData {
7+
#ifdef SDL_VIDEO_OPENGL_EGL
8+
EGLSurface egl_xcomponent;
9+
EGLContext egl_context;
10+
#endif
11+
bool backup_done;
12+
OHNativeWindow *native_window;
13+
uint64_t width;
14+
uint64_t height;
15+
double x;
16+
double y;
17+
};
18+
19+
#endif

0 commit comments

Comments
 (0)