Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
7f04d36b by Steve Lhomme at 2026-01-08T13:42:18+00:00
opengl: call ANativeWindow_setBuffersGeometry() directly on Android
It's always available via the NDK [^1].
[^1]:
https://developer.android.com/ndk/reference/group/a-native-window#anativewindow_setbuffersgeometry
Message-ID:
<fc0e3cf8c15e4e5c282fe8d27d22f19133a63702.1767790087.git.rob...@ycbcr.xyz>
- - - - -
436e6353 by Steve Lhomme at 2026-01-08T13:42:18+00:00
android: utils: remove unused native_window_api_t
Message-ID:
<ff6fd1dfe80a528f10f76c4d32656c92f5793a0d.1767790087.git.rob...@ycbcr.xyz>
- - - - -
851bae84 by Steve Lhomme at 2026-01-08T13:42:18+00:00
android: utils: call ANativeWindow_xxx() directly
These API's are always available [^1] [^2] [^3].
We still load ASurfaceTexture_xxx() API's dynamically as they are only available
in Android API 28 and API 26 for ANativeWindow_toSurface().
[^1]:
https://developer.android.com/ndk/reference/group/native-activity#anativewindow_fromsurface
[^2]:
https://developer.android.com/ndk/reference/group/a-native-window#anativewindow_acquire
[^3]:
https://developer.android.com/ndk/reference/group/a-native-window#anativewindow_release
Message-ID:
<3a2d86fc9819db4800c7ac715481e2ec5cd14aca.1767790087.git.rob...@ycbcr.xyz>
- - - - -
ae88d720 by Steve Lhomme at 2026-01-08T13:42:18+00:00
android: utils: remove unused ptr_ANativeWindow_fromSurfaceTexture signature
Message-ID:
<a3e0b4e2468b171973197956c09f8f450a0f513a.1767790087.git.rob...@ycbcr.xyz>
- - - - -
4 changed files:
- modules/video_filter/egl_surfacetexture.c
- modules/video_output/android/utils.c
- modules/video_output/android/utils.h
- modules/video_output/opengl/egl.c
Changes:
=====================================
modules/video_filter/egl_surfacetexture.c
=====================================
@@ -133,9 +133,7 @@ static picture_context_t *CreatePictureContext(vlc_gl_t *gl)
goto error;
struct ANativeWindow *window = ctx->texture->window;
- native_window_api_t *api =
- AWindowHandler_getANativeWindowAPI(gl->device->opaque);
- api->setBuffersGeometry(window, sys->fmt_out.i_width,
sys->fmt_out.i_height,
+ ANativeWindow_setBuffersGeometry(window, sys->fmt_out.i_width,
sys->fmt_out.i_height,
AHARDWAREBUFFER_FORMAT_BLOB);
/* Create a drawing surface */
=====================================
modules/video_output/android/utils.c
=====================================
@@ -38,11 +38,6 @@
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
-typedef ANativeWindow* (*ptr_ANativeWindow_fromSurface)(JNIEnv*, jobject);
-typedef ANativeWindow* (*ptr_ANativeWindow_fromSurfaceTexture)(JNIEnv*,
jobject);
-typedef void (*ptr_ANativeWindow_acquire)(ANativeWindow*);
-typedef void (*ptr_ANativeWindow_release)(ANativeWindow*);
-
typedef void (*ptr_ASurfaceTexture_getTransformMatrix)
(ASurfaceTexture *st, float mtx[16]);
typedef ASurfaceTexture* (*ptr_ASurfaceTexture_fromSurfaceTexture)
@@ -130,10 +125,6 @@ struct AWindowHandler
} views[AWindow_Max];
void *p_anw_dl;
- ptr_ANativeWindow_fromSurface pf_winFromSurface;
- ptr_ANativeWindow_acquire pf_winAcquire;
- ptr_ANativeWindow_release pf_winRelease;
- native_window_api_t anw_api;
struct ASurfaceTextureAPI ndk_ast_api;
bool b_has_ndk_ast_api;
@@ -208,7 +199,7 @@ static void NDKSurfaceTexture_destroy(
handle->awh->jfields.SurfaceTexture.release);
if (handle->surface.window)
- handle->awh->pf_winRelease(handle->surface.window);
+ ANativeWindow_release(handle->surface.window);
if (handle->surface.jsurface)
(*p_env)->DeleteGlobalRef(p_env, handle->surface.jsurface);
@@ -334,7 +325,7 @@ static void JNISurfaceTexture_destroy(
handle->awh->jfields.SurfaceTexture.release);
if (handle->surface.window)
- handle->awh->pf_winRelease(handle->surface.window);
+ ANativeWindow_release(handle->surface.window);
if (handle->surface.jsurface)
(*p_env)->DeleteGlobalRef(p_env, handle->surface.jsurface);
@@ -399,21 +390,8 @@ LoadNativeWindowAPI(AWindowHandler *p_awh)
if (!p_library)
return;
- p_awh->pf_winFromSurface = dlsym(p_library, "ANativeWindow_fromSurface");
- p_awh->pf_winAcquire = dlsym(p_library, "ANativeWindow_acquire");
- p_awh->pf_winRelease = dlsym(p_library, "ANativeWindow_release");
- p_awh->anw_api.setBuffersGeometry = dlsym(p_library,
"ANativeWindow_setBuffersGeometry");
-
- if (p_awh->pf_winFromSurface && p_awh->pf_winAcquire &&
p_awh->pf_winRelease
- && p_awh->anw_api.setBuffersGeometry)
- {
- p_awh->b_has_ndk_ast_api = !LoadNDKSurfaceTextureAPI(p_awh, p_library);
- p_awh->p_anw_dl = p_library;
- }
- else
- {
- dlclose(p_library);
- }
+ p_awh->b_has_ndk_ast_api = !LoadNDKSurfaceTextureAPI(p_awh, p_library);
+ p_awh->p_anw_dl = p_library;
}
static void
@@ -684,19 +662,14 @@ AWindowHandler_newFromANWs(vlc_object_t *obj,
ANativeWindow *video,
awh->wnd = NULL;
LoadNativeWindowAPI(awh);
- if (awh->pf_winAcquire == NULL)
- {
- free(awh);
- return NULL;
- }
awh->views[AWindow_Video].p_anw = video;
- awh->pf_winAcquire(video);
+ ANativeWindow_acquire(video);
awh->capabilities = 0;
awh->views[AWindow_Subtitles].p_anw = subtitle;
if (subtitle != NULL)
- awh->pf_winAcquire(subtitle);
+ ANativeWindow_acquire(subtitle);
return awh;
}
@@ -709,7 +682,7 @@ AWindowHandler_releaseANativeWindowEnv(AWindowHandler
*p_awh, JNIEnv *p_env,
if (p_awh->views[id].p_anw)
{
- p_awh->pf_winRelease(p_awh->views[id].p_anw);
+ ANativeWindow_release(p_awh->views[id].p_anw);
p_awh->views[id].p_anw = NULL;
}
@@ -752,12 +725,6 @@ AWindowHandler_destroy(AWindowHandler *p_awh)
free(p_awh);
}
-native_window_api_t *
-AWindowHandler_getANativeWindowAPI(AWindowHandler *p_awh)
-{
- return &p_awh->anw_api;
-}
-
static struct vlc_asurfacetexture_priv* CreateSurfaceTexture(
AWindowHandler *p_awh, JNIEnv *p_env, bool single_buffer)
{
@@ -922,7 +889,7 @@ success:
goto error;
handle->surface.window =
- p_awh->pf_winFromSurface(p_env, handle->surface.jsurface);
+ ANativeWindow_fromSurface(p_env, handle->surface.jsurface);
handle->surface.ops = &JNISurfaceAPI;
}
@@ -955,7 +922,7 @@ error:
eglTerminate(display);
if (handle->surface.window != NULL)
- p_awh->pf_winRelease(handle->surface.window);
+ ANativeWindow_release(handle->surface.window);
if (handle->surface.jsurface != NULL)
(*p_env)->DeleteGlobalRef(p_env, handle->surface.jsurface);
@@ -1029,7 +996,7 @@ AWindowHandler_getANativeWindow(AWindowHandler *p_awh,
enum AWindow_ID id)
assert(p_awh->views[id].jsurface != NULL);
if (!p_awh->views[id].p_anw)
- p_awh->views[id].p_anw = p_awh->pf_winFromSurface(p_env,
+ p_awh->views[id].p_anw = ANativeWindow_fromSurface(p_env,
p_awh->views[id].jsurface);
return p_awh->views[id].p_anw;
=====================================
modules/video_output/android/utils.h
=====================================
@@ -47,14 +47,6 @@ enum AWindow_ID {
AWindow_Max,
};
-/**
- * native_window_api_t. See android/native_window.h in NDK
- */
-typedef struct
-{
- int32_t (*setBuffersGeometry)(ANativeWindow*, int32_t, int32_t, int32_t);
/* can be NULL */
-} native_window_api_t;
-
struct awh_mouse_coords
{
int i_action;
@@ -132,14 +124,6 @@ AWindowHandler *
AWindowHandler_newFromANWs(vlc_object_t *obj, ANativeWindow *video,
ANativeWindow *subtitle);
-/**
- * Get the public native window API
- *
- * Used to access the public ANativeWindow API.
- * \return a valid native_window_api_t. It doesn't need to be released.
- */
-native_window_api_t *AWindowHandler_getANativeWindowAPI(AWindowHandler *p_awh);
-
/**
* Get the Video or the Subtitles ANativeWindow
*
=====================================
modules/video_output/opengl/egl.c
=====================================
@@ -527,9 +527,7 @@ static EGLSurface CreateSurface(vlc_gl_t *gl, EGLDisplay
dpy, EGLConfig config,
int awh_caps =
AWindowHandler_getCapabilities(gl->surface->display.anativewindow);
if ((awh_caps & AWH_CAPS_SURFACE_VIEW) == 0)
{
- native_window_api_t *api =
-
AWindowHandler_getANativeWindowAPI(gl->surface->display.anativewindow);
- api->setBuffersGeometry(anw, width, height,
AHARDWAREBUFFER_FORMAT_BLOB);
+ ANativeWindow_setBuffersGeometry(anw, width, height,
AHARDWAREBUFFER_FORMAT_BLOB);
}
return eglCreateWindowSurface(dpy, config, anw, NULL);
View it on GitLab:
https://code.videolan.org/videolan/vlc/-/compare/8c98ea2d43b4f4440b3c8ed9b51744e923d7de6d...ae88d7206c802d3496f6cb41bab27e1871d1fef8
--
View it on GitLab:
https://code.videolan.org/videolan/vlc/-/compare/8c98ea2d43b4f4440b3c8ed9b51744e923d7de6d...ae88d7206c802d3496f6cb41bab27e1871d1fef8
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance_______________________________________________
vlc-commits mailing list
[email protected]
https://mailman.videolan.org/listinfo/vlc-commits