Skip to content

Commit 973260a

Browse files
committed
OpenHarmony Port (renderer)
1 parent e7fdb9c commit 973260a

File tree

3 files changed

+7
-31
lines changed

3 files changed

+7
-31
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,7 +1516,9 @@ elseif(OHOS)
15161516
set(SDL_VULKAN ON)
15171517
set(HAVE_VULKAN ON)
15181518
set(SDL_VIDEO_VULKAN ON)
1519+
set(SDL_VIDEO_RENDER_VULKAN 1)
15191520
set(HAVE_RENDER_VULKAN TRUE)
1521+
add_definitions(-DVK_USE_PLATFORM_OHOS=1)
15201522

15211523
if(SDL_OPENGLES)
15221524
set(SDL_VIDEO_OPENGL_EGL 1)

src/core/ohos/SDL_ohos.c

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "SDL_internal.h"
2+
#include "dynapi/SDL_dynapi_overrides.h"
23
#include <EGL/egl.h>
34
#include <EGL/eglplatform.h>
45
#include <dlfcn.h>
@@ -140,31 +141,6 @@ int OHOS_FetchHeight()
140141
return hei;
141142
}
142143

143-
static napi_value minus(napi_env env, napi_callback_info info)
144-
{
145-
size_t argc = 2;
146-
napi_value args[2] = { NULL };
147-
148-
napi_get_cb_info(env, info, &argc, args, NULL, NULL);
149-
150-
napi_valuetype valuetype0;
151-
napi_typeof(env, args[0], &valuetype0);
152-
153-
napi_valuetype valuetype1;
154-
napi_typeof(env, args[1], &valuetype1);
155-
156-
double value0;
157-
napi_get_value_double(env, args[0], &value0);
158-
159-
double value1;
160-
napi_get_value_double(env, args[1], &value1);
161-
162-
napi_value sum;
163-
napi_create_double(env, value0 - value1, &sum);
164-
165-
return sum;
166-
}
167-
168144
static void sdlJSCallback(napi_env env, napi_value jsCb, void *content, void *data)
169145
{
170146
napiCallbackData *ar = (napiCallbackData *)data;
@@ -248,9 +224,9 @@ static napi_value sdlCallbackInit(napi_env env, napi_callback_info info)
248224
data->func = "test";
249225
data->argCount = 0;
250226

251-
napi_call_threadsafe_function(napiEnv.func, data, napi_tsfn_nonblocking);
227+
napi_call_threadsafe_function(napiEnv.func, data, napi_tsfn_blocking);
252228

253-
SDL_free(data);
229+
// SDL_free(data);
254230

255231
napi_value result;
256232
napi_create_int32(env, 0, &result);
@@ -286,6 +262,7 @@ static napi_value sdlLaunchMain(napi_env env, napi_callback_info info)
286262

287263
static void OnSurfaceCreatedCB(OH_NativeXComponent *component, void *window)
288264
{
265+
SDL_Log("Native window: %p", window);
289266
g_ohosNativeWindow = (OHNativeWindow *)window;
290267

291268
uint64_t width;
@@ -408,7 +385,6 @@ static void onNativeMouse(OH_NativeXComponent *component, void *window) {}
408385
static napi_value SDL_OHOS_NAPI_Init(napi_env env, napi_value exports)
409386
{
410387
napi_property_descriptor desc[] = {
411-
{ "minus", NULL, minus, NULL, NULL, NULL, napi_default, NULL },
412388
{ "sdlCallbackInit", NULL, sdlCallbackInit, NULL, NULL, NULL, napi_default, NULL },
413389
{ "sdlLaunchMain", NULL, sdlLaunchMain, NULL, NULL, NULL, napi_default, NULL }
414390
};

src/video/ohos/SDL_ohosvideo.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ bool OHOS_VideoInit(SDL_VideoDevice *_this)
1616
mode.h = OHOS_FetchHeight();
1717
mode.refresh_rate = 60;
1818

19-
SDL_DisplayID displayID = SDL_AddBasicVideoDisplay(&mode);
20-
SDL_Log("testvid: %u", displayID);
21-
SDL_Log("testvid: %u", _this->displays[0]->id);
19+
SDL_AddBasicVideoDisplay(&mode);
2220
return true;
2321
}
2422
void OHOS_VideoQuit(SDL_VideoDevice *_this)

0 commit comments

Comments
 (0)