Skip to content

Commit a4b48d3

Browse files
committed
Harmony port: surface destroy
1 parent 01fed59 commit a4b48d3

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/core/ohos/SDL_ohos.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "SDL3/SDL_video.h"
12
#include "SDL_internal.h"
23
#include <EGL/egl.h>
34
#include <EGL/eglplatform.h>
@@ -328,6 +329,24 @@ static void OnSurfaceChangedCB(OH_NativeXComponent *component, void *window)
328329
}
329330
static void OnSurfaceDestroyedCB(OH_NativeXComponent *component, void *window)
330331
{
332+
SDL_VideoDevice *_this = SDL_GetVideoDevice();
333+
SDL_Window *win = _this->windows;
334+
while (win != NULL)
335+
{
336+
#ifdef SDL_VIDEO_OPENGL_EGL
337+
if (win->flags & SDL_WINDOW_OPENGL) {
338+
if (win->internal->egl_context)
339+
{
340+
SDL_EGL_DestroyContext(_this, win->internal->egl_context);
341+
}
342+
if (win->internal->egl_surface)
343+
{
344+
SDL_EGL_DestroySurface(_this, win->internal->egl_surface);
345+
}
346+
}
347+
#endif
348+
win = win->next;
349+
}
331350
}
332351
static void onKeyEvent(OH_NativeXComponent *component, void *window)
333352
{

0 commit comments

Comments
 (0)