[vlc-devel] [PATCH 1/2] opengl: rename HasExtension to generic StrHasToken

Thomas Guillem thomas at gllm.fr
Wed May 23 14:42:41 CEST 2018


Fine with me. 

On Wed, May 23, 2018, at 13:51, Zhao Zhili wrote:
> ---
>  include/vlc_opengl.h                           |  2 +-
>  modules/video_output/opengl/converter_sw.c     | 10 +++++-----
>  modules/video_output/opengl/converter_vaapi.c  |  4 ++--
>  modules/video_output/opengl/converter_vdpau.c  |  2 +-
>  modules/video_output/opengl/fragment_shaders.c |  2 +-
>  modules/video_output/opengl/vout_helper.c      |  4 ++--
>  modules/video_output/win32/direct3d9.c         |  2 +-
>  modules/video_output/win32/wgl.c               |  2 +-
>  8 files changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/include/vlc_opengl.h b/include/vlc_opengl.h
> index 178d158..57a1e71 100644
> --- a/include/vlc_opengl.h
> +++ b/include/vlc_opengl.h
> @@ -118,7 +118,7 @@ VLC_API vlc_gl_t *vlc_gl_surface_Create(vlc_object_t *,
>  VLC_API bool vlc_gl_surface_CheckSize(vlc_gl_t *, unsigned *w, unsigned *h);
>  VLC_API void vlc_gl_surface_Destroy(vlc_gl_t *);
>  
> -static inline bool vlc_gl_HasExtension(const char *apis, const char 
> *api)
> +static inline bool vlc_gl_StrHasToken(const char *apis, const char 
> *api)
>  {
>      size_t apilen = strlen(api);
>      while (apis) {
> diff --git a/modules/video_output/opengl/converter_sw.c b/modules/
> video_output/opengl/converter_sw.c
> index 2c31ffc..93b0d91 100644
> --- a/modules/video_output/opengl/converter_sw.c
> +++ b/modules/video_output/opengl/converter_sw.c
> @@ -586,19 +586,19 @@ 
> opengl_tex_converter_generic_init(opengl_tex_converter_t *tc, bool 
> allow_dr)
>  
>      /* OpenGL or OpenGL ES2 with GL_EXT_unpack_subimage ext */
>      priv->has_unpack_subimage =
> -        !tc->is_gles || vlc_gl_HasExtension(tc->glexts, 
> "GL_EXT_unpack_subimage");
> +        !tc->is_gles || vlc_gl_StrHasToken(tc->glexts, 
> "GL_EXT_unpack_subimage");
>  
>      if (allow_dr && priv->has_unpack_subimage)
>      {
>          bool supports_map_persistent = false;
>  
>          const bool has_pbo =
> -            vlc_gl_HasExtension(tc->glexts, "GL_ARB_pixel_buffer_object") ||
> -            vlc_gl_HasExtension(tc->glexts, "GL_EXT_pixel_buffer_object");
> +            vlc_gl_StrHasToken(tc->glexts, "GL_ARB_pixel_buffer_object") ||
> +            vlc_gl_StrHasToken(tc->glexts, "GL_EXT_pixel_buffer_object");
>  
>          const bool has_bs =
> -            vlc_gl_HasExtension(tc->glexts, "GL_ARB_buffer_storage") ||
> -            vlc_gl_HasExtension(tc->glexts, "GL_EXT_buffer_storage");
> +            vlc_gl_StrHasToken(tc->glexts, "GL_ARB_buffer_storage") ||
> +            vlc_gl_StrHasToken(tc->glexts, "GL_EXT_buffer_storage");
>  
>          /* Ensure we do direct rendering with OpenGL 3.0 or higher. 
> Indeed,
>           * persistent mapped buffers seems to be slow with OpenGL 2.1 
> drivers
> diff --git a/modules/video_output/opengl/converter_vaapi.c b/modules/
> video_output/opengl/converter_vaapi.c
> index 322743f..8ff9af0 100644
> --- a/modules/video_output/opengl/converter_vaapi.c
> +++ b/modules/video_output/opengl/converter_vaapi.c
> @@ -406,11 +406,11 @@ Open(vlc_object_t *obj)
>       || tc->gl->egl.destroyImageKHR == NULL)
>          return VLC_EGENERIC;
>  
> -    if (!vlc_gl_HasExtension(tc->glexts, "GL_OES_EGL_image"))
> +    if (!vlc_gl_StrHasToken(tc->glexts, "GL_OES_EGL_image"))
>          return VLC_EGENERIC;
>  
>      const char *eglexts = tc->gl->egl.queryString(tc->gl, 
> EGL_EXTENSIONS);
> -    if (eglexts == NULL || !vlc_gl_HasExtension(eglexts, 
> "EGL_EXT_image_dma_buf_import"))
> +    if (eglexts == NULL || !vlc_gl_StrHasToken(eglexts, 
> "EGL_EXT_image_dma_buf_import"))
>          return VLC_EGENERIC;
>  
>      struct priv *priv = tc->priv = calloc(1, sizeof(struct priv));
> diff --git a/modules/video_output/opengl/converter_vdpau.c b/modules/
> video_output/opengl/converter_vdpau.c
> index 0e7e0e0..0599796 100644
> --- a/modules/video_output/opengl/converter_vdpau.c
> +++ b/modules/video_output/opengl/converter_vdpau.c
> @@ -175,7 +175,7 @@ Open(vlc_object_t *obj)
>      if ((tc->fmt.i_chroma != VLC_CODEC_VDPAU_VIDEO_420 &&
>           tc->fmt.i_chroma != VLC_CODEC_VDPAU_VIDEO_422 &&
>           tc->fmt.i_chroma != VLC_CODEC_VDPAU_VIDEO_444) ||
> -        !vlc_gl_HasExtension(tc->glexts, "GL_NV_vdpau_interop") ||
> +        !vlc_gl_StrHasToken(tc->glexts, "GL_NV_vdpau_interop") ||
>          tc->gl->surface->type != VOUT_WINDOW_TYPE_XID)
>          return VLC_EGENERIC;
>  
> diff --git a/modules/video_output/opengl/fragment_shaders.c b/modules/
> video_output/opengl/fragment_shaders.c
> index 337a2c7..29e6c0b 100644
> --- a/modules/video_output/opengl/fragment_shaders.c
> +++ b/modules/video_output/opengl/fragment_shaders.c
> @@ -104,7 +104,7 @@ tc_yuv_base_init(opengl_tex_converter_t *tc, GLenum 
> tex_target,
>      GLint oneplane_texfmt, oneplane16_texfmt,
>            twoplanes_texfmt, twoplanes16_texfmt;
>  
> -    if (vlc_gl_HasExtension(tc->glexts, "GL_ARB_texture_rg"))
> +    if (vlc_gl_StrHasToken(tc->glexts, "GL_ARB_texture_rg"))
>      {
>          oneplane_texfmt = GL_RED;
>          oneplane16_texfmt = GL_R16;
> diff --git a/modules/video_output/opengl/vout_helper.c b/modules/
> video_output/opengl/vout_helper.c
> index cba43ca..8727a6d 100644
> --- a/modules/video_output/opengl/vout_helper.c
> +++ b/modules/video_output/opengl/vout_helper.c
> @@ -871,8 +871,8 @@ vout_display_opengl_t 
> *vout_display_opengl_New(video_format_t *fmt,
>       * so checks for extensions are bound to fail. Check for OpenGL ES 
> version instead. */
>      vgl->supports_npot = true;
>  #else
> -    vgl->supports_npot = vlc_gl_HasExtension(extensions, 
> "GL_ARB_texture_non_power_of_two") ||
> -                         vlc_gl_HasExtension(extensions, 
> "GL_APPLE_texture_2D_limited_npot");
> +    vgl->supports_npot = vlc_gl_StrHasToken(extensions, 
> "GL_ARB_texture_non_power_of_two") ||
> +                         vlc_gl_StrHasToken(extensions, 
> "GL_APPLE_texture_2D_limited_npot");
>  #endif
>  
>      bool b_dump_shaders = var_InheritInteger(gl, "verbose") >= 4;
> diff --git a/modules/video_output/win32/direct3d9.c b/modules/
> video_output/win32/direct3d9.c
> index 5dea6d2..18ddc75 100644
> --- a/modules/video_output/win32/direct3d9.c
> +++ b/modules/video_output/win32/direct3d9.c
> @@ -1943,7 +1943,7 @@ GLConvOpen(vlc_object_t *obj)
>  
>      const char *wglExt = tc->gl->wgl.getExtensionsString(tc->gl);
>  
> -    if (wglExt == NULL || !vlc_gl_HasExtension(wglExt, "WGL_NV_DX_interop"))
> +    if (wglExt == NULL || !vlc_gl_StrHasToken(wglExt, "WGL_NV_DX_interop"))
>          return VLC_EGENERIC;
>  
>      struct wgl_vt vt;
> diff --git a/modules/video_output/win32/wgl.c b/modules/video_output/
> win32/wgl.c
> index 8b6d291..346025e 100644
> --- a/modules/video_output/win32/wgl.c
> +++ b/modules/video_output/win32/wgl.c
> @@ -198,7 +198,7 @@ static int Open(vlc_object_t *object)
>  #ifdef WGL_EXT_swap_control
>      /* Create an GPU Affinity DC */
>      const char *extensions = (const char*)glGetString(GL_EXTENSIONS);
> -    if (vlc_gl_HasExtension(extensions, "WGL_EXT_swap_control")) {
> +    if (vlc_gl_StrHasToken(extensions, "WGL_EXT_swap_control")) {
>          PFNWGLSWAPINTERVALEXTPROC SwapIntervalEXT = 
> (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
>          if (SwapIntervalEXT)
>              SwapIntervalEXT(1);
> -- 
> 2.9.5
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list