mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-13 01:45:45 +00:00
Harmony port: review changes
This commit is contained in:
parent
590509b34d
commit
c99ae6e155
3 changed files with 58 additions and 15 deletions
|
|
@ -1,3 +1,4 @@
|
|||
#include "SDL3/SDL_video.h"
|
||||
#include "SDL_internal.h"
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglplatform.h>
|
||||
|
|
@ -62,6 +63,16 @@ void OHOS_windowDataFill(SDL_Window* w)
|
|||
|
||||
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
||||
|
||||
if (_this->windows == NULL)
|
||||
{
|
||||
_this->windows = w;
|
||||
}
|
||||
else
|
||||
{
|
||||
_this->windows->next = w;
|
||||
w->prev = _this->windows;
|
||||
}
|
||||
|
||||
#ifdef SDL_VIDEO_OPENGL_EGL
|
||||
if (w->flags & SDL_WINDOW_OPENGL) {
|
||||
SDL_LockMutex(g_ohosPageMutex);
|
||||
|
|
@ -73,6 +84,51 @@ void OHOS_windowDataFill(SDL_Window* w)
|
|||
}
|
||||
#endif
|
||||
}
|
||||
void OHOS_removeWindow(SDL_Window* w)
|
||||
{
|
||||
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
||||
if (_this->windows == w)
|
||||
{
|
||||
_this->windows = _this->windows->next;
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_Window* curWin = _this->windows;
|
||||
while (curWin != NULL)
|
||||
{
|
||||
if (curWin == w)
|
||||
{
|
||||
if (curWin->next == NULL)
|
||||
{
|
||||
curWin->prev->next = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
curWin->prev->next = curWin->next;
|
||||
curWin->next->prev = curWin->prev;
|
||||
}
|
||||
break;
|
||||
}
|
||||
curWin = curWin->next;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SDL_VIDEO_OPENGL_EGL
|
||||
if (w->flags & SDL_WINDOW_OPENGL) {
|
||||
SDL_LockMutex(g_ohosPageMutex);
|
||||
if (w->internal->egl_context)
|
||||
{
|
||||
SDL_EGL_DestroyContext(_this, w->internal->egl_context);
|
||||
}
|
||||
if (w->internal->egl_surface != EGL_NO_SURFACE)
|
||||
{
|
||||
SDL_EGL_DestroySurface(_this, w->internal->egl_surface);
|
||||
}
|
||||
SDL_UnlockMutex(g_ohosPageMutex);
|
||||
}
|
||||
SDL_free(w->internal);
|
||||
#endif
|
||||
}
|
||||
|
||||
static napi_value minus(napi_env env, napi_callback_info info)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
extern SDL_Mutex *g_ohosPageMutex;
|
||||
|
||||
void OHOS_windowDataFill(SDL_Window* w);
|
||||
void OHOS_removeWindow(SDL_Window* w);
|
||||
|
||||
typedef struct SDL_VideoData {
|
||||
SDL_Rect textRect;
|
||||
|
|
|
|||
|
|
@ -14,21 +14,7 @@ bool OHOS_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propertie
|
|||
|
||||
void OHOS_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
{
|
||||
#ifdef SDL_VIDEO_OPENGL_EGL
|
||||
if (window->flags & SDL_WINDOW_OPENGL) {
|
||||
SDL_LockMutex(g_ohosPageMutex);
|
||||
if (window->internal->egl_context)
|
||||
{
|
||||
SDL_EGL_DestroyContext(_this, window->internal->egl_context);
|
||||
}
|
||||
if (window->internal->egl_surface != EGL_NO_SURFACE)
|
||||
{
|
||||
SDL_EGL_DestroySurface(_this, window->internal->egl_surface);
|
||||
}
|
||||
SDL_UnlockMutex(g_ohosPageMutex);
|
||||
}
|
||||
SDL_free(window->internal);
|
||||
#endif
|
||||
OHOS_removeWindow(window);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue