vlc | branch: master | Thomas Guillem <[email protected]> | Wed Oct 24 10:58:08 2018 +0200| [3564252edcad6395ba9e1e8b3008e5d18b37fff8] | committer: Thomas Guillem
vout/vulkan: add Android extension module > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3564252edcad6395ba9e1e8b3008e5d18b37fff8 --- modules/video_output/Makefile.am | 9 ++++ modules/video_output/vulkan/platform_android.c | 64 ++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/modules/video_output/Makefile.am b/modules/video_output/Makefile.am index 32889e3da7..74b9372347 100644 --- a/modules/video_output/Makefile.am +++ b/modules/video_output/Makefile.am @@ -154,6 +154,12 @@ libvk_win32_plugin_la_CFLAGS = $(AM_CFLAGS) $(VULKAN_COMMONCFLAGS) \ -DVK_USE_PLATFORM_WIN32_KHR -DPLATFORM_NAME=Win32 libvk_win32_plugin_la_LIBADD = $(VULKAN_COMMONLIBS) +libvk_android_plugin_la_SOURCES = $(VULKAN_COMMONSOURCES) video_output/vulkan/surface.c \ + video_output/vulkan/platform_android.c +libvk_android_plugin_la_CFLAGS = $(AM_CFLAGS) $(VULKAN_COMMONCFLAGS) \ + -DVK_USE_PLATFORM_ANDROID_KHR -DPLATFORM_NAME=Android +libvk_android_plugin_la_LIBADD = $(VULKAN_COMMONLIBS) + if HAVE_VULKAN vout_LTLIBRARIES += libvk_plugin.la if HAVE_XCB @@ -162,6 +168,9 @@ endif if HAVE_WIN32_DESKTOP vout_LTLIBRARIES += libvk_win32_plugin.la endif +if HAVE_ANDROID +vout_LTLIBRARIES += libvk_android_plugin.la +endif endif ### XCB ### diff --git a/modules/video_output/vulkan/platform_android.c b/modules/video_output/vulkan/platform_android.c new file mode 100644 index 0000000000..adb66114ca --- /dev/null +++ b/modules/video_output/vulkan/platform_android.c @@ -0,0 +1,64 @@ +/** + * @file platform_android.c + * @brief Vulkan platform-specific code for Android + */ +/***************************************************************************** + * Copyright © 2018 Niklas Haas, Thomas Guillem + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#include "platform.h" +#include "../android/utils.h" + +int vlc_vk_InitPlatform(vlc_vk_t *vk) +{ + if (vk->window->type != VOUT_WINDOW_TYPE_ANDROID_NATIVE) + return VLC_EGENERIC; + + return VLC_SUCCESS; +} + +void vlc_vk_ClosePlatform(vlc_vk_t *vk) +{ + AWindowHandler_releaseANativeWindow(vk->window->handle.anativewindow, + AWindow_Video); +} + +const char * const vlc_vk_PlatformExt = VK_KHR_ANDROID_SURFACE_EXTENSION_NAME; + +int vlc_vk_CreateSurface(vlc_vk_t *vk) +{ + VkInstance vkinst = vk->instance->instance; + + ANativeWindow *anw = + AWindowHandler_getANativeWindow(vk->window->handle.anativewindow, + AWindow_Video); + + VkAndroidSurfaceCreateInfoKHR ainfo = { + .sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR, + .pNext = NULL, + .flags = 0, + .window = anw, + }; + + VkResult res = vkCreateAndroidSurfaceKHR(vkinst, &ainfo, NULL, &vk->surface); + if (res != VK_SUCCESS) { + msg_Err(vk, "Failed creating Android surface"); + return VLC_EGENERIC; + } + + return VLC_SUCCESS; +} _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
