egl/android: set window usage flags
authorDavid Stevens <stevensd@chromium.org>
Thu, 5 Mar 2020 03:52:38 +0000 (12:52 +0900)
committerDavid Stevens <stevensd@chromium.org>
Thu, 12 Mar 2020 02:03:32 +0000 (11:03 +0900)
When creating an egl surface from an ANativeWindow, the window's usage
flags need to be set so that buffers are allocated properly.

Signed-off-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Lepton Wu <lepton@chromium.org>
src/egl/drivers/dri2/platform_android.c

index 8973017324bdc97f1c73ded82a078ad8a05178b2..c682b06d20069370afb66035281b00ac2c890557 100644 (file)
@@ -432,6 +432,11 @@ droid_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
 
       window->query(window, NATIVE_WINDOW_WIDTH, &dri2_surf->base.Width);
       window->query(window, NATIVE_WINDOW_HEIGHT, &dri2_surf->base.Height);
+
+      uint32_t usage = strcmp(dri2_dpy->driver_name, "kms_swrast") == 0
+            ? GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN
+            : GRALLOC_USAGE_HW_RENDER;
+      native_window_set_usage(window, usage);
    }
 
    config = dri2_get_dri_config(dri2_conf, type,