[Mesa-dev] [PATCH] egl: android: query native window default width and height
Kristian Høgsberg
hoegsberg at gmail.com
Thu Jul 28 16:44:51 UTC 2016
On Wed, Jul 27, 2016 at 5:57 PM, Haixia Shi <hshi at chromium.org> wrote:
> On android platform, the width and height of a native window surface may
> be updated after initialization. It is therefore necessary to query android
> framework for the current width and height.
>
> TEST=dEQP-EGL.functional.resize.surface_size#* on cyan-cheets
>
> Signed-off-by: Haixia Shi <hshi at chromium.org>
Reviewed-by: Kristian H. Kristensen <hoegsberg at chromium.org>
> ---
> src/egl/drivers/dri2/egl_dri2.c | 13 +++++++++++++
> src/egl/drivers/dri2/egl_dri2.h | 4 ++++
> src/egl/drivers/dri2/platform_android.c | 27 +++++++++++++++++++++++++++
> 3 files changed, 44 insertions(+)
>
> diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
> index 030227d..7f63f55 100644
> --- a/src/egl/drivers/dri2/egl_dri2.c
> +++ b/src/egl/drivers/dri2/egl_dri2.c
> @@ -1745,6 +1745,16 @@ dri2_create_image_khr_texture(_EGLDisplay *disp, _EGLContext *ctx,
> return &dri2_img->base;
> }
>
> +#ifdef HAVE_ANDROID_PLATFORM
> +static EGLBoolean
> +dri2_query_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
> + EGLint attribute, EGLint *value)
> +{
> + struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
> + return dri2_dpy->vtbl->query_surface(drv, dpy, surf, attribute, value);
> +}
> +#endif
> +
> static struct wl_buffer*
> dri2_create_wayland_buffer_from_image(_EGLDriver *drv, _EGLDisplay *dpy,
> _EGLImage *img)
> @@ -2817,6 +2827,9 @@ _eglBuiltInDriverDRI2(const char *args)
> dri2_drv->base.API.CreateImageKHR = dri2_create_image;
> dri2_drv->base.API.DestroyImageKHR = dri2_destroy_image_khr;
> dri2_drv->base.API.CreateWaylandBufferFromImageWL = dri2_create_wayland_buffer_from_image;
> +#ifdef HAVE_ANDROID_PLATFORM
> + dri2_drv->base.API.QuerySurface = dri2_query_surface;
> +#endif
> #ifdef HAVE_LIBDRM
> dri2_drv->base.API.CreateDRMImageMESA = dri2_create_drm_image_mesa;
> dri2_drv->base.API.ExportDRMImageMESA = dri2_export_drm_image_mesa;
> diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
> index 317de06..1a0ace7 100644
> --- a/src/egl/drivers/dri2/egl_dri2.h
> +++ b/src/egl/drivers/dri2/egl_dri2.h
> @@ -143,6 +143,10 @@ struct dri2_egl_display_vtbl {
> EGLint (*query_buffer_age)(_EGLDriver *drv, _EGLDisplay *dpy,
> _EGLSurface *surf);
>
> + EGLBoolean (*query_surface)(_EGLDriver *drv, _EGLDisplay *dpy,
> + _EGLSurface *surf, EGLint attribute,
> + EGLint *value);
> +
> struct wl_buffer* (*create_wayland_buffer_from_image)(
> _EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *img);
>
> diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
> index e3d5f0b..3038ca5 100644
> --- a/src/egl/drivers/dri2/platform_android.c
> +++ b/src/egl/drivers/dri2/platform_android.c
> @@ -467,6 +467,32 @@ droid_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
> return EGL_TRUE;
> }
>
> +static EGLBoolean
> +droid_query_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
> + EGLint attribute, EGLint *value)
> +{
> + struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
> + switch (attribute) {
> + case EGL_WIDTH:
> + if (dri2_surf->base.Type == EGL_WINDOW_BIT && dri2_surf->window) {
> + dri2_surf->window->query(dri2_surf->window,
> + NATIVE_WINDOW_DEFAULT_WIDTH, value);
> + return EGL_TRUE;
> + }
> + break;
> + case EGL_HEIGHT:
> + if (dri2_surf->base.Type == EGL_WINDOW_BIT && dri2_surf->window) {
> + dri2_surf->window->query(dri2_surf->window,
> + NATIVE_WINDOW_DEFAULT_HEIGHT, value);
> + return EGL_TRUE;
> + }
> + break;
> + default:
> + break;
> + }
> + return _eglQuerySurface(drv, dpy, surf, attribute, value);
> +}
> +
> static _EGLImage *
> dri2_create_image_android_native_buffer(_EGLDisplay *disp,
> _EGLContext *ctx,
> @@ -792,6 +818,7 @@ static struct dri2_egl_display_vtbl droid_display_vtbl = {
> .post_sub_buffer = dri2_fallback_post_sub_buffer,
> .copy_buffers = dri2_fallback_copy_buffers,
> .query_buffer_age = dri2_fallback_query_buffer_age,
> + .query_surface = droid_query_surface,
> .create_wayland_buffer_from_image = dri2_fallback_create_wayland_buffer_from_image,
> .get_sync_values = dri2_fallback_get_sync_values,
> .get_dri_drawable = dri2_surface_get_dri_drawable,
> --
> 2.8.0.rc3.226.g39d4020
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list