summaryrefslogtreecommitdiffstats
path: root/src/egl/drivers/dri2/platform_android.c
diff options
context:
space:
mode:
authorRob Herring <robh@kernel.org>2016-04-28 15:37:30 -0500
committerEmil Velikov <emil.l.velikov@gmail.com>2016-05-01 12:31:28 +0100
commit81a6fff4c5246c0604b065a6b34145cdad9be423 (patch)
treec554292772f5f5b9b38e65895ededd0403e889bc /src/egl/drivers/dri2/platform_android.c
parentdfaccf25f577987737568a8e1b21ba3a68ef2d80 (diff)
downloadexternal_mesa3d-81a6fff4c5246c0604b065a6b34145cdad9be423.zip
external_mesa3d-81a6fff4c5246c0604b065a6b34145cdad9be423.tar.gz
external_mesa3d-81a6fff4c5246c0604b065a6b34145cdad9be423.tar.bz2
egl: android: factor out back buffer handling code
In preparation to use the same code for dma-bufs, factor out the code to a separate function. Signed-off-by: Rob Herring <robh@kernel.org> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Diffstat (limited to 'src/egl/drivers/dri2/platform_android.c')
-rw-r--r--src/egl/drivers/dri2/platform_android.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
index dd62eda..ea05818 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -312,6 +312,27 @@ droid_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
return EGL_TRUE;
}
+static int
+update_buffers(struct dri2_egl_surface *dri2_surf)
+{
+ if (dri2_surf->base.Type != EGL_WINDOW_BIT)
+ return 0;
+
+ /* try to dequeue the next back buffer */
+ if (!dri2_surf->buffer && !droid_window_dequeue_buffer(dri2_surf))
+ return -1;
+
+ /* free outdated buffers and update the surface size */
+ if (dri2_surf->base.Width != dri2_surf->buffer->width ||
+ dri2_surf->base.Height != dri2_surf->buffer->height) {
+ droid_free_local_buffers(dri2_surf);
+ dri2_surf->base.Width = dri2_surf->buffer->width;
+ dri2_surf->base.Height = dri2_surf->buffer->height;
+ }
+
+ return 0;
+}
+
static EGLBoolean
droid_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
{
@@ -484,19 +505,8 @@ droid_get_buffers_with_format(__DRIdrawable * driDrawable,
dri2_egl_display(dri2_surf->base.Resource.Display);
int i;
- if (dri2_surf->base.Type == EGL_WINDOW_BIT) {
- /* try to dequeue the next back buffer */
- if (!dri2_surf->buffer && !droid_window_dequeue_buffer(dri2_surf))
- return NULL;
-
- /* free outdated buffers and update the surface size */
- if (dri2_surf->base.Width != dri2_surf->buffer->width ||
- dri2_surf->base.Height != dri2_surf->buffer->height) {
- droid_free_local_buffers(dri2_surf);
- dri2_surf->base.Width = dri2_surf->buffer->width;
- dri2_surf->base.Height = dri2_surf->buffer->height;
- }
- }
+ if (update_buffers(dri2_surf) < 0)
+ return NULL;
dri2_surf->buffer_count =
droid_get_buffers_parse_attachments(dri2_surf, attachments, count);