aboutsummaryrefslogtreecommitdiffstats
path: root/src/egl/drivers/dri2/platform_android.c
diff options
context:
space:
mode:
authorHarish Krupo <[email protected]>2017-06-09 20:13:34 +0530
committerEric Engestrom <[email protected]>2017-06-11 01:02:09 +0100
commit9827547313c7239486efbd4067529575f98f1622 (patch)
treed7480589edac8c714e0f689d6b5b00ed6eb4eaa2 /src/egl/drivers/dri2/platform_android.c
parentf3c0bbe18ac65d22b2630f89fc1628bfe79695d4 (diff)
egl/android: support for EGL_KHR_partial_update
This patch adds support for the EGL_KHR_partial_update extension for android platform. It passes 36/37 tests in dEQP for EGL_KHR_partial_update. 1 test not supported. v2: add fallback for eglSetDamageRegionKHR (Tapani) v3: The native_window_set_surface_damage call is available only from Android version 6.0. Reintroduce the ANDROID_VERSION guard and advertise extension only if version is >= 6.0. (Emil Velikov) v4: use newly introduced ANDROID_API_LEVEL guard rather than ANDROID_VERSION guard to advertise the extension.The extension is advertised only if ANDROID_API_LEVEL >= 23 (Android 6.0 or greater). Add fallback function for platforms other than Android. Fix possible math overflow. (Emil Velikov) Return immediately when n_rects is 0. Place function's entrypoint in alphabetical order. (Eric Engestrom) v5: Replace unnecessary calloc with malloc (Eric) Check for BAD_ALLOC error (Emil) Check for error in native_window_set_damage_region. (Emil, Tapani, Eric). Signed-off-by: Harish Krupo <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
Diffstat (limited to 'src/egl/drivers/dri2/platform_android.c')
-rw-r--r--src/egl/drivers/dri2/platform_android.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
index 4c979351192..7a73419d148 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -656,6 +656,45 @@ droid_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
return EGL_TRUE;
}
+#if ANDROID_API_LEVEL >= 23
+static EGLBoolean
+droid_set_damage_region(_EGLDriver *drv,
+ _EGLDisplay *disp,
+ _EGLSurface *draw, const EGLint* rects, EGLint n_rects)
+{
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ struct dri2_egl_surface *dri2_surf = dri2_egl_surface(draw);
+ android_native_rect_t* droid_rects = NULL;
+ int ret;
+
+ if (n_rects == 0)
+ return EGL_TRUE;
+
+ droid_rects = malloc(n_rects * sizeof(android_native_rect_t));
+ if (droid_rects == NULL) {
+ _eglError(EGL_BAD_ALLOC, "eglSetDamageRegionKHR");
+ return EGL_FALSE;
+ }
+
+ for (EGLint num_drects = 0; num_drects < n_rects; num_drects++) {
+ EGLint i = num_drects * 4;
+ droid_rects[num_drects].left = rects[i];
+ droid_rects[num_drects].bottom = rects[i + 1];
+ droid_rects[num_drects].right = rects[i] + rects[i + 2];
+ droid_rects[num_drects].top = rects[i + 1] + rects[i + 3];
+ }
+
+ /*
+ * XXX/TODO: Need to check for other return values
+ */
+
+ ret = native_window_set_surface_damage(dri2_surf->window, droid_rects, n_rects);
+ free(droid_rects);
+
+ return ret == 0 ? EGL_TRUE : EGL_FALSE;
+}
+#endif
+
static _EGLImage *
droid_create_image_from_prime_fd_yuv(_EGLDisplay *disp, _EGLContext *ctx,
struct ANativeWindowBuffer *buf, int fd)
@@ -1066,6 +1105,11 @@ static const struct dri2_egl_display_vtbl droid_display_vtbl = {
.swap_buffers = droid_swap_buffers,
.swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage,
.swap_buffers_region = dri2_fallback_swap_buffers_region,
+#if ANDROID_API_LEVEL >= 23
+ .set_damage_region = droid_set_damage_region,
+#else
+ .set_damage_region = dri2_fallback_set_damage_region,
+#endif
.post_sub_buffer = dri2_fallback_post_sub_buffer,
.copy_buffers = dri2_fallback_copy_buffers,
.query_buffer_age = droid_query_buffer_age,
@@ -1176,6 +1220,9 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *dpy)
dpy->Extensions.ANDROID_image_native_buffer = EGL_TRUE;
dpy->Extensions.ANDROID_recordable = EGL_TRUE;
dpy->Extensions.EXT_buffer_age = EGL_TRUE;
+#if ANDROID_API_LEVEL >= 23
+ dpy->Extensions.KHR_partial_update = EGL_TRUE;
+#endif
/* Fill vtbl last to prevent accidentally calling virtual function during
* initialization.