Mesa (master): egl/drm: flatten codeflow
Emil Velikov
evelikov at kemper.freedesktop.org
Mon May 29 16:02:28 UTC 2017
Module: Mesa
Branch: master
Commit: 1398ece02c9a3bf93ad5a52987fca3a30a22fdf8
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1398ece02c9a3bf93ad5a52987fca3a30a22fdf8
Author: Emil Velikov <emil.velikov at collabora.com>
Date: Mon May 22 17:28:12 2017 +0100
egl/drm: flatten codeflow
Rework the code to return early and drop an indentation level.
It should be easier to read.
Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
src/egl/drivers/dri2/platform_drm.c | 39 +++++++++++++++++++------------------
1 file changed, 20 insertions(+), 19 deletions(-)
diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c
index e8f007f0cd..c037662f93 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -428,30 +428,31 @@ dri2_drm_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
if (!dri2_dpy->flush) {
dri2_dpy->core->swapBuffers(dri2_surf->dri_drawable);
- } else {
- if (dri2_surf->base.Type == EGL_WINDOW_BIT) {
- if (dri2_surf->current)
- _eglError(EGL_BAD_SURFACE, "dri2_swap_buffers");
- for (i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++)
- if (dri2_surf->color_buffers[i].age > 0)
- dri2_surf->color_buffers[i].age++;
-
- /* Make sure we have a back buffer in case we're swapping without
- * ever rendering. */
- if (get_back_bo(dri2_surf) < 0) {
- _eglError(EGL_BAD_ALLOC, "dri2_swap_buffers");
- return EGL_FALSE;
- }
+ return EGL_TRUE;
+ }
- dri2_surf->current = dri2_surf->back;
- dri2_surf->current->age = 1;
- dri2_surf->back = NULL;
+ if (dri2_surf->base.Type == EGL_WINDOW_BIT) {
+ if (dri2_surf->current)
+ _eglError(EGL_BAD_SURFACE, "dri2_swap_buffers");
+ for (i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++)
+ if (dri2_surf->color_buffers[i].age > 0)
+ dri2_surf->color_buffers[i].age++;
+
+ /* Make sure we have a back buffer in case we're swapping without
+ * ever rendering. */
+ if (get_back_bo(dri2_surf) < 0) {
+ _eglError(EGL_BAD_ALLOC, "dri2_swap_buffers");
+ return EGL_FALSE;
}
- dri2_flush_drawable_for_swapbuffers(disp, draw);
- dri2_dpy->flush->invalidate(dri2_surf->dri_drawable);
+ dri2_surf->current = dri2_surf->back;
+ dri2_surf->current->age = 1;
+ dri2_surf->back = NULL;
}
+ dri2_flush_drawable_for_swapbuffers(disp, draw);
+ dri2_dpy->flush->invalidate(dri2_surf->dri_drawable);
+
return EGL_TRUE;
}
More information about the mesa-commit
mailing list