diff options
author | Gwan-gyeong Mun <[email protected]> | 2017-08-05 00:16:11 +0900 |
---|---|---|
committer | Emil Velikov <[email protected]> | 2017-08-22 12:10:15 +0100 |
commit | 640b6e607cb25d0ccc2bf1a1c609f497eb10f673 (patch) | |
tree | 9208b93fc29f7a802160650a7d6b3b166758d64d /src/egl/drivers/dri2/egl_dri2.c | |
parent | 46a8c4ef811ce1b909615f29a4059e079db3b930 (diff) |
egl: deduplicate allocations of local buffer over each platform backend (v2)
platform_drm, platform_wayland and platform_android have similiar local buffer
allocation routines. For deduplicating, it unifies dri2_egl_surface's
local buffer allocation routines. And it polishes inconsistent indentations.
Note that as dri2_wl_get_buffers_with_format() have not make a __DRI_BUFFER_BACK_LEFT
attachment buffer for local_buffers, new helper function, dri2_egl_surface_free_local_buffers(),
will drop the __DRI_BUFFER_BACK_LEFT check.
So if other platforms use new helper functions, we have to ensure not to make
__DRI_BUFFER_BACK_LEFT attachment buffer for local_buffers.
v2: Fixes from Emil's review:
a) Make local_buffers variable, dri2_egl_surface_alloc_local_buffer() and
dri2_egl_surface_free_local_buffers() unconditionally.
b) Preserve the original codeflow for error_path and normal_path.
c) Add note on commit messages for dropping of __DRI_BUFFER_BACK_LEFT check.
c) Rollback the unrelated whitespace changes.
d) Add a missing blank line.
Signed-off-by: Mun Gwan-gyeong <[email protected]>
Reviewed-by: Emil Velikov <[email protected]>
Reviewed-by: Eric Engestrom <[email protected]>
Reviewed-by: Tomasz Figa <[email protected]>
Diffstat (limited to 'src/egl/drivers/dri2/egl_dri2.c')
-rw-r--r-- | src/egl/drivers/dri2/egl_dri2.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 125943333be..aa6f02a34b5 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -1011,6 +1011,40 @@ dri2_display_destroy(_EGLDisplay *disp) disp->DriverData = NULL; } +__DRIbuffer * +dri2_egl_surface_alloc_local_buffer(struct dri2_egl_surface *dri2_surf, + unsigned int att, unsigned int format) +{ + struct dri2_egl_display *dri2_dpy = + dri2_egl_display(dri2_surf->base.Resource.Display); + + if (att >= ARRAY_SIZE(dri2_surf->local_buffers)) + return NULL; + + if (!dri2_surf->local_buffers[att]) { + dri2_surf->local_buffers[att] = + dri2_dpy->dri2->allocateBuffer(dri2_dpy->dri_screen, att, format, + dri2_surf->base.Width, dri2_surf->base.Height); + } + + return dri2_surf->local_buffers[att]; +} + +void +dri2_egl_surface_free_local_buffers(struct dri2_egl_surface *dri2_surf) +{ + struct dri2_egl_display *dri2_dpy = + dri2_egl_display(dri2_surf->base.Resource.Display); + + for (int i = 0; i < ARRAY_SIZE(dri2_surf->local_buffers); i++) { + if (dri2_surf->local_buffers[i]) { + dri2_dpy->dri2->releaseBuffer(dri2_dpy->dri_screen, + dri2_surf->local_buffers[i]); + dri2_surf->local_buffers[i] = NULL; + } + } +} + /** * Called via eglTerminate(), drv->API.Terminate(). * |